appletalk: handle SIOCATALKDIFADDR compat ioctl
[deliverable/linux.git] / fs / compat_ioctl.c
CommitLineData
1da177e4
LT
1/*
2 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
3 *
4 * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
5 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
6 * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs
7 * Copyright (C) 2003 Pavel Machek (pavel@suse.cz)
8 *
9 * These routines maintain argument size conversion between 32bit and 64bit
10 * ioctls.
11 */
12
3fee37c1
AM
13#include <linux/joystick.h>
14
1da177e4
LT
15#include <linux/types.h>
16#include <linux/compat.h>
17#include <linux/kernel.h>
16f7e0fe 18#include <linux/capability.h>
1da177e4
LT
19#include <linux/compiler.h>
20#include <linux/sched.h>
21#include <linux/smp.h>
405f5571 22#include <linux/smp_lock.h>
1da177e4
LT
23#include <linux/ioctl.h>
24#include <linux/if.h>
25#include <linux/if_bridge.h>
26#include <linux/slab.h>
bff61975 27#include <linux/raid/md_u.h>
1da177e4 28#include <linux/kd.h>
1da177e4
LT
29#include <linux/route.h>
30#include <linux/in6.h>
31#include <linux/ipv6_route.h>
32#include <linux/skbuff.h>
33#include <linux/netlink.h>
34#include <linux/vt.h>
3e63cbb1 35#include <linux/falloc.h>
1da177e4
LT
36#include <linux/fs.h>
37#include <linux/file.h>
1da177e4
LT
38#include <linux/ppp_defs.h>
39#include <linux/if_ppp.h>
40#include <linux/if_pppox.h>
41#include <linux/mtio.h>
1da177e4
LT
42#include <linux/auto_fs.h>
43#include <linux/auto_fs4.h>
1da177e4
LT
44#include <linux/tty.h>
45#include <linux/vt_kern.h>
46#include <linux/fb.h>
1da177e4
LT
47#include <linux/videodev.h>
48#include <linux/netdevice.h>
49#include <linux/raw.h>
50#include <linux/smb_fs.h>
1da177e4
LT
51#include <linux/blkdev.h>
52#include <linux/elevator.h>
53#include <linux/rtc.h>
54#include <linux/pci.h>
55#include <linux/module.h>
56#include <linux/serial.h>
1da177e4
LT
57#include <linux/if_tun.h>
58#include <linux/ctype.h>
1da177e4 59#include <linux/syscalls.h>
1da177e4
LT
60#include <linux/i2c.h>
61#include <linux/i2c-dev.h>
1da177e4
LT
62#include <linux/atalk.h>
63
1da177e4
LT
64#include <net/bluetooth/bluetooth.h>
65#include <net/bluetooth/hci.h>
66#include <net/bluetooth/rfcomm.h>
67
68#include <linux/capi.h>
5024ad4a 69#include <linux/gigaset_dev.h>
1da177e4 70
3c3622dc 71#ifdef CONFIG_BLOCK
1ba0c7db 72#include <linux/loop.h>
1da177e4 73#include <scsi/scsi.h>
1da177e4 74#include <scsi/scsi_ioctl.h>
1da177e4 75#include <scsi/sg.h>
3c3622dc 76#endif
1da177e4 77
1da177e4
LT
78#include <asm/uaccess.h>
79#include <linux/ethtool.h>
80#include <linux/mii.h>
81#include <linux/if_bonding.h>
82#include <linux/watchdog.h>
1da177e4 83
1da177e4
LT
84#include <linux/soundcard.h>
85#include <linux/lp.h>
86#include <linux/ppdev.h>
87
88#include <linux/atm.h>
89#include <linux/atmarp.h>
90#include <linux/atmclip.h>
91#include <linux/atmdev.h>
92#include <linux/atmioc.h>
93#include <linux/atmlec.h>
94#include <linux/atmmpc.h>
95#include <linux/atmsvc.h>
96#include <linux/atm_tcp.h>
97#include <linux/sonet.h>
98#include <linux/atm_suni.h>
1da177e4
LT
99
100#include <linux/usb.h>
101#include <linux/usbdevice_fs.h>
102#include <linux/nbd.h>
103#include <linux/random.h>
104#include <linux/filter.h>
1da177e4
LT
105#include <linux/pktcdvd.h>
106
107#include <linux/hiddev.h>
108
6e87abd0
DM
109#include <linux/dvb/audio.h>
110#include <linux/dvb/dmx.h>
111#include <linux/dvb/frontend.h>
112#include <linux/dvb/video.h>
113
8163904e
DM
114#ifdef CONFIG_SPARC
115#include <asm/fbio.h>
116#endif
117
e6a6d2ef
CH
118static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
119 unsigned long arg, struct file *f)
120{
121 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
122}
123
1da177e4
LT
124static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
125{
126 mm_segment_t old_fs = get_fs();
127 int err;
128 unsigned long val;
129
130 set_fs (KERNEL_DS);
131 err = sys_ioctl(fd, cmd, (unsigned long)&val);
132 set_fs (old_fs);
133 if (!err && put_user(val, (u32 __user *)compat_ptr(arg)))
134 return -EFAULT;
135 return err;
136}
137
138static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg)
139{
140 mm_segment_t old_fs = get_fs();
141 u32 __user *argptr = compat_ptr(arg);
142 int err;
143 unsigned long val;
144
145 if(get_user(val, argptr))
146 return -EFAULT;
147 set_fs (KERNEL_DS);
148 err = sys_ioctl(fd, cmd, (unsigned long)&val);
149 set_fs (old_fs);
150 if (!err && put_user(val, argptr))
151 return -EFAULT;
152 return err;
153}
154
6e87abd0
DM
155struct compat_video_event {
156 int32_t type;
157 compat_time_t timestamp;
158 union {
159 video_size_t size;
160 unsigned int frame_rate;
161 } u;
162};
163
164static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long arg)
165{
166 struct video_event kevent;
167 mm_segment_t old_fs = get_fs();
168 int err;
169
170 set_fs(KERNEL_DS);
171 err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
172 set_fs(old_fs);
173
174 if (!err) {
175 struct compat_video_event __user *up = compat_ptr(arg);
176
177 err = put_user(kevent.type, &up->type);
178 err |= put_user(kevent.timestamp, &up->timestamp);
179 err |= put_user(kevent.u.size.w, &up->u.size.w);
180 err |= put_user(kevent.u.size.h, &up->u.size.h);
181 err |= put_user(kevent.u.size.aspect_ratio,
182 &up->u.size.aspect_ratio);
183 if (err)
184 err = -EFAULT;
185 }
186
187 return err;
188}
189
190struct compat_video_still_picture {
191 compat_uptr_t iFrame;
192 int32_t size;
193};
194
195static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned long arg)
196{
197 struct compat_video_still_picture __user *up;
198 struct video_still_picture __user *up_native;
199 compat_uptr_t fp;
200 int32_t size;
201 int err;
202
203 up = (struct compat_video_still_picture __user *) arg;
204 err = get_user(fp, &up->iFrame);
205 err |= get_user(size, &up->size);
206 if (err)
207 return -EFAULT;
208
209 up_native =
210 compat_alloc_user_space(sizeof(struct video_still_picture));
211
7116e994
HC
212 err = put_user(compat_ptr(fp), &up_native->iFrame);
213 err |= put_user(size, &up_native->size);
214 if (err)
215 return -EFAULT;
6e87abd0
DM
216
217 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
218
219 return err;
220}
221
222struct compat_video_spu_palette {
223 int length;
224 compat_uptr_t palette;
225};
226
227static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned long arg)
228{
229 struct compat_video_spu_palette __user *up;
230 struct video_spu_palette __user *up_native;
231 compat_uptr_t palp;
232 int length, err;
233
234 up = (struct compat_video_spu_palette __user *) arg;
235 err = get_user(palp, &up->palette);
236 err |= get_user(length, &up->length);
237
238 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
7116e994
HC
239 err = put_user(compat_ptr(palp), &up_native->palette);
240 err |= put_user(length, &up_native->length);
241 if (err)
242 return -EFAULT;
6e87abd0
DM
243
244 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
245
246 return err;
247}
248
1da177e4
LT
249#ifdef CONFIG_NET
250static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
251{
252 struct compat_timeval __user *up = compat_ptr(arg);
253 struct timeval ktv;
254 mm_segment_t old_fs = get_fs();
255 int err;
256
257 set_fs(KERNEL_DS);
258 err = sys_ioctl(fd, cmd, (unsigned long)&ktv);
259 set_fs(old_fs);
260 if(!err) {
261 err = put_user(ktv.tv_sec, &up->tv_sec);
262 err |= __put_user(ktv.tv_usec, &up->tv_usec);
263 }
264 return err;
265}
266
ae40eb1e
ED
267static int do_siocgstampns(unsigned int fd, unsigned int cmd, unsigned long arg)
268{
269 struct compat_timespec __user *up = compat_ptr(arg);
270 struct timespec kts;
271 mm_segment_t old_fs = get_fs();
272 int err;
273
274 set_fs(KERNEL_DS);
275 err = sys_ioctl(fd, cmd, (unsigned long)&kts);
276 set_fs(old_fs);
277 if (!err) {
278 err = put_user(kts.tv_sec, &up->tv_sec);
279 err |= __put_user(kts.tv_nsec, &up->tv_nsec);
280 }
281 return err;
282}
283
1da177e4
LT
284struct ifmap32 {
285 compat_ulong_t mem_start;
286 compat_ulong_t mem_end;
287 unsigned short base_addr;
288 unsigned char irq;
289 unsigned char dma;
290 unsigned char port;
291};
292
293struct ifreq32 {
294#define IFHWADDRLEN 6
295#define IFNAMSIZ 16
296 union {
297 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
298 } ifr_ifrn;
299 union {
300 struct sockaddr ifru_addr;
301 struct sockaddr ifru_dstaddr;
302 struct sockaddr ifru_broadaddr;
303 struct sockaddr ifru_netmask;
304 struct sockaddr ifru_hwaddr;
305 short ifru_flags;
306 compat_int_t ifru_ivalue;
307 compat_int_t ifru_mtu;
308 struct ifmap32 ifru_map;
309 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
310 char ifru_newname[IFNAMSIZ];
311 compat_caddr_t ifru_data;
312 /* XXXX? ifru_settings should be here */
313 } ifr_ifru;
314};
315
316struct ifconf32 {
317 compat_int_t ifc_len; /* size of buffer */
318 compat_caddr_t ifcbuf;
319};
320
321static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
322{
32da477a 323 struct ifreq __user *uifr;
1da177e4
LT
324 int err;
325
32da477a 326 uifr = compat_alloc_user_space(sizeof(struct ifreq));
be48be08 327 if (copy_in_user(uifr, compat_ptr(arg), sizeof(struct ifreq32)))
1da177e4
LT
328 return -EFAULT;
329
32da477a
EB
330 err = sys_ioctl(fd, SIOCGIFNAME, (unsigned long)uifr);
331 if (err)
332 return err;
1da177e4 333
32da477a
EB
334 if (copy_in_user(compat_ptr(arg), uifr, sizeof(struct ifreq32)))
335 return -EFAULT;
336
337 return 0;
1da177e4
LT
338}
339
340static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)
341{
342 struct ifconf32 ifc32;
343 struct ifconf ifc;
344 struct ifconf __user *uifc;
345 struct ifreq32 __user *ifr32;
346 struct ifreq __user *ifr;
347 unsigned int i, j;
348 int err;
349
350 if (copy_from_user(&ifc32, compat_ptr(arg), sizeof(struct ifconf32)))
351 return -EFAULT;
352
353 if (ifc32.ifcbuf == 0) {
354 ifc32.ifc_len = 0;
355 ifc.ifc_len = 0;
356 ifc.ifc_req = NULL;
357 uifc = compat_alloc_user_space(sizeof(struct ifconf));
358 } else {
359 size_t len =((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) *
360 sizeof (struct ifreq);
361 uifc = compat_alloc_user_space(sizeof(struct ifconf) + len);
362 ifc.ifc_len = len;
363 ifr = ifc.ifc_req = (void __user *)(uifc + 1);
364 ifr32 = compat_ptr(ifc32.ifcbuf);
365 for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) {
366 if (copy_in_user(ifr, ifr32, sizeof(struct ifreq32)))
367 return -EFAULT;
368 ifr++;
369 ifr32++;
370 }
371 }
372 if (copy_to_user(uifc, &ifc, sizeof(struct ifconf)))
373 return -EFAULT;
374
375 err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)uifc);
376 if (err)
377 return err;
378
379 if (copy_from_user(&ifc, uifc, sizeof(struct ifconf)))
380 return -EFAULT;
381
382 ifr = ifc.ifc_req;
383 ifr32 = compat_ptr(ifc32.ifcbuf);
4909724b 384 for (i = 0, j = 0;
1efa3c05 385 i + sizeof (struct ifreq32) <= ifc32.ifc_len && j < ifc.ifc_len;
1da177e4
LT
386 i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
387 if (copy_in_user(ifr32, ifr, sizeof (struct ifreq32)))
388 return -EFAULT;
389 ifr32++;
390 ifr++;
391 }
392
393 if (ifc32.ifcbuf == 0) {
394 /* Translate from 64-bit structure multiple to
395 * a 32-bit one.
396 */
397 i = ifc.ifc_len;
398 i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32));
399 ifc32.ifc_len = i;
400 } else {
4909724b 401 ifc32.ifc_len = i;
1da177e4
LT
402 }
403 if (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32)))
404 return -EFAULT;
405
406 return 0;
407}
408
409static int ethtool_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
410{
411 struct ifreq __user *ifr;
412 struct ifreq32 __user *ifr32;
413 u32 data;
414 void __user *datap;
415
416 ifr = compat_alloc_user_space(sizeof(*ifr));
417 ifr32 = compat_ptr(arg);
418
419 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
420 return -EFAULT;
421
422 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
423 return -EFAULT;
424
425 datap = compat_ptr(data);
426 if (put_user(datap, &ifr->ifr_ifru.ifru_data))
427 return -EFAULT;
428
429 return sys_ioctl(fd, cmd, (unsigned long) ifr);
430}
431
432static int bond_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
433{
434 struct ifreq kifr;
435 struct ifreq __user *uifr;
436 struct ifreq32 __user *ifr32 = compat_ptr(arg);
437 mm_segment_t old_fs;
438 int err;
439 u32 data;
440 void __user *datap;
441
442 switch (cmd) {
443 case SIOCBONDENSLAVE:
444 case SIOCBONDRELEASE:
445 case SIOCBONDSETHWADDR:
446 case SIOCBONDCHANGEACTIVE:
447 if (copy_from_user(&kifr, ifr32, sizeof(struct ifreq32)))
448 return -EFAULT;
449
450 old_fs = get_fs();
451 set_fs (KERNEL_DS);
452 err = sys_ioctl (fd, cmd, (unsigned long)&kifr);
453 set_fs (old_fs);
454
455 return err;
456 case SIOCBONDSLAVEINFOQUERY:
457 case SIOCBONDINFOQUERY:
458 uifr = compat_alloc_user_space(sizeof(*uifr));
459 if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
460 return -EFAULT;
461
462 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
463 return -EFAULT;
464
465 datap = compat_ptr(data);
466 if (put_user(datap, &uifr->ifr_ifru.ifru_data))
467 return -EFAULT;
468
469 return sys_ioctl (fd, cmd, (unsigned long)uifr);
470 default:
471 return -EINVAL;
472 };
473}
474
6272e266 475static int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
1da177e4
LT
476{
477 struct ifreq __user *u_ifreq64;
478 struct ifreq32 __user *u_ifreq32 = compat_ptr(arg);
479 char tmp_buf[IFNAMSIZ];
480 void __user *data64;
481 u32 data32;
482
483 if (copy_from_user(&tmp_buf[0], &(u_ifreq32->ifr_ifrn.ifrn_name[0]),
484 IFNAMSIZ))
485 return -EFAULT;
486 if (__get_user(data32, &u_ifreq32->ifr_ifru.ifru_data))
487 return -EFAULT;
488 data64 = compat_ptr(data32);
489
490 u_ifreq64 = compat_alloc_user_space(sizeof(*u_ifreq64));
491
492 /* Don't check these user accesses, just let that get trapped
493 * in the ioctl handler instead.
494 */
495 if (copy_to_user(&u_ifreq64->ifr_ifrn.ifrn_name[0], &tmp_buf[0],
496 IFNAMSIZ))
497 return -EFAULT;
498 if (__put_user(data64, &u_ifreq64->ifr_ifru.ifru_data))
499 return -EFAULT;
500
501 return sys_ioctl(fd, cmd, (unsigned long) u_ifreq64);
502}
503
504static int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg)
505{
506 struct ifreq ifr;
507 struct ifreq32 __user *uifr32;
508 struct ifmap32 __user *uifmap32;
509 mm_segment_t old_fs;
510 int err;
511
512 uifr32 = compat_ptr(arg);
513 uifmap32 = &uifr32->ifr_ifru.ifru_map;
514 switch (cmd) {
515 case SIOCSIFMAP:
516 err = copy_from_user(&ifr, uifr32, sizeof(ifr.ifr_name));
517 err |= __get_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
518 err |= __get_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
519 err |= __get_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
520 err |= __get_user(ifr.ifr_map.irq, &uifmap32->irq);
521 err |= __get_user(ifr.ifr_map.dma, &uifmap32->dma);
522 err |= __get_user(ifr.ifr_map.port, &uifmap32->port);
523 if (err)
524 return -EFAULT;
525 break;
d24fff22
PO
526 case SIOCSHWTSTAMP:
527 if (copy_from_user(&ifr, uifr32, sizeof(*uifr32)))
528 return -EFAULT;
529 ifr.ifr_data = compat_ptr(uifr32->ifr_ifru.ifru_data);
530 break;
1da177e4
LT
531 default:
532 if (copy_from_user(&ifr, uifr32, sizeof(*uifr32)))
533 return -EFAULT;
534 break;
535 }
536 old_fs = get_fs();
537 set_fs (KERNEL_DS);
538 err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
539 set_fs (old_fs);
540 if (!err) {
541 switch (cmd) {
1da177e4
LT
542 case SIOCGIFFLAGS:
543 case SIOCGIFMETRIC:
544 case SIOCGIFMTU:
545 case SIOCGIFMEM:
546 case SIOCGIFHWADDR:
547 case SIOCGIFINDEX:
548 case SIOCGIFADDR:
549 case SIOCGIFBRDADDR:
550 case SIOCGIFDSTADDR:
551 case SIOCGIFNETMASK:
552 case SIOCGIFTXQLEN:
553 if (copy_to_user(uifr32, &ifr, sizeof(*uifr32)))
554 return -EFAULT;
555 break;
556 case SIOCGIFMAP:
557 err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name));
558 err |= __put_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
559 err |= __put_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
560 err |= __put_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
561 err |= __put_user(ifr.ifr_map.irq, &uifmap32->irq);
562 err |= __put_user(ifr.ifr_map.dma, &uifmap32->dma);
563 err |= __put_user(ifr.ifr_map.port, &uifmap32->port);
564 if (err)
565 err = -EFAULT;
566 break;
567 }
568 }
569 return err;
570}
571
572struct rtentry32 {
573 u32 rt_pad1;
574 struct sockaddr rt_dst; /* target address */
575 struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
576 struct sockaddr rt_genmask; /* target network mask (IP) */
577 unsigned short rt_flags;
578 short rt_pad2;
579 u32 rt_pad3;
580 unsigned char rt_tos;
581 unsigned char rt_class;
582 short rt_pad4;
583 short rt_metric; /* +1 for binary compatibility! */
584 /* char * */ u32 rt_dev; /* forcing the device at add */
585 u32 rt_mtu; /* per route MTU/Window */
586 u32 rt_window; /* Window clamping */
587 unsigned short rt_irtt; /* Initial RTT */
588
589};
590
591struct in6_rtmsg32 {
592 struct in6_addr rtmsg_dst;
593 struct in6_addr rtmsg_src;
594 struct in6_addr rtmsg_gateway;
595 u32 rtmsg_type;
596 u16 rtmsg_dst_len;
597 u16 rtmsg_src_len;
598 u32 rtmsg_metric;
599 u32 rtmsg_info;
600 u32 rtmsg_flags;
601 s32 rtmsg_ifindex;
602};
603
604static int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
605{
606 int ret;
607 void *r = NULL;
608 struct in6_rtmsg r6;
609 struct rtentry r4;
610 char devname[16];
611 u32 rtdev;
612 mm_segment_t old_fs = get_fs();
613
614 struct socket *mysock = sockfd_lookup(fd, &ret);
615
616 if (mysock && mysock->sk && mysock->sk->sk_family == AF_INET6) { /* ipv6 */
617 struct in6_rtmsg32 __user *ur6 = compat_ptr(arg);
618 ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst),
619 3 * sizeof(struct in6_addr));
620 ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type));
621 ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len));
622 ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len));
623 ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric));
624 ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info));
625 ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags));
626 ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex));
627
628 r = (void *) &r6;
629 } else { /* ipv4 */
630 struct rtentry32 __user *ur4 = compat_ptr(arg);
631 ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst),
632 3 * sizeof(struct sockaddr));
633 ret |= __get_user (r4.rt_flags, &(ur4->rt_flags));
634 ret |= __get_user (r4.rt_metric, &(ur4->rt_metric));
635 ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu));
636 ret |= __get_user (r4.rt_window, &(ur4->rt_window));
637 ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt));
638 ret |= __get_user (rtdev, &(ur4->rt_dev));
639 if (rtdev) {
640 ret |= copy_from_user (devname, compat_ptr(rtdev), 15);
641 r4.rt_dev = devname; devname[15] = 0;
642 } else
643 r4.rt_dev = NULL;
644
645 r = (void *) &r4;
646 }
647
d99901d6
KK
648 if (ret) {
649 ret = -EFAULT;
650 goto out;
651 }
1da177e4
LT
652
653 set_fs (KERNEL_DS);
654 ret = sys_ioctl (fd, cmd, (unsigned long) r);
655 set_fs (old_fs);
656
d99901d6 657out:
1da177e4
LT
658 if (mysock)
659 sockfd_put(mysock);
660
661 return ret;
662}
663#endif
664
9361401e 665#ifdef CONFIG_BLOCK
1da177e4
LT
666typedef struct sg_io_hdr32 {
667 compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */
668 compat_int_t dxfer_direction; /* [i] data transfer direction */
669 unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
670 unsigned char mx_sb_len; /* [i] max length to write to sbp */
671 unsigned short iovec_count; /* [i] 0 implies no scatter gather */
672 compat_uint_t dxfer_len; /* [i] byte count of data transfer */
673 compat_uint_t dxferp; /* [i], [*io] points to data transfer memory
674 or scatter gather list */
675 compat_uptr_t cmdp; /* [i], [*i] points to command to perform */
676 compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */
677 compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
678 compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */
679 compat_int_t pack_id; /* [i->o] unused internally (normally) */
680 compat_uptr_t usr_ptr; /* [i->o] unused internally */
681 unsigned char status; /* [o] scsi status */
682 unsigned char masked_status; /* [o] shifted, masked scsi status */
683 unsigned char msg_status; /* [o] messaging level data (optional) */
684 unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
685 unsigned short host_status; /* [o] errors from host adapter */
686 unsigned short driver_status; /* [o] errors from software driver */
687 compat_int_t resid; /* [o] dxfer_len - actual_transferred */
688 compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */
689 compat_uint_t info; /* [o] auxiliary information */
690} sg_io_hdr32_t; /* 64 bytes long (on sparc32) */
691
692typedef struct sg_iovec32 {
693 compat_uint_t iov_base;
694 compat_uint_t iov_len;
695} sg_iovec32_t;
696
697static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count)
698{
699 sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1);
700 sg_iovec32_t __user *iov32 = dxferp;
701 int i;
702
703 for (i = 0; i < iovec_count; i++) {
704 u32 base, len;
705
706 if (get_user(base, &iov32[i].iov_base) ||
707 get_user(len, &iov32[i].iov_len) ||
708 put_user(compat_ptr(base), &iov[i].iov_base) ||
709 put_user(len, &iov[i].iov_len))
710 return -EFAULT;
711 }
712
713 if (put_user(iov, &sgio->dxferp))
714 return -EFAULT;
715 return 0;
716}
717
718static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
719{
720 sg_io_hdr_t __user *sgio;
721 sg_io_hdr32_t __user *sgio32;
722 u16 iovec_count;
723 u32 data;
724 void __user *dxferp;
725 int err;
726
727 sgio32 = compat_ptr(arg);
728 if (get_user(iovec_count, &sgio32->iovec_count))
729 return -EFAULT;
730
731 {
732 void __user *top = compat_alloc_user_space(0);
733 void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) +
734 (iovec_count * sizeof(sg_iovec_t)));
735 if (new > top)
736 return -EINVAL;
737
738 sgio = new;
739 }
740
741 /* Ok, now construct. */
742 if (copy_in_user(&sgio->interface_id, &sgio32->interface_id,
743 (2 * sizeof(int)) +
744 (2 * sizeof(unsigned char)) +
745 (1 * sizeof(unsigned short)) +
746 (1 * sizeof(unsigned int))))
747 return -EFAULT;
748
749 if (get_user(data, &sgio32->dxferp))
750 return -EFAULT;
751 dxferp = compat_ptr(data);
752 if (iovec_count) {
753 if (sg_build_iovec(sgio, dxferp, iovec_count))
754 return -EFAULT;
755 } else {
756 if (put_user(dxferp, &sgio->dxferp))
757 return -EFAULT;
758 }
759
760 {
761 unsigned char __user *cmdp;
762 unsigned char __user *sbp;
763
764 if (get_user(data, &sgio32->cmdp))
765 return -EFAULT;
766 cmdp = compat_ptr(data);
767
768 if (get_user(data, &sgio32->sbp))
769 return -EFAULT;
770 sbp = compat_ptr(data);
771
772 if (put_user(cmdp, &sgio->cmdp) ||
773 put_user(sbp, &sgio->sbp))
774 return -EFAULT;
775 }
776
777 if (copy_in_user(&sgio->timeout, &sgio32->timeout,
778 3 * sizeof(int)))
779 return -EFAULT;
780
781 if (get_user(data, &sgio32->usr_ptr))
782 return -EFAULT;
783 if (put_user(compat_ptr(data), &sgio->usr_ptr))
784 return -EFAULT;
785
1da177e4
LT
786 err = sys_ioctl(fd, cmd, (unsigned long) sgio);
787
788 if (err >= 0) {
789 void __user *datap;
790
791 if (copy_in_user(&sgio32->pack_id, &sgio->pack_id,
792 sizeof(int)) ||
793 get_user(datap, &sgio->usr_ptr) ||
794 put_user((u32)(unsigned long)datap,
795 &sgio32->usr_ptr) ||
796 copy_in_user(&sgio32->status, &sgio->status,
797 (4 * sizeof(unsigned char)) +
798 (2 * sizeof(unsigned short)) +
799 (3 * sizeof(int))))
800 err = -EFAULT;
801 }
802
803 return err;
804}
805
2966387b
AK
806struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
807 char req_state;
808 char orphan;
809 char sg_io_owned;
810 char problem;
811 int pack_id;
812 compat_uptr_t usr_ptr;
813 unsigned int duration;
814 int unused;
815};
816
817static int sg_grt_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
818{
819 int err, i;
6b2b4e5a
AV
820 sg_req_info_t __user *r;
821 struct compat_sg_req_info __user *o = (void __user *)arg;
2966387b
AK
822 r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE);
823 err = sys_ioctl(fd,cmd,(unsigned long)r);
824 if (err < 0)
825 return err;
826 for (i = 0; i < SG_MAX_QUEUE; i++) {
827 void __user *ptr;
828 int d;
829
830 if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) ||
831 get_user(ptr, &r[i].usr_ptr) ||
832 get_user(d, &r[i].duration) ||
833 put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) ||
834 put_user(d, &o[i].duration))
835 return -EFAULT;
836 }
837 return err;
838}
9361401e 839#endif /* CONFIG_BLOCK */
2966387b 840
1da177e4
LT
841struct sock_fprog32 {
842 unsigned short len;
843 compat_caddr_t filter;
844};
845
846#define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
847#define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
848
849static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
850{
851 struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg);
852 struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
853 void __user *fptr64;
854 u32 fptr32;
855 u16 flen;
856
857 if (get_user(flen, &u_fprog32->len) ||
858 get_user(fptr32, &u_fprog32->filter))
859 return -EFAULT;
860
861 fptr64 = compat_ptr(fptr32);
862
863 if (put_user(flen, &u_fprog64->len) ||
864 put_user(fptr64, &u_fprog64->filter))
865 return -EFAULT;
866
867 if (cmd == PPPIOCSPASS32)
868 cmd = PPPIOCSPASS;
869 else
870 cmd = PPPIOCSACTIVE;
871
872 return sys_ioctl(fd, cmd, (unsigned long) u_fprog64);
873}
874
875struct ppp_option_data32 {
876 compat_caddr_t ptr;
877 u32 length;
878 compat_int_t transmit;
879};
880#define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
881
882struct ppp_idle32 {
883 compat_time_t xmit_idle;
884 compat_time_t recv_idle;
885};
886#define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
887
888static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg)
889{
890 struct ppp_idle __user *idle;
891 struct ppp_idle32 __user *idle32;
892 __kernel_time_t xmit, recv;
893 int err;
894
895 idle = compat_alloc_user_space(sizeof(*idle));
896 idle32 = compat_ptr(arg);
897
898 err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle);
899
900 if (!err) {
901 if (get_user(xmit, &idle->xmit_idle) ||
902 get_user(recv, &idle->recv_idle) ||
903 put_user(xmit, &idle32->xmit_idle) ||
904 put_user(recv, &idle32->recv_idle))
905 err = -EFAULT;
906 }
907 return err;
908}
909
910static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg)
911{
912 struct ppp_option_data __user *odata;
913 struct ppp_option_data32 __user *odata32;
914 __u32 data;
915 void __user *datap;
916
917 odata = compat_alloc_user_space(sizeof(*odata));
918 odata32 = compat_ptr(arg);
919
920 if (get_user(data, &odata32->ptr))
921 return -EFAULT;
922
923 datap = compat_ptr(data);
924 if (put_user(datap, &odata->ptr))
925 return -EFAULT;
926
927 if (copy_in_user(&odata->length, &odata32->length,
928 sizeof(__u32) + sizeof(int)))
929 return -EFAULT;
930
931 return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata);
932}
933
934static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
935{
936 int err;
937
938 switch (cmd) {
939 case PPPIOCGIDLE32:
940 err = ppp_gidle(fd, cmd, arg);
941 break;
942
943 case PPPIOCSCOMPRESS32:
944 err = ppp_scompress(fd, cmd, arg);
945 break;
946
947 default:
948 do {
949 static int count;
950 if (++count <= 20)
951 printk("ppp_ioctl: Unknown cmd fd(%d) "
952 "cmd(%08x) arg(%08x)\n",
953 (int)fd, (unsigned int)cmd, (unsigned int)arg);
954 } while(0);
955 err = -EINVAL;
956 break;
957 };
958
959 return err;
960}
961
962
9361401e 963#ifdef CONFIG_BLOCK
1da177e4
LT
964struct mtget32 {
965 compat_long_t mt_type;
966 compat_long_t mt_resid;
967 compat_long_t mt_dsreg;
968 compat_long_t mt_gstat;
969 compat_long_t mt_erreg;
970 compat_daddr_t mt_fileno;
971 compat_daddr_t mt_blkno;
972};
973#define MTIOCGET32 _IOR('m', 2, struct mtget32)
974
975struct mtpos32 {
976 compat_long_t mt_blkno;
977};
978#define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
979
980static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
981{
982 mm_segment_t old_fs = get_fs();
983 struct mtget get;
984 struct mtget32 __user *umget32;
985 struct mtpos pos;
986 struct mtpos32 __user *upos32;
987 unsigned long kcmd;
988 void *karg;
989 int err = 0;
990
991 switch(cmd) {
992 case MTIOCPOS32:
993 kcmd = MTIOCPOS;
994 karg = &pos;
995 break;
996 case MTIOCGET32:
997 kcmd = MTIOCGET;
998 karg = &get;
999 break;
1000 default:
1001 do {
1002 static int count;
1003 if (++count <= 20)
1004 printk("mt_ioctl: Unknown cmd fd(%d) "
1005 "cmd(%08x) arg(%08x)\n",
1006 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1007 } while(0);
1008 return -EINVAL;
1009 }
1010 set_fs (KERNEL_DS);
1011 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1012 set_fs (old_fs);
1013 if (err)
1014 return err;
1015 switch (cmd) {
1016 case MTIOCPOS32:
1017 upos32 = compat_ptr(arg);
1018 err = __put_user(pos.mt_blkno, &upos32->mt_blkno);
1019 break;
1020 case MTIOCGET32:
1021 umget32 = compat_ptr(arg);
1022 err = __put_user(get.mt_type, &umget32->mt_type);
1023 err |= __put_user(get.mt_resid, &umget32->mt_resid);
1024 err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg);
1025 err |= __put_user(get.mt_gstat, &umget32->mt_gstat);
1026 err |= __put_user(get.mt_erreg, &umget32->mt_erreg);
1027 err |= __put_user(get.mt_fileno, &umget32->mt_fileno);
1028 err |= __put_user(get.mt_blkno, &umget32->mt_blkno);
1029 break;
1030 }
1031 return err ? -EFAULT: 0;
1032}
1033
9361401e 1034#endif /* CONFIG_BLOCK */
1da177e4 1035
1da177e4
LT
1036#ifdef CONFIG_VT
1037
1038static int vt_check(struct file *file)
1039{
1040 struct tty_struct *tty;
0f7fc9e4 1041 struct inode *inode = file->f_path.dentry->d_inode;
f4d43bd5 1042 struct vc_data *vc;
1da177e4 1043
04f378b1 1044 if (file->f_op->unlocked_ioctl != tty_ioctl)
1da177e4
LT
1045 return -EINVAL;
1046
1047 tty = (struct tty_struct *)file->private_data;
1048 if (tty_paranoia_check(tty, inode, "tty_ioctl"))
1049 return -EINVAL;
1050
f34d7a5b 1051 if (tty->ops->ioctl != vt_ioctl)
1da177e4 1052 return -EINVAL;
f4d43bd5
HD
1053
1054 vc = (struct vc_data *)tty->driver_data;
1055 if (!vc_cons_allocated(vc->vc_num)) /* impossible? */
1056 return -ENOIOCTLCMD;
1057
1da177e4
LT
1058 /*
1059 * To have permissions to do most of the vt ioctls, we either have
f4d43bd5 1060 * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.
1da177e4 1061 */
f4d43bd5 1062 if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG))
1da177e4
LT
1063 return 1;
1064 return 0;
1065}
1066
1067struct consolefontdesc32 {
1068 unsigned short charcount; /* characters in font (256 or 512) */
1069 unsigned short charheight; /* scan lines per character (1-32) */
1070 compat_caddr_t chardata; /* font data in expanded form */
1071};
1072
1073static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1074{
1075 struct consolefontdesc32 __user *user_cfd = compat_ptr(arg);
1076 struct console_font_op op;
1077 compat_caddr_t data;
1078 int i, perm;
1079
1080 perm = vt_check(file);
1081 if (perm < 0) return perm;
1082
1083 switch (cmd) {
1084 case PIO_FONTX:
1085 if (!perm)
1086 return -EPERM;
1087 op.op = KD_FONT_OP_SET;
1088 op.flags = 0;
1089 op.width = 8;
1090 if (get_user(op.height, &user_cfd->charheight) ||
1091 get_user(op.charcount, &user_cfd->charcount) ||
1092 get_user(data, &user_cfd->chardata))
1093 return -EFAULT;
1094 op.data = compat_ptr(data);
1095 return con_font_op(vc_cons[fg_console].d, &op);
1096 case GIO_FONTX:
1097 op.op = KD_FONT_OP_GET;
1098 op.flags = 0;
1099 op.width = 8;
1100 if (get_user(op.height, &user_cfd->charheight) ||
1101 get_user(op.charcount, &user_cfd->charcount) ||
1102 get_user(data, &user_cfd->chardata))
1103 return -EFAULT;
1104 if (!data)
1105 return 0;
1106 op.data = compat_ptr(data);
1107 i = con_font_op(vc_cons[fg_console].d, &op);
1108 if (i)
1109 return i;
1110 if (put_user(op.height, &user_cfd->charheight) ||
1111 put_user(op.charcount, &user_cfd->charcount) ||
1112 put_user((compat_caddr_t)(unsigned long)op.data,
1113 &user_cfd->chardata))
1114 return -EFAULT;
1115 return 0;
1116 }
1117 return -EINVAL;
1118}
1119
1120struct console_font_op32 {
1121 compat_uint_t op; /* operation code KD_FONT_OP_* */
1122 compat_uint_t flags; /* KD_FONT_FLAG_* */
1123 compat_uint_t width, height; /* font size */
1124 compat_uint_t charcount;
1125 compat_caddr_t data; /* font data with height fixed to 32 */
1126};
1127
1128static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1129{
1130 struct console_font_op op;
1131 struct console_font_op32 __user *fontop = compat_ptr(arg);
1132 int perm = vt_check(file), i;
1133 struct vc_data *vc;
1134
1135 if (perm < 0) return perm;
1136
1137 if (copy_from_user(&op, fontop, sizeof(struct console_font_op32)))
1138 return -EFAULT;
1139 if (!perm && op.op != KD_FONT_OP_GET)
1140 return -EPERM;
1141 op.data = compat_ptr(((struct console_font_op32 *)&op)->data);
1142 op.flags |= KD_FONT_FLAG_OLD;
1143 vc = ((struct tty_struct *)file->private_data)->driver_data;
1144 i = con_font_op(vc, &op);
1145 if (i)
1146 return i;
1147 ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
1148 if (copy_to_user(fontop, &op, sizeof(struct console_font_op32)))
1149 return -EFAULT;
1150 return 0;
1151}
1152
1153struct unimapdesc32 {
1154 unsigned short entry_ct;
1155 compat_caddr_t entries;
1156};
1157
1158static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1159{
1160 struct unimapdesc32 tmp;
1161 struct unimapdesc32 __user *user_ud = compat_ptr(arg);
1162 int perm = vt_check(file);
f4d43bd5
HD
1163 struct vc_data *vc;
1164
1165 if (perm < 0)
1166 return perm;
1da177e4
LT
1167 if (copy_from_user(&tmp, user_ud, sizeof tmp))
1168 return -EFAULT;
f4d43bd5
HD
1169 if (tmp.entries)
1170 if (!access_ok(VERIFY_WRITE, compat_ptr(tmp.entries),
1171 tmp.entry_ct*sizeof(struct unipair)))
1172 return -EFAULT;
1173 vc = ((struct tty_struct *)file->private_data)->driver_data;
1da177e4
LT
1174 switch (cmd) {
1175 case PIO_UNIMAP:
f4d43bd5
HD
1176 if (!perm)
1177 return -EPERM;
1178 return con_set_unimap(vc, tmp.entry_ct,
1179 compat_ptr(tmp.entries));
1da177e4 1180 case GIO_UNIMAP:
f4d43bd5
HD
1181 if (!perm && fg_console != vc->vc_num)
1182 return -EPERM;
1183 return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct),
1184 compat_ptr(tmp.entries));
1da177e4
LT
1185 }
1186 return 0;
1187}
1188
1189#endif /* CONFIG_VT */
1190
1191static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg)
1192{
1193 mm_segment_t old_fs = get_fs();
1194 __kernel_uid_t kuid;
1195 int err;
1196
1197 cmd = SMB_IOC_GETMOUNTUID;
1198
1199 set_fs(KERNEL_DS);
1200 err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
1201 set_fs(old_fs);
1202
1203 if (err >= 0)
1204 err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg));
1205
1206 return err;
1207}
1208
1209struct atmif_sioc32 {
1210 compat_int_t number;
1211 compat_int_t length;
1212 compat_caddr_t arg;
1213};
1214
1215struct atm_iobuf32 {
1216 compat_int_t length;
1217 compat_caddr_t buffer;
1218};
1219
1220#define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32)
1221#define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32)
1222#define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32)
1223#define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32)
1224#define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32)
1225#define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32)
1226#define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32)
1227#define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32)
1228#define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32)
1229#define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32)
1230#define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32)
1231#define ATM_SETESIF32 _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32)
1232#define ATM_GETSTAT32 _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32)
1233#define ATM_GETSTATZ32 _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32)
1234#define ATM_GETLOOP32 _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32)
1235#define ATM_SETLOOP32 _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32)
1236#define ATM_QUERYLOOP32 _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32)
1237
1238static struct {
1239 unsigned int cmd32;
1240 unsigned int cmd;
1241} atm_ioctl_map[] = {
1242 { ATM_GETLINKRATE32, ATM_GETLINKRATE },
1243 { ATM_GETNAMES32, ATM_GETNAMES },
1244 { ATM_GETTYPE32, ATM_GETTYPE },
1245 { ATM_GETESI32, ATM_GETESI },
1246 { ATM_GETADDR32, ATM_GETADDR },
1247 { ATM_RSTADDR32, ATM_RSTADDR },
1248 { ATM_ADDADDR32, ATM_ADDADDR },
1249 { ATM_DELADDR32, ATM_DELADDR },
1250 { ATM_GETCIRANGE32, ATM_GETCIRANGE },
1251 { ATM_SETCIRANGE32, ATM_SETCIRANGE },
1252 { ATM_SETESI32, ATM_SETESI },
1253 { ATM_SETESIF32, ATM_SETESIF },
1254 { ATM_GETSTAT32, ATM_GETSTAT },
1255 { ATM_GETSTATZ32, ATM_GETSTATZ },
1256 { ATM_GETLOOP32, ATM_GETLOOP },
1257 { ATM_SETLOOP32, ATM_SETLOOP },
1258 { ATM_QUERYLOOP32, ATM_QUERYLOOP }
1259};
1260
e8c96f8c 1261#define NR_ATM_IOCTL ARRAY_SIZE(atm_ioctl_map)
1da177e4
LT
1262
1263static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg)
1264{
1265 struct atm_iobuf __user *iobuf;
1266 struct atm_iobuf32 __user *iobuf32;
1267 u32 data;
1268 void __user *datap;
1269 int len, err;
1270
1271 iobuf = compat_alloc_user_space(sizeof(*iobuf));
1272 iobuf32 = compat_ptr(arg);
1273
1274 if (get_user(len, &iobuf32->length) ||
1275 get_user(data, &iobuf32->buffer))
1276 return -EFAULT;
1277 datap = compat_ptr(data);
1278 if (put_user(len, &iobuf->length) ||
1279 put_user(datap, &iobuf->buffer))
1280 return -EFAULT;
1281
1282 err = sys_ioctl(fd, cmd, (unsigned long)iobuf);
1283
1284 if (!err) {
1285 if (copy_in_user(&iobuf32->length, &iobuf->length,
1286 sizeof(int)))
1287 err = -EFAULT;
1288 }
1289
1290 return err;
1291}
1292
1293static int do_atmif_sioc(unsigned int fd, unsigned int cmd, unsigned long arg)
1294{
1295 struct atmif_sioc __user *sioc;
1296 struct atmif_sioc32 __user *sioc32;
1297 u32 data;
1298 void __user *datap;
1299 int err;
1300
1301 sioc = compat_alloc_user_space(sizeof(*sioc));
1302 sioc32 = compat_ptr(arg);
1303
1304 if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) ||
1305 get_user(data, &sioc32->arg))
1306 return -EFAULT;
1307 datap = compat_ptr(data);
1308 if (put_user(datap, &sioc->arg))
1309 return -EFAULT;
1310
1311 err = sys_ioctl(fd, cmd, (unsigned long) sioc);
1312
1313 if (!err) {
1314 if (copy_in_user(&sioc32->length, &sioc->length,
1315 sizeof(int)))
1316 err = -EFAULT;
1317 }
1318 return err;
1319}
1320
1321static int do_atm_ioctl(unsigned int fd, unsigned int cmd32, unsigned long arg)
1322{
1323 int i;
1324 unsigned int cmd = 0;
1325
1326 switch (cmd32) {
1327 case SONET_GETSTAT:
1328 case SONET_GETSTATZ:
1329 case SONET_GETDIAG:
1330 case SONET_SETDIAG:
1331 case SONET_CLRDIAG:
1332 case SONET_SETFRAMING:
1333 case SONET_GETFRAMING:
1334 case SONET_GETFRSENSE:
1335 return do_atmif_sioc(fd, cmd32, arg);
1336 }
1337
1338 for (i = 0; i < NR_ATM_IOCTL; i++) {
1339 if (cmd32 == atm_ioctl_map[i].cmd32) {
1340 cmd = atm_ioctl_map[i].cmd;
1341 break;
1342 }
1343 }
1344 if (i == NR_ATM_IOCTL)
1345 return -EINVAL;
1346
1347 switch (cmd) {
1348 case ATM_GETNAMES:
1349 return do_atm_iobuf(fd, cmd, arg);
1350
1351 case ATM_GETLINKRATE:
1352 case ATM_GETTYPE:
1353 case ATM_GETESI:
1354 case ATM_GETADDR:
1355 case ATM_RSTADDR:
1356 case ATM_ADDADDR:
1357 case ATM_DELADDR:
1358 case ATM_GETCIRANGE:
1359 case ATM_SETCIRANGE:
1360 case ATM_SETESI:
1361 case ATM_SETESIF:
1362 case ATM_GETSTAT:
1363 case ATM_GETSTATZ:
1364 case ATM_GETLOOP:
1365 case ATM_SETLOOP:
1366 case ATM_QUERYLOOP:
1367 return do_atmif_sioc(fd, cmd, arg);
1368 }
1369
1370 return -EINVAL;
1371}
1372
3ff6eecc 1373static __used int
1da177e4
LT
1374ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
1375{
1376 return -EINVAL;
1377}
1378
1da177e4
LT
1379static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
1380{
1381 return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
1382}
1383
1da177e4
LT
1384/* Bluetooth ioctls */
1385#define HCIUARTSETPROTO _IOW('U', 200, int)
1386#define HCIUARTGETPROTO _IOR('U', 201, int)
1387
1388#define BNEPCONNADD _IOW('B', 200, int)
1389#define BNEPCONNDEL _IOW('B', 201, int)
1390#define BNEPGETCONNLIST _IOR('B', 210, int)
1391#define BNEPGETCONNINFO _IOR('B', 211, int)
1392
1393#define CMTPCONNADD _IOW('C', 200, int)
1394#define CMTPCONNDEL _IOW('C', 201, int)
1395#define CMTPGETCONNLIST _IOR('C', 210, int)
1396#define CMTPGETCONNINFO _IOR('C', 211, int)
1397
1398#define HIDPCONNADD _IOW('H', 200, int)
1399#define HIDPCONNDEL _IOW('H', 201, int)
1400#define HIDPGETCONNLIST _IOR('H', 210, int)
1401#define HIDPGETCONNINFO _IOR('H', 211, int)
1402
9361401e 1403#ifdef CONFIG_BLOCK
1da177e4
LT
1404struct raw32_config_request
1405{
1406 compat_int_t raw_minor;
1407 __u64 block_major;
1408 __u64 block_minor;
1409} __attribute__((packed));
1410
1411static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
1412{
1413 int ret;
1414
1415 if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request)))
1416 return -EFAULT;
1417
1418 ret = __get_user(req->raw_minor, &user_req->raw_minor);
1419 ret |= __get_user(req->block_major, &user_req->block_major);
1420 ret |= __get_user(req->block_minor, &user_req->block_minor);
1421
1422 return ret ? -EFAULT : 0;
1423}
1424
1425static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
1426{
1427 int ret;
1428
1429 if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request)))
1430 return -EFAULT;
1431
1432 ret = __put_user(req->raw_minor, &user_req->raw_minor);
1433 ret |= __put_user(req->block_major, &user_req->block_major);
1434 ret |= __put_user(req->block_minor, &user_req->block_minor);
1435
1436 return ret ? -EFAULT : 0;
1437}
1438
1439static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
1440{
1441 int ret;
1442
1443 switch (cmd) {
1444 case RAW_SETBIND:
1445 case RAW_GETBIND: {
1446 struct raw_config_request req;
1447 struct raw32_config_request __user *user_req = compat_ptr(arg);
1448 mm_segment_t oldfs = get_fs();
1449
1450 if ((ret = get_raw32_request(&req, user_req)))
1451 return ret;
1452
1453 set_fs(KERNEL_DS);
1454 ret = sys_ioctl(fd,cmd,(unsigned long)&req);
1455 set_fs(oldfs);
1456
1457 if ((!ret) && (cmd == RAW_GETBIND)) {
1458 ret = set_raw32_request(&req, user_req);
1459 }
1460 break;
1461 }
1462 default:
1463 ret = sys_ioctl(fd, cmd, arg);
1464 break;
1465 }
1466 return ret;
1467}
9361401e 1468#endif /* CONFIG_BLOCK */
1da177e4
LT
1469
1470struct serial_struct32 {
1471 compat_int_t type;
1472 compat_int_t line;
1473 compat_uint_t port;
1474 compat_int_t irq;
1475 compat_int_t flags;
1476 compat_int_t xmit_fifo_size;
1477 compat_int_t custom_divisor;
1478 compat_int_t baud_base;
1479 unsigned short close_delay;
1480 char io_type;
1481 char reserved_char[1];
1482 compat_int_t hub6;
1483 unsigned short closing_wait; /* time to wait before closing */
1484 unsigned short closing_wait2; /* no longer used... */
1485 compat_uint_t iomem_base;
1486 unsigned short iomem_reg_shift;
1487 unsigned int port_high;
1488 /* compat_ulong_t iomap_base FIXME */
1489 compat_int_t reserved[1];
1490};
1491
1492static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
1493{
1494 typedef struct serial_struct SS;
1495 typedef struct serial_struct32 SS32;
1496 struct serial_struct32 __user *ss32 = compat_ptr(arg);
1497 int err;
1498 struct serial_struct ss;
1499 mm_segment_t oldseg = get_fs();
1500 __u32 udata;
7116e994 1501 unsigned int base;
1da177e4
LT
1502
1503 if (cmd == TIOCSSERIAL) {
1504 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
1505 return -EFAULT;
1506 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
1507 return -EFAULT;
7116e994
HC
1508 if (__get_user(udata, &ss32->iomem_base))
1509 return -EFAULT;
1da177e4 1510 ss.iomem_base = compat_ptr(udata);
7116e994
HC
1511 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
1512 __get_user(ss.port_high, &ss32->port_high))
1513 return -EFAULT;
1da177e4
LT
1514 ss.iomap_base = 0UL;
1515 }
1516 set_fs(KERNEL_DS);
1517 err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
1518 set_fs(oldseg);
1519 if (cmd == TIOCGSERIAL && err >= 0) {
1520 if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32)))
1521 return -EFAULT;
1522 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
1523 return -EFAULT;
7116e994
HC
1524 base = (unsigned long)ss.iomem_base >> 32 ?
1525 0xffffffff : (unsigned)(unsigned long)ss.iomem_base;
1526 if (__put_user(base, &ss32->iomem_base) ||
1527 __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
1528 __put_user(ss.port_high, &ss32->port_high))
1529 return -EFAULT;
1da177e4
LT
1530 }
1531 return err;
1532}
1533
1534struct usbdevfs_ctrltransfer32 {
1535 u8 bRequestType;
1536 u8 bRequest;
1537 u16 wValue;
1538 u16 wIndex;
1539 u16 wLength;
1540 u32 timeout; /* in milliseconds */
1541 compat_caddr_t data;
1542};
1543
1544#define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
1545
1546static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
1547{
1548 struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg);
1549 struct usbdevfs_ctrltransfer __user *p;
1550 __u32 udata;
1551 p = compat_alloc_user_space(sizeof(*p));
1552 if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
1553 get_user(udata, &p32->data) ||
1554 put_user(compat_ptr(udata), &p->data))
1555 return -EFAULT;
1556 return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p);
1557}
1558
1559
1560struct usbdevfs_bulktransfer32 {
1561 compat_uint_t ep;
1562 compat_uint_t len;
1563 compat_uint_t timeout; /* in milliseconds */
1564 compat_caddr_t data;
1565};
1566
1567#define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
1568
1569static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
1570{
1571 struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg);
1572 struct usbdevfs_bulktransfer __user *p;
1573 compat_uint_t n;
1574 compat_caddr_t addr;
1575
1576 p = compat_alloc_user_space(sizeof(*p));
1577
1578 if (get_user(n, &p32->ep) || put_user(n, &p->ep) ||
1579 get_user(n, &p32->len) || put_user(n, &p->len) ||
1580 get_user(n, &p32->timeout) || put_user(n, &p->timeout) ||
1581 get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data))
1582 return -EFAULT;
1583
1584 return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p);
1585}
1586
1587
1588/*
1589 * USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY
1590 * are handled in usbdevfs core. -Christopher Li
1591 */
1592
1593struct usbdevfs_disconnectsignal32 {
1594 compat_int_t signr;
1595 compat_caddr_t context;
1596};
1597
1598#define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
1599
1600static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
1601{
1602 struct usbdevfs_disconnectsignal kdis;
1603 struct usbdevfs_disconnectsignal32 __user *udis;
1604 mm_segment_t old_fs;
1605 u32 uctx;
1606 int err;
1607
1608 udis = compat_ptr(arg);
1609
1610 if (get_user(kdis.signr, &udis->signr) ||
1611 __get_user(uctx, &udis->context))
1612 return -EFAULT;
1613
1614 kdis.context = compat_ptr(uctx);
1615
1616 old_fs = get_fs();
1617 set_fs(KERNEL_DS);
1618 err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
1619 set_fs(old_fs);
1620
1621 return err;
1622}
1623
1624/*
1625 * I2C layer ioctls
1626 */
1627
1628struct i2c_msg32 {
1629 u16 addr;
1630 u16 flags;
1631 u16 len;
1632 compat_caddr_t buf;
1633};
1634
1635struct i2c_rdwr_ioctl_data32 {
1636 compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
1637 u32 nmsgs;
1638};
1639
1640struct i2c_smbus_ioctl_data32 {
1641 u8 read_write;
1642 u8 command;
1643 u32 size;
1644 compat_caddr_t data; /* union i2c_smbus_data *data */
1645};
1646
1647struct i2c_rdwr_aligned {
1648 struct i2c_rdwr_ioctl_data cmd;
1649 struct i2c_msg msgs[0];
1650};
1651
1652static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
1653{
1654 struct i2c_rdwr_ioctl_data32 __user *udata = compat_ptr(arg);
1655 struct i2c_rdwr_aligned __user *tdata;
1656 struct i2c_msg __user *tmsgs;
1657 struct i2c_msg32 __user *umsgs;
1658 compat_caddr_t datap;
1659 int nmsgs, i;
1660
1661 if (get_user(nmsgs, &udata->nmsgs))
1662 return -EFAULT;
1663 if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
1664 return -EINVAL;
1665
1666 if (get_user(datap, &udata->msgs))
1667 return -EFAULT;
1668 umsgs = compat_ptr(datap);
1669
1670 tdata = compat_alloc_user_space(sizeof(*tdata) +
1671 nmsgs * sizeof(struct i2c_msg));
1672 tmsgs = &tdata->msgs[0];
1673
1674 if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
1675 put_user(tmsgs, &tdata->cmd.msgs))
1676 return -EFAULT;
1677
1678 for (i = 0; i < nmsgs; i++) {
1679 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
1680 return -EFAULT;
1681 if (get_user(datap, &umsgs[i].buf) ||
1682 put_user(compat_ptr(datap), &tmsgs[i].buf))
1683 return -EFAULT;
1684 }
1685 return sys_ioctl(fd, cmd, (unsigned long)tdata);
1686}
1687
1688static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
1689{
1690 struct i2c_smbus_ioctl_data __user *tdata;
1691 struct i2c_smbus_ioctl_data32 __user *udata;
1692 compat_caddr_t datap;
1693
1694 tdata = compat_alloc_user_space(sizeof(*tdata));
1695 if (tdata == NULL)
1696 return -ENOMEM;
1697 if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
1698 return -EFAULT;
1699
1700 udata = compat_ptr(arg);
1701 if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
1702 return -EFAULT;
1703
1704 if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
1705 return -EFAULT;
1706 if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
1707 return -EFAULT;
1708 if (__get_user(datap, &udata->data) ||
1709 __put_user(compat_ptr(datap), &tdata->data))
1710 return -EFAULT;
1711
1712 return sys_ioctl(fd, cmd, (unsigned long)tdata);
1713}
1714
1da177e4
LT
1715/* Since old style bridge ioctl's endup using SIOCDEVPRIVATE
1716 * for some operations; this forces use of the newer bridge-utils that
ab2274af 1717 * use compatible ioctls
1da177e4
LT
1718 */
1719static int old_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
1720{
1721 u32 tmp;
1722
1723 if (get_user(tmp, (u32 __user *) arg))
1724 return -EFAULT;
1725 if (tmp == BRCTL_GET_VERSION)
1726 return BRCTL_VERSION + 1;
1727 return -EINVAL;
1728}
1729
ec3cad96
CH
1730#define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
1731#define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t)
1732#define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
1733#define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t)
1734
1735static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
1736{
1737 mm_segment_t oldfs = get_fs();
1738 compat_ulong_t val32;
1739 unsigned long kval;
1740 int ret;
1741
1742 switch (cmd) {
1743 case RTC_IRQP_READ32:
1744 case RTC_EPOCH_READ32:
1745 set_fs(KERNEL_DS);
1746 ret = sys_ioctl(fd, (cmd == RTC_IRQP_READ32) ?
1747 RTC_IRQP_READ : RTC_EPOCH_READ,
1748 (unsigned long)&kval);
1749 set_fs(oldfs);
1750 if (ret)
1751 return ret;
1752 val32 = kval;
1753 return put_user(val32, (unsigned int __user *)arg);
1754 case RTC_IRQP_SET32:
fc5870f6 1755 return sys_ioctl(fd, RTC_IRQP_SET, arg);
ec3cad96 1756 case RTC_EPOCH_SET32:
fc5870f6 1757 return sys_ioctl(fd, RTC_EPOCH_SET, arg);
ec3cad96
CH
1758 default:
1759 /* unreached */
1760 return -ENOIOCTLCMD;
1761 }
1762}
1763
c6b44d10
AK
1764static int
1765lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1766{
6b2b4e5a
AV
1767 struct compat_timeval __user *tc = (struct compat_timeval __user *)arg;
1768 struct timeval __user *tn = compat_alloc_user_space(sizeof(struct timeval));
c6b44d10
AK
1769 struct timeval ts;
1770 if (get_user(ts.tv_sec, &tc->tv_sec) ||
1771 get_user(ts.tv_usec, &tc->tv_usec) ||
1772 put_user(ts.tv_sec, &tn->tv_sec) ||
1773 put_user(ts.tv_usec, &tn->tv_usec))
1774 return -EFAULT;
1775 return sys_ioctl(fd, cmd, (unsigned long)tn);
1776}
1777
3e63cbb1
AJ
1778/* on ia32 l_start is on a 32-bit boundary */
1779#if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
1780struct space_resv_32 {
1781 __s16 l_type;
1782 __s16 l_whence;
1783 __s64 l_start __attribute__((packed));
1784 /* len == 0 means until end of file */
1785 __s64 l_len __attribute__((packed));
1786 __s32 l_sysid;
1787 __u32 l_pid;
1788 __s32 l_pad[4]; /* reserve area */
1789};
1790
1791#define FS_IOC_RESVSP_32 _IOW ('X', 40, struct space_resv_32)
1792#define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32)
1793
1794/* just account for different alignment */
1795static int compat_ioctl_preallocate(struct file *file, unsigned long arg)
1796{
1797 struct space_resv_32 __user *p32 = (void __user *)arg;
1798 struct space_resv __user *p = compat_alloc_user_space(sizeof(*p));
1799
1800 if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) ||
1801 copy_in_user(&p->l_whence, &p32->l_whence, sizeof(s16)) ||
1802 copy_in_user(&p->l_start, &p32->l_start, sizeof(s64)) ||
1803 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
1804 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
1805 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
1806 copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
1807 return -EFAULT;
1808
1809 return ioctl_preallocate(file, p);
1810}
1811#endif
1812
6272e266
CH
1813
1814typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int,
1815 unsigned long, struct file *);
1816
1817struct ioctl_trans {
1818 unsigned long cmd;
1819 ioctl_trans_handler_t handler;
1820 struct ioctl_trans *next;
1821};
1822
e6a6d2ef
CH
1823#define HANDLE_IOCTL(cmd,handler) \
1824 { (cmd), (ioctl_trans_handler_t)(handler) },
1825
1826/* pointer to compatible structure or no argument */
1827#define COMPATIBLE_IOCTL(cmd) \
1828 { (cmd), do_ioctl32_pointer },
1829
1830/* argument is an unsigned long integer, not a pointer */
1831#define ULONG_IOCTL(cmd) \
1832 { (cmd), (ioctl_trans_handler_t)sys_ioctl },
1da177e4 1833
421f0281
AK
1834/* ioctl should not be warned about even if it's not implemented.
1835 Valid reasons to use this:
1836 - It is implemented with ->compat_ioctl on some device, but programs
1837 call it on others too.
1838 - The ioctl is not implemented in the native kernel, but programs
1839 call it commonly anyways.
1840 Most other reasons are not valid. */
1841#define IGNORE_IOCTL(cmd) COMPATIBLE_IOCTL(cmd)
e6a6d2ef 1842
6272e266 1843static struct ioctl_trans ioctl_start[] = {
644fd4f5
CH
1844/* compatible ioctls first */
1845COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */
1846COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */
1847
1848/* Big T */
1849COMPATIBLE_IOCTL(TCGETA)
1850COMPATIBLE_IOCTL(TCSETA)
1851COMPATIBLE_IOCTL(TCSETAW)
1852COMPATIBLE_IOCTL(TCSETAF)
1853COMPATIBLE_IOCTL(TCSBRK)
1854ULONG_IOCTL(TCSBRKP)
1855COMPATIBLE_IOCTL(TCXONC)
1856COMPATIBLE_IOCTL(TCFLSH)
1857COMPATIBLE_IOCTL(TCGETS)
1858COMPATIBLE_IOCTL(TCSETS)
1859COMPATIBLE_IOCTL(TCSETSW)
1860COMPATIBLE_IOCTL(TCSETSF)
1861COMPATIBLE_IOCTL(TIOCLINUX)
1862COMPATIBLE_IOCTL(TIOCSBRK)
1863COMPATIBLE_IOCTL(TIOCCBRK)
1864ULONG_IOCTL(TIOCMIWAIT)
1865COMPATIBLE_IOCTL(TIOCGICOUNT)
1866/* Little t */
1867COMPATIBLE_IOCTL(TIOCGETD)
1868COMPATIBLE_IOCTL(TIOCSETD)
1869COMPATIBLE_IOCTL(TIOCEXCL)
1870COMPATIBLE_IOCTL(TIOCNXCL)
1871COMPATIBLE_IOCTL(TIOCCONS)
1872COMPATIBLE_IOCTL(TIOCGSOFTCAR)
1873COMPATIBLE_IOCTL(TIOCSSOFTCAR)
1874COMPATIBLE_IOCTL(TIOCSWINSZ)
1875COMPATIBLE_IOCTL(TIOCGWINSZ)
1876COMPATIBLE_IOCTL(TIOCMGET)
1877COMPATIBLE_IOCTL(TIOCMBIC)
1878COMPATIBLE_IOCTL(TIOCMBIS)
1879COMPATIBLE_IOCTL(TIOCMSET)
1880COMPATIBLE_IOCTL(TIOCPKT)
1881COMPATIBLE_IOCTL(TIOCNOTTY)
1882COMPATIBLE_IOCTL(TIOCSTI)
1883COMPATIBLE_IOCTL(TIOCOUTQ)
1884COMPATIBLE_IOCTL(TIOCSPGRP)
1885COMPATIBLE_IOCTL(TIOCGPGRP)
1886ULONG_IOCTL(TIOCSCTTY)
1887COMPATIBLE_IOCTL(TIOCGPTN)
1888COMPATIBLE_IOCTL(TIOCSPTLCK)
1889COMPATIBLE_IOCTL(TIOCSERGETLSR)
81257def
HC
1890#ifdef TCGETS2
1891COMPATIBLE_IOCTL(TCGETS2)
1892COMPATIBLE_IOCTL(TCSETS2)
1893COMPATIBLE_IOCTL(TCSETSW2)
1894COMPATIBLE_IOCTL(TCSETSF2)
1895#endif
644fd4f5
CH
1896/* Little f */
1897COMPATIBLE_IOCTL(FIOCLEX)
1898COMPATIBLE_IOCTL(FIONCLEX)
1899COMPATIBLE_IOCTL(FIOASYNC)
1900COMPATIBLE_IOCTL(FIONBIO)
1901COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */
69130c7c 1902COMPATIBLE_IOCTL(FS_IOC_FIEMAP)
644fd4f5
CH
1903/* 0x00 */
1904COMPATIBLE_IOCTL(FIBMAP)
1905COMPATIBLE_IOCTL(FIGETBSZ)
5cf8cf41
CH
1906/* 'X' - originally XFS but some now in the VFS */
1907COMPATIBLE_IOCTL(FIFREEZE)
1908COMPATIBLE_IOCTL(FITHAW)
644fd4f5
CH
1909/* RAID */
1910COMPATIBLE_IOCTL(RAID_VERSION)
1911COMPATIBLE_IOCTL(GET_ARRAY_INFO)
1912COMPATIBLE_IOCTL(GET_DISK_INFO)
1913COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
1914COMPATIBLE_IOCTL(RAID_AUTORUN)
1915COMPATIBLE_IOCTL(CLEAR_ARRAY)
1916COMPATIBLE_IOCTL(ADD_NEW_DISK)
1917ULONG_IOCTL(HOT_REMOVE_DISK)
1918COMPATIBLE_IOCTL(SET_ARRAY_INFO)
1919COMPATIBLE_IOCTL(SET_DISK_INFO)
1920COMPATIBLE_IOCTL(WRITE_RAID_INFO)
1921COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
1922COMPATIBLE_IOCTL(PROTECT_ARRAY)
1923ULONG_IOCTL(HOT_ADD_DISK)
1924ULONG_IOCTL(SET_DISK_FAULTY)
1925COMPATIBLE_IOCTL(RUN_ARRAY)
1926COMPATIBLE_IOCTL(STOP_ARRAY)
1927COMPATIBLE_IOCTL(STOP_ARRAY_RO)
1928COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
1929COMPATIBLE_IOCTL(GET_BITMAP_FILE)
1930ULONG_IOCTL(SET_BITMAP_FILE)
644fd4f5
CH
1931/* Big K */
1932COMPATIBLE_IOCTL(PIO_FONT)
1933COMPATIBLE_IOCTL(GIO_FONT)
2db69a93
BN
1934COMPATIBLE_IOCTL(PIO_CMAP)
1935COMPATIBLE_IOCTL(GIO_CMAP)
644fd4f5
CH
1936ULONG_IOCTL(KDSIGACCEPT)
1937COMPATIBLE_IOCTL(KDGETKEYCODE)
1938COMPATIBLE_IOCTL(KDSETKEYCODE)
1939ULONG_IOCTL(KIOCSOUND)
1940ULONG_IOCTL(KDMKTONE)
1941COMPATIBLE_IOCTL(KDGKBTYPE)
1942ULONG_IOCTL(KDSETMODE)
1943COMPATIBLE_IOCTL(KDGETMODE)
1944ULONG_IOCTL(KDSKBMODE)
1945COMPATIBLE_IOCTL(KDGKBMODE)
1946ULONG_IOCTL(KDSKBMETA)
1947COMPATIBLE_IOCTL(KDGKBMETA)
1948COMPATIBLE_IOCTL(KDGKBENT)
1949COMPATIBLE_IOCTL(KDSKBENT)
1950COMPATIBLE_IOCTL(KDGKBSENT)
1951COMPATIBLE_IOCTL(KDSKBSENT)
1952COMPATIBLE_IOCTL(KDGKBDIACR)
1953COMPATIBLE_IOCTL(KDSKBDIACR)
1954COMPATIBLE_IOCTL(KDKBDREP)
1955COMPATIBLE_IOCTL(KDGKBLED)
1956ULONG_IOCTL(KDSKBLED)
1957COMPATIBLE_IOCTL(KDGETLED)
1958ULONG_IOCTL(KDSETLED)
1959COMPATIBLE_IOCTL(GIO_SCRNMAP)
1960COMPATIBLE_IOCTL(PIO_SCRNMAP)
1961COMPATIBLE_IOCTL(GIO_UNISCRNMAP)
1962COMPATIBLE_IOCTL(PIO_UNISCRNMAP)
1963COMPATIBLE_IOCTL(PIO_FONTRESET)
1964COMPATIBLE_IOCTL(PIO_UNIMAPCLR)
3c3622dc 1965#ifdef CONFIG_BLOCK
644fd4f5
CH
1966/* Big S */
1967COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
1968COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
1969COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
1970COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
1971COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
1972COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
1973COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
1974COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
3c3622dc 1975#endif
644fd4f5
CH
1976/* Big V */
1977COMPATIBLE_IOCTL(VT_SETMODE)
1978COMPATIBLE_IOCTL(VT_GETMODE)
1979COMPATIBLE_IOCTL(VT_GETSTATE)
1980COMPATIBLE_IOCTL(VT_OPENQRY)
1981ULONG_IOCTL(VT_ACTIVATE)
1982ULONG_IOCTL(VT_WAITACTIVE)
1983ULONG_IOCTL(VT_RELDISP)
1984ULONG_IOCTL(VT_DISALLOCATE)
1985COMPATIBLE_IOCTL(VT_RESIZE)
1986COMPATIBLE_IOCTL(VT_RESIZEX)
1987COMPATIBLE_IOCTL(VT_LOCKSWITCH)
1988COMPATIBLE_IOCTL(VT_UNLOCKSWITCH)
1989COMPATIBLE_IOCTL(VT_GETHIFONTMASK)
1990/* Little p (/dev/rtc, /dev/envctrl, etc.) */
1991COMPATIBLE_IOCTL(RTC_AIE_ON)
1992COMPATIBLE_IOCTL(RTC_AIE_OFF)
1993COMPATIBLE_IOCTL(RTC_UIE_ON)
1994COMPATIBLE_IOCTL(RTC_UIE_OFF)
1995COMPATIBLE_IOCTL(RTC_PIE_ON)
1996COMPATIBLE_IOCTL(RTC_PIE_OFF)
1997COMPATIBLE_IOCTL(RTC_WIE_ON)
1998COMPATIBLE_IOCTL(RTC_WIE_OFF)
1999COMPATIBLE_IOCTL(RTC_ALM_SET)
2000COMPATIBLE_IOCTL(RTC_ALM_READ)
2001COMPATIBLE_IOCTL(RTC_RD_TIME)
2002COMPATIBLE_IOCTL(RTC_SET_TIME)
2003COMPATIBLE_IOCTL(RTC_WKALM_SET)
2004COMPATIBLE_IOCTL(RTC_WKALM_RD)
2005/*
2006 * These two are only for the sbus rtc driver, but
2007 * hwclock tries them on every rtc device first when
2008 * running on sparc. On other architectures the entries
2009 * are useless but harmless.
2010 */
2011COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
2012COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
2013/* Little m */
2014COMPATIBLE_IOCTL(MTIOCTOP)
2015/* Socket level stuff */
2016COMPATIBLE_IOCTL(FIOQSIZE)
2017COMPATIBLE_IOCTL(FIOSETOWN)
2018COMPATIBLE_IOCTL(SIOCSPGRP)
2019COMPATIBLE_IOCTL(FIOGETOWN)
2020COMPATIBLE_IOCTL(SIOCGPGRP)
2021COMPATIBLE_IOCTL(SIOCATMARK)
2022COMPATIBLE_IOCTL(SIOCSIFLINK)
644fd4f5
CH
2023COMPATIBLE_IOCTL(SIOCSIFNAME)
2024COMPATIBLE_IOCTL(SIOCSARP)
2025COMPATIBLE_IOCTL(SIOCGARP)
2026COMPATIBLE_IOCTL(SIOCDARP)
2027COMPATIBLE_IOCTL(SIOCSRARP)
2028COMPATIBLE_IOCTL(SIOCGRARP)
2029COMPATIBLE_IOCTL(SIOCDRARP)
2030COMPATIBLE_IOCTL(SIOCADDDLCI)
2031COMPATIBLE_IOCTL(SIOCDELDLCI)
2032COMPATIBLE_IOCTL(SIOCGMIIPHY)
2033COMPATIBLE_IOCTL(SIOCGMIIREG)
2034COMPATIBLE_IOCTL(SIOCSMIIREG)
2035COMPATIBLE_IOCTL(SIOCGIFVLAN)
2036COMPATIBLE_IOCTL(SIOCSIFVLAN)
2037COMPATIBLE_IOCTL(SIOCBRADDBR)
2038COMPATIBLE_IOCTL(SIOCBRDELBR)
3c3622dc 2039#ifdef CONFIG_BLOCK
644fd4f5
CH
2040/* SG stuff */
2041COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
2042COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
2043COMPATIBLE_IOCTL(SG_EMULATED_HOST)
2044ULONG_IOCTL(SG_SET_TRANSFORM)
2045COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
2046COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
2047COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
2048COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
2049COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
2050COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
2051COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
2052COMPATIBLE_IOCTL(SG_GET_PACK_ID)
2053COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
2054COMPATIBLE_IOCTL(SG_SET_DEBUG)
2055COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
2056COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
2057COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
2058COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
2059COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
2060COMPATIBLE_IOCTL(SG_SCSI_RESET)
2061COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
2062COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
2063COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
3c3622dc 2064#endif
644fd4f5
CH
2065/* PPP stuff */
2066COMPATIBLE_IOCTL(PPPIOCGFLAGS)
2067COMPATIBLE_IOCTL(PPPIOCSFLAGS)
2068COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
2069COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
2070COMPATIBLE_IOCTL(PPPIOCGUNIT)
2071COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
2072COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
2073COMPATIBLE_IOCTL(PPPIOCGMRU)
2074COMPATIBLE_IOCTL(PPPIOCSMRU)
2075COMPATIBLE_IOCTL(PPPIOCSMAXCID)
2076COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
2077COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
2078COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
2079/* PPPIOCSCOMPRESS is translated */
2080COMPATIBLE_IOCTL(PPPIOCGNPMODE)
2081COMPATIBLE_IOCTL(PPPIOCSNPMODE)
2082COMPATIBLE_IOCTL(PPPIOCGDEBUG)
2083COMPATIBLE_IOCTL(PPPIOCSDEBUG)
2084/* PPPIOCSPASS is translated */
2085/* PPPIOCSACTIVE is translated */
2086/* PPPIOCGIDLE is translated */
2087COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
2088COMPATIBLE_IOCTL(PPPIOCATTACH)
2089COMPATIBLE_IOCTL(PPPIOCDETACH)
2090COMPATIBLE_IOCTL(PPPIOCSMRRU)
2091COMPATIBLE_IOCTL(PPPIOCCONNECT)
2092COMPATIBLE_IOCTL(PPPIOCDISCONN)
2093COMPATIBLE_IOCTL(PPPIOCATTCHAN)
2094COMPATIBLE_IOCTL(PPPIOCGCHAN)
2095/* PPPOX */
2096COMPATIBLE_IOCTL(PPPOEIOCSFWD)
2097COMPATIBLE_IOCTL(PPPOEIOCDFWD)
2098/* LP */
2099COMPATIBLE_IOCTL(LPGETSTATUS)
2100/* ppdev */
2101COMPATIBLE_IOCTL(PPSETMODE)
2102COMPATIBLE_IOCTL(PPRSTATUS)
2103COMPATIBLE_IOCTL(PPRCONTROL)
2104COMPATIBLE_IOCTL(PPWCONTROL)
2105COMPATIBLE_IOCTL(PPFCONTROL)
2106COMPATIBLE_IOCTL(PPRDATA)
2107COMPATIBLE_IOCTL(PPWDATA)
2108COMPATIBLE_IOCTL(PPCLAIM)
2109COMPATIBLE_IOCTL(PPRELEASE)
2110COMPATIBLE_IOCTL(PPYIELD)
2111COMPATIBLE_IOCTL(PPEXCL)
2112COMPATIBLE_IOCTL(PPDATADIR)
2113COMPATIBLE_IOCTL(PPNEGOT)
2114COMPATIBLE_IOCTL(PPWCTLONIRQ)
2115COMPATIBLE_IOCTL(PPCLRIRQ)
2116COMPATIBLE_IOCTL(PPSETPHASE)
2117COMPATIBLE_IOCTL(PPGETMODES)
2118COMPATIBLE_IOCTL(PPGETMODE)
2119COMPATIBLE_IOCTL(PPGETPHASE)
2120COMPATIBLE_IOCTL(PPGETFLAGS)
2121COMPATIBLE_IOCTL(PPSETFLAGS)
644fd4f5
CH
2122/* pktcdvd */
2123COMPATIBLE_IOCTL(PACKET_CTRL_CMD)
2124/* Big A */
2125/* sparc only */
2126/* Big Q for sound/OSS */
2127COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
2128COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
2129COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
2130COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
2131COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
2132COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
2133COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
2134COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
2135COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
2136COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
2137COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
2138COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
2139COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
2140COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
2141COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
2142COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
2143COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
2144COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
2145COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
2146COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
2147COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
2148COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
2149/* Big T for sound/OSS */
2150COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
2151COMPATIBLE_IOCTL(SNDCTL_TMR_START)
2152COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
2153COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
2154COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
2155COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
2156COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
2157COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
2158/* Little m for sound/OSS */
2159COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
2160COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
2161COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
2162/* Big P for sound/OSS */
2163COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
2164COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
2165COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
2166COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
2167COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
2168COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
2169COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
2170COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
2171COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
2172COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
2173COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
2174COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
2175COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
2176COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
2177COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
2178COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
2179COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
2180COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
2181COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
2182COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
2183/* SNDCTL_DSP_MAPINBUF, XXX needs translation */
2184/* SNDCTL_DSP_MAPOUTBUF, XXX needs translation */
2185COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
2186COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
2187COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
2188COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
2189COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
2190COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
2191COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
2192COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
2193/* Big C for sound/OSS */
2194COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
2195COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
2196COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
2197COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
2198COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
2199COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
2200COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
2201COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
2202COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
2203COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
2204/* Big M for sound/OSS */
2205COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
2206COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
2207COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
2208COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
2209COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
2210COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
2211COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
2212COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
2213COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
2214COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
2215COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
2216COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
2217COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
2218COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
2219COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
2220COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
2221COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
2222COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
2223COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
2224COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
2225COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
2226COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
2227COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
2228COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
2229COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
2230COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
2231/* SOUND_MIXER_READ_ENHANCE, same value as READ_MUTE */
2232/* SOUND_MIXER_READ_LOUD, same value as READ_MUTE */
2233COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
2234COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
2235COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
2236COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
2237COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
2238COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
2239COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
2240COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
2241COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
2242COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
2243COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
2244COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
2245COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
2246COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
2247COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
2248COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
2249COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
2250COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
2251COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
2252COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
2253COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
2254COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
2255COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
2256COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
2257COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
2258COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
2259COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
2260COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
2261COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
2262COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
2263COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
2264/* SOUND_MIXER_WRITE_ENHANCE, same value as WRITE_MUTE */
2265/* SOUND_MIXER_WRITE_LOUD, same value as WRITE_MUTE */
2266COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
2267COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
2268COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
2269COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
2270COMPATIBLE_IOCTL(SOUND_MIXER_AGC)
2271COMPATIBLE_IOCTL(SOUND_MIXER_3DSE)
2272COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
2273COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
2274COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
2275COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
2276COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
2277COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
2278COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
2279COMPATIBLE_IOCTL(OSS_GETVERSION)
2280/* AUTOFS */
2281ULONG_IOCTL(AUTOFS_IOC_READY)
2282ULONG_IOCTL(AUTOFS_IOC_FAIL)
2283COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
2284COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
2285COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
2286COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI)
2287COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOSUBVER)
644fd4f5
CH
2288COMPATIBLE_IOCTL(AUTOFS_IOC_ASKUMOUNT)
2289/* Raw devices */
2290COMPATIBLE_IOCTL(RAW_SETBIND)
2291COMPATIBLE_IOCTL(RAW_GETBIND)
2292/* SMB ioctls which do not need any translations */
2293COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
2294/* Little a */
2295COMPATIBLE_IOCTL(ATMSIGD_CTRL)
2296COMPATIBLE_IOCTL(ATMARPD_CTRL)
2297COMPATIBLE_IOCTL(ATMLEC_CTRL)
2298COMPATIBLE_IOCTL(ATMLEC_MCAST)
2299COMPATIBLE_IOCTL(ATMLEC_DATA)
2300COMPATIBLE_IOCTL(ATM_SETSC)
2301COMPATIBLE_IOCTL(SIOCSIFATMTCP)
2302COMPATIBLE_IOCTL(SIOCMKCLIP)
2303COMPATIBLE_IOCTL(ATMARP_MKIP)
2304COMPATIBLE_IOCTL(ATMARP_SETENTRY)
2305COMPATIBLE_IOCTL(ATMARP_ENCAP)
2306COMPATIBLE_IOCTL(ATMTCP_CREATE)
2307COMPATIBLE_IOCTL(ATMTCP_REMOVE)
2308COMPATIBLE_IOCTL(ATMMPC_CTRL)
2309COMPATIBLE_IOCTL(ATMMPC_DATA)
2310/* Watchdog */
2311COMPATIBLE_IOCTL(WDIOC_GETSUPPORT)
2312COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
2313COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS)
2314COMPATIBLE_IOCTL(WDIOC_GETTEMP)
2315COMPATIBLE_IOCTL(WDIOC_SETOPTIONS)
2316COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
2317COMPATIBLE_IOCTL(WDIOC_SETTIMEOUT)
2318COMPATIBLE_IOCTL(WDIOC_GETTIMEOUT)
2319/* Big R */
2320COMPATIBLE_IOCTL(RNDGETENTCNT)
2321COMPATIBLE_IOCTL(RNDADDTOENTCNT)
2322COMPATIBLE_IOCTL(RNDGETPOOL)
2323COMPATIBLE_IOCTL(RNDADDENTROPY)
2324COMPATIBLE_IOCTL(RNDZAPENTCNT)
2325COMPATIBLE_IOCTL(RNDCLEARPOOL)
2326/* Bluetooth */
2327COMPATIBLE_IOCTL(HCIDEVUP)
2328COMPATIBLE_IOCTL(HCIDEVDOWN)
2329COMPATIBLE_IOCTL(HCIDEVRESET)
2330COMPATIBLE_IOCTL(HCIDEVRESTAT)
2331COMPATIBLE_IOCTL(HCIGETDEVLIST)
2332COMPATIBLE_IOCTL(HCIGETDEVINFO)
2333COMPATIBLE_IOCTL(HCIGETCONNLIST)
2334COMPATIBLE_IOCTL(HCIGETCONNINFO)
40be492f 2335COMPATIBLE_IOCTL(HCIGETAUTHINFO)
644fd4f5
CH
2336COMPATIBLE_IOCTL(HCISETRAW)
2337COMPATIBLE_IOCTL(HCISETSCAN)
2338COMPATIBLE_IOCTL(HCISETAUTH)
2339COMPATIBLE_IOCTL(HCISETENCRYPT)
2340COMPATIBLE_IOCTL(HCISETPTYPE)
2341COMPATIBLE_IOCTL(HCISETLINKPOL)
2342COMPATIBLE_IOCTL(HCISETLINKMODE)
2343COMPATIBLE_IOCTL(HCISETACLMTU)
2344COMPATIBLE_IOCTL(HCISETSCOMTU)
2345COMPATIBLE_IOCTL(HCIINQUIRY)
2346COMPATIBLE_IOCTL(HCIUARTSETPROTO)
2347COMPATIBLE_IOCTL(HCIUARTGETPROTO)
2348COMPATIBLE_IOCTL(RFCOMMCREATEDEV)
2349COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
2350COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
2351COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
2352COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
2353COMPATIBLE_IOCTL(BNEPCONNADD)
2354COMPATIBLE_IOCTL(BNEPCONNDEL)
2355COMPATIBLE_IOCTL(BNEPGETCONNLIST)
2356COMPATIBLE_IOCTL(BNEPGETCONNINFO)
2357COMPATIBLE_IOCTL(CMTPCONNADD)
2358COMPATIBLE_IOCTL(CMTPCONNDEL)
2359COMPATIBLE_IOCTL(CMTPGETCONNLIST)
2360COMPATIBLE_IOCTL(CMTPGETCONNINFO)
2361COMPATIBLE_IOCTL(HIDPCONNADD)
2362COMPATIBLE_IOCTL(HIDPCONNDEL)
2363COMPATIBLE_IOCTL(HIDPGETCONNLIST)
2364COMPATIBLE_IOCTL(HIDPGETCONNINFO)
2365/* CAPI */
2366COMPATIBLE_IOCTL(CAPI_REGISTER)
2367COMPATIBLE_IOCTL(CAPI_GET_MANUFACTURER)
2368COMPATIBLE_IOCTL(CAPI_GET_VERSION)
2369COMPATIBLE_IOCTL(CAPI_GET_SERIAL)
2370COMPATIBLE_IOCTL(CAPI_GET_PROFILE)
2371COMPATIBLE_IOCTL(CAPI_MANUFACTURER_CMD)
2372COMPATIBLE_IOCTL(CAPI_GET_ERRCODE)
2373COMPATIBLE_IOCTL(CAPI_INSTALLED)
2374COMPATIBLE_IOCTL(CAPI_GET_FLAGS)
2375COMPATIBLE_IOCTL(CAPI_SET_FLAGS)
2376COMPATIBLE_IOCTL(CAPI_CLR_FLAGS)
2377COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT)
2378COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT)
2379/* Siemens Gigaset */
2380COMPATIBLE_IOCTL(GIGASET_REDIR)
2381COMPATIBLE_IOCTL(GIGASET_CONFIG)
2382COMPATIBLE_IOCTL(GIGASET_BRKCHARS)
2383COMPATIBLE_IOCTL(GIGASET_VERSION)
2384/* Misc. */
2385COMPATIBLE_IOCTL(0x41545900) /* ATYIO_CLKR */
2386COMPATIBLE_IOCTL(0x41545901) /* ATYIO_CLKW */
2387COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
2388COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
2389COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
2390COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
2391/* USB */
2392COMPATIBLE_IOCTL(USBDEVFS_RESETEP)
2393COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE)
2394COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION)
2395COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER)
2396COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB)
2397COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE)
2398COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE)
2399COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO)
2400COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO)
2401COMPATIBLE_IOCTL(USBDEVFS_RESET)
2402COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32)
2403COMPATIBLE_IOCTL(USBDEVFS_REAPURB32)
2404COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32)
2405COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
644fd4f5
CH
2406/* NBD */
2407ULONG_IOCTL(NBD_SET_SOCK)
2408ULONG_IOCTL(NBD_SET_BLKSIZE)
2409ULONG_IOCTL(NBD_SET_SIZE)
2410COMPATIBLE_IOCTL(NBD_DO_IT)
2411COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
2412COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
2413COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
2414ULONG_IOCTL(NBD_SET_SIZE_BLOCKS)
2415COMPATIBLE_IOCTL(NBD_DISCONNECT)
2416/* i2c */
2417COMPATIBLE_IOCTL(I2C_SLAVE)
2418COMPATIBLE_IOCTL(I2C_SLAVE_FORCE)
2419COMPATIBLE_IOCTL(I2C_TENBIT)
2420COMPATIBLE_IOCTL(I2C_PEC)
2421COMPATIBLE_IOCTL(I2C_RETRIES)
2422COMPATIBLE_IOCTL(I2C_TIMEOUT)
644fd4f5
CH
2423/* hiddev */
2424COMPATIBLE_IOCTL(HIDIOCGVERSION)
2425COMPATIBLE_IOCTL(HIDIOCAPPLICATION)
2426COMPATIBLE_IOCTL(HIDIOCGDEVINFO)
2427COMPATIBLE_IOCTL(HIDIOCGSTRING)
2428COMPATIBLE_IOCTL(HIDIOCINITREPORT)
2429COMPATIBLE_IOCTL(HIDIOCGREPORT)
2430COMPATIBLE_IOCTL(HIDIOCSREPORT)
2431COMPATIBLE_IOCTL(HIDIOCGREPORTINFO)
2432COMPATIBLE_IOCTL(HIDIOCGFIELDINFO)
2433COMPATIBLE_IOCTL(HIDIOCGUSAGE)
2434COMPATIBLE_IOCTL(HIDIOCSUSAGE)
2435COMPATIBLE_IOCTL(HIDIOCGUCODE)
2436COMPATIBLE_IOCTL(HIDIOCGFLAG)
2437COMPATIBLE_IOCTL(HIDIOCSFLAG)
2438COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINDEX)
2439COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINFO)
2440/* dvb */
2441COMPATIBLE_IOCTL(AUDIO_STOP)
2442COMPATIBLE_IOCTL(AUDIO_PLAY)
2443COMPATIBLE_IOCTL(AUDIO_PAUSE)
2444COMPATIBLE_IOCTL(AUDIO_CONTINUE)
2445COMPATIBLE_IOCTL(AUDIO_SELECT_SOURCE)
2446COMPATIBLE_IOCTL(AUDIO_SET_MUTE)
2447COMPATIBLE_IOCTL(AUDIO_SET_AV_SYNC)
2448COMPATIBLE_IOCTL(AUDIO_SET_BYPASS_MODE)
2449COMPATIBLE_IOCTL(AUDIO_CHANNEL_SELECT)
2450COMPATIBLE_IOCTL(AUDIO_GET_STATUS)
2451COMPATIBLE_IOCTL(AUDIO_GET_CAPABILITIES)
2452COMPATIBLE_IOCTL(AUDIO_CLEAR_BUFFER)
2453COMPATIBLE_IOCTL(AUDIO_SET_ID)
2454COMPATIBLE_IOCTL(AUDIO_SET_MIXER)
2455COMPATIBLE_IOCTL(AUDIO_SET_STREAMTYPE)
2456COMPATIBLE_IOCTL(AUDIO_SET_EXT_ID)
2457COMPATIBLE_IOCTL(AUDIO_SET_ATTRIBUTES)
2458COMPATIBLE_IOCTL(AUDIO_SET_KARAOKE)
2459COMPATIBLE_IOCTL(DMX_START)
2460COMPATIBLE_IOCTL(DMX_STOP)
2461COMPATIBLE_IOCTL(DMX_SET_FILTER)
2462COMPATIBLE_IOCTL(DMX_SET_PES_FILTER)
2463COMPATIBLE_IOCTL(DMX_SET_BUFFER_SIZE)
2464COMPATIBLE_IOCTL(DMX_GET_PES_PIDS)
2465COMPATIBLE_IOCTL(DMX_GET_CAPS)
2466COMPATIBLE_IOCTL(DMX_SET_SOURCE)
2467COMPATIBLE_IOCTL(DMX_GET_STC)
2468COMPATIBLE_IOCTL(FE_GET_INFO)
2469COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD)
2470COMPATIBLE_IOCTL(FE_DISEQC_SEND_MASTER_CMD)
2471COMPATIBLE_IOCTL(FE_DISEQC_RECV_SLAVE_REPLY)
2472COMPATIBLE_IOCTL(FE_DISEQC_SEND_BURST)
2473COMPATIBLE_IOCTL(FE_SET_TONE)
2474COMPATIBLE_IOCTL(FE_SET_VOLTAGE)
2475COMPATIBLE_IOCTL(FE_ENABLE_HIGH_LNB_VOLTAGE)
2476COMPATIBLE_IOCTL(FE_READ_STATUS)
2477COMPATIBLE_IOCTL(FE_READ_BER)
2478COMPATIBLE_IOCTL(FE_READ_SIGNAL_STRENGTH)
2479COMPATIBLE_IOCTL(FE_READ_SNR)
2480COMPATIBLE_IOCTL(FE_READ_UNCORRECTED_BLOCKS)
2481COMPATIBLE_IOCTL(FE_SET_FRONTEND)
2482COMPATIBLE_IOCTL(FE_GET_FRONTEND)
2483COMPATIBLE_IOCTL(FE_GET_EVENT)
2484COMPATIBLE_IOCTL(FE_DISHNETWORK_SEND_LEGACY_CMD)
2485COMPATIBLE_IOCTL(VIDEO_STOP)
2486COMPATIBLE_IOCTL(VIDEO_PLAY)
2487COMPATIBLE_IOCTL(VIDEO_FREEZE)
2488COMPATIBLE_IOCTL(VIDEO_CONTINUE)
2489COMPATIBLE_IOCTL(VIDEO_SELECT_SOURCE)
2490COMPATIBLE_IOCTL(VIDEO_SET_BLANK)
2491COMPATIBLE_IOCTL(VIDEO_GET_STATUS)
2492COMPATIBLE_IOCTL(VIDEO_SET_DISPLAY_FORMAT)
2493COMPATIBLE_IOCTL(VIDEO_FAST_FORWARD)
2494COMPATIBLE_IOCTL(VIDEO_SLOWMOTION)
2495COMPATIBLE_IOCTL(VIDEO_GET_CAPABILITIES)
2496COMPATIBLE_IOCTL(VIDEO_CLEAR_BUFFER)
2497COMPATIBLE_IOCTL(VIDEO_SET_ID)
2498COMPATIBLE_IOCTL(VIDEO_SET_STREAMTYPE)
2499COMPATIBLE_IOCTL(VIDEO_SET_FORMAT)
2500COMPATIBLE_IOCTL(VIDEO_SET_SYSTEM)
2501COMPATIBLE_IOCTL(VIDEO_SET_HIGHLIGHT)
2502COMPATIBLE_IOCTL(VIDEO_SET_SPU)
2503COMPATIBLE_IOCTL(VIDEO_GET_NAVI)
2504COMPATIBLE_IOCTL(VIDEO_SET_ATTRIBUTES)
2505COMPATIBLE_IOCTL(VIDEO_GET_SIZE)
2506COMPATIBLE_IOCTL(VIDEO_GET_FRAME_RATE)
2507
3fee37c1
AM
2508/* joystick */
2509COMPATIBLE_IOCTL(JSIOCGVERSION)
2510COMPATIBLE_IOCTL(JSIOCGAXES)
2511COMPATIBLE_IOCTL(JSIOCGBUTTONS)
2512COMPATIBLE_IOCTL(JSIOCGNAME(0))
2513
644fd4f5 2514/* now things that need handlers */
1da177e4
LT
2515#ifdef CONFIG_NET
2516HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
2517HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)
2518HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc)
2519HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc)
2520HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc)
2521HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc)
2522HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc)
2523HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc)
2524HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc)
2525HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc)
2526HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc)
2527HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc)
2528HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc)
2529HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc)
2530HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc)
2531HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc)
2532HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
2533HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
2534HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
67fd44fe 2535HANDLE_IOCTL(SIOCSIFHWBROADCAST, dev_ifsioc)
d24fff22 2536HANDLE_IOCTL(SIOCSHWTSTAMP, dev_ifsioc)
1da177e4
LT
2537
2538/* ioctls used by appletalk ddp.c */
1da177e4
LT
2539HANDLE_IOCTL(SIOCDIFADDR, dev_ifsioc)
2540HANDLE_IOCTL(SIOCSARP, dev_ifsioc)
2541HANDLE_IOCTL(SIOCDARP, dev_ifsioc)
2542
2543HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc)
2544HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc)
2545HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc)
2546HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc)
2547HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc)
2548HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc)
2549HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc)
2550HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc)
2551HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc)
2552HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc)
1da177e4
LT
2553HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl)
2554HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl)
2555HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl)
2556HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl)
2557HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl)
2558HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl)
2559HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl)
2560HANDLE_IOCTL(SIOCADDRT, routing_ioctl)
2561HANDLE_IOCTL(SIOCDELRT, routing_ioctl)
2562HANDLE_IOCTL(SIOCBRADDIF, dev_ifsioc)
2563HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc)
2564/* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
2565HANDLE_IOCTL(SIOCRTMSG, ret_einval)
2566HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
ae40eb1e 2567HANDLE_IOCTL(SIOCGSTAMPNS, do_siocgstampns)
1da177e4 2568#endif
9361401e 2569#ifdef CONFIG_BLOCK
1da177e4 2570HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
2966387b 2571HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans)
9361401e 2572#endif
1da177e4
LT
2573HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans)
2574HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans)
2575HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans)
2576HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans)
9361401e 2577#ifdef CONFIG_BLOCK
1da177e4
LT
2578HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans)
2579HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans)
9361401e 2580#endif
1da177e4
LT
2581#define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
2582HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout)
2583#ifdef CONFIG_VT
2584HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl)
2585HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl)
2586HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl)
2587HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl)
2588HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl)
2589#endif
1da177e4
LT
2590/* One SMB ioctl needs translations. */
2591#define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
2592HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
2593HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl)
2594HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl)
2595HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl)
2596HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl)
2597HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl)
2598HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl)
2599HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl)
2600HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl)
2601HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl)
2602HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl)
2603HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl)
2604HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl)
2605HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl)
2606HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl)
2607HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl)
2608HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl)
2609HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl)
2610HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl)
2611HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl)
2612HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl)
2613HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl)
2614HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl)
2615HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl)
2616HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl)
2617HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl)
2618/* block stuff */
9361401e 2619#ifdef CONFIG_BLOCK
1ba0c7db
AB
2620/* loop */
2621IGNORE_IOCTL(LOOP_CLR_FD)
1da177e4
LT
2622/* Raw devices */
2623HANDLE_IOCTL(RAW_SETBIND, raw_ioctl)
2624HANDLE_IOCTL(RAW_GETBIND, raw_ioctl)
9361401e 2625#endif
1da177e4
LT
2626/* Serial */
2627HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl)
2628HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl)
9c0cbd54
CH
2629#ifdef TIOCGLTC
2630COMPATIBLE_IOCTL(TIOCGLTC)
2631COMPATIBLE_IOCTL(TIOCSLTC)
2632#endif
7a81e316
CH
2633#ifdef TIOCSTART
2634/*
2635 * For these two we have defintions in ioctls.h and/or termios.h on
2636 * some architectures but no actual implemention. Some applications
2637 * like bash call them if they are defined in the headers, so we provide
2638 * entries here to avoid syslog message spew.
2639 */
2640COMPATIBLE_IOCTL(TIOCSTART)
2641COMPATIBLE_IOCTL(TIOCSTOP)
2642#endif
1da177e4
LT
2643/* Usbdevfs */
2644HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
2645HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
2646HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
c36fc889 2647COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
1da177e4
LT
2648/* i2c */
2649HANDLE_IOCTL(I2C_FUNCS, w_long)
2650HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
2651HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
169a3ec4 2652/* bridge */
1da177e4
LT
2653HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl)
2654HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl)
9d016dd4
AK
2655/* Not implemented in the native kernel */
2656IGNORE_IOCTL(SIOCGIFCOUNT)
ec3cad96
CH
2657HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl)
2658HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl)
2659HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl)
2660HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl)
1da177e4 2661
6e87abd0 2662/* dvb */
6e87abd0
DM
2663HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event)
2664HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture)
2665HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette)
c6b44d10
AK
2666
2667/* parport */
2668COMPATIBLE_IOCTL(LPTIME)
2669COMPATIBLE_IOCTL(LPCHAR)
2670COMPATIBLE_IOCTL(LPABORTOPEN)
2671COMPATIBLE_IOCTL(LPCAREFUL)
2672COMPATIBLE_IOCTL(LPWAIT)
2673COMPATIBLE_IOCTL(LPSETIRQ)
2674COMPATIBLE_IOCTL(LPGETSTATUS)
2675COMPATIBLE_IOCTL(LPGETSTATUS)
2676COMPATIBLE_IOCTL(LPRESET)
2677/*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/
2678COMPATIBLE_IOCTL(LPGETFLAGS)
2679HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans)
2724b6db
AK
2680
2681/* fat 'r' ioctls. These are handled by fat with ->compat_ioctl,
2682 but we don't want warnings on other file systems. So declare
2683 them as compatible here. */
2684#define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
2685#define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
2686
2687IGNORE_IOCTL(VFAT_IOCTL_READDIR_BOTH32)
2688IGNORE_IOCTL(VFAT_IOCTL_READDIR_SHORT32)
98701dc1 2689
8163904e
DM
2690#ifdef CONFIG_SPARC
2691/* Sparc framebuffers, handled in sbusfb_compat_ioctl() */
2692IGNORE_IOCTL(FBIOGTYPE)
2693IGNORE_IOCTL(FBIOSATTR)
2694IGNORE_IOCTL(FBIOGATTR)
2695IGNORE_IOCTL(FBIOSVIDEO)
2696IGNORE_IOCTL(FBIOGVIDEO)
2697IGNORE_IOCTL(FBIOSCURPOS)
2698IGNORE_IOCTL(FBIOGCURPOS)
2699IGNORE_IOCTL(FBIOGCURMAX)
2700IGNORE_IOCTL(FBIOPUTCMAP32)
2701IGNORE_IOCTL(FBIOGETCMAP32)
2702IGNORE_IOCTL(FBIOSCURSOR32)
2703IGNORE_IOCTL(FBIOGCURSOR32)
2704#endif
e6a6d2ef 2705};
6e87abd0 2706
6272e266
CH
2707#define IOCTL_HASHSIZE 256
2708static struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE];
2709
2710static inline unsigned long ioctl32_hash(unsigned long cmd)
2711{
2712 return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE;
2713}
2714
2715static void compat_ioctl_error(struct file *filp, unsigned int fd,
2716 unsigned int cmd, unsigned long arg)
2717{
2718 char buf[10];
2719 char *fn = "?";
2720 char *path;
2721
2722 /* find the name of the device. */
2723 path = (char *)__get_free_page(GFP_KERNEL);
2724 if (path) {
cf28b486 2725 fn = d_path(&filp->f_path, path, PAGE_SIZE);
6272e266
CH
2726 if (IS_ERR(fn))
2727 fn = "?";
2728 }
2729
2730 sprintf(buf,"'%c'", (cmd>>_IOC_TYPESHIFT) & _IOC_TYPEMASK);
2731 if (!isprint(buf[1]))
2732 sprintf(buf, "%02x", buf[1]);
2733 compat_printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
2734 "cmd(%08x){t:%s;sz:%u} arg(%08x) on %s\n",
2735 current->comm, current->pid,
2736 (int)fd, (unsigned int)cmd, buf,
2737 (cmd >> _IOC_SIZESHIFT) & _IOC_SIZEMASK,
2738 (unsigned int)arg, fn);
2739
2740 if (path)
2741 free_page((unsigned long)path);
2742}
2743
2744asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
2745 unsigned long arg)
2746{
2747 struct file *filp;
2748 int error = -EBADF;
2749 struct ioctl_trans *t;
2750 int fput_needed;
2751
2752 filp = fget_light(fd, &fput_needed);
2753 if (!filp)
2754 goto out;
2755
2756 /* RED-PEN how should LSM module know it's handling 32bit? */
2757 error = security_file_ioctl(filp, cmd, arg);
2758 if (error)
2759 goto out_fput;
2760
2761 /*
2762 * To allow the compat_ioctl handlers to be self contained
2763 * we need to check the common ioctls here first.
2764 * Just handle them with the standard handlers below.
2765 */
2766 switch (cmd) {
2767 case FIOCLEX:
2768 case FIONCLEX:
2769 case FIONBIO:
2770 case FIOASYNC:
2771 case FIOQSIZE:
2772 break;
2773
3e63cbb1
AJ
2774#if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
2775 case FS_IOC_RESVSP_32:
2776 case FS_IOC_RESVSP64_32:
2777 error = compat_ioctl_preallocate(filp, arg);
2778 goto out_fput;
2779#else
2780 case FS_IOC_RESVSP:
2781 case FS_IOC_RESVSP64:
2782 error = ioctl_preallocate(filp, (void __user *)arg);
2783 goto out_fput;
2784#endif
2785
6272e266
CH
2786 case FIBMAP:
2787 case FIGETBSZ:
2788 case FIONREAD:
2789 if (S_ISREG(filp->f_path.dentry->d_inode->i_mode))
2790 break;
2791 /*FALL THROUGH*/
2792
2793 default:
2794 if (filp->f_op && filp->f_op->compat_ioctl) {
2795 error = filp->f_op->compat_ioctl(filp, cmd, arg);
2796 if (error != -ENOIOCTLCMD)
2797 goto out_fput;
2798 }
2799
2800 if (!filp->f_op ||
2801 (!filp->f_op->ioctl && !filp->f_op->unlocked_ioctl))
2802 goto do_ioctl;
2803 break;
2804 }
2805
2806 for (t = ioctl32_hash_table[ioctl32_hash(cmd)]; t; t = t->next) {
2807 if (t->cmd == cmd)
2808 goto found_handler;
2809 }
2810
d9de2622 2811#ifdef CONFIG_NET
6272e266
CH
2812 if (S_ISSOCK(filp->f_path.dentry->d_inode->i_mode) &&
2813 cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) {
2814 error = siocdevprivate_ioctl(fd, cmd, arg);
d9de2622
SH
2815 } else
2816#endif
2817 {
6272e266
CH
2818 static int count;
2819
2820 if (++count <= 50)
2821 compat_ioctl_error(filp, fd, cmd, arg);
2822 error = -EINVAL;
2823 }
2824
2825 goto out_fput;
2826
2827 found_handler:
2828 if (t->handler) {
2829 lock_kernel();
2830 error = t->handler(fd, cmd, arg, filp);
2831 unlock_kernel();
2832 goto out_fput;
2833 }
2834
2835 do_ioctl:
deb21db7 2836 error = do_vfs_ioctl(filp, fd, cmd, arg);
6272e266
CH
2837 out_fput:
2838 fput_light(filp, fput_needed);
2839 out:
2840 return error;
2841}
2842
2843static void ioctl32_insert_translation(struct ioctl_trans *trans)
2844{
2845 unsigned long hash;
2846 struct ioctl_trans *t;
2847
2848 hash = ioctl32_hash (trans->cmd);
2849 if (!ioctl32_hash_table[hash])
2850 ioctl32_hash_table[hash] = trans;
2851 else {
2852 t = ioctl32_hash_table[hash];
2853 while (t->next)
2854 t = t->next;
2855 trans->next = NULL;
2856 t->next = trans;
2857 }
2858}
2859
2860static int __init init_sys32_ioctl(void)
2861{
2862 int i;
2863
2864 for (i = 0; i < ARRAY_SIZE(ioctl_start); i++) {
c80544dc 2865 if (ioctl_start[i].next) {
6272e266
CH
2866 printk("ioctl translation %d bad\n",i);
2867 return -1;
2868 }
2869
2870 ioctl32_insert_translation(&ioctl_start[i]);
2871 }
2872 return 0;
2873}
2874__initcall(init_sys32_ioctl);
This page took 0.661105 seconds and 5 git commands to generate.