diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-05-06 17:51:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-07 15:13:03 -0400 |
commit | ef0470c053274c343b2be8737e0146d65e17f9be (patch) | |
tree | 68809a8af1da35e3bb3530a667eea080e086fae0 /arch/um/os-Linux/process.c | |
parent | 3d564047a5f45cb628ec72514f68076e532988f3 (diff) |
uml: tidy libc code
This patch lays some groundwork for the next one, which converts calls to
os_{read,write}_file into {read,write}, by doing some tidying in the affected
areas.
do_not_aio gets restructured to make the final result a bit cleaner.
There are also whitespace and other formatting fixes, fixes in error messages,
and a typo fix.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
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 | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index 37933d3f92b8..a84a45843f83 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c | |||
@@ -40,14 +40,14 @@ unsigned long os_process_pc(int pid) | |||
40 | if(fd < 0){ | 40 | if(fd < 0){ |
41 | printk("os_process_pc - couldn't open '%s', err = %d\n", | 41 | printk("os_process_pc - couldn't open '%s', err = %d\n", |
42 | proc_stat, -fd); | 42 | proc_stat, -fd); |
43 | return(ARBITRARY_ADDR); | 43 | return ARBITRARY_ADDR; |
44 | } | 44 | } |
45 | err = os_read_file(fd, buf, sizeof(buf)); | 45 | err = os_read_file(fd, buf, sizeof(buf)); |
46 | if(err < 0){ | 46 | if(err < 0){ |
47 | printk("os_process_pc - couldn't read '%s', err = %d\n", | 47 | printk("os_process_pc - couldn't read '%s', err = %d\n", |
48 | proc_stat, -err); | 48 | proc_stat, -err); |
49 | os_close_file(fd); | 49 | os_close_file(fd); |
50 | return(ARBITRARY_ADDR); | 50 | return ARBITRARY_ADDR; |
51 | } | 51 | } |
52 | os_close_file(fd); | 52 | os_close_file(fd); |
53 | pc = ARBITRARY_ADDR; | 53 | pc = ARBITRARY_ADDR; |
@@ -56,7 +56,7 @@ unsigned long os_process_pc(int pid) | |||
56 | "%*d %*d %*d %*d %*d %lu", &pc) != 1){ | 56 | "%*d %*d %*d %*d %*d %lu", &pc) != 1){ |
57 | printk("os_process_pc - couldn't find pc in '%s'\n", buf); | 57 | printk("os_process_pc - couldn't find pc in '%s'\n", buf); |
58 | } | 58 | } |
59 | return(pc); | 59 | return pc; |
60 | } | 60 | } |
61 | 61 | ||
62 | int os_process_parent(int pid) | 62 | int os_process_parent(int pid) |
@@ -65,13 +65,14 @@ int os_process_parent(int pid) | |||
65 | char data[256]; | 65 | char data[256]; |
66 | int parent, n, fd; | 66 | int parent, n, fd; |
67 | 67 | ||
68 | if(pid == -1) return(-1); | 68 | if(pid == -1) |
69 | return -1; | ||
69 | 70 | ||
70 | snprintf(stat, sizeof(stat), "/proc/%d/stat", pid); | 71 | snprintf(stat, sizeof(stat), "/proc/%d/stat", pid); |
71 | fd = os_open_file(stat, of_read(OPENFLAGS()), 0); | 72 | fd = os_open_file(stat, of_read(OPENFLAGS()), 0); |
72 | if(fd < 0){ | 73 | if(fd < 0){ |
73 | printk("Couldn't open '%s', err = %d\n", stat, -fd); | 74 | printk("Couldn't open '%s', err = %d\n", stat, -fd); |
74 | return(FAILURE_PID); | 75 | return FAILURE_PID; |
75 | } | 76 | } |
76 | 77 | ||
77 | n = os_read_file(fd, data, sizeof(data)); | 78 | n = os_read_file(fd, data, sizeof(data)); |
@@ -79,7 +80,7 @@ int os_process_parent(int pid) | |||
79 | 80 | ||
80 | if(n < 0){ | 81 | if(n < 0){ |
81 | printk("Couldn't read '%s', err = %d\n", stat, -n); | 82 | printk("Couldn't read '%s', err = %d\n", stat, -n); |
82 | return(FAILURE_PID); | 83 | return FAILURE_PID; |
83 | } | 84 | } |
84 | 85 | ||
85 | parent = FAILURE_PID; | 86 | parent = FAILURE_PID; |
@@ -87,7 +88,7 @@ int os_process_parent(int pid) | |||
87 | if(n != 1) | 88 | if(n != 1) |
88 | printk("Failed to scan '%s'\n", data); | 89 | printk("Failed to scan '%s'\n", data); |
89 | 90 | ||
90 | return(parent); | 91 | return parent; |
91 | } | 92 | } |
92 | 93 | ||
93 | void os_stop_process(int pid) | 94 | void os_stop_process(int pid) |
@@ -145,7 +146,7 @@ void os_usr1_process(int pid) | |||
145 | 146 | ||
146 | int os_getpid(void) | 147 | int os_getpid(void) |
147 | { | 148 | { |
148 | return(syscall(__NR_getpid)); | 149 | return syscall(__NR_getpid); |
149 | } | 150 | } |
150 | 151 | ||
151 | int os_getpgrp(void) | 152 | int os_getpgrp(void) |
@@ -165,8 +166,8 @@ int os_map_memory(void *virt, int fd, unsigned long long off, unsigned long len, | |||
165 | loc = mmap64((void *) virt, len, prot, MAP_SHARED | MAP_FIXED, | 166 | loc = mmap64((void *) virt, len, prot, MAP_SHARED | MAP_FIXED, |
166 | fd, off); | 167 | fd, off); |
167 | if(loc == MAP_FAILED) | 168 | if(loc == MAP_FAILED) |
168 | return(-errno); | 169 | return -errno; |
169 | return(0); | 170 | return 0; |
170 | } | 171 | } |
171 | 172 | ||
172 | int os_protect_memory(void *addr, unsigned long len, int r, int w, int x) | 173 | int os_protect_memory(void *addr, unsigned long len, int r, int w, int x) |
@@ -175,8 +176,8 @@ int os_protect_memory(void *addr, unsigned long len, int r, int w, int x) | |||
175 | (x ? PROT_EXEC : 0)); | 176 | (x ? PROT_EXEC : 0)); |
176 | 177 | ||
177 | if(mprotect(addr, len, prot) < 0) | 178 | if(mprotect(addr, len, prot) < 0) |
178 | return(-errno); | 179 | return -errno; |
179 | return(0); | 180 | return 0; |
180 | } | 181 | } |
181 | 182 | ||
182 | int os_unmap_memory(void *addr, int len) | 183 | int os_unmap_memory(void *addr, int len) |
@@ -185,8 +186,8 @@ int os_unmap_memory(void *addr, int len) | |||
185 | 186 | ||
186 | err = munmap(addr, len); | 187 | err = munmap(addr, len); |
187 | if(err < 0) | 188 | if(err < 0) |
188 | return(-errno); | 189 | return -errno; |
189 | return(0); | 190 | return 0; |
190 | } | 191 | } |
191 | 192 | ||
192 | #ifndef MADV_REMOVE | 193 | #ifndef MADV_REMOVE |