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 __user
*it
=
78 (struct irix_termios __user
*) arg
;
81 printk("TCGETS, %08lx) ", arg
);
83 if (!access_ok(VERIFY_WRITE
, it
, sizeof(*it
))) {
87 old_fs
= get_fs(); set_fs(get_ds());
88 error
= sys_ioctl(fd
, TCGETS
, (unsigned long) &kt
);
93 error
= __put_user(kt
.c_iflag
, &it
->c_iflag
);
94 error
|= __put_user(kt
.c_oflag
, &it
->c_oflag
);
95 error
|= __put_user(kt
.c_cflag
, &it
->c_cflag
);
96 error
|= __put_user(kt
.c_lflag
, &it
->c_lflag
);
98 for (i
= 0; i
< NCCS
; i
++)
99 error
|= __put_user(kt
.c_cc
[i
], &it
->c_cc
[i
]);
105 struct irix_termios
*it
= (struct irix_termios
*) arg
;
108 printk("TCSETS, %08lx) ", arg
);
110 if (!access_ok(VERIFY_READ
, it
, sizeof(*it
))) {
114 old_fs
= get_fs(); set_fs(get_ds());
115 error
= sys_ioctl(fd
, TCGETS
, (unsigned long) &kt
);
120 error
= __get_user(kt
.c_iflag
, &it
->c_iflag
);
121 error
|= __get_user(kt
.c_oflag
, &it
->c_oflag
);
122 error
|= __get_user(kt
.c_cflag
, &it
->c_cflag
);
123 error
|= __get_user(kt
.c_lflag
, &it
->c_lflag
);
125 for (i
= 0; i
< NCCS
; i
++)
126 error
|= __get_user(kt
.c_cc
[i
], &it
->c_cc
[i
]);
130 old_fs
= get_fs(); set_fs(get_ds());
131 error
= sys_ioctl(fd
, TCSETS
, (unsigned long) &kt
);
138 printk("TCSETSW, %08lx) ", arg
);
140 error
= sys_ioctl(fd
, TCSETSW
, arg
);
145 printk("TIOCNOTTY, %08lx) ", arg
);
147 error
= sys_ioctl(fd
, TIOCNOTTY
, arg
);
152 printk("TIOCGSID, %08lx) ", arg
);
159 rtp
= get_real_tty(tp
);
161 printk("rtp->session=%d ", rtp
->session
);
163 error
= put_user(rtp
->session
, (unsigned long __user
*) arg
);
167 /* TIOCSTART, same effect as hitting ^Q */
169 printk("TIOCSTART, %08lx) ", arg
);
176 rtp
= get_real_tty(tp
);
182 printk("SIOCGETLABEL, %08lx) ", arg
);
189 printk("TIOCGPGRP, %08lx) ", arg
);
191 error
= sys_ioctl(fd
, TIOCGPGRP
, arg
);
193 printk("arg=%d ", *(int *)arg
);
199 printk("TIOCGWINSZ, %08lx) ", arg
);
201 error
= sys_ioctl(fd
, TIOCGWINSZ
, arg
);
205 error
= sys_ioctl(fd
, FIONBIO
, arg
);
209 error
= sys_ioctl(fd
, TIOCSPGRP
, arg
);
213 error
= sys_ioctl(fd
, SIOCSIFADDR
, arg
);
217 error
= sys_ioctl(fd
, SIOCSIFFLAGS
, arg
);
221 error
= sys_ioctl(fd
, SIOCGIFFLAGS
, arg
);
225 error
= sys_ioctl(fd
, SIOCGIFMETRIC
, arg
);
229 #ifdef DEBUG_MISSING_IOCTL
230 char *msg
= "Unimplemented IOCTL cmd tell linux-mips@linux-mips.org\n";
233 printk("UNIMP_IOCTL, %08lx)\n", arg
);
235 old_fs
= get_fs(); set_fs(get_ds());
236 sys_write(2, msg
, strlen(msg
));
238 printk("[%s:%d] Does unimplemented IRIX ioctl cmd %08lx\n",
239 current
->comm
, current
->pid
, cmd
);
242 error
= sys_ioctl (fd
, cmd
, arg
);
248 printk("error=%d\n", error
);