aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2008-02-05 01:31:04 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-05 12:44:29 -0500
commitbf8fde785b872282e7e86d9ea8a9c4e543985bb3 (patch)
treecb813edfbb04c8474caab0f8a26a8512a503cf82 /arch/um
parent7b5cc6ee6cf9001775c348bac09814a45f1276b7 (diff)
uml: miscellaneous code cleanups
Code tidying - the pid field of struct irq_fd isn't used, so it is removed os_set_fd_async needed to read flags before changing them, it doesn't need a pid passed in because it can call getpid itself, and a block of unused code needed deleting os_get_exec_close was unused, so it is removed ptrace_child called _exit for historical reasons which are no longer valid, so just calls exit instead Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/include/irq_user.h1
-rw-r--r--arch/um/include/os.h3
-rw-r--r--arch/um/kernel/irq.c6
-rw-r--r--arch/um/kernel/ksyms.c1
-rw-r--r--arch/um/kernel/smp.c6
-rw-r--r--arch/um/os-Linux/file.c38
-rw-r--r--arch/um/os-Linux/start_up.c3
7 files changed, 18 insertions, 40 deletions
diff --git a/arch/um/include/irq_user.h b/arch/um/include/irq_user.h
index 884a9c17eea0..e60b31873de1 100644
--- a/arch/um/include/irq_user.h
+++ b/arch/um/include/irq_user.h
@@ -14,7 +14,6 @@ struct irq_fd {
14 int fd; 14 int fd;
15 int type; 15 int type;
16 int irq; 16 int irq;
17 int pid;
18 int events; 17 int events;
19 int current_events; 18 int current_events;
20}; 19};
diff --git a/arch/um/include/os.h b/arch/um/include/os.h
index 9428d34792ca..fdac1a55d031 100644
--- a/arch/um/include/os.h
+++ b/arch/um/include/os.h
@@ -127,7 +127,6 @@ static inline struct openflags of_cloexec(struct openflags flags)
127extern int os_stat_file(const char *file_name, struct uml_stat *buf); 127extern int os_stat_file(const char *file_name, struct uml_stat *buf);
128extern int os_stat_fd(const int fd, struct uml_stat *buf); 128extern int os_stat_fd(const int fd, struct uml_stat *buf);
129extern int os_access(const char *file, int mode); 129extern int os_access(const char *file, int mode);
130extern int os_get_exec_close(int fd, int *close_on_exec);
131extern int os_set_exec_close(int fd); 130extern int os_set_exec_close(int fd);
132extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg); 131extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg);
133extern int os_get_ifname(int fd, char *namebuf); 132extern int os_get_ifname(int fd, char *namebuf);
@@ -142,7 +141,7 @@ extern int os_write_file(int fd, const void *buf, int count);
142extern int os_file_size(const char *file, unsigned long long *size_out); 141extern int os_file_size(const char *file, unsigned long long *size_out);
143extern int os_file_modtime(const char *file, unsigned long *modtime); 142extern int os_file_modtime(const char *file, unsigned long *modtime);
144extern int os_pipe(int *fd, int stream, int close_on_exec); 143extern int os_pipe(int *fd, int stream, int close_on_exec);
145extern int os_set_fd_async(int fd, int owner); 144extern int os_set_fd_async(int fd);
146extern int os_clear_fd_async(int fd); 145extern int os_clear_fd_async(int fd);
147extern int os_set_fd_block(int fd, int blocking); 146extern int os_set_fd_block(int fd, int blocking);
148extern int os_accept_connection(int fd); 147extern int os_accept_connection(int fd);
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index ba11ccd6a8a3..91587f8db340 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -107,10 +107,9 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
107 struct pollfd *tmp_pfd; 107 struct pollfd *tmp_pfd;
108 struct irq_fd *new_fd, *irq_fd; 108 struct irq_fd *new_fd, *irq_fd;
109 unsigned long flags; 109 unsigned long flags;
110 int pid, events, err, n; 110 int events, err, n;
111 111
112 pid = os_getpid(); 112 err = os_set_fd_async(fd);
113 err = os_set_fd_async(fd, pid);
114 if (err < 0) 113 if (err < 0)
115 goto out; 114 goto out;
116 115
@@ -127,7 +126,6 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
127 .fd = fd, 126 .fd = fd,
128 .type = type, 127 .type = type,
129 .irq = irq, 128 .irq = irq,
130 .pid = pid,
131 .events = events, 129 .events = events,
132 .current_events = 0 } ); 130 .current_events = 0 } );
133 131
diff --git a/arch/um/kernel/ksyms.c b/arch/um/kernel/ksyms.c
index 187a756f3e5b..5311ee93ede3 100644
--- a/arch/um/kernel/ksyms.c
+++ b/arch/um/kernel/ksyms.c
@@ -36,7 +36,6 @@ EXPORT_SYMBOL(uml_strdup);
36EXPORT_SYMBOL(os_stat_fd); 36EXPORT_SYMBOL(os_stat_fd);
37EXPORT_SYMBOL(os_stat_file); 37EXPORT_SYMBOL(os_stat_file);
38EXPORT_SYMBOL(os_access); 38EXPORT_SYMBOL(os_access);
39EXPORT_SYMBOL(os_get_exec_close);
40EXPORT_SYMBOL(os_set_exec_close); 39EXPORT_SYMBOL(os_set_exec_close);
41EXPORT_SYMBOL(os_getpid); 40EXPORT_SYMBOL(os_getpid);
42EXPORT_SYMBOL(os_open_file); 41EXPORT_SYMBOL(os_open_file);
diff --git a/arch/um/kernel/smp.c b/arch/um/kernel/smp.c
index a12e5bd15790..869ac6802209 100644
--- a/arch/um/kernel/smp.c
+++ b/arch/um/kernel/smp.c
@@ -74,8 +74,7 @@ static int idle_proc(void *cpup)
74 if (err < 0) 74 if (err < 0)
75 panic("CPU#%d failed to create IPI pipe, err = %d", cpu, -err); 75 panic("CPU#%d failed to create IPI pipe, err = %d", cpu, -err);
76 76
77 os_set_fd_async(cpu_data[cpu].ipi_pipe[0], 77 os_set_fd_async(cpu_data[cpu].ipi_pipe[0]);
78 current->thread.mode.tt.extern_pid);
79 78
80 wmb(); 79 wmb();
81 if (cpu_test_and_set(cpu, cpu_callin_map)) { 80 if (cpu_test_and_set(cpu, cpu_callin_map)) {
@@ -128,8 +127,7 @@ void smp_prepare_cpus(unsigned int maxcpus)
128 if (err < 0) 127 if (err < 0)
129 panic("CPU#0 failed to create IPI pipe, errno = %d", -err); 128 panic("CPU#0 failed to create IPI pipe, errno = %d", -err);
130 129
131 os_set_fd_async(cpu_data[me].ipi_pipe[0], 130 os_set_fd_async(cpu_data[me].ipi_pipe[0]);
132 current->thread.mode.tt.extern_pid);
133 131
134 for (cpu = 1; cpu < ncpus; cpu++) { 132 for (cpu = 1; cpu < ncpus; cpu++) {
135 printk(KERN_INFO "Booting processor %d...\n", cpu); 133 printk(KERN_INFO "Booting processor %d...\n", cpu);
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
index 9387cb11c0ad..4f547d75b17e 100644
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -328,19 +328,6 @@ int os_file_modtime(const char *file, unsigned long *modtime)
328 return 0; 328 return 0;
329} 329}
330 330
331int os_get_exec_close(int fd, int *close_on_exec)
332{
333 int ret;
334
335 CATCH_EINTR(ret = fcntl(fd, F_GETFD));
336
337 if(ret < 0)
338 return -errno;
339
340 *close_on_exec = (ret & FD_CLOEXEC) ? 1 : 0;
341 return ret;
342}
343
344int os_set_exec_close(int fd) 331int os_set_exec_close(int fd)
345{ 332{
346 int err; 333 int err;
@@ -380,30 +367,27 @@ int os_pipe(int *fds, int stream, int close_on_exec)
380 return err; 367 return err;
381} 368}
382 369
383int os_set_fd_async(int fd, int owner) 370int os_set_fd_async(int fd)
384{ 371{
385 int err; 372 int err, flags;
373
374 flags = fcntl(fd, F_GETFL);
375 if (flags < 0)
376 return -errno;
386 377
387 /* XXX This should do F_GETFL first */ 378 flags |= O_ASYNC | O_NONBLOCK;
388 if(fcntl(fd, F_SETFL, O_ASYNC | O_NONBLOCK) < 0){ 379 if (fcntl(fd, F_SETFL, flags) < 0) {
389 err = -errno; 380 err = -errno;
390 printk("os_set_fd_async : failed to set O_ASYNC and " 381 printk("os_set_fd_async : failed to set O_ASYNC and "
391 "O_NONBLOCK on fd # %d, errno = %d\n", fd, errno); 382 "O_NONBLOCK on fd # %d, errno = %d\n", fd, errno);
392 return err; 383 return err;
393 } 384 }
394#ifdef notdef
395 if(fcntl(fd, F_SETFD, 1) < 0){
396 printk("os_set_fd_async : Setting FD_CLOEXEC failed, "
397 "errno = %d\n", errno);
398 }
399#endif
400 385
401 if((fcntl(fd, F_SETSIG, SIGIO) < 0) || 386 if ((fcntl(fd, F_SETSIG, SIGIO) < 0) ||
402 (fcntl(fd, F_SETOWN, owner) < 0)){ 387 (fcntl(fd, F_SETOWN, os_getpid()) < 0)) {
403 err = -errno; 388 err = -errno;
404 printk("os_set_fd_async : Failed to fcntl F_SETOWN " 389 printk("os_set_fd_async : Failed to fcntl F_SETOWN "
405 "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd, 390 "(or F_SETSIG) fd %d, errno = %d\n", fd, errno);
406 owner, errno);
407 return err; 391 return err;
408 } 392 }
409 393
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 6d56d15884fd..bcf0c9b86b10 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -60,7 +60,8 @@ static int ptrace_child(void)
60 * the UML code itself. 60 * the UML code itself.
61 */ 61 */
62 ret = 2; 62 ret = 2;
63 _exit(ret); 63
64 exit(ret);
64} 65}
65 66
66static void fatal_perror(const char *str) 67static void fatal_perror(const char *str)