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>
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
;
36 spin_lock(¤t
->files
->file_lock
);
38 if(filp
&& filp
->private_data
) {
39 ttyp
= (struct tty_struct
*) filp
->private_data
;
41 if(ttyp
->magic
!= TTY_MAGIC
)
44 spin_unlock(¤t
->files
->file_lock
);
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
*it
= (struct irix_termios
*) arg
;
79 printk("TCGETS, %08lx) ", arg
);
81 if(!access_ok(VERIFY_WRITE
, it
, sizeof(*it
))) {
85 old_fs
= get_fs(); set_fs(get_ds());
86 error
= sys_ioctl(fd
, TCGETS
, (unsigned long) &kt
);
90 __put_user(kt
.c_iflag
, &it
->c_iflag
);
91 __put_user(kt
.c_oflag
, &it
->c_oflag
);
92 __put_user(kt
.c_cflag
, &it
->c_cflag
);
93 __put_user(kt
.c_lflag
, &it
->c_lflag
);
94 for(error
= 0; error
< NCCS
; error
++)
95 __put_user(kt
.c_cc
[error
], &it
->c_cc
[error
]);
102 struct irix_termios
*it
= (struct irix_termios
*) arg
;
105 printk("TCSETS, %08lx) ", arg
);
107 if (!access_ok(VERIFY_READ
, it
, sizeof(*it
))) {
111 old_fs
= get_fs(); set_fs(get_ds());
112 error
= sys_ioctl(fd
, TCGETS
, (unsigned long) &kt
);
116 __get_user(kt
.c_iflag
, &it
->c_iflag
);
117 __get_user(kt
.c_oflag
, &it
->c_oflag
);
118 __get_user(kt
.c_cflag
, &it
->c_cflag
);
119 __get_user(kt
.c_lflag
, &it
->c_lflag
);
120 for(error
= 0; error
< NCCS
; error
++)
121 __get_user(kt
.c_cc
[error
], &it
->c_cc
[error
]);
122 old_fs
= get_fs(); set_fs(get_ds());
123 error
= sys_ioctl(fd
, TCSETS
, (unsigned long) &kt
);
130 printk("TCSETSW, %08lx) ", arg
);
132 error
= sys_ioctl(fd
, TCSETSW
, arg
);
137 printk("TIOCNOTTY, %08lx) ", arg
);
139 error
= sys_ioctl(fd
, TIOCNOTTY
, arg
);
144 printk("TIOCGSID, %08lx) ", arg
);
151 rtp
= get_real_tty(tp
);
153 printk("rtp->session=%d ", rtp
->session
);
155 error
= put_user(rtp
->session
, (unsigned long *) arg
);
159 /* TIOCSTART, same effect as hitting ^Q */
161 printk("TIOCSTART, %08lx) ", arg
);
168 rtp
= get_real_tty(tp
);
174 printk("SIOCGETLABEL, %08lx) ", arg
);
181 printk("TIOCGPGRP, %08lx) ", arg
);
183 error
= sys_ioctl(fd
, TIOCGPGRP
, arg
);
185 printk("arg=%d ", *(int *)arg
);
191 printk("TIOCGWINSZ, %08lx) ", arg
);
193 error
= sys_ioctl(fd
, TIOCGWINSZ
, arg
);
198 printk("FIONBIO, %08lx) arg=%d ", arg
, *(int *)arg
);
200 error
= sys_ioctl(fd
, FIONBIO
, arg
);
205 printk("TIOCSPGRP, %08lx) arg=%d ", arg
, *(int *)arg
);
207 error
= sys_ioctl(fd
, TIOCSPGRP
, arg
);
212 printk("SIOCSIFADDR, %08lx) arg=%d ", arg
, *(int *)arg
);
214 error
= sys_ioctl(fd
, SIOCSIFADDR
, arg
);
219 printk("SIOCSIFFLAGS, %08lx) arg=%d ", arg
, *(int *)arg
);
221 error
= sys_ioctl(fd
, SIOCSIFFLAGS
, arg
);
226 printk("SIOCGIFFLAGS, %08lx) arg=%d ", arg
, *(int *)arg
);
228 error
= sys_ioctl(fd
, SIOCGIFFLAGS
, arg
);
233 printk("SIOCGIFMETRIC, %08lx) arg=%d ", arg
, *(int *)arg
);
235 error
= sys_ioctl(fd
, SIOCGIFMETRIC
, arg
);
239 #ifdef DEBUG_MISSING_IOCTL
240 char *msg
= "Unimplemented IOCTL cmd tell linux@engr.sgi.com\n";
243 printk("UNIMP_IOCTL, %08lx)\n", arg
);
245 old_fs
= get_fs(); set_fs(get_ds());
246 sys_write(2, msg
, strlen(msg
));
248 printk("[%s:%d] Does unimplemented IRIX ioctl cmd %08lx\n",
249 current
->comm
, current
->pid
, cmd
);
252 error
= sys_ioctl (fd
, cmd
, arg
);
258 printk("error=%d\n", error
);