2 * irixioctl.c: A fucking mess...
4 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
7 #include <linux/kernel.h>
8 #include <linux/sched.h>
11 #include <linux/smp.h>
12 #include <linux/sockios.h>
13 #include <linux/syscalls.h>
14 #include <linux/tty.h>
15 #include <linux/file.h>
16 #include <linux/rcupdate.h>
18 #include <asm/uaccess.h>
19 #include <asm/ioctl.h>
20 #include <asm/ioctls.h>
23 #undef DEBUG_MISSING_IOCTL
26 tcflag_t c_iflag, c_oflag, c_cflag, c_lflag;
30 extern void start_tty(struct tty_struct *tty);
31 static struct tty_struct *get_tty(int fd)
34 struct tty_struct *ttyp = NULL;
38 if(filp && filp->private_data) {
39 ttyp = (struct tty_struct *) filp->private_data;
41 if(ttyp->magic != TTY_MAGIC)
48 static struct tty_struct *get_real_tty(struct tty_struct *tp)
50 if (tp->driver->type == TTY_DRIVER_TYPE_PTY &&
51 tp->driver->subtype == PTY_TYPE_MASTER)
57 asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg)
59 struct tty_struct *tp, *rtp;
64 printk("[%s:%d] irix_ioctl(%d, ", current->comm, current->pid, fd);
69 printk("TCGETA, %08lx) ", arg);
71 error = sys_ioctl(fd, TCGETA, arg);
76 struct irix_termios __user *it =
77 (struct irix_termios __user *) arg;
80 printk("TCGETS, %08lx) ", arg);
82 if (!access_ok(VERIFY_WRITE, it, sizeof(*it))) {
86 old_fs = get_fs(); set_fs(get_ds());
87 error = sys_ioctl(fd, TCGETS, (unsigned long) &kt);
92 error = __put_user(kt.c_iflag, &it->c_iflag);
93 error |= __put_user(kt.c_oflag, &it->c_oflag);
94 error |= __put_user(kt.c_cflag, &it->c_cflag);
95 error |= __put_user(kt.c_lflag, &it->c_lflag);
97 for (i = 0; i < NCCS; i++)
98 error |= __put_user(kt.c_cc[i], &it->c_cc[i]);
104 struct irix_termios *it = (struct irix_termios *) arg;
107 printk("TCSETS, %08lx) ", arg);
109 if (!access_ok(VERIFY_READ, it, sizeof(*it))) {
113 old_fs = get_fs(); set_fs(get_ds());
114 error = sys_ioctl(fd, TCGETS, (unsigned long) &kt);
119 error = __get_user(kt.c_iflag, &it->c_iflag);
120 error |= __get_user(kt.c_oflag, &it->c_oflag);
121 error |= __get_user(kt.c_cflag, &it->c_cflag);
122 error |= __get_user(kt.c_lflag, &it->c_lflag);
124 for (i = 0; i < NCCS; i++)
125 error |= __get_user(kt.c_cc[i], &it->c_cc[i]);
129 old_fs = get_fs(); set_fs(get_ds());
130 error = sys_ioctl(fd, TCSETS, (unsigned long) &kt);
137 printk("TCSETSW, %08lx) ", arg);
139 error = sys_ioctl(fd, TCSETSW, arg);
144 printk("TIOCNOTTY, %08lx) ", arg);
146 error = sys_ioctl(fd, TIOCNOTTY, arg);
151 printk("TIOCGSID, %08lx) ", arg);
158 rtp = get_real_tty(tp);
160 printk("rtp->session=%d ", rtp->session);
162 error = put_user(rtp->session, (unsigned long __user *) arg);
166 /* TIOCSTART, same effect as hitting ^Q */
168 printk("TIOCSTART, %08lx) ", arg);
175 rtp = get_real_tty(tp);
181 printk("SIOCGETLABEL, %08lx) ", arg);
188 printk("TIOCGPGRP, %08lx) ", arg);
190 error = sys_ioctl(fd, TIOCGPGRP, arg);
192 printk("arg=%d ", *(int *)arg);
198 printk("TIOCGWINSZ, %08lx) ", arg);
200 error = sys_ioctl(fd, TIOCGWINSZ, arg);
204 error = sys_ioctl(fd, FIONBIO, arg);
208 error = sys_ioctl(fd, TIOCSPGRP, arg);
212 error = sys_ioctl(fd, SIOCSIFADDR, arg);
216 error = sys_ioctl(fd, SIOCSIFFLAGS, arg);
220 error = sys_ioctl(fd, SIOCGIFFLAGS, arg);
224 error = sys_ioctl(fd, SIOCGIFMETRIC, arg);
228 #ifdef DEBUG_MISSING_IOCTL
229 char *msg = "Unimplemented IOCTL cmd tell linux-mips@linux-mips.org\n";
232 printk("UNIMP_IOCTL, %08lx)\n", arg);
234 old_fs = get_fs(); set_fs(get_ds());
235 sys_write(2, msg, strlen(msg));
237 printk("[%s:%d] Does unimplemented IRIX ioctl cmd %08lx\n",
238 current->comm, current->pid, cmd);
241 error = sys_ioctl(fd, cmd, arg);
247 printk("error=%d\n", error);