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