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/smp_lock.h>
13 #include <linux/sockios.h>
14 #include <linux/syscalls.h>
15 #include <linux/tty.h>
16 #include <linux/file.h>
17 #include <linux/rcupdate.h>
19 #include <asm/uaccess.h>
20 #include <asm/ioctl.h>
21 #include <asm/ioctls.h>
24 #undef DEBUG_MISSING_IOCTL
27 tcflag_t c_iflag, c_oflag, c_cflag, c_lflag;
31 extern void start_tty(struct tty_struct *tty);
32 static struct tty_struct *get_tty(int fd)
35 struct tty_struct *ttyp = NULL;
39 if(filp && filp->private_data) {
40 ttyp = (struct tty_struct *) filp->private_data;
42 if(ttyp->magic != TTY_MAGIC)
49 static struct tty_struct *get_real_tty(struct tty_struct *tp)
51 if (tp->driver->type == TTY_DRIVER_TYPE_PTY &&
52 tp->driver->subtype == PTY_TYPE_MASTER)
58 asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg)
60 struct tty_struct *tp, *rtp;
65 printk("[%s:%d] irix_ioctl(%d, ", current->comm, current->pid, fd);
70 printk("TCGETA, %08lx) ", arg);
72 error = sys_ioctl(fd, TCGETA, arg);
77 struct irix_termios *it = (struct irix_termios *) 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);
91 __put_user(kt.c_iflag, &it->c_iflag);
92 __put_user(kt.c_oflag, &it->c_oflag);
93 __put_user(kt.c_cflag, &it->c_cflag);
94 __put_user(kt.c_lflag, &it->c_lflag);
95 for(error = 0; error < NCCS; error++)
96 __put_user(kt.c_cc[error], &it->c_cc[error]);
103 struct irix_termios *it = (struct irix_termios *) arg;
106 printk("TCSETS, %08lx) ", arg);
108 if (!access_ok(VERIFY_READ, it, sizeof(*it))) {
112 old_fs = get_fs(); set_fs(get_ds());
113 error = sys_ioctl(fd, TCGETS, (unsigned long) &kt);
117 __get_user(kt.c_iflag, &it->c_iflag);
118 __get_user(kt.c_oflag, &it->c_oflag);
119 __get_user(kt.c_cflag, &it->c_cflag);
120 __get_user(kt.c_lflag, &it->c_lflag);
121 for(error = 0; error < NCCS; error++)
122 __get_user(kt.c_cc[error], &it->c_cc[error]);
123 old_fs = get_fs(); set_fs(get_ds());
124 error = sys_ioctl(fd, TCSETS, (unsigned long) &kt);
131 printk("TCSETSW, %08lx) ", arg);
133 error = sys_ioctl(fd, TCSETSW, arg);
138 printk("TIOCNOTTY, %08lx) ", arg);
140 error = sys_ioctl(fd, TIOCNOTTY, arg);
145 printk("TIOCGSID, %08lx) ", arg);
152 rtp = get_real_tty(tp);
154 printk("rtp->session=%d ", rtp->session);
156 error = put_user(rtp->session, (unsigned long *) arg);
160 /* TIOCSTART, same effect as hitting ^Q */
162 printk("TIOCSTART, %08lx) ", arg);
169 rtp = get_real_tty(tp);
175 printk("SIOCGETLABEL, %08lx) ", arg);
182 printk("TIOCGPGRP, %08lx) ", arg);
184 error = sys_ioctl(fd, TIOCGPGRP, arg);
186 printk("arg=%d ", *(int *)arg);
192 printk("TIOCGWINSZ, %08lx) ", arg);
194 error = sys_ioctl(fd, TIOCGWINSZ, arg);
199 printk("FIONBIO, %08lx) arg=%d ", arg, *(int *)arg);
201 error = sys_ioctl(fd, FIONBIO, arg);
206 printk("TIOCSPGRP, %08lx) arg=%d ", arg, *(int *)arg);
208 error = sys_ioctl(fd, TIOCSPGRP, arg);
213 printk("SIOCSIFADDR, %08lx) arg=%d ", arg, *(int *)arg);
215 error = sys_ioctl(fd, SIOCSIFADDR, arg);
220 printk("SIOCSIFFLAGS, %08lx) arg=%d ", arg, *(int *)arg);
222 error = sys_ioctl(fd, SIOCSIFFLAGS, arg);
227 printk("SIOCGIFFLAGS, %08lx) arg=%d ", arg, *(int *)arg);
229 error = sys_ioctl(fd, SIOCGIFFLAGS, arg);
234 printk("SIOCGIFMETRIC, %08lx) arg=%d ", arg, *(int *)arg);
236 error = sys_ioctl(fd, SIOCGIFMETRIC, arg);
240 #ifdef DEBUG_MISSING_IOCTL
241 char *msg = "Unimplemented IOCTL cmd tell linux@engr.sgi.com\n";
244 printk("UNIMP_IOCTL, %08lx)\n", arg);
246 old_fs = get_fs(); set_fs(get_ds());
247 sys_write(2, msg, strlen(msg));
249 printk("[%s:%d] Does unimplemented IRIX ioctl cmd %08lx\n",
250 current->comm, current->pid, cmd);
253 error = sys_ioctl (fd, cmd, arg);
259 printk("error=%d\n", error);