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