1 /* $Id: sunos_ioctl32.c,v 1.11 2000/07/30 23:12:24 davem Exp $
2 * sunos_ioctl32.c: SunOS ioctl compatibility on sparc64.
4 * Copyright (C) 1995 Miguel de Icaza (miguel@nuclecu.unam.mx)
5 * Copyright (C) 1995, 1996, 1997 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/tty.h>
15 #include <linux/ioctl.h>
16 #include <linux/route.h>
17 #include <linux/sockios.h>
19 #include <linux/netdevice.h>
20 #include <linux/if_arp.h>
22 #include <linux/file.h>
24 #include <linux/smp.h>
25 #include <linux/smp_lock.h>
26 #include <linux/syscalls.h>
27 #include <linux/compat.h>
29 #define SUNOS_NR_OPEN 256
33 struct sockaddr rt_dst; /* target address */
34 struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
35 struct sockaddr rt_genmask; /* target network mask (IP) */
36 unsigned short rt_flags;
40 unsigned char rt_class;
42 short rt_metric; /* +1 for binary compatibility! */
43 /* char * */ u32 rt_dev; /* forcing the device at add */
44 u32 rt_mtu; /* per route MTU/Window */
45 u32 rt_window; /* Window clamping */
46 unsigned short rt_irtt; /* Initial RTT */
53 unsigned short base_addr;
63 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
66 struct sockaddr ifru_addr;
67 struct sockaddr ifru_dstaddr;
68 struct sockaddr ifru_broadaddr;
69 struct sockaddr ifru_netmask;
70 struct sockaddr ifru_hwaddr;
74 struct ifmap32 ifru_map;
75 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
76 compat_caddr_t ifru_data;
81 int ifc_len; /* size of buffer */
82 compat_caddr_t ifcbuf;
85 extern asmlinkage int compat_sys_ioctl(unsigned int, unsigned int, u32);
87 asmlinkage int sunos_ioctl (int fd, u32 cmd, u32 arg)
91 if(fd >= SUNOS_NR_OPEN)
97 mm_segment_t old_fs = get_fs();
102 p = (int __user *) (unsigned long) arg;
108 ret = sys_ioctl(fd, cmd, (unsigned long) &ntty);
110 ret = (ret == -EINVAL ? -EOPNOTSUPP : ret);
114 if(cmd == TIOCNOTTY) {
119 case _IOW('r', 10, struct rtentry32):
120 ret = compat_sys_ioctl(fd, SIOCADDRT, arg);
122 case _IOW('r', 11, struct rtentry32):
123 ret = compat_sys_ioctl(fd, SIOCDELRT, arg);
126 case _IOW('i', 12, struct ifreq32):
127 ret = compat_sys_ioctl(fd, SIOCSIFADDR, arg);
129 case _IOWR('i', 13, struct ifreq32):
130 ret = compat_sys_ioctl(fd, SIOCGIFADDR, arg);
132 case _IOW('i', 14, struct ifreq32):
133 ret = compat_sys_ioctl(fd, SIOCSIFDSTADDR, arg);
135 case _IOWR('i', 15, struct ifreq32):
136 ret = compat_sys_ioctl(fd, SIOCGIFDSTADDR, arg);
138 case _IOW('i', 16, struct ifreq32):
139 ret = compat_sys_ioctl(fd, SIOCSIFFLAGS, arg);
141 case _IOWR('i', 17, struct ifreq32):
142 ret = compat_sys_ioctl(fd, SIOCGIFFLAGS, arg);
144 case _IOW('i', 18, struct ifreq32):
145 ret = compat_sys_ioctl(fd, SIOCSIFMEM, arg);
147 case _IOWR('i', 19, struct ifreq32):
148 ret = compat_sys_ioctl(fd, SIOCGIFMEM, arg);
151 case _IOWR('i', 20, struct ifconf32):
152 ret = compat_sys_ioctl(fd, SIOCGIFCONF, arg);
155 case _IOW('i', 21, struct ifreq32):
156 ret = compat_sys_ioctl(fd, SIOCSIFMTU, arg);
159 case _IOWR('i', 22, struct ifreq32):
160 ret = compat_sys_ioctl(fd, SIOCGIFMTU, arg);
163 case _IOWR('i', 23, struct ifreq32):
164 ret = compat_sys_ioctl(fd, SIOCGIFBRDADDR, arg);
166 case _IOW('i', 24, struct ifreq32):
167 ret = compat_sys_ioctl(fd, SIOCSIFBRDADDR, arg);
169 case _IOWR('i', 25, struct ifreq32):
170 ret = compat_sys_ioctl(fd, SIOCGIFNETMASK, arg);
172 case _IOW('i', 26, struct ifreq32):
173 ret = compat_sys_ioctl(fd, SIOCSIFNETMASK, arg);
175 case _IOWR('i', 27, struct ifreq32):
176 ret = compat_sys_ioctl(fd, SIOCGIFMETRIC, arg);
178 case _IOW('i', 28, struct ifreq32):
179 ret = compat_sys_ioctl(fd, SIOCSIFMETRIC, arg);
182 case _IOW('i', 30, struct arpreq):
183 ret = compat_sys_ioctl(fd, SIOCSARP, arg);
185 case _IOWR('i', 31, struct arpreq):
186 ret = compat_sys_ioctl(fd, SIOCGARP, arg);
188 case _IOW('i', 32, struct arpreq):
189 ret = compat_sys_ioctl(fd, SIOCDARP, arg);
192 case _IOW('i', 40, struct ifreq32): /* SIOCUPPER */
193 case _IOW('i', 41, struct ifreq32): /* SIOCLOWER */
194 case _IOW('i', 44, struct ifreq32): /* SIOCSETSYNC */
195 case _IOW('i', 45, struct ifreq32): /* SIOCGETSYNC */
196 case _IOW('i', 46, struct ifreq32): /* SIOCSSDSTATS */
197 case _IOW('i', 47, struct ifreq32): /* SIOCSSESTATS */
198 case _IOW('i', 48, struct ifreq32): /* SIOCSPROMISC */
202 case _IOW('i', 49, struct ifreq32):
203 ret = compat_sys_ioctl(fd, SIOCADDMULTI, arg);
205 case _IOW('i', 50, struct ifreq32):
206 ret = compat_sys_ioctl(fd, SIOCDELMULTI, arg);
209 /* FDDI interface ioctls, unsupported. */
211 case _IOW('i', 51, struct ifreq32): /* SIOCFDRESET */
212 case _IOW('i', 52, struct ifreq32): /* SIOCFDSLEEP */
213 case _IOW('i', 53, struct ifreq32): /* SIOCSTRTFMWAR */
214 case _IOW('i', 54, struct ifreq32): /* SIOCLDNSTRTFW */
215 case _IOW('i', 55, struct ifreq32): /* SIOCGETFDSTAT */
216 case _IOW('i', 56, struct ifreq32): /* SIOCFDNMIINT */
217 case _IOW('i', 57, struct ifreq32): /* SIOCFDEXUSER */
218 case _IOW('i', 58, struct ifreq32): /* SIOCFDGNETMAP */
219 case _IOW('i', 59, struct ifreq32): /* SIOCFDGIOCTL */
220 printk("FDDI ioctl, returning EOPNOTSUPP\n");
224 case _IOW('t', 125, int):
225 /* More stupid tty sunos ioctls, just
232 case _IOW('t', 118, int): {
233 int oldval, newval, __user *ptr;
236 ptr = (int __user *) (unsigned long) arg;
238 if(get_user(oldval, ptr))
240 ret = compat_sys_ioctl(fd, cmd, arg);
241 __get_user(newval, ptr);
243 __put_user(oldval, ptr);
251 case _IOR('t', 119, int): {
252 int oldval, newval, __user *ptr;
255 ptr = (int __user *) (unsigned long) arg;
257 if(get_user(oldval, ptr))
259 ret = compat_sys_ioctl(fd, cmd, arg);
260 __get_user(newval, ptr);
262 __put_user(oldval, ptr);
271 ret = compat_sys_ioctl(fd, cmd, arg);
273 ret = (ret == -EINVAL ? -EOPNOTSUPP : ret);