diff options
Diffstat (limited to 'arch/um/drivers/tty.c')
-rw-r--r-- | arch/um/drivers/tty.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/arch/um/drivers/tty.c b/arch/um/drivers/tty.c index a9f87e19c5bf..c930fedc5172 100644 --- a/arch/um/drivers/tty.c +++ b/arch/um/drivers/tty.c | |||
@@ -1,16 +1,16 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.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 <stdio.h> | ||
7 | #include <termios.h> | ||
8 | #include <errno.h> | 6 | #include <errno.h> |
9 | #include <unistd.h> | 7 | #include <fcntl.h> |
8 | #include <termios.h> | ||
10 | #include "chan_user.h" | 9 | #include "chan_user.h" |
11 | #include "user.h" | 10 | #include "kern_constants.h" |
12 | #include "os.h" | 11 | #include "os.h" |
13 | #include "um_malloc.h" | 12 | #include "um_malloc.h" |
13 | #include "user.h" | ||
14 | 14 | ||
15 | struct tty_chan { | 15 | struct tty_chan { |
16 | char *dev; | 16 | char *dev; |
@@ -22,15 +22,15 @@ static void *tty_chan_init(char *str, int device, const struct chan_opts *opts) | |||
22 | { | 22 | { |
23 | struct tty_chan *data; | 23 | struct tty_chan *data; |
24 | 24 | ||
25 | if(*str != ':'){ | 25 | if (*str != ':') { |
26 | printk("tty_init : channel type 'tty' must specify " | 26 | printk(UM_KERN_ERR "tty_init : channel type 'tty' must specify " |
27 | "a device\n"); | 27 | "a device\n"); |
28 | return NULL; | 28 | return NULL; |
29 | } | 29 | } |
30 | str++; | 30 | str++; |
31 | 31 | ||
32 | data = kmalloc(sizeof(*data), UM_GFP_KERNEL); | 32 | data = kmalloc(sizeof(*data), UM_GFP_KERNEL); |
33 | if(data == NULL) | 33 | if (data == NULL) |
34 | return NULL; | 34 | return NULL; |
35 | *data = ((struct tty_chan) { .dev = str, | 35 | *data = ((struct tty_chan) { .dev = str, |
36 | .raw = opts->raw }); | 36 | .raw = opts->raw }); |
@@ -42,19 +42,26 @@ static int tty_open(int input, int output, int primary, void *d, | |||
42 | char **dev_out) | 42 | char **dev_out) |
43 | { | 43 | { |
44 | struct tty_chan *data = d; | 44 | struct tty_chan *data = d; |
45 | int fd, err; | 45 | int fd, err, mode = 0; |
46 | |||
47 | if (input && output) | ||
48 | mode = O_RDWR; | ||
49 | else if (input) | ||
50 | mode = O_RDONLY; | ||
51 | else if (output) | ||
52 | mode = O_WRONLY; | ||
46 | 53 | ||
47 | fd = os_open_file(data->dev, of_set_rw(OPENFLAGS(), input, output), 0); | 54 | fd = open(data->dev, mode); |
48 | if(fd < 0) | 55 | if (fd < 0) |
49 | return fd; | 56 | return -errno; |
50 | 57 | ||
51 | if(data->raw){ | 58 | if (data->raw) { |
52 | CATCH_EINTR(err = tcgetattr(fd, &data->tt)); | 59 | CATCH_EINTR(err = tcgetattr(fd, &data->tt)); |
53 | if(err) | 60 | if (err) |
54 | return err; | 61 | return err; |
55 | 62 | ||
56 | err = raw(fd); | 63 | err = raw(fd); |
57 | if(err) | 64 | if (err) |
58 | return err; | 65 | return err; |
59 | } | 66 | } |
60 | 67 | ||