Blame view
arch/um/os-Linux/tty.c
1.01 KB
edea13858 uml: tidy kern_ut... |
1 2 |
/* * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
1da177e4c Linux-2.6.12-rc2 |
3 4 5 6 |
* Licensed under the GPL */ #include <stdlib.h> |
edea13858 uml: tidy kern_ut... |
7 |
#include <unistd.h> |
1da177e4c Linux-2.6.12-rc2 |
8 |
#include <errno.h> |
edea13858 uml: tidy kern_ut... |
9 |
#include <fcntl.h> |
edea13858 uml: tidy kern_ut... |
10 |
#include "kern_util.h" |
1da177e4c Linux-2.6.12-rc2 |
11 |
#include "os.h" |
1da177e4c Linux-2.6.12-rc2 |
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
struct grantpt_info { int fd; int res; int err; }; static void grantpt_cb(void *arg) { struct grantpt_info *info = arg; info->res = grantpt(info->fd); info->err = errno; } int get_pty(void) { struct grantpt_info info; |
edea13858 uml: tidy kern_ut... |
30 31 32 33 34 35 36 37 38 |
int fd, err; fd = open("/dev/ptmx", O_RDWR); if (fd < 0) { err = -errno; printk(UM_KERN_ERR "get_pty : Couldn't open /dev/ptmx - " "err = %d ", errno); return err; |
1da177e4c Linux-2.6.12-rc2 |
39 40 41 42 |
} info.fd = fd; initial_thread_cb(grantpt_cb, &info); |
edea13858 uml: tidy kern_ut... |
43 44 45 46 47 48 |
if (info.res < 0) { err = -info.err; printk(UM_KERN_ERR "get_pty : Couldn't grant pty - " "errno = %d ", -info.err); goto out; |
1da177e4c Linux-2.6.12-rc2 |
49 |
} |
edea13858 uml: tidy kern_ut... |
50 51 52 53 54 55 56 |
if (unlockpt(fd) < 0) { err = -errno; printk(UM_KERN_ERR "get_pty : Couldn't unlock pty - " "errno = %d ", errno); goto out; |
1da177e4c Linux-2.6.12-rc2 |
57 |
} |
edea13858 uml: tidy kern_ut... |
58 59 60 61 |
return fd; out: close(fd); return err; |
1da177e4c Linux-2.6.12-rc2 |
62 |
} |