aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>2006-10-20 02:28:21 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-20 13:26:36 -0400
commit8b028bcd0e746ae0f2f218b911032232a32dedd5 (patch)
tree1941cc3dacc3450626df453a7ec228b8e9d371bd /arch/um
parentc13e569073b89eb75216a2551e89ae93ad1f9951 (diff)
[PATCH] uml: code convention cleanup of a file
Fix coding conventions violations is arch/um/os-Linux/helper.c. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Cc: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/os-Linux/helper.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c
index cd15b9df5b5c..8a78bf03b468 100644
--- a/arch/um/os-Linux/helper.c
+++ b/arch/um/os-Linux/helper.c
@@ -35,18 +35,18 @@ static int helper_child(void *arg)
35 char **argv = data->argv; 35 char **argv = data->argv;
36 int errval; 36 int errval;
37 37
38 if(helper_pause){ 38 if (helper_pause){
39 signal(SIGHUP, helper_hup); 39 signal(SIGHUP, helper_hup);
40 pause(); 40 pause();
41 } 41 }
42 if(data->pre_exec != NULL) 42 if (data->pre_exec != NULL)
43 (*data->pre_exec)(data->pre_data); 43 (*data->pre_exec)(data->pre_data);
44 execvp(argv[0], argv); 44 execvp(argv[0], argv);
45 errval = -errno; 45 errval = -errno;
46 printk("helper_child - execve of '%s' failed - errno = %d\n", argv[0], errno); 46 printk("helper_child - execve of '%s' failed - errno = %d\n", argv[0], errno);
47 os_write_file(data->fd, &errval, sizeof(errval)); 47 os_write_file(data->fd, &errval, sizeof(errval));
48 kill(os_getpid(), SIGKILL); 48 kill(os_getpid(), SIGKILL);
49 return(0); 49 return 0;
50} 50}
51 51
52/* Returns either the pid of the child process we run or -E* on failure. 52/* Returns either the pid of the child process we run or -E* on failure.
@@ -58,20 +58,21 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
58 unsigned long stack, sp; 58 unsigned long stack, sp;
59 int pid, fds[2], ret, n; 59 int pid, fds[2], ret, n;
60 60
61 if((stack_out != NULL) && (*stack_out != 0)) 61 if ((stack_out != NULL) && (*stack_out != 0))
62 stack = *stack_out; 62 stack = *stack_out;
63 else stack = alloc_stack(0, __cant_sleep()); 63 else
64 if(stack == 0) 64 stack = alloc_stack(0, __cant_sleep());
65 if (stack == 0)
65 return -ENOMEM; 66 return -ENOMEM;
66 67
67 ret = os_pipe(fds, 1, 0); 68 ret = os_pipe(fds, 1, 0);
68 if(ret < 0){ 69 if (ret < 0) {
69 printk("run_helper : pipe failed, ret = %d\n", -ret); 70 printk("run_helper : pipe failed, ret = %d\n", -ret);
70 goto out_free; 71 goto out_free;
71 } 72 }
72 73
73 ret = os_set_exec_close(fds[1], 1); 74 ret = os_set_exec_close(fds[1], 1);
74 if(ret < 0){ 75 if (ret < 0) {
75 printk("run_helper : setting FD_CLOEXEC failed, ret = %d\n", 76 printk("run_helper : setting FD_CLOEXEC failed, ret = %d\n",
76 -ret); 77 -ret);
77 goto out_close; 78 goto out_close;
@@ -83,7 +84,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
83 data.argv = argv; 84 data.argv = argv;
84 data.fd = fds[1]; 85 data.fd = fds[1];
85 pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); 86 pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data);
86 if(pid < 0){ 87 if (pid < 0) {
87 ret = -errno; 88 ret = -errno;
88 printk("run_helper : clone failed, errno = %d\n", errno); 89 printk("run_helper : clone failed, errno = %d\n", errno);
89 goto out_close; 90 goto out_close;
@@ -95,10 +96,10 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
95 /* Read the errno value from the child, if the exec failed, or get 0 if 96 /* Read the errno value from the child, if the exec failed, or get 0 if
96 * the exec succeeded because the pipe fd was set as close-on-exec. */ 97 * the exec succeeded because the pipe fd was set as close-on-exec. */
97 n = os_read_file(fds[0], &ret, sizeof(ret)); 98 n = os_read_file(fds[0], &ret, sizeof(ret));
98 if(n == 0) 99 if (n == 0) {
99 ret = pid; 100 ret = pid;
100 else { 101 } else {
101 if(n < 0){ 102 if (n < 0) {
102 printk("run_helper : read on pipe failed, ret = %d\n", 103 printk("run_helper : read on pipe failed, ret = %d\n",
103 -n); 104 -n);
104 ret = n; 105 ret = n;
@@ -112,10 +113,11 @@ out_close:
112 close(fds[1]); 113 close(fds[1]);
113 close(fds[0]); 114 close(fds[0]);
114out_free: 115out_free:
115 if(stack_out == NULL) 116 if (stack_out == NULL)
116 free_stack(stack, 0); 117 free_stack(stack, 0);
117 else *stack_out = stack; 118 else
118 return(ret); 119 *stack_out = stack;
120 return ret;
119} 121}
120 122
121int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, 123int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
@@ -125,31 +127,32 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
125 int pid, status, err; 127 int pid, status, err;
126 128
127 stack = alloc_stack(stack_order, __cant_sleep()); 129 stack = alloc_stack(stack_order, __cant_sleep());
128 if(stack == 0) return(-ENOMEM); 130 if (stack == 0)
131 return -ENOMEM;
129 132
130 sp = stack + (page_size() << stack_order) - sizeof(void *); 133 sp = stack + (page_size() << stack_order) - sizeof(void *);
131 pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); 134 pid = clone(proc, (void *) sp, flags | SIGCHLD, arg);
132 if(pid < 0){ 135 if (pid < 0) {
133 err = -errno; 136 err = -errno;
134 printk("run_helper_thread : clone failed, errno = %d\n", 137 printk("run_helper_thread : clone failed, errno = %d\n",
135 errno); 138 errno);
136 return err; 139 return err;
137 } 140 }
138 if(stack_out == NULL){ 141 if (stack_out == NULL) {
139 CATCH_EINTR(pid = waitpid(pid, &status, 0)); 142 CATCH_EINTR(pid = waitpid(pid, &status, 0));
140 if(pid < 0){ 143 if (pid < 0) {
141 err = -errno; 144 err = -errno;
142 printk("run_helper_thread - wait failed, errno = %d\n", 145 printk("run_helper_thread - wait failed, errno = %d\n",
143 errno); 146 errno);
144 pid = err; 147 pid = err;
145 } 148 }
146 if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) 149 if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0))
147 printk("run_helper_thread - thread returned status " 150 printk("run_helper_thread - thread returned status "
148 "0x%x\n", status); 151 "0x%x\n", status);
149 free_stack(stack, stack_order); 152 free_stack(stack, stack_order);
150 } 153 } else
151 else *stack_out = stack; 154 *stack_out = stack;
152 return(pid); 155 return pid;
153} 156}
154 157
155int helper_wait(int pid) 158int helper_wait(int pid)
@@ -157,9 +160,9 @@ int helper_wait(int pid)
157 int ret; 160 int ret;
158 161
159 CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG)); 162 CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG));
160 if(ret < 0){ 163 if (ret < 0) {
161 ret = -errno; 164 ret = -errno;
162 printk("helper_wait : waitpid failed, errno = %d\n", errno); 165 printk("helper_wait : waitpid failed, errno = %d\n", errno);
163 } 166 }
164 return(ret); 167 return ret;
165} 168}