diff options
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/drivers/chan_user.c | 18 | ||||
-rw-r--r-- | arch/um/drivers/cow_user.c | 133 | ||||
-rw-r--r-- | arch/um/drivers/fd.c | 13 | ||||
-rw-r--r-- | arch/um/drivers/hostaudio_kern.c | 118 | ||||
-rw-r--r-- | arch/um/drivers/mconsole_user.c | 119 | ||||
-rw-r--r-- | arch/um/drivers/mmapper_kern.c | 64 | ||||
-rw-r--r-- | arch/um/drivers/null.c | 4 | ||||
-rw-r--r-- | arch/um/drivers/pty.c | 16 | ||||
-rw-r--r-- | arch/um/drivers/xterm.c | 12 |
9 files changed, 244 insertions, 253 deletions
diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c index 8443d372f67c..b88e93b3a39f 100644 --- a/arch/um/drivers/chan_user.c +++ b/arch/um/drivers/chan_user.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com) | 2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
@@ -82,17 +82,21 @@ int generic_console_write(int fd, const char *buf, int n) | |||
82 | if (err) | 82 | if (err) |
83 | goto error; | 83 | goto error; |
84 | new = save; | 84 | new = save; |
85 | /* The terminal becomes a bit less raw, to handle \n also as | 85 | /* |
86 | * The terminal becomes a bit less raw, to handle \n also as | ||
86 | * "Carriage Return", not only as "New Line". Otherwise, the new | 87 | * "Carriage Return", not only as "New Line". Otherwise, the new |
87 | * line won't start at the first column.*/ | 88 | * line won't start at the first column. |
89 | */ | ||
88 | new.c_oflag |= OPOST; | 90 | new.c_oflag |= OPOST; |
89 | CATCH_EINTR(err = tcsetattr(fd, TCSAFLUSH, &new)); | 91 | CATCH_EINTR(err = tcsetattr(fd, TCSAFLUSH, &new)); |
90 | if (err) | 92 | if (err) |
91 | goto error; | 93 | goto error; |
92 | } | 94 | } |
93 | err = generic_write(fd, buf, n, NULL); | 95 | err = generic_write(fd, buf, n, NULL); |
94 | /* Restore raw mode, in any case; we *must* ignore any error apart | 96 | /* |
95 | * EINTR, except for debug.*/ | 97 | * Restore raw mode, in any case; we *must* ignore any error apart |
98 | * EINTR, except for debug. | ||
99 | */ | ||
96 | if (isatty(fd)) | 100 | if (isatty(fd)) |
97 | CATCH_EINTR(tcsetattr(fd, TCSAFLUSH, &save)); | 101 | CATCH_EINTR(tcsetattr(fd, TCSAFLUSH, &save)); |
98 | return err; | 102 | return err; |
@@ -167,13 +171,13 @@ static int winch_thread(void *arg) | |||
167 | exit(1); | 171 | exit(1); |
168 | } | 172 | } |
169 | 173 | ||
170 | if(ioctl(pty_fd, TIOCSCTTY, 0) < 0){ | 174 | if (ioctl(pty_fd, TIOCSCTTY, 0) < 0) { |
171 | printk(UM_KERN_ERR "winch_thread : TIOCSCTTY failed on " | 175 | printk(UM_KERN_ERR "winch_thread : TIOCSCTTY failed on " |
172 | "fd %d err = %d\n", pty_fd, errno); | 176 | "fd %d err = %d\n", pty_fd, errno); |
173 | exit(1); | 177 | exit(1); |
174 | } | 178 | } |
175 | 179 | ||
176 | if(tcsetpgrp(pty_fd, os_getpid()) < 0){ | 180 | if (tcsetpgrp(pty_fd, os_getpid()) < 0) { |
177 | printk(UM_KERN_ERR "winch_thread : tcsetpgrp failed on " | 181 | printk(UM_KERN_ERR "winch_thread : tcsetpgrp failed on " |
178 | "fd %d err = %d\n", pty_fd, errno); | 182 | "fd %d err = %d\n", pty_fd, errno); |
179 | exit(1); | 183 | exit(1); |
diff --git a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c index 0ec4052db9c5..93f227a25ba4 100644 --- a/arch/um/drivers/cow_user.c +++ b/arch/um/drivers/cow_user.c | |||
@@ -1,17 +1,18 @@ | |||
1 | #include <stddef.h> | 1 | /* |
2 | #include <string.h> | 2 | * Copyright (C) 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com) |
3 | #include <errno.h> | 3 | * Licensed under the GPL |
4 | /* _XOPEN_SOURCE is needed for pread, but we define _GNU_SOURCE, which defines | 4 | */ |
5 | |||
6 | /* | ||
7 | * _XOPEN_SOURCE is needed for pread, but we define _GNU_SOURCE, which defines | ||
5 | * that. | 8 | * that. |
6 | */ | 9 | */ |
7 | #include <unistd.h> | 10 | #include <unistd.h> |
8 | #include <byteswap.h> | 11 | #include <byteswap.h> |
9 | #include <sys/time.h> | 12 | #include <errno.h> |
10 | #include <sys/param.h> | 13 | #include <string.h> |
11 | #include <sys/user.h> | 14 | #include <arpa/inet.h> |
12 | 15 | #include <asm/types.h> | |
13 | #include "os.h" | ||
14 | |||
15 | #include "cow.h" | 16 | #include "cow.h" |
16 | #include "cow_sys.h" | 17 | #include "cow_sys.h" |
17 | 18 | ||
@@ -28,7 +29,8 @@ struct cow_header_v1 { | |||
28 | __s32 sectorsize; | 29 | __s32 sectorsize; |
29 | } __attribute__((packed)); | 30 | } __attribute__((packed)); |
30 | 31 | ||
31 | /* Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in | 32 | /* |
33 | * Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in | ||
32 | * case other systems have different values for MAXPATHLEN. | 34 | * case other systems have different values for MAXPATHLEN. |
33 | * | 35 | * |
34 | * The same must hold for V2 - we want file format compatibility, not anything | 36 | * The same must hold for V2 - we want file format compatibility, not anything |
@@ -46,7 +48,8 @@ struct cow_header_v2 { | |||
46 | __s32 sectorsize; | 48 | __s32 sectorsize; |
47 | } __attribute__((packed)); | 49 | } __attribute__((packed)); |
48 | 50 | ||
49 | /* Changes from V2 - | 51 | /* |
52 | * Changes from V2 - | ||
50 | * PATH_LEN_V3 as described above | 53 | * PATH_LEN_V3 as described above |
51 | * Explicitly specify field bit lengths for systems with different | 54 | * Explicitly specify field bit lengths for systems with different |
52 | * lengths for the usual C types. Not sure whether char or | 55 | * lengths for the usual C types. Not sure whether char or |
@@ -70,7 +73,8 @@ struct cow_header_v2 { | |||
70 | * Fixed (finally!) the rounding bug | 73 | * Fixed (finally!) the rounding bug |
71 | */ | 74 | */ |
72 | 75 | ||
73 | /* Until Dec2005, __attribute__((packed)) was left out from the below | 76 | /* |
77 | * Until Dec2005, __attribute__((packed)) was left out from the below | ||
74 | * definition, leading on 64-bit systems to 4 bytes of padding after mtime, to | 78 | * definition, leading on 64-bit systems to 4 bytes of padding after mtime, to |
75 | * align size to 8-byte alignment. This shifted all fields above (no padding | 79 | * align size to 8-byte alignment. This shifted all fields above (no padding |
76 | * was present on 32-bit, no other padding was added). | 80 | * was present on 32-bit, no other padding was added). |
@@ -122,7 +126,7 @@ void cow_sizes(int version, __u64 size, int sectorsize, int align, | |||
122 | int bitmap_offset, unsigned long *bitmap_len_out, | 126 | int bitmap_offset, unsigned long *bitmap_len_out, |
123 | int *data_offset_out) | 127 | int *data_offset_out) |
124 | { | 128 | { |
125 | if(version < 3){ | 129 | if (version < 3) { |
126 | *bitmap_len_out = (size + sectorsize - 1) / (8 * sectorsize); | 130 | *bitmap_len_out = (size + sectorsize - 1) / (8 * sectorsize); |
127 | 131 | ||
128 | *data_offset_out = bitmap_offset + *bitmap_len_out; | 132 | *data_offset_out = bitmap_offset + *bitmap_len_out; |
@@ -144,46 +148,46 @@ static int absolutize(char *to, int size, char *from) | |||
144 | char save_cwd[256], *slash; | 148 | char save_cwd[256], *slash; |
145 | int remaining; | 149 | int remaining; |
146 | 150 | ||
147 | if(getcwd(save_cwd, sizeof(save_cwd)) == NULL) { | 151 | if (getcwd(save_cwd, sizeof(save_cwd)) == NULL) { |
148 | cow_printf("absolutize : unable to get cwd - errno = %d\n", | 152 | cow_printf("absolutize : unable to get cwd - errno = %d\n", |
149 | errno); | 153 | errno); |
150 | return(-1); | 154 | return -1; |
151 | } | 155 | } |
152 | slash = strrchr(from, '/'); | 156 | slash = strrchr(from, '/'); |
153 | if(slash != NULL){ | 157 | if (slash != NULL) { |
154 | *slash = '\0'; | 158 | *slash = '\0'; |
155 | if(chdir(from)){ | 159 | if (chdir(from)) { |
156 | *slash = '/'; | 160 | *slash = '/'; |
157 | cow_printf("absolutize : Can't cd to '%s' - " | 161 | cow_printf("absolutize : Can't cd to '%s' - " |
158 | "errno = %d\n", from, errno); | 162 | "errno = %d\n", from, errno); |
159 | return(-1); | 163 | return -1; |
160 | } | 164 | } |
161 | *slash = '/'; | 165 | *slash = '/'; |
162 | if(getcwd(to, size) == NULL){ | 166 | if (getcwd(to, size) == NULL) { |
163 | cow_printf("absolutize : unable to get cwd of '%s' - " | 167 | cow_printf("absolutize : unable to get cwd of '%s' - " |
164 | "errno = %d\n", from, errno); | 168 | "errno = %d\n", from, errno); |
165 | return(-1); | 169 | return -1; |
166 | } | 170 | } |
167 | remaining = size - strlen(to); | 171 | remaining = size - strlen(to); |
168 | if(strlen(slash) + 1 > remaining){ | 172 | if (strlen(slash) + 1 > remaining) { |
169 | cow_printf("absolutize : unable to fit '%s' into %d " | 173 | cow_printf("absolutize : unable to fit '%s' into %d " |
170 | "chars\n", from, size); | 174 | "chars\n", from, size); |
171 | return(-1); | 175 | return -1; |
172 | } | 176 | } |
173 | strcat(to, slash); | 177 | strcat(to, slash); |
174 | } | 178 | } |
175 | else { | 179 | else { |
176 | if(strlen(save_cwd) + 1 + strlen(from) + 1 > size){ | 180 | if (strlen(save_cwd) + 1 + strlen(from) + 1 > size) { |
177 | cow_printf("absolutize : unable to fit '%s' into %d " | 181 | cow_printf("absolutize : unable to fit '%s' into %d " |
178 | "chars\n", from, size); | 182 | "chars\n", from, size); |
179 | return(-1); | 183 | return -1; |
180 | } | 184 | } |
181 | strcpy(to, save_cwd); | 185 | strcpy(to, save_cwd); |
182 | strcat(to, "/"); | 186 | strcat(to, "/"); |
183 | strcat(to, from); | 187 | strcat(to, from); |
184 | } | 188 | } |
185 | chdir(save_cwd); | 189 | chdir(save_cwd); |
186 | return(0); | 190 | return 0; |
187 | } | 191 | } |
188 | 192 | ||
189 | int write_cow_header(char *cow_file, int fd, char *backing_file, | 193 | int write_cow_header(char *cow_file, int fd, char *backing_file, |
@@ -194,22 +198,23 @@ int write_cow_header(char *cow_file, int fd, char *backing_file, | |||
194 | int err; | 198 | int err; |
195 | 199 | ||
196 | err = cow_seek_file(fd, 0); | 200 | err = cow_seek_file(fd, 0); |
197 | if(err < 0){ | 201 | if (err < 0) { |
198 | cow_printf("write_cow_header - lseek failed, err = %d\n", -err); | 202 | cow_printf("write_cow_header - lseek failed, err = %d\n", -err); |
199 | goto out; | 203 | goto out; |
200 | } | 204 | } |
201 | 205 | ||
202 | err = -ENOMEM; | 206 | err = -ENOMEM; |
203 | header = cow_malloc(sizeof(*header)); | 207 | header = cow_malloc(sizeof(*header)); |
204 | if(header == NULL){ | 208 | if (header == NULL) { |
205 | cow_printf("write_cow_header - failed to allocate COW V3 header\n"); | 209 | cow_printf("write_cow_header - failed to allocate COW V3 " |
210 | "header\n"); | ||
206 | goto out; | 211 | goto out; |
207 | } | 212 | } |
208 | header->magic = htonl(COW_MAGIC); | 213 | header->magic = htonl(COW_MAGIC); |
209 | header->version = htonl(COW_VERSION); | 214 | header->version = htonl(COW_VERSION); |
210 | 215 | ||
211 | err = -EINVAL; | 216 | err = -EINVAL; |
212 | if(strlen(backing_file) > sizeof(header->backing_file) - 1){ | 217 | if (strlen(backing_file) > sizeof(header->backing_file) - 1) { |
213 | /* Below, %zd is for a size_t value */ | 218 | /* Below, %zd is for a size_t value */ |
214 | cow_printf("Backing file name \"%s\" is too long - names are " | 219 | cow_printf("Backing file name \"%s\" is too long - names are " |
215 | "limited to %zd characters\n", backing_file, | 220 | "limited to %zd characters\n", backing_file, |
@@ -217,12 +222,12 @@ int write_cow_header(char *cow_file, int fd, char *backing_file, | |||
217 | goto out_free; | 222 | goto out_free; |
218 | } | 223 | } |
219 | 224 | ||
220 | if(absolutize(header->backing_file, sizeof(header->backing_file), | 225 | if (absolutize(header->backing_file, sizeof(header->backing_file), |
221 | backing_file)) | 226 | backing_file)) |
222 | goto out_free; | 227 | goto out_free; |
223 | 228 | ||
224 | err = os_file_modtime(header->backing_file, &modtime); | 229 | err = os_file_modtime(header->backing_file, &modtime); |
225 | if(err < 0){ | 230 | if (err < 0) { |
226 | cow_printf("write_cow_header - backing file '%s' mtime " | 231 | cow_printf("write_cow_header - backing file '%s' mtime " |
227 | "request failed, err = %d\n", header->backing_file, | 232 | "request failed, err = %d\n", header->backing_file, |
228 | -err); | 233 | -err); |
@@ -230,7 +235,7 @@ int write_cow_header(char *cow_file, int fd, char *backing_file, | |||
230 | } | 235 | } |
231 | 236 | ||
232 | err = cow_file_size(header->backing_file, size); | 237 | err = cow_file_size(header->backing_file, size); |
233 | if(err < 0){ | 238 | if (err < 0) { |
234 | cow_printf("write_cow_header - couldn't get size of " | 239 | cow_printf("write_cow_header - couldn't get size of " |
235 | "backing file '%s', err = %d\n", | 240 | "backing file '%s', err = %d\n", |
236 | header->backing_file, -err); | 241 | header->backing_file, -err); |
@@ -244,7 +249,7 @@ int write_cow_header(char *cow_file, int fd, char *backing_file, | |||
244 | header->cow_format = COW_BITMAP; | 249 | header->cow_format = COW_BITMAP; |
245 | 250 | ||
246 | err = cow_write_file(fd, header, sizeof(*header)); | 251 | err = cow_write_file(fd, header, sizeof(*header)); |
247 | if(err != sizeof(*header)){ | 252 | if (err != sizeof(*header)) { |
248 | cow_printf("write_cow_header - write of header to " | 253 | cow_printf("write_cow_header - write of header to " |
249 | "new COW file '%s' failed, err = %d\n", cow_file, | 254 | "new COW file '%s' failed, err = %d\n", cow_file, |
250 | -err); | 255 | -err); |
@@ -254,14 +259,14 @@ int write_cow_header(char *cow_file, int fd, char *backing_file, | |||
254 | out_free: | 259 | out_free: |
255 | cow_free(header); | 260 | cow_free(header); |
256 | out: | 261 | out: |
257 | return(err); | 262 | return err; |
258 | } | 263 | } |
259 | 264 | ||
260 | int file_reader(__u64 offset, char *buf, int len, void *arg) | 265 | int file_reader(__u64 offset, char *buf, int len, void *arg) |
261 | { | 266 | { |
262 | int fd = *((int *) arg); | 267 | int fd = *((int *) arg); |
263 | 268 | ||
264 | return(pread(fd, buf, len, offset)); | 269 | return pread(fd, buf, len, offset); |
265 | } | 270 | } |
266 | 271 | ||
267 | /* XXX Need to sanity-check the values read from the header */ | 272 | /* XXX Need to sanity-check the values read from the header */ |
@@ -278,31 +283,29 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, | |||
278 | unsigned long version, magic; | 283 | unsigned long version, magic; |
279 | 284 | ||
280 | header = cow_malloc(sizeof(*header)); | 285 | header = cow_malloc(sizeof(*header)); |
281 | if(header == NULL){ | 286 | if (header == NULL) { |
282 | cow_printf("read_cow_header - Failed to allocate header\n"); | 287 | cow_printf("read_cow_header - Failed to allocate header\n"); |
283 | return(-ENOMEM); | 288 | return -ENOMEM; |
284 | } | 289 | } |
285 | err = -EINVAL; | 290 | err = -EINVAL; |
286 | n = (*reader)(0, (char *) header, sizeof(*header), arg); | 291 | n = (*reader)(0, (char *) header, sizeof(*header), arg); |
287 | if(n < offsetof(typeof(header->v1), backing_file)){ | 292 | if (n < offsetof(typeof(header->v1), backing_file)) { |
288 | cow_printf("read_cow_header - short header\n"); | 293 | cow_printf("read_cow_header - short header\n"); |
289 | goto out; | 294 | goto out; |
290 | } | 295 | } |
291 | 296 | ||
292 | magic = header->v1.magic; | 297 | magic = header->v1.magic; |
293 | if(magic == COW_MAGIC) { | 298 | if (magic == COW_MAGIC) |
294 | version = header->v1.version; | 299 | version = header->v1.version; |
295 | } | 300 | else if (magic == ntohl(COW_MAGIC)) |
296 | else if(magic == ntohl(COW_MAGIC)){ | ||
297 | version = ntohl(header->v1.version); | 301 | version = ntohl(header->v1.version); |
298 | } | ||
299 | /* No error printed because the non-COW case comes through here */ | 302 | /* No error printed because the non-COW case comes through here */ |
300 | else goto out; | 303 | else goto out; |
301 | 304 | ||
302 | *version_out = version; | 305 | *version_out = version; |
303 | 306 | ||
304 | if(version == 1){ | 307 | if (version == 1) { |
305 | if(n < sizeof(header->v1)){ | 308 | if (n < sizeof(header->v1)) { |
306 | cow_printf("read_cow_header - failed to read V1 " | 309 | cow_printf("read_cow_header - failed to read V1 " |
307 | "header\n"); | 310 | "header\n"); |
308 | goto out; | 311 | goto out; |
@@ -314,8 +317,8 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, | |||
314 | *align_out = *sectorsize_out; | 317 | *align_out = *sectorsize_out; |
315 | file = header->v1.backing_file; | 318 | file = header->v1.backing_file; |
316 | } | 319 | } |
317 | else if(version == 2){ | 320 | else if (version == 2) { |
318 | if(n < sizeof(header->v2)){ | 321 | if (n < sizeof(header->v2)) { |
319 | cow_printf("read_cow_header - failed to read V2 " | 322 | cow_printf("read_cow_header - failed to read V2 " |
320 | "header\n"); | 323 | "header\n"); |
321 | goto out; | 324 | goto out; |
@@ -328,8 +331,8 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, | |||
328 | file = header->v2.backing_file; | 331 | file = header->v2.backing_file; |
329 | } | 332 | } |
330 | /* This is very subtle - see above at union cow_header definition */ | 333 | /* This is very subtle - see above at union cow_header definition */ |
331 | else if(version == 3 && (*((int*)header->v3.backing_file) != 0)){ | 334 | else if (version == 3 && (*((int*)header->v3.backing_file) != 0)) { |
332 | if(n < sizeof(header->v3)){ | 335 | if (n < sizeof(header->v3)) { |
333 | cow_printf("read_cow_header - failed to read V3 " | 336 | cow_printf("read_cow_header - failed to read V3 " |
334 | "header\n"); | 337 | "header\n"); |
335 | goto out; | 338 | goto out; |
@@ -345,17 +348,18 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, | |||
345 | *bitmap_offset_out = ROUND_UP(sizeof(header->v3), *align_out); | 348 | *bitmap_offset_out = ROUND_UP(sizeof(header->v3), *align_out); |
346 | file = header->v3.backing_file; | 349 | file = header->v3.backing_file; |
347 | } | 350 | } |
348 | else if(version == 3){ | 351 | else if (version == 3) { |
349 | cow_printf("read_cow_header - broken V3 file with" | 352 | cow_printf("read_cow_header - broken V3 file with" |
350 | " 64-bit layout - recovering content.\n"); | 353 | " 64-bit layout - recovering content.\n"); |
351 | 354 | ||
352 | if(n < sizeof(header->v3_b)){ | 355 | if (n < sizeof(header->v3_b)) { |
353 | cow_printf("read_cow_header - failed to read V3 " | 356 | cow_printf("read_cow_header - failed to read V3 " |
354 | "header\n"); | 357 | "header\n"); |
355 | goto out; | 358 | goto out; |
356 | } | 359 | } |
357 | 360 | ||
358 | /* this was used until Dec2005 - 64bits are needed to represent | 361 | /* |
362 | * this was used until Dec2005 - 64bits are needed to represent | ||
359 | * 2038+. I.e. we can safely do this truncating cast. | 363 | * 2038+. I.e. we can safely do this truncating cast. |
360 | * | 364 | * |
361 | * Additionally, we must use ntohl() instead of ntohll(), since | 365 | * Additionally, we must use ntohl() instead of ntohll(), since |
@@ -381,7 +385,7 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, | |||
381 | } | 385 | } |
382 | err = -ENOMEM; | 386 | err = -ENOMEM; |
383 | *backing_file_out = cow_strdup(file); | 387 | *backing_file_out = cow_strdup(file); |
384 | if(*backing_file_out == NULL){ | 388 | if (*backing_file_out == NULL) { |
385 | cow_printf("read_cow_header - failed to allocate backing " | 389 | cow_printf("read_cow_header - failed to allocate backing " |
386 | "file\n"); | 390 | "file\n"); |
387 | goto out; | 391 | goto out; |
@@ -389,7 +393,7 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, | |||
389 | err = 0; | 393 | err = 0; |
390 | out: | 394 | out: |
391 | cow_free(header); | 395 | cow_free(header); |
392 | return(err); | 396 | return err; |
393 | } | 397 | } |
394 | 398 | ||
395 | int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize, | 399 | int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize, |
@@ -402,7 +406,7 @@ int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize, | |||
402 | 406 | ||
403 | err = write_cow_header(cow_file, fd, backing_file, sectorsize, | 407 | err = write_cow_header(cow_file, fd, backing_file, sectorsize, |
404 | alignment, &size); | 408 | alignment, &size); |
405 | if(err) | 409 | if (err) |
406 | goto out; | 410 | goto out; |
407 | 411 | ||
408 | *bitmap_offset_out = ROUND_UP(sizeof(struct cow_header_v3), alignment); | 412 | *bitmap_offset_out = ROUND_UP(sizeof(struct cow_header_v3), alignment); |
@@ -411,17 +415,18 @@ int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize, | |||
411 | 415 | ||
412 | offset = *data_offset_out + size - sizeof(zero); | 416 | offset = *data_offset_out + size - sizeof(zero); |
413 | err = cow_seek_file(fd, offset); | 417 | err = cow_seek_file(fd, offset); |
414 | if(err < 0){ | 418 | if (err < 0) { |
415 | cow_printf("cow bitmap lseek failed : err = %d\n", -err); | 419 | cow_printf("cow bitmap lseek failed : err = %d\n", -err); |
416 | goto out; | 420 | goto out; |
417 | } | 421 | } |
418 | 422 | ||
419 | /* does not really matter how much we write it is just to set EOF | 423 | /* |
424 | * does not really matter how much we write it is just to set EOF | ||
420 | * this also sets the entire COW bitmap | 425 | * this also sets the entire COW bitmap |
421 | * to zero without having to allocate it | 426 | * to zero without having to allocate it |
422 | */ | 427 | */ |
423 | err = cow_write_file(fd, &zero, sizeof(zero)); | 428 | err = cow_write_file(fd, &zero, sizeof(zero)); |
424 | if(err != sizeof(zero)){ | 429 | if (err != sizeof(zero)) { |
425 | cow_printf("Write of bitmap to new COW file '%s' failed, " | 430 | cow_printf("Write of bitmap to new COW file '%s' failed, " |
426 | "err = %d\n", cow_file, -err); | 431 | "err = %d\n", cow_file, -err); |
427 | if (err >= 0) | 432 | if (err >= 0) |
@@ -429,15 +434,7 @@ int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize, | |||
429 | goto out; | 434 | goto out; |
430 | } | 435 | } |
431 | 436 | ||
432 | return(0); | 437 | return 0; |
433 | |||
434 | out: | 438 | out: |
435 | return(err); | 439 | return err; |
436 | } | 440 | } |
437 | |||
438 | /* | ||
439 | * --------------------------------------------------------------------------- | ||
440 | * Local variables: | ||
441 | * c-file-style: "linux" | ||
442 | * End: | ||
443 | */ | ||
diff --git a/arch/um/drivers/fd.c b/arch/um/drivers/fd.c index 207b0444c9d9..0a2bb5b64b82 100644 --- a/arch/um/drivers/fd.c +++ b/arch/um/drivers/fd.c | |||
@@ -1,19 +1,18 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com) | 2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stddef.h> | ||
7 | #include <stdlib.h> | ||
8 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | #include <stdlib.h> | ||
8 | #include <unistd.h> | ||
9 | #include <errno.h> | 9 | #include <errno.h> |
10 | #include <termios.h> | 10 | #include <termios.h> |
11 | #include <unistd.h> | ||
12 | #include "chan_user.h" | 11 | #include "chan_user.h" |
12 | #include "kern_constants.h" | ||
13 | #include "os.h" | ||
13 | #include "um_malloc.h" | 14 | #include "um_malloc.h" |
14 | #include "user.h" | 15 | #include "user.h" |
15 | #include "os.h" | ||
16 | #include "kern_constants.h" | ||
17 | 16 | ||
18 | struct fd_chan { | 17 | struct fd_chan { |
19 | int fd; | 18 | int fd; |
@@ -42,7 +41,7 @@ static void *fd_init(char *str, int device, const struct chan_opts *opts) | |||
42 | } | 41 | } |
43 | 42 | ||
44 | data = kmalloc(sizeof(*data), UM_GFP_KERNEL); | 43 | data = kmalloc(sizeof(*data), UM_GFP_KERNEL); |
45 | if(data == NULL) | 44 | if (data == NULL) |
46 | return NULL; | 45 | return NULL; |
47 | 46 | ||
48 | *data = ((struct fd_chan) { .fd = n, | 47 | *data = ((struct fd_chan) { .fd = n, |
diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c index 10e08a8c17c3..ff1b22b69e9c 100644 --- a/arch/um/drivers/hostaudio_kern.c +++ b/arch/um/drivers/hostaudio_kern.c | |||
@@ -1,16 +1,14 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 Steve Schmidtke | 2 | * Copyright (C) 2002 Steve Schmidtke |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "linux/fs.h" | ||
6 | #include "linux/module.h" | 7 | #include "linux/module.h" |
7 | #include "linux/init.h" | ||
8 | #include "linux/slab.h" | 8 | #include "linux/slab.h" |
9 | #include "linux/fs.h" | ||
10 | #include "linux/sound.h" | 9 | #include "linux/sound.h" |
11 | #include "linux/soundcard.h" | 10 | #include "linux/soundcard.h" |
12 | #include "asm/uaccess.h" | 11 | #include "asm/uaccess.h" |
13 | #include "kern_util.h" | ||
14 | #include "init.h" | 12 | #include "init.h" |
15 | #include "os.h" | 13 | #include "os.h" |
16 | 14 | ||
@@ -25,7 +23,8 @@ struct hostmixer_state { | |||
25 | #define HOSTAUDIO_DEV_DSP "/dev/sound/dsp" | 23 | #define HOSTAUDIO_DEV_DSP "/dev/sound/dsp" |
26 | #define HOSTAUDIO_DEV_MIXER "/dev/sound/mixer" | 24 | #define HOSTAUDIO_DEV_MIXER "/dev/sound/mixer" |
27 | 25 | ||
28 | /* Changed either at boot time or module load time. At boot, this is | 26 | /* |
27 | * Changed either at boot time or module load time. At boot, this is | ||
29 | * single-threaded; at module load, multiple modules would each have | 28 | * single-threaded; at module load, multiple modules would each have |
30 | * their own copy of these variables. | 29 | * their own copy of these variables. |
31 | */ | 30 | */ |
@@ -44,7 +43,7 @@ static char *mixer = HOSTAUDIO_DEV_MIXER; | |||
44 | static int set_dsp(char *name, int *add) | 43 | static int set_dsp(char *name, int *add) |
45 | { | 44 | { |
46 | dsp = name; | 45 | dsp = name; |
47 | return(0); | 46 | return 0; |
48 | } | 47 | } |
49 | 48 | ||
50 | __uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP); | 49 | __uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP); |
@@ -52,7 +51,7 @@ __uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP); | |||
52 | static int set_mixer(char *name, int *add) | 51 | static int set_mixer(char *name, int *add) |
53 | { | 52 | { |
54 | mixer = name; | 53 | mixer = name; |
55 | return(0); | 54 | return 0; |
56 | } | 55 | } |
57 | 56 | ||
58 | __uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP); | 57 | __uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP); |
@@ -77,23 +76,23 @@ static ssize_t hostaudio_read(struct file *file, char __user *buffer, | |||
77 | int err; | 76 | int err; |
78 | 77 | ||
79 | #ifdef DEBUG | 78 | #ifdef DEBUG |
80 | printk("hostaudio: read called, count = %d\n", count); | 79 | printk(KERN_DEBUG "hostaudio: read called, count = %d\n", count); |
81 | #endif | 80 | #endif |
82 | 81 | ||
83 | kbuf = kmalloc(count, GFP_KERNEL); | 82 | kbuf = kmalloc(count, GFP_KERNEL); |
84 | if(kbuf == NULL) | 83 | if (kbuf == NULL) |
85 | return(-ENOMEM); | 84 | return -ENOMEM; |
86 | 85 | ||
87 | err = os_read_file(state->fd, kbuf, count); | 86 | err = os_read_file(state->fd, kbuf, count); |
88 | if(err < 0) | 87 | if (err < 0) |
89 | goto out; | 88 | goto out; |
90 | 89 | ||
91 | if(copy_to_user(buffer, kbuf, err)) | 90 | if (copy_to_user(buffer, kbuf, err)) |
92 | err = -EFAULT; | 91 | err = -EFAULT; |
93 | 92 | ||
94 | out: | 93 | out: |
95 | kfree(kbuf); | 94 | kfree(kbuf); |
96 | return(err); | 95 | return err; |
97 | } | 96 | } |
98 | 97 | ||
99 | static ssize_t hostaudio_write(struct file *file, const char __user *buffer, | 98 | static ssize_t hostaudio_write(struct file *file, const char __user *buffer, |
@@ -104,40 +103,40 @@ static ssize_t hostaudio_write(struct file *file, const char __user *buffer, | |||
104 | int err; | 103 | int err; |
105 | 104 | ||
106 | #ifdef DEBUG | 105 | #ifdef DEBUG |
107 | printk("hostaudio: write called, count = %d\n", count); | 106 | printk(KERN_DEBUG "hostaudio: write called, count = %d\n", count); |
108 | #endif | 107 | #endif |
109 | 108 | ||
110 | kbuf = kmalloc(count, GFP_KERNEL); | 109 | kbuf = kmalloc(count, GFP_KERNEL); |
111 | if(kbuf == NULL) | 110 | if (kbuf == NULL) |
112 | return(-ENOMEM); | 111 | return -ENOMEM; |
113 | 112 | ||
114 | err = -EFAULT; | 113 | err = -EFAULT; |
115 | if(copy_from_user(kbuf, buffer, count)) | 114 | if (copy_from_user(kbuf, buffer, count)) |
116 | goto out; | 115 | goto out; |
117 | 116 | ||
118 | err = os_write_file(state->fd, kbuf, count); | 117 | err = os_write_file(state->fd, kbuf, count); |
119 | if(err < 0) | 118 | if (err < 0) |
120 | goto out; | 119 | goto out; |
121 | *ppos += err; | 120 | *ppos += err; |
122 | 121 | ||
123 | out: | 122 | out: |
124 | kfree(kbuf); | 123 | kfree(kbuf); |
125 | return(err); | 124 | return err; |
126 | } | 125 | } |
127 | 126 | ||
128 | static unsigned int hostaudio_poll(struct file *file, | 127 | static unsigned int hostaudio_poll(struct file *file, |
129 | struct poll_table_struct *wait) | 128 | struct poll_table_struct *wait) |
130 | { | 129 | { |
131 | unsigned int mask = 0; | 130 | unsigned int mask = 0; |
132 | 131 | ||
133 | #ifdef DEBUG | 132 | #ifdef DEBUG |
134 | printk("hostaudio: poll called (unimplemented)\n"); | 133 | printk(KERN_DEBUG "hostaudio: poll called (unimplemented)\n"); |
135 | #endif | 134 | #endif |
136 | 135 | ||
137 | return(mask); | 136 | return mask; |
138 | } | 137 | } |
139 | 138 | ||
140 | static int hostaudio_ioctl(struct inode *inode, struct file *file, | 139 | static int hostaudio_ioctl(struct inode *inode, struct file *file, |
141 | unsigned int cmd, unsigned long arg) | 140 | unsigned int cmd, unsigned long arg) |
142 | { | 141 | { |
143 | struct hostaudio_state *state = file->private_data; | 142 | struct hostaudio_state *state = file->private_data; |
@@ -145,7 +144,7 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file, | |||
145 | int err; | 144 | int err; |
146 | 145 | ||
147 | #ifdef DEBUG | 146 | #ifdef DEBUG |
148 | printk("hostaudio: ioctl called, cmd = %u\n", cmd); | 147 | printk(KERN_DEBUG "hostaudio: ioctl called, cmd = %u\n", cmd); |
149 | #endif | 148 | #endif |
150 | switch(cmd){ | 149 | switch(cmd){ |
151 | case SNDCTL_DSP_SPEED: | 150 | case SNDCTL_DSP_SPEED: |
@@ -154,8 +153,8 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file, | |||
154 | case SNDCTL_DSP_CHANNELS: | 153 | case SNDCTL_DSP_CHANNELS: |
155 | case SNDCTL_DSP_SUBDIVIDE: | 154 | case SNDCTL_DSP_SUBDIVIDE: |
156 | case SNDCTL_DSP_SETFRAGMENT: | 155 | case SNDCTL_DSP_SETFRAGMENT: |
157 | if(get_user(data, (int __user *) arg)) | 156 | if (get_user(data, (int __user *) arg)) |
158 | return(-EFAULT); | 157 | return EFAULT; |
159 | break; | 158 | break; |
160 | default: | 159 | default: |
161 | break; | 160 | break; |
@@ -170,14 +169,14 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file, | |||
170 | case SNDCTL_DSP_CHANNELS: | 169 | case SNDCTL_DSP_CHANNELS: |
171 | case SNDCTL_DSP_SUBDIVIDE: | 170 | case SNDCTL_DSP_SUBDIVIDE: |
172 | case SNDCTL_DSP_SETFRAGMENT: | 171 | case SNDCTL_DSP_SETFRAGMENT: |
173 | if(put_user(data, (int __user *) arg)) | 172 | if (put_user(data, (int __user *) arg)) |
174 | return(-EFAULT); | 173 | return -EFAULT; |
175 | break; | 174 | break; |
176 | default: | 175 | default: |
177 | break; | 176 | break; |
178 | } | 177 | } |
179 | 178 | ||
180 | return(err); | 179 | return err; |
181 | } | 180 | } |
182 | 181 | ||
183 | static int hostaudio_open(struct inode *inode, struct file *file) | 182 | static int hostaudio_open(struct inode *inode, struct file *file) |
@@ -187,24 +186,26 @@ static int hostaudio_open(struct inode *inode, struct file *file) | |||
187 | int ret; | 186 | int ret; |
188 | 187 | ||
189 | #ifdef DEBUG | 188 | #ifdef DEBUG |
190 | printk("hostaudio: open called (host: %s)\n", dsp); | 189 | printk(KERN_DEBUG "hostaudio: open called (host: %s)\n", dsp); |
191 | #endif | 190 | #endif |
192 | 191 | ||
193 | state = kmalloc(sizeof(struct hostaudio_state), GFP_KERNEL); | 192 | state = kmalloc(sizeof(struct hostaudio_state), GFP_KERNEL); |
194 | if(state == NULL) | 193 | if (state == NULL) |
195 | return(-ENOMEM); | 194 | return -ENOMEM; |
196 | 195 | ||
197 | if(file->f_mode & FMODE_READ) r = 1; | 196 | if (file->f_mode & FMODE_READ) |
198 | if(file->f_mode & FMODE_WRITE) w = 1; | 197 | r = 1; |
198 | if (file->f_mode & FMODE_WRITE) | ||
199 | w = 1; | ||
199 | 200 | ||
200 | ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0); | 201 | ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0); |
201 | if(ret < 0){ | 202 | if (ret < 0) { |
202 | kfree(state); | 203 | kfree(state); |
203 | return(ret); | 204 | return ret; |
204 | } | 205 | } |
205 | state->fd = ret; | 206 | state->fd = ret; |
206 | file->private_data = state; | 207 | file->private_data = state; |
207 | return(0); | 208 | return 0; |
208 | } | 209 | } |
209 | 210 | ||
210 | static int hostaudio_release(struct inode *inode, struct file *file) | 211 | static int hostaudio_release(struct inode *inode, struct file *file) |
@@ -212,26 +213,26 @@ static int hostaudio_release(struct inode *inode, struct file *file) | |||
212 | struct hostaudio_state *state = file->private_data; | 213 | struct hostaudio_state *state = file->private_data; |
213 | 214 | ||
214 | #ifdef DEBUG | 215 | #ifdef DEBUG |
215 | printk("hostaudio: release called\n"); | 216 | printk(KERN_DEBUG "hostaudio: release called\n"); |
216 | #endif | 217 | #endif |
217 | os_close_file(state->fd); | 218 | os_close_file(state->fd); |
218 | kfree(state); | 219 | kfree(state); |
219 | 220 | ||
220 | return(0); | 221 | return 0; |
221 | } | 222 | } |
222 | 223 | ||
223 | /* /dev/mixer file operations */ | 224 | /* /dev/mixer file operations */ |
224 | 225 | ||
225 | static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file, | 226 | static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file, |
226 | unsigned int cmd, unsigned long arg) | 227 | unsigned int cmd, unsigned long arg) |
227 | { | 228 | { |
228 | struct hostmixer_state *state = file->private_data; | 229 | struct hostmixer_state *state = file->private_data; |
229 | 230 | ||
230 | #ifdef DEBUG | 231 | #ifdef DEBUG |
231 | printk("hostmixer: ioctl called\n"); | 232 | printk(KERN_DEBUG "hostmixer: ioctl called\n"); |
232 | #endif | 233 | #endif |
233 | 234 | ||
234 | return(os_ioctl_generic(state->fd, cmd, arg)); | 235 | return os_ioctl_generic(state->fd, cmd, arg); |
235 | } | 236 | } |
236 | 237 | ||
237 | static int hostmixer_open_mixdev(struct inode *inode, struct file *file) | 238 | static int hostmixer_open_mixdev(struct inode *inode, struct file *file) |
@@ -241,26 +242,29 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file) | |||
241 | int ret; | 242 | int ret; |
242 | 243 | ||
243 | #ifdef DEBUG | 244 | #ifdef DEBUG |
244 | printk("hostmixer: open called (host: %s)\n", mixer); | 245 | printk(KERN_DEBUG "hostmixer: open called (host: %s)\n", mixer); |
245 | #endif | 246 | #endif |
246 | 247 | ||
247 | state = kmalloc(sizeof(struct hostmixer_state), GFP_KERNEL); | 248 | state = kmalloc(sizeof(struct hostmixer_state), GFP_KERNEL); |
248 | if(state == NULL) return(-ENOMEM); | 249 | if (state == NULL) |
250 | return -ENOMEM; | ||
249 | 251 | ||
250 | if(file->f_mode & FMODE_READ) r = 1; | 252 | if (file->f_mode & FMODE_READ) |
251 | if(file->f_mode & FMODE_WRITE) w = 1; | 253 | r = 1; |
254 | if (file->f_mode & FMODE_WRITE) | ||
255 | w = 1; | ||
252 | 256 | ||
253 | ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0); | 257 | ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0); |
254 | 258 | ||
255 | if(ret < 0){ | 259 | if (ret < 0) { |
256 | printk("hostaudio_open_mixdev failed to open '%s', err = %d\n", | 260 | printk(KERN_ERR "hostaudio_open_mixdev failed to open '%s', " |
257 | dsp, -ret); | 261 | "err = %d\n", dsp, -ret); |
258 | kfree(state); | 262 | kfree(state); |
259 | return(ret); | 263 | return ret; |
260 | } | 264 | } |
261 | 265 | ||
262 | file->private_data = state; | 266 | file->private_data = state; |
263 | return(0); | 267 | return 0; |
264 | } | 268 | } |
265 | 269 | ||
266 | static int hostmixer_release(struct inode *inode, struct file *file) | 270 | static int hostmixer_release(struct inode *inode, struct file *file) |
@@ -268,13 +272,13 @@ static int hostmixer_release(struct inode *inode, struct file *file) | |||
268 | struct hostmixer_state *state = file->private_data; | 272 | struct hostmixer_state *state = file->private_data; |
269 | 273 | ||
270 | #ifdef DEBUG | 274 | #ifdef DEBUG |
271 | printk("hostmixer: release called\n"); | 275 | printk(KERN_DEBUG "hostmixer: release called\n"); |
272 | #endif | 276 | #endif |
273 | 277 | ||
274 | os_close_file(state->fd); | 278 | os_close_file(state->fd); |
275 | kfree(state); | 279 | kfree(state); |
276 | 280 | ||
277 | return(0); | 281 | return 0; |
278 | } | 282 | } |
279 | 283 | ||
280 | /* kernel module operations */ | 284 | /* kernel module operations */ |
@@ -314,13 +318,13 @@ static int __init hostaudio_init_module(void) | |||
314 | dsp, mixer); | 318 | dsp, mixer); |
315 | 319 | ||
316 | module_data.dev_audio = register_sound_dsp(&hostaudio_fops, -1); | 320 | module_data.dev_audio = register_sound_dsp(&hostaudio_fops, -1); |
317 | if(module_data.dev_audio < 0){ | 321 | if (module_data.dev_audio < 0) { |
318 | printk(KERN_ERR "hostaudio: couldn't register DSP device!\n"); | 322 | printk(KERN_ERR "hostaudio: couldn't register DSP device!\n"); |
319 | return -ENODEV; | 323 | return -ENODEV; |
320 | } | 324 | } |
321 | 325 | ||
322 | module_data.dev_mixer = register_sound_mixer(&hostmixer_fops, -1); | 326 | module_data.dev_mixer = register_sound_mixer(&hostmixer_fops, -1); |
323 | if(module_data.dev_mixer < 0){ | 327 | if (module_data.dev_mixer < 0) { |
324 | printk(KERN_ERR "hostmixer: couldn't register mixer " | 328 | printk(KERN_ERR "hostmixer: couldn't register mixer " |
325 | "device!\n"); | 329 | "device!\n"); |
326 | unregister_sound_dsp(module_data.dev_audio); | 330 | unregister_sound_dsp(module_data.dev_audio); |
diff --git a/arch/um/drivers/mconsole_user.c b/arch/um/drivers/mconsole_user.c index f31e71546e52..430c024a19b0 100644 --- a/arch/um/drivers/mconsole_user.c +++ b/arch/um/drivers/mconsole_user.c | |||
@@ -1,25 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) | 2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) |
3 | * Copyright (C) 2001 - 2003 Jeff Dike (jdike@addtoit.com) | 3 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
4 | * Licensed under the GPL | 4 | * Licensed under the GPL |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <stdio.h> | ||
8 | #include <stdlib.h> | ||
9 | #include <errno.h> | 7 | #include <errno.h> |
10 | #include <signal.h> | 8 | #include <string.h> |
9 | #include <unistd.h> | ||
11 | #include <sys/socket.h> | 10 | #include <sys/socket.h> |
12 | #include <sys/types.h> | ||
13 | #include <sys/uio.h> | 11 | #include <sys/uio.h> |
14 | #include <sys/un.h> | 12 | #include <sys/un.h> |
15 | #include <unistd.h> | 13 | #include "kern_constants.h" |
16 | #include "user.h" | ||
17 | #include "sysdep/ptrace.h" | ||
18 | #include "mconsole.h" | 14 | #include "mconsole.h" |
19 | #include "os.h" | 15 | #include "user.h" |
20 | 16 | ||
21 | static struct mconsole_command commands[] = { | 17 | static struct mconsole_command commands[] = { |
22 | /* With uts namespaces, uts information becomes process-specific, so | 18 | /* |
19 | * With uts namespaces, uts information becomes process-specific, so | ||
23 | * we need a process context. If we try handling this in interrupt | 20 | * we need a process context. If we try handling this in interrupt |
24 | * context, we may hit an exiting process without a valid uts | 21 | * context, we may hit an exiting process without a valid uts |
25 | * namespace. | 22 | * namespace. |
@@ -36,7 +33,7 @@ static struct mconsole_command commands[] = { | |||
36 | { "go", mconsole_go, MCONSOLE_INTR }, | 33 | { "go", mconsole_go, MCONSOLE_INTR }, |
37 | { "log", mconsole_log, MCONSOLE_INTR }, | 34 | { "log", mconsole_log, MCONSOLE_INTR }, |
38 | { "proc", mconsole_proc, MCONSOLE_PROC }, | 35 | { "proc", mconsole_proc, MCONSOLE_PROC }, |
39 | { "stack", mconsole_stack, MCONSOLE_INTR }, | 36 | { "stack", mconsole_stack, MCONSOLE_INTR }, |
40 | }; | 37 | }; |
41 | 38 | ||
42 | /* Initialized in mconsole_init, which is an initcall */ | 39 | /* Initialized in mconsole_init, which is an initcall */ |
@@ -44,21 +41,21 @@ char mconsole_socket_name[256]; | |||
44 | 41 | ||
45 | int mconsole_reply_v0(struct mc_request *req, char *reply) | 42 | int mconsole_reply_v0(struct mc_request *req, char *reply) |
46 | { | 43 | { |
47 | struct iovec iov; | 44 | struct iovec iov; |
48 | struct msghdr msg; | 45 | struct msghdr msg; |
49 | 46 | ||
50 | iov.iov_base = reply; | 47 | iov.iov_base = reply; |
51 | iov.iov_len = strlen(reply); | 48 | iov.iov_len = strlen(reply); |
52 | 49 | ||
53 | msg.msg_name = &(req->origin); | 50 | msg.msg_name = &(req->origin); |
54 | msg.msg_namelen = req->originlen; | 51 | msg.msg_namelen = req->originlen; |
55 | msg.msg_iov = &iov; | 52 | msg.msg_iov = &iov; |
56 | msg.msg_iovlen = 1; | 53 | msg.msg_iovlen = 1; |
57 | msg.msg_control = NULL; | 54 | msg.msg_control = NULL; |
58 | msg.msg_controllen = 0; | 55 | msg.msg_controllen = 0; |
59 | msg.msg_flags = 0; | 56 | msg.msg_flags = 0; |
60 | 57 | ||
61 | return sendmsg(req->originating_fd, &msg, 0); | 58 | return sendmsg(req->originating_fd, &msg, 0); |
62 | } | 59 | } |
63 | 60 | ||
64 | static struct mconsole_command *mconsole_parse(struct mc_request *req) | 61 | static struct mconsole_command *mconsole_parse(struct mc_request *req) |
@@ -66,10 +63,10 @@ static struct mconsole_command *mconsole_parse(struct mc_request *req) | |||
66 | struct mconsole_command *cmd; | 63 | struct mconsole_command *cmd; |
67 | int i; | 64 | int i; |
68 | 65 | ||
69 | for(i = 0; i < ARRAY_SIZE(commands); i++){ | 66 | for (i = 0; i < ARRAY_SIZE(commands); i++) { |
70 | cmd = &commands[i]; | 67 | cmd = &commands[i]; |
71 | if(!strncmp(req->request.data, cmd->command, | 68 | if (!strncmp(req->request.data, cmd->command, |
72 | strlen(cmd->command))){ | 69 | strlen(cmd->command))) { |
73 | return cmd; | 70 | return cmd; |
74 | } | 71 | } |
75 | } | 72 | } |
@@ -94,9 +91,9 @@ int mconsole_get_request(int fd, struct mc_request *req) | |||
94 | 91 | ||
95 | req->originating_fd = fd; | 92 | req->originating_fd = fd; |
96 | 93 | ||
97 | if(req->request.magic != MCONSOLE_MAGIC){ | 94 | if (req->request.magic != MCONSOLE_MAGIC) { |
98 | /* Unversioned request */ | 95 | /* Unversioned request */ |
99 | len = MIN(sizeof(req->request.data) - 1, | 96 | len = MIN(sizeof(req->request.data) - 1, |
100 | strlen((char *) &req->request)); | 97 | strlen((char *) &req->request)); |
101 | memmove(req->request.data, &req->request, len); | 98 | memmove(req->request.data, &req->request, len); |
102 | req->request.data[len] = '\0'; | 99 | req->request.data[len] = '\0'; |
@@ -107,32 +104,33 @@ int mconsole_get_request(int fd, struct mc_request *req) | |||
107 | 104 | ||
108 | mconsole_reply_v0(req, "ERR Version 0 mconsole clients are " | 105 | mconsole_reply_v0(req, "ERR Version 0 mconsole clients are " |
109 | "not supported by this driver"); | 106 | "not supported by this driver"); |
110 | return(0); | 107 | return 0; |
111 | } | 108 | } |
112 | 109 | ||
113 | if(req->request.len >= MCONSOLE_MAX_DATA){ | 110 | if (req->request.len >= MCONSOLE_MAX_DATA) { |
114 | mconsole_reply(req, "Request too large", 1, 0); | 111 | mconsole_reply(req, "Request too large", 1, 0); |
115 | return(0); | 112 | return 0; |
116 | } | 113 | } |
117 | if(req->request.version != MCONSOLE_VERSION){ | 114 | if (req->request.version != MCONSOLE_VERSION) { |
118 | mconsole_reply(req, "This driver only supports version " | 115 | mconsole_reply(req, "This driver only supports version " |
119 | STRING(MCONSOLE_VERSION) " clients", 1, 0); | 116 | STRING(MCONSOLE_VERSION) " clients", 1, 0); |
120 | } | 117 | } |
121 | 118 | ||
122 | req->request.data[req->request.len] = '\0'; | 119 | req->request.data[req->request.len] = '\0'; |
123 | req->cmd = mconsole_parse(req); | 120 | req->cmd = mconsole_parse(req); |
124 | if(req->cmd == NULL){ | 121 | if (req->cmd == NULL) { |
125 | mconsole_reply(req, "Unknown command", 1, 0); | 122 | mconsole_reply(req, "Unknown command", 1, 0); |
126 | return(0); | 123 | return 0; |
127 | } | 124 | } |
128 | 125 | ||
129 | return(1); | 126 | return 1; |
130 | } | 127 | } |
131 | 128 | ||
132 | int mconsole_reply_len(struct mc_request *req, const char *str, int total, | 129 | int mconsole_reply_len(struct mc_request *req, const char *str, int total, |
133 | int err, int more) | 130 | int err, int more) |
134 | { | 131 | { |
135 | /* XXX This is a stack consumption problem. It'd be nice to | 132 | /* |
133 | * XXX This is a stack consumption problem. It'd be nice to | ||
136 | * make it global and serialize access to it, but there are a | 134 | * make it global and serialize access to it, but there are a |
137 | * ton of callers to this function. | 135 | * ton of callers to this function. |
138 | */ | 136 | */ |
@@ -147,7 +145,7 @@ int mconsole_reply_len(struct mc_request *req, const char *str, int total, | |||
147 | 145 | ||
148 | len = MIN(total, MCONSOLE_MAX_DATA - 1); | 146 | len = MIN(total, MCONSOLE_MAX_DATA - 1); |
149 | 147 | ||
150 | if(len == total) reply.more = more; | 148 | if (len == total) reply.more = more; |
151 | else reply.more = 1; | 149 | else reply.more = 1; |
152 | 150 | ||
153 | memcpy(reply.data, str, len); | 151 | memcpy(reply.data, str, len); |
@@ -161,9 +159,10 @@ int mconsole_reply_len(struct mc_request *req, const char *str, int total, | |||
161 | n = sendto(req->originating_fd, &reply, len, 0, | 159 | n = sendto(req->originating_fd, &reply, len, 0, |
162 | (struct sockaddr *) req->origin, req->originlen); | 160 | (struct sockaddr *) req->origin, req->originlen); |
163 | 161 | ||
164 | if(n < 0) return(-errno); | 162 | if (n < 0) |
165 | } while(total > 0); | 163 | return -errno; |
166 | return(0); | 164 | } while (total > 0); |
165 | return 0; | ||
167 | } | 166 | } |
168 | 167 | ||
169 | int mconsole_reply(struct mc_request *req, const char *str, int err, int more) | 168 | int mconsole_reply(struct mc_request *req, const char *str, int err, int more) |
@@ -187,18 +186,18 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len) | |||
187 | int n, err = 0; | 186 | int n, err = 0; |
188 | 187 | ||
189 | lock_notify(); | 188 | lock_notify(); |
190 | if(notify_sock < 0){ | 189 | if (notify_sock < 0) { |
191 | notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0); | 190 | notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0); |
192 | if(notify_sock < 0){ | 191 | if (notify_sock < 0) { |
193 | err = -errno; | 192 | err = -errno; |
194 | printk("mconsole_notify - socket failed, errno = %d\n", | 193 | printk(UM_KERN_ERR "mconsole_notify - socket failed, " |
195 | err); | 194 | "errno = %d\n", errno); |
196 | } | 195 | } |
197 | } | 196 | } |
198 | unlock_notify(); | 197 | unlock_notify(); |
199 | 198 | ||
200 | if(err) | 199 | if (err) |
201 | return(err); | 200 | return err; |
202 | 201 | ||
203 | target.sun_family = AF_UNIX; | 202 | target.sun_family = AF_UNIX; |
204 | strcpy(target.sun_path, sock_name); | 203 | strcpy(target.sun_path, sock_name); |
@@ -212,22 +211,12 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len) | |||
212 | 211 | ||
213 | err = 0; | 212 | err = 0; |
214 | len = sizeof(packet) + packet.len - sizeof(packet.data); | 213 | len = sizeof(packet) + packet.len - sizeof(packet.data); |
215 | n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target, | 214 | n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target, |
216 | sizeof(target)); | 215 | sizeof(target)); |
217 | if(n < 0){ | 216 | if (n < 0) { |
218 | err = -errno; | 217 | err = -errno; |
219 | printk("mconsole_notify - sendto failed, errno = %d\n", errno); | 218 | printk(UM_KERN_ERR "mconsole_notify - sendto failed, " |
219 | "errno = %d\n", errno); | ||
220 | } | 220 | } |
221 | return(err); | 221 | return err; |
222 | } | 222 | } |
223 | |||
224 | /* | ||
225 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
226 | * Emacs will notice this stuff at the end of the file and automatically | ||
227 | * adjust the settings for this buffer only. This must remain at the end | ||
228 | * of the file. | ||
229 | * --------------------------------------------------------------------------- | ||
230 | * Local variables: | ||
231 | * c-file-style: "linux" | ||
232 | * End: | ||
233 | */ | ||
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c index 867666a02339..67b2f55a602f 100644 --- a/arch/um/drivers/mmapper_kern.c +++ b/arch/um/drivers/mmapper_kern.c | |||
@@ -9,27 +9,29 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/init.h> | 12 | #include <linux/stddef.h> |
13 | #include <linux/module.h> | 13 | #include <linux/types.h> |
14 | #include <linux/mm.h> | ||
15 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
15 | #include <linux/init.h> | ||
16 | #include <linux/miscdevice.h> | 16 | #include <linux/miscdevice.h> |
17 | #include <linux/module.h> | ||
18 | #include <linux/mm.h> | ||
17 | #include <asm/uaccess.h> | 19 | #include <asm/uaccess.h> |
18 | #include "mem_user.h" | 20 | #include "mem_user.h" |
19 | 21 | ||
20 | /* These are set in mmapper_init, which is called at boot time */ | 22 | /* These are set in mmapper_init, which is called at boot time */ |
21 | static unsigned long mmapper_size; | 23 | static unsigned long mmapper_size; |
22 | static unsigned long p_buf = 0; | 24 | static unsigned long p_buf; |
23 | static char *v_buf = NULL; | 25 | static char *v_buf; |
24 | 26 | ||
25 | static ssize_t | 27 | static ssize_t mmapper_read(struct file *file, char __user *buf, size_t count, |
26 | mmapper_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | 28 | loff_t *ppos) |
27 | { | 29 | { |
28 | return simple_read_from_buffer(buf, count, ppos, v_buf, mmapper_size); | 30 | return simple_read_from_buffer(buf, count, ppos, v_buf, mmapper_size); |
29 | } | 31 | } |
30 | 32 | ||
31 | static ssize_t | 33 | static ssize_t mmapper_write(struct file *file, const char __user *buf, |
32 | mmapper_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | 34 | size_t count, loff_t *ppos) |
33 | { | 35 | { |
34 | if (*ppos > mmapper_size) | 36 | if (*ppos > mmapper_size) |
35 | return -EINVAL; | 37 | return -EINVAL; |
@@ -39,48 +41,46 @@ mmapper_write(struct file *file, const char __user *buf, size_t count, loff_t *p | |||
39 | 41 | ||
40 | if (copy_from_user(&v_buf[*ppos], buf, count)) | 42 | if (copy_from_user(&v_buf[*ppos], buf, count)) |
41 | return -EFAULT; | 43 | return -EFAULT; |
42 | 44 | ||
43 | return count; | 45 | return count; |
44 | } | 46 | } |
45 | 47 | ||
46 | static int | 48 | static int mmapper_ioctl(struct inode *inode, struct file *file, |
47 | mmapper_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | 49 | unsigned int cmd, unsigned long arg) |
48 | unsigned long arg) | ||
49 | { | 50 | { |
50 | return(-ENOIOCTLCMD); | 51 | return -ENOIOCTLCMD; |
51 | } | 52 | } |
52 | 53 | ||
53 | static int | 54 | static int mmapper_mmap(struct file *file, struct vm_area_struct *vma) |
54 | mmapper_mmap(struct file *file, struct vm_area_struct * vma) | ||
55 | { | 55 | { |
56 | int ret = -EINVAL; | 56 | int ret = -EINVAL; |
57 | int size; | 57 | int size; |
58 | 58 | ||
59 | if (vma->vm_pgoff != 0) | 59 | if (vma->vm_pgoff != 0) |
60 | goto out; | 60 | goto out; |
61 | 61 | ||
62 | size = vma->vm_end - vma->vm_start; | 62 | size = vma->vm_end - vma->vm_start; |
63 | if(size > mmapper_size) return(-EFAULT); | 63 | if (size > mmapper_size) |
64 | return -EFAULT; | ||
64 | 65 | ||
65 | /* XXX A comment above remap_pfn_range says it should only be | 66 | /* |
67 | * XXX A comment above remap_pfn_range says it should only be | ||
66 | * called when the mm semaphore is held | 68 | * called when the mm semaphore is held |
67 | */ | 69 | */ |
68 | if (remap_pfn_range(vma, vma->vm_start, p_buf >> PAGE_SHIFT, size, | 70 | if (remap_pfn_range(vma, vma->vm_start, p_buf >> PAGE_SHIFT, size, |
69 | vma->vm_page_prot)) | 71 | vma->vm_page_prot)) |
70 | goto out; | 72 | goto out; |
71 | ret = 0; | 73 | ret = 0; |
72 | out: | 74 | out: |
73 | return ret; | 75 | return ret; |
74 | } | 76 | } |
75 | 77 | ||
76 | static int | 78 | static int mmapper_open(struct inode *inode, struct file *file) |
77 | mmapper_open(struct inode *inode, struct file *file) | ||
78 | { | 79 | { |
79 | return 0; | 80 | return 0; |
80 | } | 81 | } |
81 | 82 | ||
82 | static int | 83 | static int mmapper_release(struct inode *inode, struct file *file) |
83 | mmapper_release(struct inode *inode, struct file *file) | ||
84 | { | 84 | { |
85 | return 0; | 85 | return 0; |
86 | } | 86 | } |
@@ -95,7 +95,9 @@ static const struct file_operations mmapper_fops = { | |||
95 | .release = mmapper_release, | 95 | .release = mmapper_release, |
96 | }; | 96 | }; |
97 | 97 | ||
98 | /* No locking needed - only used (and modified) by below initcall and exitcall. */ | 98 | /* |
99 | * No locking needed - only used (and modified) by below initcall and exitcall. | ||
100 | */ | ||
99 | static struct miscdevice mmapper_dev = { | 101 | static struct miscdevice mmapper_dev = { |
100 | .minor = MISC_DYNAMIC_MINOR, | 102 | .minor = MISC_DYNAMIC_MINOR, |
101 | .name = "mmapper", | 103 | .name = "mmapper", |
@@ -109,13 +111,13 @@ static int __init mmapper_init(void) | |||
109 | printk(KERN_INFO "Mapper v0.1\n"); | 111 | printk(KERN_INFO "Mapper v0.1\n"); |
110 | 112 | ||
111 | v_buf = (char *) find_iomem("mmapper", &mmapper_size); | 113 | v_buf = (char *) find_iomem("mmapper", &mmapper_size); |
112 | if(mmapper_size == 0){ | 114 | if (mmapper_size == 0) { |
113 | printk(KERN_ERR "mmapper_init - find_iomem failed\n"); | 115 | printk(KERN_ERR "mmapper_init - find_iomem failed\n"); |
114 | goto out; | 116 | goto out; |
115 | } | 117 | } |
116 | 118 | ||
117 | err = misc_register(&mmapper_dev); | 119 | err = misc_register(&mmapper_dev); |
118 | if(err){ | 120 | if (err) { |
119 | printk(KERN_ERR "mmapper - misc_register failed, err = %d\n", | 121 | printk(KERN_ERR "mmapper - misc_register failed, err = %d\n", |
120 | err); | 122 | err); |
121 | goto out; | 123 | goto out; |
@@ -136,9 +138,3 @@ module_exit(mmapper_exit); | |||
136 | 138 | ||
137 | MODULE_AUTHOR("Greg Lonnon <glonnon@ridgerun.com>"); | 139 | MODULE_AUTHOR("Greg Lonnon <glonnon@ridgerun.com>"); |
138 | MODULE_DESCRIPTION("DSPLinux simulator mmapper driver"); | 140 | MODULE_DESCRIPTION("DSPLinux simulator mmapper driver"); |
139 | /* | ||
140 | * --------------------------------------------------------------------------- | ||
141 | * Local variables: | ||
142 | * c-file-style: "linux" | ||
143 | * End: | ||
144 | */ | ||
diff --git a/arch/um/drivers/null.c b/arch/um/drivers/null.c index b808641ee679..21ad3d7932b3 100644 --- a/arch/um/drivers/null.c +++ b/arch/um/drivers/null.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com) | 2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
@@ -6,8 +6,8 @@ | |||
6 | #include <stddef.h> | 6 | #include <stddef.h> |
7 | #include <errno.h> | 7 | #include <errno.h> |
8 | #include <fcntl.h> | 8 | #include <fcntl.h> |
9 | #include "os.h" | ||
10 | #include "chan_user.h" | 9 | #include "chan_user.h" |
10 | #include "os.h" | ||
11 | 11 | ||
12 | /* This address is used only as a unique identifer */ | 12 | /* This address is used only as a unique identifer */ |
13 | static int null_chan; | 13 | static int null_chan; |
diff --git a/arch/um/drivers/pty.c b/arch/um/drivers/pty.c index 4123fe1fca98..49c79dda6046 100644 --- a/arch/um/drivers/pty.c +++ b/arch/um/drivers/pty.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | 2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
@@ -6,16 +6,16 @@ | |||
6 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <unistd.h> | 8 | #include <unistd.h> |
9 | #include <string.h> | ||
10 | #include <fcntl.h> | ||
11 | #include <errno.h> | 9 | #include <errno.h> |
10 | #include <fcntl.h> | ||
11 | #include <string.h> | ||
12 | #include <termios.h> | 12 | #include <termios.h> |
13 | #include <sys/stat.h> | 13 | #include <sys/stat.h> |
14 | #include "chan_user.h" | 14 | #include "chan_user.h" |
15 | #include "os.h" | ||
16 | #include "user.h" | ||
17 | #include "kern_constants.h" | 15 | #include "kern_constants.h" |
16 | #include "os.h" | ||
18 | #include "um_malloc.h" | 17 | #include "um_malloc.h" |
18 | #include "user.h" | ||
19 | 19 | ||
20 | struct pty_chan { | 20 | struct pty_chan { |
21 | void (*announce)(char *dev_name, int dev); | 21 | void (*announce)(char *dev_name, int dev); |
@@ -33,7 +33,7 @@ static void *pty_chan_init(char *str, int device, const struct chan_opts *opts) | |||
33 | if (data == NULL) | 33 | if (data == NULL) |
34 | return NULL; | 34 | return NULL; |
35 | 35 | ||
36 | *data = ((struct pty_chan) { .announce = opts->announce, | 36 | *data = ((struct pty_chan) { .announce = opts->announce, |
37 | .dev = device, | 37 | .dev = device, |
38 | .raw = opts->raw }); | 38 | .raw = opts->raw }); |
39 | return data; | 39 | return data; |
@@ -101,7 +101,7 @@ static int getmaster(char *line) | |||
101 | *tp = 't'; | 101 | *tp = 't'; |
102 | err = access(line, R_OK | W_OK); | 102 | err = access(line, R_OK | W_OK); |
103 | *tp = 'p'; | 103 | *tp = 'p'; |
104 | if(!err) | 104 | if (!err) |
105 | return master; | 105 | return master; |
106 | close(master); | 106 | close(master); |
107 | } | 107 | } |
@@ -130,7 +130,7 @@ static int pty_open(int input, int output, int primary, void *d, | |||
130 | return err; | 130 | return err; |
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | if (data->announce) | 134 | if (data->announce) |
135 | (*data->announce)(dev, data->dev); | 135 | (*data->announce)(dev, data->dev); |
136 | 136 | ||
diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c index 87e18bf2c667..8a1c18a9b240 100644 --- a/arch/um/drivers/xterm.c +++ b/arch/um/drivers/xterm.c | |||
@@ -1,11 +1,11 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | 2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stddef.h> | 6 | #include <stddef.h> |
7 | #include <stdlib.h> | ||
8 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | #include <stdlib.h> | ||
9 | #include <unistd.h> | 9 | #include <unistd.h> |
10 | #include <errno.h> | 10 | #include <errno.h> |
11 | #include <string.h> | 11 | #include <string.h> |
@@ -96,8 +96,10 @@ static int xterm_open(int input, int output, int primary, void *d, | |||
96 | if (access(argv[4], X_OK) < 0) | 96 | if (access(argv[4], X_OK) < 0) |
97 | argv[4] = "port-helper"; | 97 | argv[4] = "port-helper"; |
98 | 98 | ||
99 | /* Check that DISPLAY is set, this doesn't guarantee the xterm | 99 | /* |
100 | * will work but w/o it we can be pretty sure it won't. */ | 100 | * Check that DISPLAY is set, this doesn't guarantee the xterm |
101 | * will work but w/o it we can be pretty sure it won't. | ||
102 | */ | ||
101 | if (getenv("DISPLAY") == NULL) { | 103 | if (getenv("DISPLAY") == NULL) { |
102 | printk(UM_KERN_ERR "xterm_open: $DISPLAY not set.\n"); | 104 | printk(UM_KERN_ERR "xterm_open: $DISPLAY not set.\n"); |
103 | return -ENODEV; | 105 | return -ENODEV; |
@@ -196,7 +198,7 @@ static int xterm_open(int input, int output, int primary, void *d, | |||
196 | static void xterm_close(int fd, void *d) | 198 | static void xterm_close(int fd, void *d) |
197 | { | 199 | { |
198 | struct xterm_chan *data = d; | 200 | struct xterm_chan *data = d; |
199 | 201 | ||
200 | if (data->pid != -1) | 202 | if (data->pid != -1) |
201 | os_kill_process(data->pid, 1); | 203 | os_kill_process(data->pid, 1); |
202 | data->pid = -1; | 204 | data->pid = -1; |