1 /* $Id: sunos_ioctl.c,v 1.34 2000/09/03 14:10:56 anton Exp $
2 * sunos_ioctl.c: The Linux Operating system: SunOS ioctl compatibility.
4 * Copyright (C) 1995 Miguel de Icaza (miguel@nuclecu.unam.mx)
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
8 #include <asm/uaccess.h>
10 #include <linux/sched.h>
11 #include <linux/errno.h>
12 #include <linux/string.h>
13 #include <linux/termios.h>
14 #include <linux/ioctl.h>
15 #include <linux/route.h>
16 #include <linux/sockios.h>
18 #include <linux/netdevice.h>
19 #include <linux/if_arp.h>
22 #include <linux/smp.h>
23 #include <linux/smp_lock.h>
24 #include <linux/syscalls.h>
25 #include <linux/file.h>
29 extern char sunkbd_type
;
30 extern char sunkbd_layout
;
33 /* NR_OPEN is now larger and dynamic in recent kernels. */
34 #define SUNOS_NR_OPEN 256
36 asmlinkage
int sunos_ioctl (int fd
, unsigned long cmd
, unsigned long arg
)
40 if (fd
>= SUNOS_NR_OPEN
|| !fcheck(fd
))
43 /* First handle an easy compat. case for tty ldisc. */
44 if (cmd
== TIOCSETD
) {
46 int ntty
= N_TTY
, tmp
;
49 p
= (int __user
*) arg
;
56 ret
= sys_ioctl(fd
, cmd
, (unsigned long) &ntty
);
58 ret
= (ret
== -EINVAL
? -EOPNOTSUPP
: ret
);
63 /* Binary compatibility is good American knowhow fuckin' up. */
64 if (cmd
== TIOCNOTTY
) {
69 /* SunOS networking ioctls. */
71 case _IOW('r', 10, struct rtentry
):
72 ret
= sys_ioctl(fd
, SIOCADDRT
, arg
);
74 case _IOW('r', 11, struct rtentry
):
75 ret
= sys_ioctl(fd
, SIOCDELRT
, arg
);
77 case _IOW('i', 12, struct ifreq
):
78 ret
= sys_ioctl(fd
, SIOCSIFADDR
, arg
);
80 case _IOWR('i', 13, struct ifreq
):
81 ret
= sys_ioctl(fd
, SIOCGIFADDR
, arg
);
83 case _IOW('i', 14, struct ifreq
):
84 ret
= sys_ioctl(fd
, SIOCSIFDSTADDR
, arg
);
86 case _IOWR('i', 15, struct ifreq
):
87 ret
= sys_ioctl(fd
, SIOCGIFDSTADDR
, arg
);
89 case _IOW('i', 16, struct ifreq
):
90 ret
= sys_ioctl(fd
, SIOCSIFFLAGS
, arg
);
92 case _IOWR('i', 17, struct ifreq
):
93 ret
= sys_ioctl(fd
, SIOCGIFFLAGS
, arg
);
95 case _IOW('i', 18, struct ifreq
):
96 ret
= sys_ioctl(fd
, SIOCSIFMEM
, arg
);
98 case _IOWR('i', 19, struct ifreq
):
99 ret
= sys_ioctl(fd
, SIOCGIFMEM
, arg
);
101 case _IOWR('i', 20, struct ifconf
):
102 ret
= sys_ioctl(fd
, SIOCGIFCONF
, arg
);
104 case _IOW('i', 21, struct ifreq
): /* SIOCSIFMTU */
105 ret
= sys_ioctl(fd
, SIOCSIFMTU
, arg
);
107 case _IOWR('i', 22, struct ifreq
): /* SIOCGIFMTU */
108 ret
= sys_ioctl(fd
, SIOCGIFMTU
, arg
);
111 case _IOWR('i', 23, struct ifreq
):
112 ret
= sys_ioctl(fd
, SIOCGIFBRDADDR
, arg
);
114 case _IOW('i', 24, struct ifreq
):
115 ret
= sys_ioctl(fd
, SIOCSIFBRDADDR
, arg
);
117 case _IOWR('i', 25, struct ifreq
):
118 ret
= sys_ioctl(fd
, SIOCGIFNETMASK
, arg
);
120 case _IOW('i', 26, struct ifreq
):
121 ret
= sys_ioctl(fd
, SIOCSIFNETMASK
, arg
);
123 case _IOWR('i', 27, struct ifreq
):
124 ret
= sys_ioctl(fd
, SIOCGIFMETRIC
, arg
);
126 case _IOW('i', 28, struct ifreq
):
127 ret
= sys_ioctl(fd
, SIOCSIFMETRIC
, arg
);
130 case _IOW('i', 30, struct arpreq
):
131 ret
= sys_ioctl(fd
, SIOCSARP
, arg
);
133 case _IOWR('i', 31, struct arpreq
):
134 ret
= sys_ioctl(fd
, SIOCGARP
, arg
);
136 case _IOW('i', 32, struct arpreq
):
137 ret
= sys_ioctl(fd
, SIOCDARP
, arg
);
140 case _IOW('i', 40, struct ifreq
): /* SIOCUPPER */
141 case _IOW('i', 41, struct ifreq
): /* SIOCLOWER */
142 case _IOW('i', 44, struct ifreq
): /* SIOCSETSYNC */
143 case _IOW('i', 45, struct ifreq
): /* SIOCGETSYNC */
144 case _IOW('i', 46, struct ifreq
): /* SIOCSSDSTATS */
145 case _IOW('i', 47, struct ifreq
): /* SIOCSSESTATS */
146 case _IOW('i', 48, struct ifreq
): /* SIOCSPROMISC */
150 case _IOW('i', 49, struct ifreq
):
151 ret
= sys_ioctl(fd
, SIOCADDMULTI
, arg
);
153 case _IOW('i', 50, struct ifreq
):
154 ret
= sys_ioctl(fd
, SIOCDELMULTI
, arg
);
157 /* FDDI interface ioctls, unsupported. */
159 case _IOW('i', 51, struct ifreq
): /* SIOCFDRESET */
160 case _IOW('i', 52, struct ifreq
): /* SIOCFDSLEEP */
161 case _IOW('i', 53, struct ifreq
): /* SIOCSTRTFMWAR */
162 case _IOW('i', 54, struct ifreq
): /* SIOCLDNSTRTFW */
163 case _IOW('i', 55, struct ifreq
): /* SIOCGETFDSTAT */
164 case _IOW('i', 56, struct ifreq
): /* SIOCFDNMIINT */
165 case _IOW('i', 57, struct ifreq
): /* SIOCFDEXUSER */
166 case _IOW('i', 58, struct ifreq
): /* SIOCFDGNETMAP */
167 case _IOW('i', 59, struct ifreq
): /* SIOCFDGIOCTL */
168 printk("FDDI ioctl, returning EOPNOTSUPP\n");
172 case _IOW('t', 125, int):
173 /* More stupid tty sunos ioctls, just
179 case _IOW('t', 118, int): {
180 int oldval
, newval
, __user
*ptr
;
183 ptr
= (int __user
*) arg
;
185 if (get_user(oldval
, ptr
))
187 ret
= sys_ioctl(fd
, cmd
, arg
);
188 __get_user(newval
, ptr
);
190 __put_user(oldval
, ptr
);
198 case _IOR('t', 119, int): {
199 int oldval
, newval
, __user
*ptr
;
202 ptr
= (int __user
*) arg
;
204 if (get_user(oldval
, ptr
))
206 ret
= sys_ioctl(fd
, cmd
, arg
);
207 __get_user(newval
, ptr
);
209 __put_user(oldval
, ptr
);
219 if ((cmd
& 0xff00) == ('k' << 8)) {
220 printk ("[[KBIO: %8.8x\n", (unsigned int) cmd
);
224 ret
= sys_ioctl(fd
, cmd
, arg
);
226 ret
= (ret
== -EINVAL
? -EOPNOTSUPP
: ret
);