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