blk: rq_data_dir() should not return a boolean
[cris-mirror.git] / arch / um / os-Linux / tty.c
blob721d8afa329b17e5547a59885aec1a054b5e8ab5
1 /*
2 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
4 */
6 #include <stdlib.h>
7 #include <unistd.h>
8 #include <errno.h>
9 #include <fcntl.h>
10 #include <kern_util.h>
11 #include <os.h>
13 struct grantpt_info {
14 int fd;
15 int res;
16 int err;
19 static void grantpt_cb(void *arg)
21 struct grantpt_info *info = arg;
23 info->res = grantpt(info->fd);
24 info->err = errno;
27 int get_pty(void)
29 struct grantpt_info info;
30 int fd, err;
32 fd = open("/dev/ptmx", O_RDWR);
33 if (fd < 0) {
34 err = -errno;
35 printk(UM_KERN_ERR "get_pty : Couldn't open /dev/ptmx - "
36 "err = %d\n", errno);
37 return err;
40 info.fd = fd;
41 initial_thread_cb(grantpt_cb, &info);
43 if (info.res < 0) {
44 err = -info.err;
45 printk(UM_KERN_ERR "get_pty : Couldn't grant pty - "
46 "errno = %d\n", -info.err);
47 goto out;
50 if (unlockpt(fd) < 0) {
51 err = -errno;
52 printk(UM_KERN_ERR "get_pty : Couldn't unlock pty - "
53 "errno = %d\n", errno);
54 goto out;
56 return fd;
57 out:
58 close(fd);
59 return err;