1 /* $Id: irixioctl.c,v 1.6 1999/02/06 05:12:56 adevries Exp $
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/tty.h>
14 #include <linux/file.h>
16 #include <asm/uaccess.h>
17 #include <asm/ioctl.h>
18 #include <asm/ioctls.h>
21 #undef DEBUG_MISSING_IOCTL
24 tcflag_t c_iflag
, c_oflag
, c_cflag
, c_lflag
;
28 extern asmlinkage
int sys_ioctl(unsigned int fd
, unsigned int cmd
,
30 extern asmlinkage
int sys_write(unsigned int fd
,char * buf
,unsigned int count
);
31 extern void start_tty(struct tty_struct
*tty
);
32 static struct tty_struct
*get_tty(int fd
)
35 struct tty_struct
*ttyp
= NULL
;
37 read_lock(¤t
->files
->file_lock
);
39 if(filp
&& filp
->private_data
) {
40 ttyp
= (struct tty_struct
*) filp
->private_data
;
42 if(ttyp
->magic
!= TTY_MAGIC
)
45 read_unlock(¤t
->files
->file_lock
);
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
;
66 printk("[%s:%d] irix_ioctl(%d, ", current
->comm
, current
->pid
, fd
);
71 printk("TCGETA, %08lx) ", arg
);
73 error
= sys_ioctl(fd
, TCGETA
, arg
);
78 struct irix_termios
*it
= (struct irix_termios
*) 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
);
92 __put_user(kt
.c_iflag
, &it
->c_iflag
);
93 __put_user(kt
.c_oflag
, &it
->c_oflag
);
94 __put_user(kt
.c_cflag
, &it
->c_cflag
);
95 __put_user(kt
.c_lflag
, &it
->c_lflag
);
96 for(error
= 0; error
< NCCS
; error
++)
97 __put_user(kt
.c_cc
[error
], &it
->c_cc
[error
]);
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
);
118 __get_user(kt
.c_iflag
, &it
->c_iflag
);
119 __get_user(kt
.c_oflag
, &it
->c_oflag
);
120 __get_user(kt
.c_cflag
, &it
->c_cflag
);
121 __get_user(kt
.c_lflag
, &it
->c_lflag
);
122 for(error
= 0; error
< NCCS
; error
++)
123 __get_user(kt
.c_cc
[error
], &it
->c_cc
[error
]);
124 old_fs
= get_fs(); set_fs(get_ds());
125 error
= sys_ioctl(fd
, TCSETS
, (unsigned long) &kt
);
132 printk("TCSETSW, %08lx) ", arg
);
134 error
= sys_ioctl(fd
, TCSETSW
, arg
);
139 printk("TIOCNOTTY, %08lx) ", arg
);
141 error
= sys_ioctl(fd
, TIOCNOTTY
, arg
);
146 printk("TIOCGSID, %08lx) ", arg
);
153 rtp
= get_real_tty(tp
);
155 printk("rtp->session=%d ", rtp
->session
);
157 error
= put_user(rtp
->session
, (unsigned long *) arg
);
161 /* TIOCSTART, same effect as hitting ^Q */
163 printk("TIOCSTART, %08lx) ", arg
);
170 rtp
= get_real_tty(tp
);
176 printk("SIOCGETLABEL, %08lx) ", arg
);
183 printk("TIOCGPGRP, %08lx) ", arg
);
185 error
= sys_ioctl(fd
, TIOCGPGRP
, arg
);
187 printk("arg=%d ", *(int *)arg
);
193 printk("TIOCGWINSZ, %08lx) ", arg
);
195 error
= sys_ioctl(fd
, TIOCGWINSZ
, arg
);
200 printk("FIONBIO, %08lx) arg=%d ", arg
, *(int *)arg
);
202 error
= sys_ioctl(fd
, FIONBIO
, arg
);
207 printk("TIOCSPGRP, %08lx) arg=%d ", arg
, *(int *)arg
);
209 error
= sys_ioctl(fd
, TIOCSPGRP
, arg
);
214 printk("SIOCSIFADDR, %08lx) arg=%d ", arg
, *(int *)arg
);
216 error
= sys_ioctl(fd
, SIOCSIFADDR
, arg
);
221 printk("SIOCSIFFLAGS, %08lx) arg=%d ", arg
, *(int *)arg
);
223 error
= sys_ioctl(fd
, SIOCSIFFLAGS
, arg
);
228 printk("SIOCGIFFLAGS, %08lx) arg=%d ", arg
, *(int *)arg
);
230 error
= sys_ioctl(fd
, SIOCGIFFLAGS
, arg
);
235 printk("SIOCGIFMETRIC, %08lx) arg=%d ", arg
, *(int *)arg
);
237 error
= sys_ioctl(fd
, SIOCGIFMETRIC
, arg
);
241 #ifdef DEBUG_MISSING_IOCTL
242 char *msg
= "Unimplemented IOCTL cmd tell linux@engr.sgi.com\n";
245 printk("UNIMP_IOCTL, %08lx)\n", arg
);
247 old_fs
= get_fs(); set_fs(get_ds());
248 sys_write(2, msg
, strlen(msg
));
250 printk("[%s:%d] Does unimplemented IRIX ioctl cmd %08lx\n",
251 current
->comm
, current
->pid
, cmd
);
254 error
= sys_ioctl (fd
, cmd
, arg
);
260 printk("error=%d\n", error
);