diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-10-16 04:27:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:43:05 -0400 |
commit | ba180fd437156f7fd8cfb2fdd021d949eeef08d6 (patch) | |
tree | b9f38b9cdd7a5b1aacf00341d1948314663c5871 /arch/um/os-Linux/start_up.c | |
parent | 77bf4400319db9d2a8af6b00c2be6faa0f3d07cb (diff) |
uml: style fixes pass 3
Formatting changes in the files which have been changed in the course
of folding foo_skas functions into their callers. These include:
copyright updates
header file trimming
style fixes
adding severity to printks
These changes should be entirely non-functional.
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/start_up.c')
-rw-r--r-- | arch/um/os-Linux/start_up.c | 153 |
1 files changed, 74 insertions, 79 deletions
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c index abfc094c3c49..f22715868929 100644 --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c | |||
@@ -1,41 +1,29 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <pty.h> | ||
7 | #include <stdio.h> | 6 | #include <stdio.h> |
8 | #include <stddef.h> | ||
9 | #include <stdarg.h> | ||
10 | #include <stdlib.h> | 7 | #include <stdlib.h> |
11 | #include <string.h> | 8 | #include <stdarg.h> |
12 | #include <unistd.h> | 9 | #include <unistd.h> |
13 | #include <signal.h> | ||
14 | #include <sched.h> | ||
15 | #include <fcntl.h> | ||
16 | #include <errno.h> | 10 | #include <errno.h> |
17 | #include <sys/time.h> | 11 | #include <fcntl.h> |
18 | #include <sys/wait.h> | 12 | #include <sched.h> |
13 | #include <signal.h> | ||
14 | #include <string.h> | ||
19 | #include <sys/mman.h> | 15 | #include <sys/mman.h> |
20 | #include <sys/resource.h> | 16 | #include <sys/ptrace.h> |
17 | #include <sys/stat.h> | ||
18 | #include <sys/wait.h> | ||
21 | #include <asm/unistd.h> | 19 | #include <asm/unistd.h> |
22 | #include <sys/types.h> | ||
23 | #include "kern_util.h" | ||
24 | #include "user.h" | ||
25 | #include "signal_kern.h" | ||
26 | #include "sysdep/ptrace.h" | ||
27 | #include "sysdep/sigcontext.h" | ||
28 | #include "irq_user.h" | ||
29 | #include "ptrace_user.h" | ||
30 | #include "mem_user.h" | ||
31 | #include "init.h" | 20 | #include "init.h" |
32 | #include "os.h" | ||
33 | #include "uml-config.h" | ||
34 | #include "tempfile.h" | ||
35 | #include "kern_constants.h" | 21 | #include "kern_constants.h" |
36 | #include "skas.h" | 22 | #include "os.h" |
37 | #include "skas_ptrace.h" | 23 | #include "mem_user.h" |
24 | #include "ptrace_user.h" | ||
38 | #include "registers.h" | 25 | #include "registers.h" |
26 | #include "skas_ptrace.h" | ||
39 | 27 | ||
40 | static int ptrace_child(void *arg) | 28 | static int ptrace_child(void *arg) |
41 | { | 29 | { |
@@ -44,26 +32,33 @@ static int ptrace_child(void *arg) | |||
44 | int sc_result; | 32 | int sc_result; |
45 | 33 | ||
46 | change_sig(SIGWINCH, 0); | 34 | change_sig(SIGWINCH, 0); |
47 | if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0){ | 35 | if (ptrace(PTRACE_TRACEME, 0, 0, 0) < 0) { |
48 | perror("ptrace"); | 36 | perror("ptrace"); |
49 | os_kill_process(pid, 0); | 37 | os_kill_process(pid, 0); |
50 | } | 38 | } |
51 | kill(pid, SIGSTOP); | 39 | kill(pid, SIGSTOP); |
52 | 40 | ||
53 | /*This syscall will be intercepted by the parent. Don't call more than | 41 | /* |
54 | * once, please.*/ | 42 | * This syscall will be intercepted by the parent. Don't call more than |
43 | * once, please. | ||
44 | */ | ||
55 | sc_result = os_getpid(); | 45 | sc_result = os_getpid(); |
56 | 46 | ||
57 | if (sc_result == pid) | 47 | if (sc_result == pid) |
58 | ret = 1; /*Nothing modified by the parent, we are running | 48 | /* Nothing modified by the parent, we are running normally. */ |
59 | normally.*/ | 49 | ret = 1; |
60 | else if (sc_result == ppid) | 50 | else if (sc_result == ppid) |
61 | ret = 0; /*Expected in check_ptrace and check_sysemu when they | 51 | /* |
62 | succeed in modifying the stack frame*/ | 52 | * Expected in check_ptrace and check_sysemu when they succeed |
53 | * in modifying the stack frame | ||
54 | */ | ||
55 | ret = 0; | ||
63 | else | 56 | else |
64 | ret = 2; /*Serious trouble! This could be caused by a bug in | 57 | /* Serious trouble! This could be caused by a bug in host 2.6 |
65 | host 2.6 SKAS3/2.6 patch before release -V6, together | 58 | * SKAS3/2.6 patch before release -V6, together with a bug in |
66 | with a bug in the UML code itself.*/ | 59 | * the UML code itself. |
60 | */ | ||
61 | ret = 2; | ||
67 | _exit(ret); | 62 | _exit(ret); |
68 | } | 63 | } |
69 | 64 | ||
@@ -104,16 +99,18 @@ static int start_ptraced_child(void **stack_out) | |||
104 | stack = mmap(NULL, UM_KERN_PAGE_SIZE, | 99 | stack = mmap(NULL, UM_KERN_PAGE_SIZE, |
105 | PROT_READ | PROT_WRITE | PROT_EXEC, | 100 | PROT_READ | PROT_WRITE | PROT_EXEC, |
106 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | 101 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
107 | if(stack == MAP_FAILED) | 102 | if (stack == MAP_FAILED) |
108 | fatal_perror("check_ptrace : mmap failed"); | 103 | fatal_perror("check_ptrace : mmap failed"); |
104 | |||
109 | sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *); | 105 | sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *); |
110 | pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL); | 106 | pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL); |
111 | if(pid < 0) | 107 | if (pid < 0) |
112 | fatal_perror("start_ptraced_child : clone failed"); | 108 | fatal_perror("start_ptraced_child : clone failed"); |
109 | |||
113 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); | 110 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); |
114 | if(n < 0) | 111 | if (n < 0) |
115 | fatal_perror("check_ptrace : clone failed"); | 112 | fatal_perror("check_ptrace : clone failed"); |
116 | if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP)) | 113 | if (!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP)) |
117 | fatal("check_ptrace : expected SIGSTOP, got status = %d", | 114 | fatal("check_ptrace : expected SIGSTOP, got status = %d", |
118 | status); | 115 | status); |
119 | 116 | ||
@@ -132,10 +129,10 @@ static int stop_ptraced_child(int pid, void *stack, int exitcode, | |||
132 | { | 129 | { |
133 | int status, n, ret = 0; | 130 | int status, n, ret = 0; |
134 | 131 | ||
135 | if(ptrace(PTRACE_CONT, pid, 0, 0) < 0) | 132 | if (ptrace(PTRACE_CONT, pid, 0, 0) < 0) |
136 | fatal_perror("stop_ptraced_child : ptrace failed"); | 133 | fatal_perror("stop_ptraced_child : ptrace failed"); |
137 | CATCH_EINTR(n = waitpid(pid, &status, 0)); | 134 | CATCH_EINTR(n = waitpid(pid, &status, 0)); |
138 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) { | 135 | if (!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) { |
139 | int exit_with = WEXITSTATUS(status); | 136 | int exit_with = WEXITSTATUS(status); |
140 | if (exit_with == 2) | 137 | if (exit_with == 2) |
141 | non_fatal("check_ptrace : child exited with status 2. " | 138 | non_fatal("check_ptrace : child exited with status 2. " |
@@ -148,7 +145,7 @@ static int stop_ptraced_child(int pid, void *stack, int exitcode, | |||
148 | ret = -1; | 145 | ret = -1; |
149 | } | 146 | } |
150 | 147 | ||
151 | if(munmap(stack, UM_KERN_PAGE_SIZE) < 0) | 148 | if (munmap(stack, UM_KERN_PAGE_SIZE) < 0) |
152 | fatal_perror("check_ptrace : munmap failed"); | 149 | fatal_perror("check_ptrace : munmap failed"); |
153 | return ret; | 150 | return ret; |
154 | } | 151 | } |
@@ -209,26 +206,26 @@ static void __init check_sysemu(void) | |||
209 | sysemu_supported = 0; | 206 | sysemu_supported = 0; |
210 | pid = start_ptraced_child(&stack); | 207 | pid = start_ptraced_child(&stack); |
211 | 208 | ||
212 | if(ptrace(PTRACE_SYSEMU, pid, 0, 0) < 0) | 209 | if (ptrace(PTRACE_SYSEMU, pid, 0, 0) < 0) |
213 | goto fail; | 210 | goto fail; |
214 | 211 | ||
215 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); | 212 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); |
216 | if (n < 0) | 213 | if (n < 0) |
217 | fatal_perror("check_sysemu : wait failed"); | 214 | fatal_perror("check_sysemu : wait failed"); |
218 | if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP)) | 215 | if (!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP)) |
219 | fatal("check_sysemu : expected SIGTRAP, got status = %d", | 216 | fatal("check_sysemu : expected SIGTRAP, got status = %d", |
220 | status); | 217 | status); |
221 | 218 | ||
222 | if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0) | 219 | if (ptrace(PTRACE_GETREGS, pid, 0, regs) < 0) |
223 | fatal_perror("check_sysemu : PTRACE_GETREGS failed"); | 220 | fatal_perror("check_sysemu : PTRACE_GETREGS failed"); |
224 | if(PT_SYSCALL_NR(regs) != __NR_getpid){ | 221 | if (PT_SYSCALL_NR(regs) != __NR_getpid) { |
225 | non_fatal("check_sysemu got system call number %d, " | 222 | non_fatal("check_sysemu got system call number %d, " |
226 | "expected %d...", PT_SYSCALL_NR(regs), __NR_getpid); | 223 | "expected %d...", PT_SYSCALL_NR(regs), __NR_getpid); |
227 | goto fail; | 224 | goto fail; |
228 | } | 225 | } |
229 | 226 | ||
230 | n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, os_getpid()); | 227 | n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, os_getpid()); |
231 | if(n < 0){ | 228 | if (n < 0) { |
232 | non_fatal("check_sysemu : failed to modify system call " | 229 | non_fatal("check_sysemu : failed to modify system call " |
233 | "return"); | 230 | "return"); |
234 | goto fail; | 231 | goto fail; |
@@ -244,30 +241,31 @@ static void __init check_sysemu(void) | |||
244 | non_fatal("Checking advanced syscall emulation patch for ptrace..."); | 241 | non_fatal("Checking advanced syscall emulation patch for ptrace..."); |
245 | pid = start_ptraced_child(&stack); | 242 | pid = start_ptraced_child(&stack); |
246 | 243 | ||
247 | if((ptrace(PTRACE_OLDSETOPTIONS, pid, 0, | 244 | if ((ptrace(PTRACE_OLDSETOPTIONS, pid, 0, |
248 | (void *) PTRACE_O_TRACESYSGOOD) < 0)) | 245 | (void *) PTRACE_O_TRACESYSGOOD) < 0)) |
249 | fatal_perror("check_ptrace: PTRACE_OLDSETOPTIONS failed"); | 246 | fatal_perror("check_ptrace: PTRACE_OLDSETOPTIONS failed"); |
250 | 247 | ||
251 | while(1){ | 248 | while (1) { |
252 | count++; | 249 | count++; |
253 | if(ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0) | 250 | if (ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0) |
254 | goto fail; | 251 | goto fail; |
255 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); | 252 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); |
256 | if(n < 0) | 253 | if (n < 0) |
257 | fatal_perror("check_ptrace : wait failed"); | 254 | fatal_perror("check_ptrace : wait failed"); |
258 | 255 | ||
259 | if(WIFSTOPPED(status) && (WSTOPSIG(status) == (SIGTRAP|0x80))){ | 256 | if (WIFSTOPPED(status) && |
257 | (WSTOPSIG(status) == (SIGTRAP|0x80))) { | ||
260 | if (!count) | 258 | if (!count) |
261 | fatal("check_ptrace : SYSEMU_SINGLESTEP " | 259 | fatal("check_ptrace : SYSEMU_SINGLESTEP " |
262 | "doesn't singlestep"); | 260 | "doesn't singlestep"); |
263 | n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, | 261 | n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, |
264 | os_getpid()); | 262 | os_getpid()); |
265 | if(n < 0) | 263 | if (n < 0) |
266 | fatal_perror("check_sysemu : failed to modify " | 264 | fatal_perror("check_sysemu : failed to modify " |
267 | "system call return"); | 265 | "system call return"); |
268 | break; | 266 | break; |
269 | } | 267 | } |
270 | else if(WIFSTOPPED(status) && (WSTOPSIG(status) == SIGTRAP)) | 268 | else if (WIFSTOPPED(status) && (WSTOPSIG(status) == SIGTRAP)) |
271 | count++; | 269 | count++; |
272 | else | 270 | else |
273 | fatal("check_ptrace : expected SIGTRAP or " | 271 | fatal("check_ptrace : expected SIGTRAP or " |
@@ -279,7 +277,7 @@ static void __init check_sysemu(void) | |||
279 | sysemu_supported = 2; | 277 | sysemu_supported = 2; |
280 | non_fatal("OK\n"); | 278 | non_fatal("OK\n"); |
281 | 279 | ||
282 | if ( !force_sysemu_disabled ) | 280 | if (!force_sysemu_disabled) |
283 | set_using_sysemu(sysemu_supported); | 281 | set_using_sysemu(sysemu_supported); |
284 | return; | 282 | return; |
285 | 283 | ||
@@ -297,29 +295,29 @@ static void __init check_ptrace(void) | |||
297 | non_fatal("Checking that ptrace can change system call numbers..."); | 295 | non_fatal("Checking that ptrace can change system call numbers..."); |
298 | pid = start_ptraced_child(&stack); | 296 | pid = start_ptraced_child(&stack); |
299 | 297 | ||
300 | if((ptrace(PTRACE_OLDSETOPTIONS, pid, 0, | 298 | if ((ptrace(PTRACE_OLDSETOPTIONS, pid, 0, |
301 | (void *) PTRACE_O_TRACESYSGOOD) < 0)) | 299 | (void *) PTRACE_O_TRACESYSGOOD) < 0)) |
302 | fatal_perror("check_ptrace: PTRACE_OLDSETOPTIONS failed"); | 300 | fatal_perror("check_ptrace: PTRACE_OLDSETOPTIONS failed"); |
303 | 301 | ||
304 | while(1){ | 302 | while (1) { |
305 | if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0) | 303 | if (ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0) |
306 | fatal_perror("check_ptrace : ptrace failed"); | 304 | fatal_perror("check_ptrace : ptrace failed"); |
307 | 305 | ||
308 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); | 306 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); |
309 | if(n < 0) | 307 | if (n < 0) |
310 | fatal_perror("check_ptrace : wait failed"); | 308 | fatal_perror("check_ptrace : wait failed"); |
311 | 309 | ||
312 | if(!WIFSTOPPED(status) || | 310 | if (!WIFSTOPPED(status) || |
313 | (WSTOPSIG(status) != (SIGTRAP | 0x80))) | 311 | (WSTOPSIG(status) != (SIGTRAP | 0x80))) |
314 | fatal("check_ptrace : expected (SIGTRAP|0x80), " | 312 | fatal("check_ptrace : expected (SIGTRAP|0x80), " |
315 | "got status = %d", status); | 313 | "got status = %d", status); |
316 | 314 | ||
317 | syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET, | 315 | syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET, |
318 | 0); | 316 | 0); |
319 | if(syscall == __NR_getpid){ | 317 | if (syscall == __NR_getpid) { |
320 | n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET, | 318 | n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET, |
321 | __NR_getppid); | 319 | __NR_getppid); |
322 | if(n < 0) | 320 | if (n < 0) |
323 | fatal_perror("check_ptrace : failed to modify " | 321 | fatal_perror("check_ptrace : failed to modify " |
324 | "system call"); | 322 | "system call"); |
325 | break; | 323 | break; |
@@ -337,18 +335,18 @@ static void __init check_coredump_limit(void) | |||
337 | struct rlimit lim; | 335 | struct rlimit lim; |
338 | int err = getrlimit(RLIMIT_CORE, &lim); | 336 | int err = getrlimit(RLIMIT_CORE, &lim); |
339 | 337 | ||
340 | if(err){ | 338 | if (err) { |
341 | perror("Getting core dump limit"); | 339 | perror("Getting core dump limit"); |
342 | return; | 340 | return; |
343 | } | 341 | } |
344 | 342 | ||
345 | printf("Core dump limits :\n\tsoft - "); | 343 | printf("Core dump limits :\n\tsoft - "); |
346 | if(lim.rlim_cur == RLIM_INFINITY) | 344 | if (lim.rlim_cur == RLIM_INFINITY) |
347 | printf("NONE\n"); | 345 | printf("NONE\n"); |
348 | else printf("%lu\n", lim.rlim_cur); | 346 | else printf("%lu\n", lim.rlim_cur); |
349 | 347 | ||
350 | printf("\thard - "); | 348 | printf("\thard - "); |
351 | if(lim.rlim_max == RLIM_INFINITY) | 349 | if (lim.rlim_max == RLIM_INFINITY) |
352 | printf("NONE\n"); | 350 | printf("NONE\n"); |
353 | else printf("%lu\n", lim.rlim_max); | 351 | else printf("%lu\n", lim.rlim_max); |
354 | } | 352 | } |
@@ -414,7 +412,7 @@ static inline void check_skas3_ptrace_faultinfo(void) | |||
414 | n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); | 412 | n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); |
415 | if (n < 0) { | 413 | if (n < 0) { |
416 | ptrace_faultinfo = 0; | 414 | ptrace_faultinfo = 0; |
417 | if(errno == EIO) | 415 | if (errno == EIO) |
418 | non_fatal("not found\n"); | 416 | non_fatal("not found\n"); |
419 | else | 417 | else |
420 | perror("not found"); | 418 | perror("not found"); |
@@ -446,7 +444,7 @@ static inline void check_skas3_ptrace_ldt(void) | |||
446 | 444 | ||
447 | n = ptrace(PTRACE_LDT, pid, 0, (unsigned long) &ldt_op); | 445 | n = ptrace(PTRACE_LDT, pid, 0, (unsigned long) &ldt_op); |
448 | if (n < 0) { | 446 | if (n < 0) { |
449 | if(errno == EIO) | 447 | if (errno == EIO) |
450 | non_fatal("not found\n"); | 448 | non_fatal("not found\n"); |
451 | else { | 449 | else { |
452 | perror("not found"); | 450 | perror("not found"); |
@@ -454,7 +452,7 @@ static inline void check_skas3_ptrace_ldt(void) | |||
454 | ptrace_ldt = 0; | 452 | ptrace_ldt = 0; |
455 | } | 453 | } |
456 | else { | 454 | else { |
457 | if(ptrace_ldt) | 455 | if (ptrace_ldt) |
458 | non_fatal("found\n"); | 456 | non_fatal("found\n"); |
459 | else | 457 | else |
460 | non_fatal("found, but use is disabled\n"); | 458 | non_fatal("found, but use is disabled\n"); |
@@ -477,12 +475,9 @@ static inline void check_skas3_proc_mm(void) | |||
477 | proc_mm = 0; | 475 | proc_mm = 0; |
478 | perror("not found"); | 476 | perror("not found"); |
479 | } | 477 | } |
480 | else { | 478 | else if (!proc_mm) |
481 | if (!proc_mm) | 479 | non_fatal("found but disabled on command line\n"); |
482 | non_fatal("found but disabled on command line\n"); | 480 | else non_fatal("found\n"); |
483 | else | ||
484 | non_fatal("found\n"); | ||
485 | } | ||
486 | } | 481 | } |
487 | 482 | ||
488 | int can_do_skas(void) | 483 | int can_do_skas(void) |
@@ -493,7 +488,7 @@ int can_do_skas(void) | |||
493 | check_skas3_ptrace_faultinfo(); | 488 | check_skas3_ptrace_faultinfo(); |
494 | check_skas3_ptrace_ldt(); | 489 | check_skas3_ptrace_ldt(); |
495 | 490 | ||
496 | if(!proc_mm || !ptrace_faultinfo || !ptrace_ldt) | 491 | if (!proc_mm || !ptrace_faultinfo || !ptrace_ldt) |
497 | skas_needs_stub = 1; | 492 | skas_needs_stub = 1; |
498 | 493 | ||
499 | return 1; | 494 | return 1; |
@@ -508,25 +503,25 @@ int __init parse_iomem(char *str, int *add) | |||
508 | 503 | ||
509 | driver = str; | 504 | driver = str; |
510 | file = strchr(str,','); | 505 | file = strchr(str,','); |
511 | if(file == NULL){ | 506 | if (file == NULL) { |
512 | printf("parse_iomem : failed to parse iomem\n"); | 507 | printf("parse_iomem : failed to parse iomem\n"); |
513 | goto out; | 508 | goto out; |
514 | } | 509 | } |
515 | *file = '\0'; | 510 | *file = '\0'; |
516 | file++; | 511 | file++; |
517 | fd = open(file, O_RDWR, 0); | 512 | fd = open(file, O_RDWR, 0); |
518 | if(fd < 0){ | 513 | if (fd < 0) { |
519 | os_print_error(fd, "parse_iomem - Couldn't open io file"); | 514 | os_print_error(fd, "parse_iomem - Couldn't open io file"); |
520 | goto out; | 515 | goto out; |
521 | } | 516 | } |
522 | 517 | ||
523 | if(fstat64(fd, &buf) < 0){ | 518 | if (fstat64(fd, &buf) < 0) { |
524 | perror("parse_iomem - cannot stat_fd file"); | 519 | perror("parse_iomem - cannot stat_fd file"); |
525 | goto out_close; | 520 | goto out_close; |
526 | } | 521 | } |
527 | 522 | ||
528 | new = malloc(sizeof(*new)); | 523 | new = malloc(sizeof(*new)); |
529 | if(new == NULL){ | 524 | if (new == NULL) { |
530 | perror("Couldn't allocate iomem_region struct"); | 525 | perror("Couldn't allocate iomem_region struct"); |
531 | goto out_close; | 526 | goto out_close; |
532 | } | 527 | } |