diff options
Diffstat (limited to 'arch/um/os-Linux/helper.c')
-rw-r--r-- | arch/um/os-Linux/helper.c | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c index c7ad6306e22f..97bed16bf4c7 100644 --- a/arch/um/os-Linux/helper.c +++ b/arch/um/os-Linux/helper.c | |||
@@ -13,9 +13,9 @@ | |||
13 | #include <sys/wait.h> | 13 | #include <sys/wait.h> |
14 | #include "user.h" | 14 | #include "user.h" |
15 | #include "kern_util.h" | 15 | #include "kern_util.h" |
16 | #include "user_util.h" | ||
17 | #include "os.h" | 16 | #include "os.h" |
18 | #include "um_malloc.h" | 17 | #include "um_malloc.h" |
18 | #include "kern_constants.h" | ||
19 | 19 | ||
20 | struct helper_data { | 20 | struct helper_data { |
21 | void (*pre_exec)(void*); | 21 | void (*pre_exec)(void*); |
@@ -25,28 +25,18 @@ struct helper_data { | |||
25 | char *buf; | 25 | char *buf; |
26 | }; | 26 | }; |
27 | 27 | ||
28 | /* Debugging aid, changed only from gdb */ | ||
29 | int helper_pause = 0; | ||
30 | |||
31 | static void helper_hup(int sig) | ||
32 | { | ||
33 | } | ||
34 | |||
35 | static int helper_child(void *arg) | 28 | static int helper_child(void *arg) |
36 | { | 29 | { |
37 | struct helper_data *data = arg; | 30 | struct helper_data *data = arg; |
38 | char **argv = data->argv; | 31 | char **argv = data->argv; |
39 | int errval; | 32 | int errval; |
40 | 33 | ||
41 | if (helper_pause){ | ||
42 | signal(SIGHUP, helper_hup); | ||
43 | pause(); | ||
44 | } | ||
45 | if (data->pre_exec != NULL) | 34 | if (data->pre_exec != NULL) |
46 | (*data->pre_exec)(data->pre_data); | 35 | (*data->pre_exec)(data->pre_data); |
47 | errval = execvp_noalloc(data->buf, argv[0], argv); | 36 | errval = execvp_noalloc(data->buf, argv[0], argv); |
48 | printk("helper_child - execvp of '%s' failed - errno = %d\n", argv[0], -errval); | 37 | printk("helper_child - execvp of '%s' failed - errno = %d\n", argv[0], |
49 | os_write_file(data->fd, &errval, sizeof(errval)); | 38 | -errval); |
39 | write(data->fd, &errval, sizeof(errval)); | ||
50 | kill(os_getpid(), SIGKILL); | 40 | kill(os_getpid(), SIGKILL); |
51 | return 0; | 41 | return 0; |
52 | } | 42 | } |
@@ -81,7 +71,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | |||
81 | goto out_close; | 71 | goto out_close; |
82 | } | 72 | } |
83 | 73 | ||
84 | sp = stack + page_size() - sizeof(void *); | 74 | sp = stack + UM_KERN_PAGE_SIZE - sizeof(void *); |
85 | data.pre_exec = pre_exec; | 75 | data.pre_exec = pre_exec; |
86 | data.pre_data = pre_data; | 76 | data.pre_data = pre_data; |
87 | data.argv = argv; | 77 | data.argv = argv; |
@@ -98,13 +88,16 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | |||
98 | close(fds[1]); | 88 | close(fds[1]); |
99 | fds[1] = -1; | 89 | fds[1] = -1; |
100 | 90 | ||
101 | /* Read the errno value from the child, if the exec failed, or get 0 if | 91 | /* |
102 | * the exec succeeded because the pipe fd was set as close-on-exec. */ | 92 | * Read the errno value from the child, if the exec failed, or get 0 if |
103 | n = os_read_file(fds[0], &ret, sizeof(ret)); | 93 | * the exec succeeded because the pipe fd was set as close-on-exec. |
94 | */ | ||
95 | n = read(fds[0], &ret, sizeof(ret)); | ||
104 | if (n == 0) { | 96 | if (n == 0) { |
105 | ret = pid; | 97 | ret = pid; |
106 | } else { | 98 | } else { |
107 | if (n < 0) { | 99 | if (n < 0) { |
100 | n = -errno; | ||
108 | printk("run_helper : read on pipe failed, ret = %d\n", | 101 | printk("run_helper : read on pipe failed, ret = %d\n", |
109 | -n); | 102 | -n); |
110 | ret = n; | 103 | ret = n; |
@@ -135,7 +128,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, | |||
135 | if (stack == 0) | 128 | if (stack == 0) |
136 | return -ENOMEM; | 129 | return -ENOMEM; |
137 | 130 | ||
138 | sp = stack + (page_size() << stack_order) - sizeof(void *); | 131 | sp = stack + (UM_KERN_PAGE_SIZE << stack_order) - sizeof(void *); |
139 | pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); | 132 | pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); |
140 | if (pid < 0) { | 133 | if (pid < 0) { |
141 | err = -errno; | 134 | err = -errno; |