1 /* $Id: sunos_ioctl32.c,v 1.10 1998/08/15 20:42:46 davem Exp $
2 * sunos_ioctl32.c: SunOS ioctl compatability 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/ioctl.h>
15 #include <linux/route.h>
16 #include <linux/sockios.h>
18 #include <linux/netdevice.h>
19 #include <linux/if_arp.h>
21 #include <linux/file.h>
23 #include <linux/smp.h>
24 #include <linux/smp_lock.h>
27 /* Use this to get at 32-bit user passed pointers. */
29 ({ unsigned long __ret; \
30 __asm__ ("srl %0, 0, %0" \
36 #define SUNOS_NR_OPEN 256
40 struct sockaddr rt_dst
; /* target address */
41 struct sockaddr rt_gateway
; /* gateway addr (RTF_GATEWAY) */
42 struct sockaddr rt_genmask
; /* target network mask (IP) */
43 unsigned short rt_flags
;
47 unsigned char rt_class
;
49 short rt_metric
; /* +1 for binary compatibility! */
50 /* char * */ u32 rt_dev
; /* forcing the device at add */
51 u32 rt_mtu
; /* per route MTU/Window */
52 u32 rt_window
; /* Window clamping */
53 unsigned short rt_irtt
; /* Initial RTT */
60 unsigned short base_addr
;
70 char ifrn_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
73 struct sockaddr ifru_addr
;
74 struct sockaddr ifru_dstaddr
;
75 struct sockaddr ifru_broadaddr
;
76 struct sockaddr ifru_netmask
;
77 struct sockaddr ifru_hwaddr
;
81 struct ifmap32 ifru_map
;
82 char ifru_slave
[IFNAMSIZ
]; /* Just fits the size */
83 __kernel_caddr_t32 ifru_data
;
88 int ifc_len
; /* size of buffer */
89 __kernel_caddr_t32 ifcbuf
;
92 extern asmlinkage
int sys_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
);
94 extern asmlinkage
int sys32_ioctl(unsigned int, unsigned int, u32
);
95 extern asmlinkage
int sys_setsid(void);
97 asmlinkage
int sunos_ioctl (int fd
, u32 cmd
, u32 arg
)
102 if(fd
>= SUNOS_NR_OPEN
)
107 if(cmd
== TIOCSETD
) {
108 mm_segment_t old_fs
= get_fs();
109 int *p
, ntty
= N_TTY
;
118 ret
= sys_ioctl(fd
, cmd
, (unsigned long) &ntty
);
120 ret
= (ret
== -EINVAL
? -EOPNOTSUPP
: ret
);
124 if(cmd
== TIOCNOTTY
) {
129 case _IOW('r', 10, struct rtentry32
):
130 ret
= sys32_ioctl(fd
, SIOCADDRT
, arg
);
132 case _IOW('r', 11, struct rtentry32
):
133 ret
= sys32_ioctl(fd
, SIOCDELRT
, arg
);
136 case _IOW('i', 12, struct ifreq32
):
137 ret
= sys32_ioctl(fd
, SIOCSIFADDR
, arg
);
139 case _IOWR('i', 13, struct ifreq32
):
140 ret
= sys32_ioctl(fd
, SIOCGIFADDR
, arg
);
142 case _IOW('i', 14, struct ifreq32
):
143 ret
= sys32_ioctl(fd
, SIOCSIFDSTADDR
, arg
);
145 case _IOWR('i', 15, struct ifreq32
):
146 ret
= sys32_ioctl(fd
, SIOCGIFDSTADDR
, arg
);
148 case _IOW('i', 16, struct ifreq32
):
149 ret
= sys32_ioctl(fd
, SIOCSIFFLAGS
, arg
);
151 case _IOWR('i', 17, struct ifreq32
):
152 ret
= sys32_ioctl(fd
, SIOCGIFFLAGS
, arg
);
154 case _IOW('i', 18, struct ifreq32
):
155 ret
= sys32_ioctl(fd
, SIOCSIFMEM
, arg
);
157 case _IOWR('i', 19, struct ifreq32
):
158 ret
= sys32_ioctl(fd
, SIOCGIFMEM
, arg
);
161 case _IOWR('i', 20, struct ifconf32
):
162 ret
= sys32_ioctl(fd
, SIOCGIFCONF
, arg
);
165 case _IOW('i', 21, struct ifreq
): /* SIOCSIFMTU */
166 ret
= sys_ioctl(fd
, SIOCSIFMTU
, arg
);
168 case _IOWR('i', 22, struct ifreq
): /* SIOCGIFMTU */
169 ret
= sys_ioctl(fd
, SIOCGIFMTU
, arg
);
172 case _IOWR('i', 23, struct ifreq32
):
173 ret
= sys32_ioctl(fd
, SIOCGIFBRDADDR
, arg
);
175 case _IOW('i', 24, struct ifreq32
):
176 ret
= sys32_ioctl(fd
, SIOCSIFBRDADDR
, arg
);
178 case _IOWR('i', 25, struct ifreq32
):
179 ret
= sys32_ioctl(fd
, SIOCGIFNETMASK
, arg
);
181 case _IOW('i', 26, struct ifreq32
):
182 ret
= sys32_ioctl(fd
, SIOCSIFNETMASK
, arg
);
184 case _IOWR('i', 27, struct ifreq32
):
185 ret
= sys32_ioctl(fd
, SIOCGIFMETRIC
, arg
);
187 case _IOW('i', 28, struct ifreq32
):
188 ret
= sys32_ioctl(fd
, SIOCSIFMETRIC
, arg
);
191 case _IOW('i', 30, struct arpreq
):
192 ret
= sys32_ioctl(fd
, SIOCSARP
, arg
);
194 case _IOWR('i', 31, struct arpreq
):
195 ret
= sys32_ioctl(fd
, SIOCGARP
, arg
);
197 case _IOW('i', 32, struct arpreq
):
198 ret
= sys32_ioctl(fd
, SIOCDARP
, arg
);
201 case _IOW('i', 40, struct ifreq32
): /* SIOCUPPER */
202 case _IOW('i', 41, struct ifreq32
): /* SIOCLOWER */
203 case _IOW('i', 44, struct ifreq32
): /* SIOCSETSYNC */
204 case _IOW('i', 45, struct ifreq32
): /* SIOCGETSYNC */
205 case _IOW('i', 46, struct ifreq32
): /* SIOCSSDSTATS */
206 case _IOW('i', 47, struct ifreq32
): /* SIOCSSESTATS */
207 case _IOW('i', 48, struct ifreq32
): /* SIOCSPROMISC */
211 case _IOW('i', 49, struct ifreq32
):
212 ret
= sys32_ioctl(fd
, SIOCADDMULTI
, arg
);
214 case _IOW('i', 50, struct ifreq32
):
215 ret
= sys32_ioctl(fd
, SIOCDELMULTI
, arg
);
218 /* FDDI interface ioctls, unsupported. */
220 case _IOW('i', 51, struct ifreq32
): /* SIOCFDRESET */
221 case _IOW('i', 52, struct ifreq32
): /* SIOCFDSLEEP */
222 case _IOW('i', 53, struct ifreq32
): /* SIOCSTRTFMWAR */
223 case _IOW('i', 54, struct ifreq32
): /* SIOCLDNSTRTFW */
224 case _IOW('i', 55, struct ifreq32
): /* SIOCGETFDSTAT */
225 case _IOW('i', 56, struct ifreq32
): /* SIOCFDNMIINT */
226 case _IOW('i', 57, struct ifreq32
): /* SIOCFDEXUSER */
227 case _IOW('i', 58, struct ifreq32
): /* SIOCFDGNETMAP */
228 case _IOW('i', 59, struct ifreq32
): /* SIOCFDGIOCTL */
229 printk("FDDI ioctl, returning EOPNOTSUPP\n");
233 case _IOW('t', 125, int):
234 /* More stupid tty sunos ioctls, just
241 case _IOW('t', 118, int): {
242 int oldval
, newval
, *ptr
;
245 ptr
= (int *) A(arg
);
247 if(get_user(oldval
, ptr
))
249 ret
= sys32_ioctl(fd
, cmd
, arg
);
250 __get_user(newval
, ptr
);
252 __put_user(oldval
, ptr
);
260 case _IOR('t', 119, int): {
261 int oldval
, newval
, *ptr
;
264 ptr
= (int *) A(arg
);
266 if(get_user(oldval
, ptr
))
268 ret
= sys32_ioctl(fd
, cmd
, arg
);
269 __get_user(newval
, ptr
);
271 __put_user(oldval
, ptr
);
280 ret
= sys32_ioctl(fd
, cmd
, arg
);
282 ret
= (ret
== -EINVAL
? -EOPNOTSUPP
: ret
);