diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/um/os-Linux/aio.c | 20 | ||||
-rw-r--r-- | arch/um/os-Linux/drivers/ethertap_user.c | 10 | ||||
-rw-r--r-- | arch/um/os-Linux/helper.c | 9 | ||||
-rw-r--r-- | arch/um/os-Linux/process.c | 29 | ||||
-rw-r--r-- | arch/um/os-Linux/sigio.c | 7 | ||||
-rw-r--r-- | arch/um/os-Linux/skas/process.c | 2 | ||||
-rw-r--r-- | arch/um/os-Linux/tty_log.c | 16 |
7 files changed, 47 insertions, 46 deletions
diff --git a/arch/um/os-Linux/aio.c b/arch/um/os-Linux/aio.c index 6ff12743a0bd..c1f0f76291cf 100644 --- a/arch/um/os-Linux/aio.c +++ b/arch/um/os-Linux/aio.c | |||
@@ -146,28 +146,21 @@ static int aio_thread(void *arg) | |||
146 | static int do_not_aio(struct aio_thread_req *req) | 146 | static int do_not_aio(struct aio_thread_req *req) |
147 | { | 147 | { |
148 | char c; | 148 | char c; |
149 | unsigned long long actual; | ||
149 | int err; | 150 | int err; |
150 | 151 | ||
152 | actual = lseek64(req->io_fd, req->offset, SEEK_SET); | ||
153 | if(actual != req->offset) | ||
154 | return -errno; | ||
155 | |||
151 | switch(req->type){ | 156 | switch(req->type){ |
152 | case AIO_READ: | 157 | case AIO_READ: |
153 | err = os_seek_file(req->io_fd, req->offset); | ||
154 | if(err) | ||
155 | goto out; | ||
156 | |||
157 | err = os_read_file(req->io_fd, req->buf, req->len); | 158 | err = os_read_file(req->io_fd, req->buf, req->len); |
158 | break; | 159 | break; |
159 | case AIO_WRITE: | 160 | case AIO_WRITE: |
160 | err = os_seek_file(req->io_fd, req->offset); | ||
161 | if(err) | ||
162 | goto out; | ||
163 | |||
164 | err = os_write_file(req->io_fd, req->buf, req->len); | 161 | err = os_write_file(req->io_fd, req->buf, req->len); |
165 | break; | 162 | break; |
166 | case AIO_MMAP: | 163 | case AIO_MMAP: |
167 | err = os_seek_file(req->io_fd, req->offset); | ||
168 | if(err) | ||
169 | goto out; | ||
170 | |||
171 | err = os_read_file(req->io_fd, &c, sizeof(c)); | 164 | err = os_read_file(req->io_fd, &c, sizeof(c)); |
172 | break; | 165 | break; |
173 | default: | 166 | default: |
@@ -176,7 +169,6 @@ static int do_not_aio(struct aio_thread_req *req) | |||
176 | break; | 169 | break; |
177 | } | 170 | } |
178 | 171 | ||
179 | out: | ||
180 | return err; | 172 | return err; |
181 | } | 173 | } |
182 | 174 | ||
@@ -207,7 +199,7 @@ static int not_aio_thread(void *arg) | |||
207 | } | 199 | } |
208 | err = do_not_aio(&req); | 200 | err = do_not_aio(&req); |
209 | reply = ((struct aio_thread_reply) { .data = req.aio, | 201 | reply = ((struct aio_thread_reply) { .data = req.aio, |
210 | .err = err }); | 202 | .err = err }); |
211 | err = os_write_file(req.aio->reply_fd, &reply, sizeof(reply)); | 203 | err = os_write_file(req.aio->reply_fd, &reply, sizeof(reply)); |
212 | if(err != sizeof(reply)) | 204 | if(err != sizeof(reply)) |
213 | printk("not_aio_thread - write failed, fd = %d, " | 205 | printk("not_aio_thread - write failed, fd = %d, " |
diff --git a/arch/um/os-Linux/drivers/ethertap_user.c b/arch/um/os-Linux/drivers/ethertap_user.c index 96e12ea8172c..fd6cfa5b4a78 100644 --- a/arch/um/os-Linux/drivers/ethertap_user.c +++ b/arch/um/os-Linux/drivers/ethertap_user.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and | 2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and |
3 | * James Leu (jleu@mindspring.net). | 3 | * James Leu (jleu@mindspring.net). |
4 | * Copyright (C) 2001 by various other people who didn't put their name here. | 4 | * Copyright (C) 2001 by various other people who didn't put their name here. |
5 | * Licensed under the GPL. | 5 | * Licensed under the GPL. |
@@ -49,8 +49,11 @@ static void etap_change(int op, unsigned char *addr, unsigned char *netmask, | |||
49 | memcpy(change.addr, addr, sizeof(change.addr)); | 49 | memcpy(change.addr, addr, sizeof(change.addr)); |
50 | memcpy(change.netmask, netmask, sizeof(change.netmask)); | 50 | memcpy(change.netmask, netmask, sizeof(change.netmask)); |
51 | n = os_write_file(fd, &change, sizeof(change)); | 51 | n = os_write_file(fd, &change, sizeof(change)); |
52 | if(n != sizeof(change)) | 52 | if(n != sizeof(change)){ |
53 | printk("etap_change - request failed, err = %d\n", -n); | 53 | printk("etap_change - request failed, err = %d\n", -n); |
54 | return; | ||
55 | } | ||
56 | |||
54 | output = um_kmalloc(UM_KERN_PAGE_SIZE); | 57 | output = um_kmalloc(UM_KERN_PAGE_SIZE); |
55 | if(output == NULL) | 58 | if(output == NULL) |
56 | printk("etap_change : Failed to allocate output buffer\n"); | 59 | printk("etap_change : Failed to allocate output buffer\n"); |
@@ -116,7 +119,8 @@ static int etap_tramp(char *dev, char *gate, int control_me, | |||
116 | pe_data.data_me = data_me; | 119 | pe_data.data_me = data_me; |
117 | pid = run_helper(etap_pre_exec, &pe_data, args, NULL); | 120 | pid = run_helper(etap_pre_exec, &pe_data, args, NULL); |
118 | 121 | ||
119 | if(pid < 0) err = pid; | 122 | if(pid < 0) |
123 | err = pid; | ||
120 | os_close_file(data_remote); | 124 | os_close_file(data_remote); |
121 | os_close_file(control_remote); | 125 | os_close_file(control_remote); |
122 | n = os_read_file(control_me, &c, sizeof(c)); | 126 | n = os_read_file(control_me, &c, sizeof(c)); |
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c index 2184ddb9cb31..8a4c9e47326c 100644 --- a/arch/um/os-Linux/helper.c +++ b/arch/um/os-Linux/helper.c | |||
@@ -34,7 +34,8 @@ static int helper_child(void *arg) | |||
34 | if (data->pre_exec != NULL) | 34 | if (data->pre_exec != NULL) |
35 | (*data->pre_exec)(data->pre_data); | 35 | (*data->pre_exec)(data->pre_data); |
36 | errval = execvp_noalloc(data->buf, argv[0], argv); | 36 | errval = execvp_noalloc(data->buf, argv[0], argv); |
37 | 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], |
38 | -errval); | ||
38 | os_write_file(data->fd, &errval, sizeof(errval)); | 39 | os_write_file(data->fd, &errval, sizeof(errval)); |
39 | kill(os_getpid(), SIGKILL); | 40 | kill(os_getpid(), SIGKILL); |
40 | return 0; | 41 | return 0; |
@@ -87,8 +88,10 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | |||
87 | close(fds[1]); | 88 | close(fds[1]); |
88 | fds[1] = -1; | 89 | fds[1] = -1; |
89 | 90 | ||
90 | /* Read the errno value from the child, if the exec failed, or get 0 if | 91 | /* |
91 | * 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 |
93 | * the exec succeeded because the pipe fd was set as close-on-exec. | ||
94 | */ | ||
92 | n = os_read_file(fds[0], &ret, sizeof(ret)); | 95 | n = os_read_file(fds[0], &ret, sizeof(ret)); |
93 | if (n == 0) { | 96 | if (n == 0) { |
94 | ret = pid; | 97 | ret = pid; |
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 |
diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c index f77ce3d6f7cc..8ccf6a36f1c6 100644 --- a/arch/um/os-Linux/sigio.c +++ b/arch/um/os-Linux/sigio.c | |||
@@ -461,15 +461,16 @@ static void tty_output(int master, int slave) | |||
461 | 461 | ||
462 | while(os_write_file(master, buf, sizeof(buf)) > 0) ; | 462 | while(os_write_file(master, buf, sizeof(buf)) > 0) ; |
463 | if(errno != EAGAIN) | 463 | if(errno != EAGAIN) |
464 | panic("check_sigio : write failed, errno = %d\n", errno); | 464 | panic("tty_output : write failed, errno = %d\n", errno); |
465 | while(((n = os_read_file(slave, buf, sizeof(buf))) > 0) && !got_sigio) ; | 465 | while(((n = os_read_file(slave, buf, sizeof(buf))) > 0) && !got_sigio) ; |
466 | 466 | ||
467 | if(got_sigio){ | 467 | if(got_sigio){ |
468 | printk("Yes\n"); | 468 | printk("Yes\n"); |
469 | pty_output_sigio = 1; | 469 | pty_output_sigio = 1; |
470 | } | 470 | } |
471 | else if(n == -EAGAIN) printk("No, enabling workaround\n"); | 471 | else if(n == -EAGAIN) |
472 | else panic("check_sigio : read failed, err = %d\n", n); | 472 | printk("No, enabling workaround\n"); |
473 | else panic("tty_output : read failed, err = %d\n", n); | ||
473 | } | 474 | } |
474 | 475 | ||
475 | static void tty_close(int master, int slave) | 476 | static void tty_close(int master, int slave) |
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 41bf8d1e14e0..47852698d5e1 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c | |||
@@ -409,7 +409,7 @@ int copy_context_skas0(unsigned long new_stack, int pid) | |||
409 | 409 | ||
410 | /* | 410 | /* |
411 | * This is used only, if stub pages are needed, while proc_mm is | 411 | * This is used only, if stub pages are needed, while proc_mm is |
412 | * availabl. Opening /proc/mm creates a new mm_context, which lacks | 412 | * available. Opening /proc/mm creates a new mm_context, which lacks |
413 | * the stub-pages. Thus, we map them using /proc/mm-fd | 413 | * the stub-pages. Thus, we map them using /proc/mm-fd |
414 | */ | 414 | */ |
415 | void map_stub_pages(int fd, unsigned long code, | 415 | void map_stub_pages(int fd, unsigned long code, |
diff --git a/arch/um/os-Linux/tty_log.c b/arch/um/os-Linux/tty_log.c index c6ba56c1560f..ae9adb1b74f2 100644 --- a/arch/um/os-Linux/tty_log.c +++ b/arch/um/os-Linux/tty_log.c | |||
@@ -55,7 +55,7 @@ int open_tty_log(void *tty, void *current_tty) | |||
55 | .usec = tv.tv_usec } ); | 55 | .usec = tv.tv_usec } ); |
56 | os_write_file(tty_log_fd, &data, sizeof(data)); | 56 | os_write_file(tty_log_fd, &data, sizeof(data)); |
57 | os_write_file(tty_log_fd, ¤t_tty, data.len); | 57 | os_write_file(tty_log_fd, ¤t_tty, data.len); |
58 | return(tty_log_fd); | 58 | return tty_log_fd; |
59 | } | 59 | } |
60 | 60 | ||
61 | sprintf(buf, "%s/%0u-%0u", tty_log_dir, (unsigned int) tv.tv_sec, | 61 | sprintf(buf, "%s/%0u-%0u", tty_log_dir, (unsigned int) tv.tv_sec, |
@@ -67,7 +67,7 @@ int open_tty_log(void *tty, void *current_tty) | |||
67 | printk("open_tty_log : couldn't open '%s', errno = %d\n", | 67 | printk("open_tty_log : couldn't open '%s', errno = %d\n", |
68 | buf, -fd); | 68 | buf, -fd); |
69 | } | 69 | } |
70 | return(fd); | 70 | return fd; |
71 | } | 71 | } |
72 | 72 | ||
73 | void close_tty_log(int fd, void *tty) | 73 | void close_tty_log(int fd, void *tty) |
@@ -101,18 +101,18 @@ static int log_chunk(int fd, const char *buf, int len) | |||
101 | n = os_write_file(fd, chunk, try); | 101 | n = os_write_file(fd, chunk, try); |
102 | if(n != try) { | 102 | if(n != try) { |
103 | if(n < 0) | 103 | if(n < 0) |
104 | return(n); | 104 | return n; |
105 | return(-EIO); | 105 | return -EIO; |
106 | } | 106 | } |
107 | if(missed != 0) | 107 | if(missed != 0) |
108 | return(-EFAULT); | 108 | return -EFAULT; |
109 | 109 | ||
110 | len -= try; | 110 | len -= try; |
111 | total += try; | 111 | total += try; |
112 | buf += try; | 112 | buf += try; |
113 | } | 113 | } |
114 | 114 | ||
115 | return(total); | 115 | return total; |
116 | } | 116 | } |
117 | 117 | ||
118 | int write_tty_log(int fd, const char *buf, int len, void *tty, int is_read) | 118 | int write_tty_log(int fd, const char *buf, int len, void *tty, int is_read) |
@@ -133,7 +133,7 @@ int write_tty_log(int fd, const char *buf, int len, void *tty, int is_read) | |||
133 | os_write_file(tty_log_fd, &data, sizeof(data)); | 133 | os_write_file(tty_log_fd, &data, sizeof(data)); |
134 | } | 134 | } |
135 | 135 | ||
136 | return(log_chunk(fd, buf, len)); | 136 | return log_chunk(fd, buf, len); |
137 | } | 137 | } |
138 | 138 | ||
139 | void log_exec(char **argv, void *tty) | 139 | void log_exec(char **argv, void *tty) |
@@ -179,7 +179,7 @@ extern void register_tty_logger(int (*opener)(void *, void *), | |||
179 | static int register_logger(void) | 179 | static int register_logger(void) |
180 | { | 180 | { |
181 | register_tty_logger(open_tty_log, write_tty_log, close_tty_log); | 181 | register_tty_logger(open_tty_log, write_tty_log, close_tty_log); |
182 | return(0); | 182 | return 0; |
183 | } | 183 | } |
184 | 184 | ||
185 | __uml_initcall(register_logger); | 185 | __uml_initcall(register_logger); |