diff options
Diffstat (limited to 'arch/um/os-Linux/tty.c')
-rw-r--r-- | arch/um/os-Linux/tty.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/arch/um/os-Linux/tty.c b/arch/um/os-Linux/tty.c new file mode 100644 index 000000000000..4cfdd18ea1ef --- /dev/null +++ b/arch/um/os-Linux/tty.c | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include <stdlib.h> | ||
7 | #include <errno.h> | ||
8 | #include "os.h" | ||
9 | #include "user.h" | ||
10 | #include "kern_util.h" | ||
11 | |||
12 | struct grantpt_info { | ||
13 | int fd; | ||
14 | int res; | ||
15 | int err; | ||
16 | }; | ||
17 | |||
18 | static void grantpt_cb(void *arg) | ||
19 | { | ||
20 | struct grantpt_info *info = arg; | ||
21 | |||
22 | info->res = grantpt(info->fd); | ||
23 | info->err = errno; | ||
24 | } | ||
25 | |||
26 | int get_pty(void) | ||
27 | { | ||
28 | struct grantpt_info info; | ||
29 | int fd; | ||
30 | |||
31 | fd = os_open_file("/dev/ptmx", of_rdwr(OPENFLAGS()), 0); | ||
32 | if(fd < 0){ | ||
33 | printk("get_pty : Couldn't open /dev/ptmx - err = %d\n", -fd); | ||
34 | return(fd); | ||
35 | } | ||
36 | |||
37 | info.fd = fd; | ||
38 | initial_thread_cb(grantpt_cb, &info); | ||
39 | |||
40 | if(info.res < 0){ | ||
41 | printk("get_pty : Couldn't grant pty - errno = %d\n", | ||
42 | -info.err); | ||
43 | return(-1); | ||
44 | } | ||
45 | if(unlockpt(fd) < 0){ | ||
46 | printk("get_pty : Couldn't unlock pty - errno = %d\n", errno); | ||
47 | return(-1); | ||
48 | } | ||
49 | return(fd); | ||
50 | } | ||
51 | |||
52 | /* | ||
53 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
54 | * Emacs will notice this stuff at the end of the file and automatically | ||
55 | * adjust the settings for this buffer only. This must remain at the end | ||
56 | * of the file. | ||
57 | * --------------------------------------------------------------------------- | ||
58 | * Local variables: | ||
59 | * c-file-style: "linux" | ||
60 | * End: | ||
61 | */ | ||