diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-10-16 04:27:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:43:06 -0400 |
commit | 8ca842c4b5cbc70b9180617e9f26b6ac9f40dbb9 (patch) | |
tree | fe3e4deeae82c7063a72ecb3fdcae47422d6de0e /arch/um/drivers | |
parent | 28078e8f9790be0854a54f06de822689ab571944 (diff) |
uml: remove os_* usage from userspace files
This patch fixes some userspace files which were calling libc through the os_*
wrappers.
It turns out that there was only one user of os_new_tty_pgrp, so it can be
deleted.
There are also some style and whitespace fixes in here.
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/drivers')
-rw-r--r-- | arch/um/drivers/chan_user.c | 37 | ||||
-rw-r--r-- | arch/um/drivers/harddog_user.c | 54 |
2 files changed, 48 insertions, 43 deletions
diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c index 74f22d27327d..8443d372f67c 100644 --- a/arch/um/drivers/chan_user.c +++ b/arch/um/drivers/chan_user.c | |||
@@ -134,12 +134,12 @@ static int winch_thread(void *arg) | |||
134 | struct winch_data *data = arg; | 134 | struct winch_data *data = arg; |
135 | sigset_t sigs; | 135 | sigset_t sigs; |
136 | int pty_fd, pipe_fd; | 136 | int pty_fd, pipe_fd; |
137 | int count, err; | 137 | int count; |
138 | char c = 1; | 138 | char c = 1; |
139 | 139 | ||
140 | pty_fd = data->pty_fd; | 140 | pty_fd = data->pty_fd; |
141 | pipe_fd = data->pipe_fd; | 141 | pipe_fd = data->pipe_fd; |
142 | count = os_write_file(pipe_fd, &c, sizeof(c)); | 142 | count = write(pipe_fd, &c, sizeof(c)); |
143 | if (count != sizeof(c)) | 143 | if (count != sizeof(c)) |
144 | printk(UM_KERN_ERR "winch_thread : failed to write " | 144 | printk(UM_KERN_ERR "winch_thread : failed to write " |
145 | "synchronization byte, err = %d\n", -count); | 145 | "synchronization byte, err = %d\n", -count); |
@@ -167,10 +167,15 @@ static int winch_thread(void *arg) | |||
167 | exit(1); | 167 | exit(1); |
168 | } | 168 | } |
169 | 169 | ||
170 | err = os_new_tty_pgrp(pty_fd, os_getpid()); | 170 | if(ioctl(pty_fd, TIOCSCTTY, 0) < 0){ |
171 | if (err < 0) { | 171 | printk(UM_KERN_ERR "winch_thread : TIOCSCTTY failed on " |
172 | printk(UM_KERN_ERR "winch_thread : new_tty_pgrp failed on " | 172 | "fd %d err = %d\n", pty_fd, errno); |
173 | "fd %d err = %d\n", pty_fd, -err); | 173 | exit(1); |
174 | } | ||
175 | |||
176 | if(tcsetpgrp(pty_fd, os_getpid()) < 0){ | ||
177 | printk(UM_KERN_ERR "winch_thread : tcsetpgrp failed on " | ||
178 | "fd %d err = %d\n", pty_fd, errno); | ||
174 | exit(1); | 179 | exit(1); |
175 | } | 180 | } |
176 | 181 | ||
@@ -180,10 +185,10 @@ static int winch_thread(void *arg) | |||
180 | * kernel semaphores. We don't use SysV semaphores because they are | 185 | * kernel semaphores. We don't use SysV semaphores because they are |
181 | * persistent. | 186 | * persistent. |
182 | */ | 187 | */ |
183 | count = os_read_file(pipe_fd, &c, sizeof(c)); | 188 | count = read(pipe_fd, &c, sizeof(c)); |
184 | if (count != sizeof(c)) | 189 | if (count != sizeof(c)) |
185 | printk(UM_KERN_ERR "winch_thread : failed to read " | 190 | printk(UM_KERN_ERR "winch_thread : failed to read " |
186 | "synchronization byte, err = %d\n", -count); | 191 | "synchronization byte, err = %d\n", errno); |
187 | 192 | ||
188 | while(1) { | 193 | while(1) { |
189 | /* | 194 | /* |
@@ -192,10 +197,10 @@ static int winch_thread(void *arg) | |||
192 | */ | 197 | */ |
193 | sigsuspend(&sigs); | 198 | sigsuspend(&sigs); |
194 | 199 | ||
195 | count = os_write_file(pipe_fd, &c, sizeof(c)); | 200 | count = write(pipe_fd, &c, sizeof(c)); |
196 | if (count != sizeof(c)) | 201 | if (count != sizeof(c)) |
197 | printk(UM_KERN_ERR "winch_thread : write failed, " | 202 | printk(UM_KERN_ERR "winch_thread : write failed, " |
198 | "err = %d\n", -count); | 203 | "err = %d\n", errno); |
199 | } | 204 | } |
200 | } | 205 | } |
201 | 206 | ||
@@ -229,11 +234,11 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out, | |||
229 | } | 234 | } |
230 | 235 | ||
231 | *fd_out = fds[0]; | 236 | *fd_out = fds[0]; |
232 | n = os_read_file(fds[0], &c, sizeof(c)); | 237 | n = read(fds[0], &c, sizeof(c)); |
233 | if (n != sizeof(c)) { | 238 | if (n != sizeof(c)) { |
234 | printk(UM_KERN_ERR "winch_tramp : failed to read " | 239 | printk(UM_KERN_ERR "winch_tramp : failed to read " |
235 | "synchronization byte\n"); | 240 | "synchronization byte\n"); |
236 | printk(UM_KERN_ERR "read failed, err = %d\n", -n); | 241 | printk(UM_KERN_ERR "read failed, err = %d\n", errno); |
237 | printk(UM_KERN_ERR "fd %d will not support SIGWINCH\n", fd); | 242 | printk(UM_KERN_ERR "fd %d will not support SIGWINCH\n", fd); |
238 | err = -EINVAL; | 243 | err = -EINVAL; |
239 | goto out_close; | 244 | goto out_close; |
@@ -248,8 +253,8 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out, | |||
248 | return err; | 253 | return err; |
249 | 254 | ||
250 | out_close: | 255 | out_close: |
251 | os_close_file(fds[1]); | 256 | close(fds[1]); |
252 | os_close_file(fds[0]); | 257 | close(fds[0]); |
253 | out: | 258 | out: |
254 | return err; | 259 | return err; |
255 | } | 260 | } |
@@ -271,9 +276,9 @@ void register_winch(int fd, struct tty_struct *tty) | |||
271 | 276 | ||
272 | register_winch_irq(thread_fd, fd, thread, tty, stack); | 277 | register_winch_irq(thread_fd, fd, thread, tty, stack); |
273 | 278 | ||
274 | count = os_write_file(thread_fd, &c, sizeof(c)); | 279 | count = write(thread_fd, &c, sizeof(c)); |
275 | if (count != sizeof(c)) | 280 | if (count != sizeof(c)) |
276 | printk(UM_KERN_ERR "register_winch : failed to write " | 281 | printk(UM_KERN_ERR "register_winch : failed to write " |
277 | "synchronization byte, err = %d\n", -count); | 282 | "synchronization byte, err = %d\n", errno); |
278 | } | 283 | } |
279 | } | 284 | } |
diff --git a/arch/um/drivers/harddog_user.c b/arch/um/drivers/harddog_user.c index 19ea26f32f14..b56f8e0196a9 100644 --- a/arch/um/drivers/harddog_user.c +++ b/arch/um/drivers/harddog_user.c | |||
@@ -1,14 +1,13 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | #include <unistd.h> | 7 | #include <unistd.h> |
8 | #include <errno.h> | 8 | #include <errno.h> |
9 | #include "user.h" | ||
10 | #include "mconsole.h" | ||
11 | #include "os.h" | 9 | #include "os.h" |
10 | #include "user.h" | ||
12 | 11 | ||
13 | struct dog_data { | 12 | struct dog_data { |
14 | int stdin; | 13 | int stdin; |
@@ -23,10 +22,10 @@ static void pre_exec(void *d) | |||
23 | dup2(data->stdin, 0); | 22 | dup2(data->stdin, 0); |
24 | dup2(data->stdout, 1); | 23 | dup2(data->stdout, 1); |
25 | dup2(data->stdout, 2); | 24 | dup2(data->stdout, 2); |
26 | os_close_file(data->stdin); | 25 | close(data->stdin); |
27 | os_close_file(data->stdout); | 26 | close(data->stdout); |
28 | os_close_file(data->close_me[0]); | 27 | close(data->close_me[0]); |
29 | os_close_file(data->close_me[1]); | 28 | close(data->close_me[1]); |
30 | } | 29 | } |
31 | 30 | ||
32 | int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock) | 31 | int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock) |
@@ -40,13 +39,13 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock) | |||
40 | char **args = NULL; | 39 | char **args = NULL; |
41 | 40 | ||
42 | err = os_pipe(in_fds, 1, 0); | 41 | err = os_pipe(in_fds, 1, 0); |
43 | if(err < 0){ | 42 | if (err < 0) { |
44 | printk("harddog_open - os_pipe failed, err = %d\n", -err); | 43 | printk("harddog_open - os_pipe failed, err = %d\n", -err); |
45 | goto out; | 44 | goto out; |
46 | } | 45 | } |
47 | 46 | ||
48 | err = os_pipe(out_fds, 1, 0); | 47 | err = os_pipe(out_fds, 1, 0); |
49 | if(err < 0){ | 48 | if (err < 0) { |
50 | printk("harddog_open - os_pipe failed, err = %d\n", -err); | 49 | printk("harddog_open - os_pipe failed, err = %d\n", -err); |
51 | goto out_close_in; | 50 | goto out_close_in; |
52 | } | 51 | } |
@@ -56,7 +55,7 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock) | |||
56 | data.close_me[0] = out_fds[1]; | 55 | data.close_me[0] = out_fds[1]; |
57 | data.close_me[1] = in_fds[0]; | 56 | data.close_me[1] = in_fds[0]; |
58 | 57 | ||
59 | if(sock != NULL){ | 58 | if (sock != NULL) { |
60 | mconsole_args[2] = sock; | 59 | mconsole_args[2] = sock; |
61 | args = mconsole_args; | 60 | args = mconsole_args; |
62 | } | 61 | } |
@@ -68,25 +67,25 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock) | |||
68 | 67 | ||
69 | pid = run_helper(pre_exec, &data, args); | 68 | pid = run_helper(pre_exec, &data, args); |
70 | 69 | ||
71 | os_close_file(out_fds[0]); | 70 | close(out_fds[0]); |
72 | os_close_file(in_fds[1]); | 71 | close(in_fds[1]); |
73 | 72 | ||
74 | if(pid < 0){ | 73 | if (pid < 0) { |
75 | err = -pid; | 74 | err = -pid; |
76 | printk("harddog_open - run_helper failed, errno = %d\n", -err); | 75 | printk("harddog_open - run_helper failed, errno = %d\n", -err); |
77 | goto out_close_out; | 76 | goto out_close_out; |
78 | } | 77 | } |
79 | 78 | ||
80 | n = os_read_file(in_fds[0], &c, sizeof(c)); | 79 | n = read(in_fds[0], &c, sizeof(c)); |
81 | if(n == 0){ | 80 | if (n == 0) { |
82 | printk("harddog_open - EOF on watchdog pipe\n"); | 81 | printk("harddog_open - EOF on watchdog pipe\n"); |
83 | helper_wait(pid); | 82 | helper_wait(pid); |
84 | err = -EIO; | 83 | err = -EIO; |
85 | goto out_close_out; | 84 | goto out_close_out; |
86 | } | 85 | } |
87 | else if(n < 0){ | 86 | else if (n < 0) { |
88 | printk("harddog_open - read of watchdog pipe failed, " | 87 | printk("harddog_open - read of watchdog pipe failed, " |
89 | "err = %d\n", -n); | 88 | "err = %d\n", errno); |
90 | helper_wait(pid); | 89 | helper_wait(pid); |
91 | err = n; | 90 | err = n; |
92 | goto out_close_out; | 91 | goto out_close_out; |
@@ -96,19 +95,19 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock) | |||
96 | return 0; | 95 | return 0; |
97 | 96 | ||
98 | out_close_in: | 97 | out_close_in: |
99 | os_close_file(in_fds[0]); | 98 | close(in_fds[0]); |
100 | os_close_file(in_fds[1]); | 99 | close(in_fds[1]); |
101 | out_close_out: | 100 | out_close_out: |
102 | os_close_file(out_fds[0]); | 101 | close(out_fds[0]); |
103 | os_close_file(out_fds[1]); | 102 | close(out_fds[1]); |
104 | out: | 103 | out: |
105 | return err; | 104 | return err; |
106 | } | 105 | } |
107 | 106 | ||
108 | void stop_watchdog(int in_fd, int out_fd) | 107 | void stop_watchdog(int in_fd, int out_fd) |
109 | { | 108 | { |
110 | os_close_file(in_fd); | 109 | close(in_fd); |
111 | os_close_file(out_fd); | 110 | close(out_fd); |
112 | } | 111 | } |
113 | 112 | ||
114 | int ping_watchdog(int fd) | 113 | int ping_watchdog(int fd) |
@@ -116,10 +115,11 @@ int ping_watchdog(int fd) | |||
116 | int n; | 115 | int n; |
117 | char c = '\n'; | 116 | char c = '\n'; |
118 | 117 | ||
119 | n = os_write_file(fd, &c, sizeof(c)); | 118 | n = write(fd, &c, sizeof(c)); |
120 | if(n != sizeof(c)){ | 119 | if (n != sizeof(c)) { |
121 | printk("ping_watchdog - write failed, err = %d\n", -n); | 120 | printk("ping_watchdog - write failed, ret = %d, err = %d\n", |
122 | if(n < 0) | 121 | n, errno); |
122 | if (n < 0) | ||
123 | return n; | 123 | return n; |
124 | return -EIO; | 124 | return -EIO; |
125 | } | 125 | } |