diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-10-16 04:27:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:43:06 -0400 |
commit | 512b6fb1c14d4c34f23a3419b0789ad01914a899 (patch) | |
tree | 29e51c256dde41db297cff28767bf4dc4a1dc73f /arch/um/os-Linux/process.c | |
parent | b21d4b08b6686fa13bf9d4cae1ae08cb23ea3d53 (diff) |
uml: userspace files should call libc directly
A number of files that were changed in the recent removal of tt mode
are userspace files which call the os_* wrappers instead of calling
libc directly. A few other files were affected by this, through
This patch makes these call glibc directly.
There are also style fixes in the affected areas.
os_print_error has no remaining callers, so it is deleted.
There is a interface change to os_set_exec_close, eliminating a
parameter which was always the same. The callers are fixed as well.
os_process_pc got its error path cleaned up.
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/os-Linux/process.c')
-rw-r--r-- | arch/um/os-Linux/process.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index 8b57eb3647f5..90b480cf78f4 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <unistd.h> | 7 | #include <unistd.h> |
8 | #include <errno.h> | 8 | #include <errno.h> |
9 | #include <signal.h> | 9 | #include <signal.h> |
10 | #include <fcntl.h> | ||
10 | #include <sys/mman.h> | 11 | #include <sys/mman.h> |
11 | #include <sys/ptrace.h> | 12 | #include <sys/ptrace.h> |
12 | #include <sys/wait.h> | 13 | #include <sys/wait.h> |
@@ -28,31 +29,32 @@ | |||
28 | unsigned long os_process_pc(int pid) | 29 | unsigned long os_process_pc(int pid) |
29 | { | 30 | { |
30 | char proc_stat[STAT_PATH_LEN], buf[256]; | 31 | char proc_stat[STAT_PATH_LEN], buf[256]; |
31 | unsigned long pc; | 32 | unsigned long pc = ARBITRARY_ADDR; |
32 | int fd, err; | 33 | int fd, err; |
33 | 34 | ||
34 | sprintf(proc_stat, "/proc/%d/stat", pid); | 35 | sprintf(proc_stat, "/proc/%d/stat", pid); |
35 | fd = os_open_file(proc_stat, of_read(OPENFLAGS()), 0); | 36 | fd = open(proc_stat, O_RDONLY, 0); |
36 | if (fd < 0) { | 37 | if (fd < 0) { |
37 | printk(UM_KERN_ERR "os_process_pc - couldn't open '%s', " | 38 | printk(UM_KERN_ERR "os_process_pc - couldn't open '%s', " |
38 | "err = %d\n", proc_stat, -fd); | 39 | "errno = %d\n", proc_stat, errno); |
39 | return ARBITRARY_ADDR; | 40 | goto out; |
40 | } | 41 | } |
41 | CATCH_EINTR(err = read(fd, buf, sizeof(buf))); | 42 | CATCH_EINTR(err = read(fd, buf, sizeof(buf))); |
42 | if (err < 0) { | 43 | if (err < 0) { |
43 | printk(UM_KERN_ERR "os_process_pc - couldn't read '%s', " | 44 | printk(UM_KERN_ERR "os_process_pc - couldn't read '%s', " |
44 | "err = %d\n", proc_stat, errno); | 45 | "err = %d\n", proc_stat, errno); |
45 | os_close_file(fd); | 46 | goto out_close; |
46 | return ARBITRARY_ADDR; | ||
47 | } | 47 | } |
48 | os_close_file(fd); | 48 | os_close_file(fd); |
49 | pc = ARBITRARY_ADDR; | 49 | pc = ARBITRARY_ADDR; |
50 | if (sscanf(buf, "%*d " COMM_SCANF " %*c %*d %*d %*d %*d %*d %*d %*d " | 50 | if (sscanf(buf, "%*d " COMM_SCANF " %*c %*d %*d %*d %*d %*d %*d %*d " |
51 | "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d " | 51 | "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d " |
52 | "%*d %*d %*d %*d %*d %lu", &pc) != 1) { | 52 | "%*d %*d %*d %*d %*d %lu", &pc) != 1) |
53 | printk(UM_KERN_ERR "os_process_pc - couldn't find pc in '%s'\n", | 53 | printk(UM_KERN_ERR "os_process_pc - couldn't find pc in '%s'\n", |
54 | buf); | 54 | buf); |
55 | } | 55 | out_close: |
56 | close(fd); | ||
57 | out: | ||
56 | return pc; | 58 | return pc; |
57 | } | 59 | } |
58 | 60 | ||
@@ -60,25 +62,26 @@ int os_process_parent(int pid) | |||
60 | { | 62 | { |
61 | char stat[STAT_PATH_LEN]; | 63 | char stat[STAT_PATH_LEN]; |
62 | char data[256]; | 64 | char data[256]; |
63 | int parent, n, fd; | 65 | int parent = FAILURE_PID, n, fd; |
64 | 66 | ||
65 | if (pid == -1) | 67 | if (pid == -1) |
66 | return -1; | 68 | return parent; |
67 | 69 | ||
68 | snprintf(stat, sizeof(stat), "/proc/%d/stat", pid); | 70 | snprintf(stat, sizeof(stat), "/proc/%d/stat", pid); |
69 | fd = os_open_file(stat, of_read(OPENFLAGS()), 0); | 71 | fd = open(stat, O_RDONLY, 0); |
70 | if (fd < 0) { | 72 | if (fd < 0) { |
71 | printk(UM_KERN_ERR "Couldn't open '%s', err = %d\n", stat, -fd); | 73 | printk(UM_KERN_ERR "Couldn't open '%s', errno = %d\n", stat, |
72 | return FAILURE_PID; | 74 | errno); |
75 | return parent; | ||
73 | } | 76 | } |
74 | 77 | ||
75 | CATCH_EINTR(n = read(fd, data, sizeof(data))); | 78 | CATCH_EINTR(n = read(fd, data, sizeof(data))); |
76 | os_close_file(fd); | 79 | close(fd); |
77 | 80 | ||
78 | if (n < 0) { | 81 | if (n < 0) { |
79 | printk(UM_KERN_ERR "Couldn't read '%s', err = %d\n", stat, | 82 | printk(UM_KERN_ERR "Couldn't read '%s', errno = %d\n", stat, |
80 | errno); | 83 | errno); |
81 | return FAILURE_PID; | 84 | return parent; |
82 | } | 85 | } |
83 | 86 | ||
84 | parent = FAILURE_PID; | 87 | parent = FAILURE_PID; |