[PATCH] USB: onetouch doesn't suspend yet
[linux/fpc-iii.git] / fs / compat_ioctl.c
blobf07e60f9e1024644166653ca2da431b31f61cbaf
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 #ifdef INCLUDES
14 #include <linux/config.h>
15 #include <linux/types.h>
16 #include <linux/compat.h>
17 #include <linux/kernel.h>
18 #include <linux/compiler.h>
19 #include <linux/sched.h>
20 #include <linux/smp.h>
21 #include <linux/smp_lock.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/hdreg.h>
27 #include <linux/raid/md.h>
28 #include <linux/kd.h>
29 #include <linux/dirent.h>
30 #include <linux/route.h>
31 #include <linux/in6.h>
32 #include <linux/ipv6_route.h>
33 #include <linux/skbuff.h>
34 #include <linux/netlink.h>
35 #include <linux/vt.h>
36 #include <linux/fs.h>
37 #include <linux/file.h>
38 #include <linux/fd.h>
39 #include <linux/ppp_defs.h>
40 #include <linux/if_ppp.h>
41 #include <linux/if_pppox.h>
42 #include <linux/mtio.h>
43 #include <linux/cdrom.h>
44 #include <linux/loop.h>
45 #include <linux/auto_fs.h>
46 #include <linux/auto_fs4.h>
47 #include <linux/devfs_fs.h>
48 #include <linux/tty.h>
49 #include <linux/vt_kern.h>
50 #include <linux/fb.h>
51 #include <linux/ext2_fs.h>
52 #include <linux/videodev.h>
53 #include <linux/netdevice.h>
54 #include <linux/raw.h>
55 #include <linux/smb_fs.h>
56 #include <linux/blkpg.h>
57 #include <linux/blkdev.h>
58 #include <linux/elevator.h>
59 #include <linux/rtc.h>
60 #include <linux/pci.h>
61 #include <linux/module.h>
62 #include <linux/serial.h>
63 #include <linux/reiserfs_fs.h>
64 #include <linux/if_tun.h>
65 #include <linux/ctype.h>
66 #include <linux/ioctl32.h>
67 #include <linux/syscalls.h>
68 #include <linux/ncp_fs.h>
69 #include <linux/i2c.h>
70 #include <linux/i2c-dev.h>
71 #include <linux/wireless.h>
72 #include <linux/atalk.h>
74 #include <net/sock.h> /* siocdevprivate_ioctl */
75 #include <net/bluetooth/bluetooth.h>
76 #include <net/bluetooth/hci.h>
77 #include <net/bluetooth/rfcomm.h>
79 #include <linux/capi.h>
81 #include <scsi/scsi.h>
82 /* Ugly hack. */
83 #undef __KERNEL__
84 #include <scsi/scsi_ioctl.h>
85 #define __KERNEL__
86 #include <scsi/sg.h>
88 #include <asm/types.h>
89 #include <asm/uaccess.h>
90 #include <linux/ethtool.h>
91 #include <linux/mii.h>
92 #include <linux/if_bonding.h>
93 #include <linux/watchdog.h>
94 #include <linux/dm-ioctl.h>
96 #include <asm/module.h>
97 #include <linux/soundcard.h>
98 #include <linux/lp.h>
99 #include <linux/ppdev.h>
101 #include <linux/atm.h>
102 #include <linux/atmarp.h>
103 #include <linux/atmclip.h>
104 #include <linux/atmdev.h>
105 #include <linux/atmioc.h>
106 #include <linux/atmlec.h>
107 #include <linux/atmmpc.h>
108 #include <linux/atmsvc.h>
109 #include <linux/atm_tcp.h>
110 #include <linux/sonet.h>
111 #include <linux/atm_suni.h>
112 #include <linux/mtd/mtd.h>
114 #include <linux/usb.h>
115 #include <linux/usbdevice_fs.h>
116 #include <linux/nbd.h>
117 #include <linux/random.h>
118 #include <linux/filter.h>
119 #include <linux/msdos_fs.h>
120 #include <linux/pktcdvd.h>
122 #include <linux/hiddev.h>
124 #include <linux/dvb/audio.h>
125 #include <linux/dvb/dmx.h>
126 #include <linux/dvb/frontend.h>
127 #include <linux/dvb/video.h>
129 #undef INCLUDES
130 #endif
132 #ifdef CODE
134 /* Aiee. Someone does not find a difference between int and long */
135 #define EXT2_IOC32_GETFLAGS _IOR('f', 1, int)
136 #define EXT2_IOC32_SETFLAGS _IOW('f', 2, int)
137 #define EXT2_IOC32_GETVERSION _IOR('v', 1, int)
138 #define EXT2_IOC32_SETVERSION _IOW('v', 2, int)
140 static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
142 mm_segment_t old_fs = get_fs();
143 int err;
144 unsigned long val;
146 set_fs (KERNEL_DS);
147 err = sys_ioctl(fd, cmd, (unsigned long)&val);
148 set_fs (old_fs);
149 if (!err && put_user(val, (u32 __user *)compat_ptr(arg)))
150 return -EFAULT;
151 return err;
154 static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg)
156 mm_segment_t old_fs = get_fs();
157 u32 __user *argptr = compat_ptr(arg);
158 int err;
159 unsigned long val;
161 if(get_user(val, argptr))
162 return -EFAULT;
163 set_fs (KERNEL_DS);
164 err = sys_ioctl(fd, cmd, (unsigned long)&val);
165 set_fs (old_fs);
166 if (!err && put_user(val, argptr))
167 return -EFAULT;
168 return err;
171 static int do_ext2_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
173 /* These are just misnamed, they actually get/put from/to user an int */
174 switch (cmd) {
175 case EXT2_IOC32_GETFLAGS: cmd = EXT2_IOC_GETFLAGS; break;
176 case EXT2_IOC32_SETFLAGS: cmd = EXT2_IOC_SETFLAGS; break;
177 case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; break;
178 case EXT2_IOC32_SETVERSION: cmd = EXT2_IOC_SETVERSION; break;
180 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
183 struct video_tuner32 {
184 compat_int_t tuner;
185 char name[32];
186 compat_ulong_t rangelow, rangehigh;
187 u32 flags; /* It is really u32 in videodev.h */
188 u16 mode, signal;
191 static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up)
193 int i;
195 if(get_user(kp->tuner, &up->tuner))
196 return -EFAULT;
197 for(i = 0; i < 32; i++)
198 __get_user(kp->name[i], &up->name[i]);
199 __get_user(kp->rangelow, &up->rangelow);
200 __get_user(kp->rangehigh, &up->rangehigh);
201 __get_user(kp->flags, &up->flags);
202 __get_user(kp->mode, &up->mode);
203 __get_user(kp->signal, &up->signal);
204 return 0;
207 static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up)
209 int i;
211 if(put_user(kp->tuner, &up->tuner))
212 return -EFAULT;
213 for(i = 0; i < 32; i++)
214 __put_user(kp->name[i], &up->name[i]);
215 __put_user(kp->rangelow, &up->rangelow);
216 __put_user(kp->rangehigh, &up->rangehigh);
217 __put_user(kp->flags, &up->flags);
218 __put_user(kp->mode, &up->mode);
219 __put_user(kp->signal, &up->signal);
220 return 0;
223 struct video_buffer32 {
224 compat_caddr_t base;
225 compat_int_t height, width, depth, bytesperline;
228 static int get_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up)
230 u32 tmp;
232 if (get_user(tmp, &up->base))
233 return -EFAULT;
235 /* This is actually a physical address stored
236 * as a void pointer.
238 kp->base = (void *)(unsigned long) tmp;
240 __get_user(kp->height, &up->height);
241 __get_user(kp->width, &up->width);
242 __get_user(kp->depth, &up->depth);
243 __get_user(kp->bytesperline, &up->bytesperline);
244 return 0;
247 static int put_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up)
249 u32 tmp = (u32)((unsigned long)kp->base);
251 if(put_user(tmp, &up->base))
252 return -EFAULT;
253 __put_user(kp->height, &up->height);
254 __put_user(kp->width, &up->width);
255 __put_user(kp->depth, &up->depth);
256 __put_user(kp->bytesperline, &up->bytesperline);
257 return 0;
260 struct video_clip32 {
261 s32 x, y, width, height; /* Its really s32 in videodev.h */
262 compat_caddr_t next;
265 struct video_window32 {
266 u32 x, y, width, height, chromakey, flags;
267 compat_caddr_t clips;
268 compat_int_t clipcount;
271 /* You get back everything except the clips... */
272 static int put_video_window32(struct video_window *kp, struct video_window32 __user *up)
274 if(put_user(kp->x, &up->x))
275 return -EFAULT;
276 __put_user(kp->y, &up->y);
277 __put_user(kp->width, &up->width);
278 __put_user(kp->height, &up->height);
279 __put_user(kp->chromakey, &up->chromakey);
280 __put_user(kp->flags, &up->flags);
281 __put_user(kp->clipcount, &up->clipcount);
282 return 0;
285 #define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32)
286 #define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32)
287 #define VIDIOCGWIN32 _IOR('v',9, struct video_window32)
288 #define VIDIOCSWIN32 _IOW('v',10, struct video_window32)
289 #define VIDIOCGFBUF32 _IOR('v',11, struct video_buffer32)
290 #define VIDIOCSFBUF32 _IOW('v',12, struct video_buffer32)
291 #define VIDIOCGFREQ32 _IOR('v',14, u32)
292 #define VIDIOCSFREQ32 _IOW('v',15, u32)
294 enum {
295 MaxClips = (~0U-sizeof(struct video_window))/sizeof(struct video_clip)
298 static int do_set_window(unsigned int fd, unsigned int cmd, unsigned long arg)
300 struct video_window32 __user *up = compat_ptr(arg);
301 struct video_window __user *vw;
302 struct video_clip __user *p;
303 int nclips;
304 u32 n;
306 if (get_user(nclips, &up->clipcount))
307 return -EFAULT;
309 /* Peculiar interface... */
310 if (nclips < 0)
311 nclips = VIDEO_CLIPMAP_SIZE;
313 if (nclips > MaxClips)
314 return -ENOMEM;
316 vw = compat_alloc_user_space(sizeof(struct video_window) +
317 nclips * sizeof(struct video_clip));
319 p = nclips ? (struct video_clip __user *)(vw + 1) : NULL;
321 if (get_user(n, &up->x) || put_user(n, &vw->x) ||
322 get_user(n, &up->y) || put_user(n, &vw->y) ||
323 get_user(n, &up->width) || put_user(n, &vw->width) ||
324 get_user(n, &up->height) || put_user(n, &vw->height) ||
325 get_user(n, &up->chromakey) || put_user(n, &vw->chromakey) ||
326 get_user(n, &up->flags) || put_user(n, &vw->flags) ||
327 get_user(n, &up->clipcount) || put_user(n, &vw->clipcount) ||
328 get_user(n, &up->clips) || put_user(p, &vw->clips))
329 return -EFAULT;
331 if (nclips) {
332 struct video_clip32 __user *u = compat_ptr(n);
333 int i;
334 if (!u)
335 return -EINVAL;
336 for (i = 0; i < nclips; i++, u++, p++) {
337 s32 v;
338 if (get_user(v, &u->x) ||
339 put_user(v, &p->x) ||
340 get_user(v, &u->y) ||
341 put_user(v, &p->y) ||
342 get_user(v, &u->width) ||
343 put_user(v, &p->width) ||
344 get_user(v, &u->height) ||
345 put_user(v, &p->height) ||
346 put_user(NULL, &p->next))
347 return -EFAULT;
351 return sys_ioctl(fd, VIDIOCSWIN, (unsigned long)p);
354 static int do_video_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
356 union {
357 struct video_tuner vt;
358 struct video_buffer vb;
359 struct video_window vw;
360 unsigned long vx;
361 } karg;
362 mm_segment_t old_fs = get_fs();
363 void __user *up = compat_ptr(arg);
364 int err = 0;
366 /* First, convert the command. */
367 switch(cmd) {
368 case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break;
369 case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break;
370 case VIDIOCGWIN32: cmd = VIDIOCGWIN; break;
371 case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break;
372 case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break;
373 case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break;
374 case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break;
377 switch(cmd) {
378 case VIDIOCSTUNER:
379 case VIDIOCGTUNER:
380 err = get_video_tuner32(&karg.vt, up);
381 break;
383 case VIDIOCSFBUF:
384 err = get_video_buffer32(&karg.vb, up);
385 break;
387 case VIDIOCSFREQ:
388 err = get_user(karg.vx, (u32 __user *)up);
389 break;
391 if(err)
392 goto out;
394 set_fs(KERNEL_DS);
395 err = sys_ioctl(fd, cmd, (unsigned long)&karg);
396 set_fs(old_fs);
398 if(err == 0) {
399 switch(cmd) {
400 case VIDIOCGTUNER:
401 err = put_video_tuner32(&karg.vt, up);
402 break;
404 case VIDIOCGWIN:
405 err = put_video_window32(&karg.vw, up);
406 break;
408 case VIDIOCGFBUF:
409 err = put_video_buffer32(&karg.vb, up);
410 break;
412 case VIDIOCGFREQ:
413 err = put_user(((u32)karg.vx), (u32 __user *)up);
414 break;
417 out:
418 return err;
421 struct compat_dmx_event {
422 dmx_event_t event;
423 compat_time_t timeStamp;
424 union
426 dmx_scrambling_status_t scrambling;
427 } u;
430 static int do_dmx_get_event(unsigned int fd, unsigned int cmd, unsigned long arg)
432 struct dmx_event kevent;
433 mm_segment_t old_fs = get_fs();
434 int err;
436 set_fs(KERNEL_DS);
437 err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
438 set_fs(old_fs);
440 if (!err) {
441 struct compat_dmx_event __user *up = compat_ptr(arg);
443 err = put_user(kevent.event, &up->event);
444 err |= put_user(kevent.timeStamp, &up->timeStamp);
445 err |= put_user(kevent.u.scrambling, &up->u.scrambling);
446 if (err)
447 err = -EFAULT;
450 return err;
453 struct compat_video_event {
454 int32_t type;
455 compat_time_t timestamp;
456 union {
457 video_size_t size;
458 unsigned int frame_rate;
459 } u;
462 static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long arg)
464 struct video_event kevent;
465 mm_segment_t old_fs = get_fs();
466 int err;
468 set_fs(KERNEL_DS);
469 err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
470 set_fs(old_fs);
472 if (!err) {
473 struct compat_video_event __user *up = compat_ptr(arg);
475 err = put_user(kevent.type, &up->type);
476 err |= put_user(kevent.timestamp, &up->timestamp);
477 err |= put_user(kevent.u.size.w, &up->u.size.w);
478 err |= put_user(kevent.u.size.h, &up->u.size.h);
479 err |= put_user(kevent.u.size.aspect_ratio,
480 &up->u.size.aspect_ratio);
481 if (err)
482 err = -EFAULT;
485 return err;
488 struct compat_video_still_picture {
489 compat_uptr_t iFrame;
490 int32_t size;
493 static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned long arg)
495 struct compat_video_still_picture __user *up;
496 struct video_still_picture __user *up_native;
497 compat_uptr_t fp;
498 int32_t size;
499 int err;
501 up = (struct compat_video_still_picture __user *) arg;
502 err = get_user(fp, &up->iFrame);
503 err |= get_user(size, &up->size);
504 if (err)
505 return -EFAULT;
507 up_native =
508 compat_alloc_user_space(sizeof(struct video_still_picture));
510 put_user(compat_ptr(fp), &up_native->iFrame);
511 put_user(size, &up_native->size);
513 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
515 return err;
518 struct compat_video_spu_palette {
519 int length;
520 compat_uptr_t palette;
523 static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned long arg)
525 struct compat_video_spu_palette __user *up;
526 struct video_spu_palette __user *up_native;
527 compat_uptr_t palp;
528 int length, err;
530 up = (struct compat_video_spu_palette __user *) arg;
531 err = get_user(palp, &up->palette);
532 err |= get_user(length, &up->length);
534 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
535 put_user(compat_ptr(palp), &up_native->palette);
536 put_user(length, &up_native->length);
538 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
540 return err;
543 #ifdef CONFIG_NET
544 static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
546 struct compat_timeval __user *up = compat_ptr(arg);
547 struct timeval ktv;
548 mm_segment_t old_fs = get_fs();
549 int err;
551 set_fs(KERNEL_DS);
552 err = sys_ioctl(fd, cmd, (unsigned long)&ktv);
553 set_fs(old_fs);
554 if(!err) {
555 err = put_user(ktv.tv_sec, &up->tv_sec);
556 err |= __put_user(ktv.tv_usec, &up->tv_usec);
558 return err;
561 struct ifmap32 {
562 compat_ulong_t mem_start;
563 compat_ulong_t mem_end;
564 unsigned short base_addr;
565 unsigned char irq;
566 unsigned char dma;
567 unsigned char port;
570 struct ifreq32 {
571 #define IFHWADDRLEN 6
572 #define IFNAMSIZ 16
573 union {
574 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
575 } ifr_ifrn;
576 union {
577 struct sockaddr ifru_addr;
578 struct sockaddr ifru_dstaddr;
579 struct sockaddr ifru_broadaddr;
580 struct sockaddr ifru_netmask;
581 struct sockaddr ifru_hwaddr;
582 short ifru_flags;
583 compat_int_t ifru_ivalue;
584 compat_int_t ifru_mtu;
585 struct ifmap32 ifru_map;
586 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
587 char ifru_newname[IFNAMSIZ];
588 compat_caddr_t ifru_data;
589 /* XXXX? ifru_settings should be here */
590 } ifr_ifru;
593 struct ifconf32 {
594 compat_int_t ifc_len; /* size of buffer */
595 compat_caddr_t ifcbuf;
598 static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
600 struct net_device *dev;
601 struct ifreq32 ifr32;
602 int err;
604 if (copy_from_user(&ifr32, compat_ptr(arg), sizeof(ifr32)))
605 return -EFAULT;
607 dev = dev_get_by_index(ifr32.ifr_ifindex);
608 if (!dev)
609 return -ENODEV;
611 strlcpy(ifr32.ifr_name, dev->name, sizeof(ifr32.ifr_name));
612 dev_put(dev);
614 err = copy_to_user(compat_ptr(arg), &ifr32, sizeof(ifr32));
615 return (err ? -EFAULT : 0);
618 static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)
620 struct ifconf32 ifc32;
621 struct ifconf ifc;
622 struct ifconf __user *uifc;
623 struct ifreq32 __user *ifr32;
624 struct ifreq __user *ifr;
625 unsigned int i, j;
626 int err;
628 if (copy_from_user(&ifc32, compat_ptr(arg), sizeof(struct ifconf32)))
629 return -EFAULT;
631 if (ifc32.ifcbuf == 0) {
632 ifc32.ifc_len = 0;
633 ifc.ifc_len = 0;
634 ifc.ifc_req = NULL;
635 uifc = compat_alloc_user_space(sizeof(struct ifconf));
636 } else {
637 size_t len =((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) *
638 sizeof (struct ifreq);
639 uifc = compat_alloc_user_space(sizeof(struct ifconf) + len);
640 ifc.ifc_len = len;
641 ifr = ifc.ifc_req = (void __user *)(uifc + 1);
642 ifr32 = compat_ptr(ifc32.ifcbuf);
643 for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) {
644 if (copy_in_user(ifr, ifr32, sizeof(struct ifreq32)))
645 return -EFAULT;
646 ifr++;
647 ifr32++;
650 if (copy_to_user(uifc, &ifc, sizeof(struct ifconf)))
651 return -EFAULT;
653 err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)uifc);
654 if (err)
655 return err;
657 if (copy_from_user(&ifc, uifc, sizeof(struct ifconf)))
658 return -EFAULT;
660 ifr = ifc.ifc_req;
661 ifr32 = compat_ptr(ifc32.ifcbuf);
662 for (i = 0, j = 0; i < ifc32.ifc_len && j < ifc.ifc_len;
663 i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
664 if (copy_in_user(ifr32, ifr, sizeof (struct ifreq32)))
665 return -EFAULT;
666 ifr32++;
667 ifr++;
670 if (ifc32.ifcbuf == 0) {
671 /* Translate from 64-bit structure multiple to
672 * a 32-bit one.
674 i = ifc.ifc_len;
675 i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32));
676 ifc32.ifc_len = i;
677 } else {
678 if (i <= ifc32.ifc_len)
679 ifc32.ifc_len = i;
680 else
681 ifc32.ifc_len = i - sizeof (struct ifreq32);
683 if (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32)))
684 return -EFAULT;
686 return 0;
689 static int ethtool_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
691 struct ifreq __user *ifr;
692 struct ifreq32 __user *ifr32;
693 u32 data;
694 void __user *datap;
696 ifr = compat_alloc_user_space(sizeof(*ifr));
697 ifr32 = compat_ptr(arg);
699 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
700 return -EFAULT;
702 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
703 return -EFAULT;
705 datap = compat_ptr(data);
706 if (put_user(datap, &ifr->ifr_ifru.ifru_data))
707 return -EFAULT;
709 return sys_ioctl(fd, cmd, (unsigned long) ifr);
712 static int bond_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
714 struct ifreq kifr;
715 struct ifreq __user *uifr;
716 struct ifreq32 __user *ifr32 = compat_ptr(arg);
717 mm_segment_t old_fs;
718 int err;
719 u32 data;
720 void __user *datap;
722 switch (cmd) {
723 case SIOCBONDENSLAVE:
724 case SIOCBONDRELEASE:
725 case SIOCBONDSETHWADDR:
726 case SIOCBONDCHANGEACTIVE:
727 if (copy_from_user(&kifr, ifr32, sizeof(struct ifreq32)))
728 return -EFAULT;
730 old_fs = get_fs();
731 set_fs (KERNEL_DS);
732 err = sys_ioctl (fd, cmd, (unsigned long)&kifr);
733 set_fs (old_fs);
735 return err;
736 case SIOCBONDSLAVEINFOQUERY:
737 case SIOCBONDINFOQUERY:
738 uifr = compat_alloc_user_space(sizeof(*uifr));
739 if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
740 return -EFAULT;
742 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
743 return -EFAULT;
745 datap = compat_ptr(data);
746 if (put_user(datap, &uifr->ifr_ifru.ifru_data))
747 return -EFAULT;
749 return sys_ioctl (fd, cmd, (unsigned long)uifr);
750 default:
751 return -EINVAL;
755 int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
757 struct ifreq __user *u_ifreq64;
758 struct ifreq32 __user *u_ifreq32 = compat_ptr(arg);
759 char tmp_buf[IFNAMSIZ];
760 void __user *data64;
761 u32 data32;
763 if (copy_from_user(&tmp_buf[0], &(u_ifreq32->ifr_ifrn.ifrn_name[0]),
764 IFNAMSIZ))
765 return -EFAULT;
766 if (__get_user(data32, &u_ifreq32->ifr_ifru.ifru_data))
767 return -EFAULT;
768 data64 = compat_ptr(data32);
770 u_ifreq64 = compat_alloc_user_space(sizeof(*u_ifreq64));
772 /* Don't check these user accesses, just let that get trapped
773 * in the ioctl handler instead.
775 if (copy_to_user(&u_ifreq64->ifr_ifrn.ifrn_name[0], &tmp_buf[0],
776 IFNAMSIZ))
777 return -EFAULT;
778 if (__put_user(data64, &u_ifreq64->ifr_ifru.ifru_data))
779 return -EFAULT;
781 return sys_ioctl(fd, cmd, (unsigned long) u_ifreq64);
784 static int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg)
786 struct ifreq ifr;
787 struct ifreq32 __user *uifr32;
788 struct ifmap32 __user *uifmap32;
789 mm_segment_t old_fs;
790 int err;
792 uifr32 = compat_ptr(arg);
793 uifmap32 = &uifr32->ifr_ifru.ifru_map;
794 switch (cmd) {
795 case SIOCSIFMAP:
796 err = copy_from_user(&ifr, uifr32, sizeof(ifr.ifr_name));
797 err |= __get_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
798 err |= __get_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
799 err |= __get_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
800 err |= __get_user(ifr.ifr_map.irq, &uifmap32->irq);
801 err |= __get_user(ifr.ifr_map.dma, &uifmap32->dma);
802 err |= __get_user(ifr.ifr_map.port, &uifmap32->port);
803 if (err)
804 return -EFAULT;
805 break;
806 default:
807 if (copy_from_user(&ifr, uifr32, sizeof(*uifr32)))
808 return -EFAULT;
809 break;
811 old_fs = get_fs();
812 set_fs (KERNEL_DS);
813 err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
814 set_fs (old_fs);
815 if (!err) {
816 switch (cmd) {
817 /* TUNSETIFF is defined as _IOW, it should be _IORW
818 * as the data is copied back to user space, but that
819 * cannot be fixed without breaking all existing apps.
821 case TUNSETIFF:
822 case SIOCGIFFLAGS:
823 case SIOCGIFMETRIC:
824 case SIOCGIFMTU:
825 case SIOCGIFMEM:
826 case SIOCGIFHWADDR:
827 case SIOCGIFINDEX:
828 case SIOCGIFADDR:
829 case SIOCGIFBRDADDR:
830 case SIOCGIFDSTADDR:
831 case SIOCGIFNETMASK:
832 case SIOCGIFTXQLEN:
833 if (copy_to_user(uifr32, &ifr, sizeof(*uifr32)))
834 return -EFAULT;
835 break;
836 case SIOCGIFMAP:
837 err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name));
838 err |= __put_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
839 err |= __put_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
840 err |= __put_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
841 err |= __put_user(ifr.ifr_map.irq, &uifmap32->irq);
842 err |= __put_user(ifr.ifr_map.dma, &uifmap32->dma);
843 err |= __put_user(ifr.ifr_map.port, &uifmap32->port);
844 if (err)
845 err = -EFAULT;
846 break;
849 return err;
852 struct rtentry32 {
853 u32 rt_pad1;
854 struct sockaddr rt_dst; /* target address */
855 struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
856 struct sockaddr rt_genmask; /* target network mask (IP) */
857 unsigned short rt_flags;
858 short rt_pad2;
859 u32 rt_pad3;
860 unsigned char rt_tos;
861 unsigned char rt_class;
862 short rt_pad4;
863 short rt_metric; /* +1 for binary compatibility! */
864 /* char * */ u32 rt_dev; /* forcing the device at add */
865 u32 rt_mtu; /* per route MTU/Window */
866 u32 rt_window; /* Window clamping */
867 unsigned short rt_irtt; /* Initial RTT */
871 struct in6_rtmsg32 {
872 struct in6_addr rtmsg_dst;
873 struct in6_addr rtmsg_src;
874 struct in6_addr rtmsg_gateway;
875 u32 rtmsg_type;
876 u16 rtmsg_dst_len;
877 u16 rtmsg_src_len;
878 u32 rtmsg_metric;
879 u32 rtmsg_info;
880 u32 rtmsg_flags;
881 s32 rtmsg_ifindex;
884 static int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
886 int ret;
887 void *r = NULL;
888 struct in6_rtmsg r6;
889 struct rtentry r4;
890 char devname[16];
891 u32 rtdev;
892 mm_segment_t old_fs = get_fs();
894 struct socket *mysock = sockfd_lookup(fd, &ret);
896 if (mysock && mysock->sk && mysock->sk->sk_family == AF_INET6) { /* ipv6 */
897 struct in6_rtmsg32 __user *ur6 = compat_ptr(arg);
898 ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst),
899 3 * sizeof(struct in6_addr));
900 ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type));
901 ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len));
902 ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len));
903 ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric));
904 ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info));
905 ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags));
906 ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex));
908 r = (void *) &r6;
909 } else { /* ipv4 */
910 struct rtentry32 __user *ur4 = compat_ptr(arg);
911 ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst),
912 3 * sizeof(struct sockaddr));
913 ret |= __get_user (r4.rt_flags, &(ur4->rt_flags));
914 ret |= __get_user (r4.rt_metric, &(ur4->rt_metric));
915 ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu));
916 ret |= __get_user (r4.rt_window, &(ur4->rt_window));
917 ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt));
918 ret |= __get_user (rtdev, &(ur4->rt_dev));
919 if (rtdev) {
920 ret |= copy_from_user (devname, compat_ptr(rtdev), 15);
921 r4.rt_dev = devname; devname[15] = 0;
922 } else
923 r4.rt_dev = NULL;
925 r = (void *) &r4;
928 if (ret) {
929 ret = -EFAULT;
930 goto out;
933 set_fs (KERNEL_DS);
934 ret = sys_ioctl (fd, cmd, (unsigned long) r);
935 set_fs (old_fs);
937 out:
938 if (mysock)
939 sockfd_put(mysock);
941 return ret;
943 #endif
945 struct hd_geometry32 {
946 unsigned char heads;
947 unsigned char sectors;
948 unsigned short cylinders;
949 u32 start;
952 static int hdio_getgeo(unsigned int fd, unsigned int cmd, unsigned long arg)
954 mm_segment_t old_fs = get_fs();
955 struct hd_geometry geo;
956 struct hd_geometry32 __user *ugeo;
957 int err;
959 set_fs (KERNEL_DS);
960 err = sys_ioctl(fd, HDIO_GETGEO, (unsigned long)&geo);
961 set_fs (old_fs);
962 ugeo = compat_ptr(arg);
963 if (!err) {
964 err = copy_to_user (ugeo, &geo, 4);
965 err |= __put_user (geo.start, &ugeo->start);
967 return err ? -EFAULT : 0;
970 static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
972 mm_segment_t old_fs = get_fs();
973 unsigned long kval;
974 unsigned int __user *uvp;
975 int error;
977 set_fs(KERNEL_DS);
978 error = sys_ioctl(fd, cmd, (long)&kval);
979 set_fs(old_fs);
981 if(error == 0) {
982 uvp = compat_ptr(arg);
983 if(put_user(kval, uvp))
984 error = -EFAULT;
986 return error;
990 typedef struct sg_io_hdr32 {
991 compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */
992 compat_int_t dxfer_direction; /* [i] data transfer direction */
993 unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
994 unsigned char mx_sb_len; /* [i] max length to write to sbp */
995 unsigned short iovec_count; /* [i] 0 implies no scatter gather */
996 compat_uint_t dxfer_len; /* [i] byte count of data transfer */
997 compat_uint_t dxferp; /* [i], [*io] points to data transfer memory
998 or scatter gather list */
999 compat_uptr_t cmdp; /* [i], [*i] points to command to perform */
1000 compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */
1001 compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
1002 compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */
1003 compat_int_t pack_id; /* [i->o] unused internally (normally) */
1004 compat_uptr_t usr_ptr; /* [i->o] unused internally */
1005 unsigned char status; /* [o] scsi status */
1006 unsigned char masked_status; /* [o] shifted, masked scsi status */
1007 unsigned char msg_status; /* [o] messaging level data (optional) */
1008 unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
1009 unsigned short host_status; /* [o] errors from host adapter */
1010 unsigned short driver_status; /* [o] errors from software driver */
1011 compat_int_t resid; /* [o] dxfer_len - actual_transferred */
1012 compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */
1013 compat_uint_t info; /* [o] auxiliary information */
1014 } sg_io_hdr32_t; /* 64 bytes long (on sparc32) */
1016 typedef struct sg_iovec32 {
1017 compat_uint_t iov_base;
1018 compat_uint_t iov_len;
1019 } sg_iovec32_t;
1021 static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count)
1023 sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1);
1024 sg_iovec32_t __user *iov32 = dxferp;
1025 int i;
1027 for (i = 0; i < iovec_count; i++) {
1028 u32 base, len;
1030 if (get_user(base, &iov32[i].iov_base) ||
1031 get_user(len, &iov32[i].iov_len) ||
1032 put_user(compat_ptr(base), &iov[i].iov_base) ||
1033 put_user(len, &iov[i].iov_len))
1034 return -EFAULT;
1037 if (put_user(iov, &sgio->dxferp))
1038 return -EFAULT;
1039 return 0;
1042 static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1044 sg_io_hdr_t __user *sgio;
1045 sg_io_hdr32_t __user *sgio32;
1046 u16 iovec_count;
1047 u32 data;
1048 void __user *dxferp;
1049 int err;
1051 sgio32 = compat_ptr(arg);
1052 if (get_user(iovec_count, &sgio32->iovec_count))
1053 return -EFAULT;
1056 void __user *top = compat_alloc_user_space(0);
1057 void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) +
1058 (iovec_count * sizeof(sg_iovec_t)));
1059 if (new > top)
1060 return -EINVAL;
1062 sgio = new;
1065 /* Ok, now construct. */
1066 if (copy_in_user(&sgio->interface_id, &sgio32->interface_id,
1067 (2 * sizeof(int)) +
1068 (2 * sizeof(unsigned char)) +
1069 (1 * sizeof(unsigned short)) +
1070 (1 * sizeof(unsigned int))))
1071 return -EFAULT;
1073 if (get_user(data, &sgio32->dxferp))
1074 return -EFAULT;
1075 dxferp = compat_ptr(data);
1076 if (iovec_count) {
1077 if (sg_build_iovec(sgio, dxferp, iovec_count))
1078 return -EFAULT;
1079 } else {
1080 if (put_user(dxferp, &sgio->dxferp))
1081 return -EFAULT;
1085 unsigned char __user *cmdp;
1086 unsigned char __user *sbp;
1088 if (get_user(data, &sgio32->cmdp))
1089 return -EFAULT;
1090 cmdp = compat_ptr(data);
1092 if (get_user(data, &sgio32->sbp))
1093 return -EFAULT;
1094 sbp = compat_ptr(data);
1096 if (put_user(cmdp, &sgio->cmdp) ||
1097 put_user(sbp, &sgio->sbp))
1098 return -EFAULT;
1101 if (copy_in_user(&sgio->timeout, &sgio32->timeout,
1102 3 * sizeof(int)))
1103 return -EFAULT;
1105 if (get_user(data, &sgio32->usr_ptr))
1106 return -EFAULT;
1107 if (put_user(compat_ptr(data), &sgio->usr_ptr))
1108 return -EFAULT;
1110 if (copy_in_user(&sgio->status, &sgio32->status,
1111 (4 * sizeof(unsigned char)) +
1112 (2 * sizeof(unsigned (short))) +
1113 (3 * sizeof(int))))
1114 return -EFAULT;
1116 err = sys_ioctl(fd, cmd, (unsigned long) sgio);
1118 if (err >= 0) {
1119 void __user *datap;
1121 if (copy_in_user(&sgio32->pack_id, &sgio->pack_id,
1122 sizeof(int)) ||
1123 get_user(datap, &sgio->usr_ptr) ||
1124 put_user((u32)(unsigned long)datap,
1125 &sgio32->usr_ptr) ||
1126 copy_in_user(&sgio32->status, &sgio->status,
1127 (4 * sizeof(unsigned char)) +
1128 (2 * sizeof(unsigned short)) +
1129 (3 * sizeof(int))))
1130 err = -EFAULT;
1133 return err;
1136 struct sock_fprog32 {
1137 unsigned short len;
1138 compat_caddr_t filter;
1141 #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
1142 #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
1144 static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1146 struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg);
1147 struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
1148 void __user *fptr64;
1149 u32 fptr32;
1150 u16 flen;
1152 if (get_user(flen, &u_fprog32->len) ||
1153 get_user(fptr32, &u_fprog32->filter))
1154 return -EFAULT;
1156 fptr64 = compat_ptr(fptr32);
1158 if (put_user(flen, &u_fprog64->len) ||
1159 put_user(fptr64, &u_fprog64->filter))
1160 return -EFAULT;
1162 if (cmd == PPPIOCSPASS32)
1163 cmd = PPPIOCSPASS;
1164 else
1165 cmd = PPPIOCSACTIVE;
1167 return sys_ioctl(fd, cmd, (unsigned long) u_fprog64);
1170 struct ppp_option_data32 {
1171 compat_caddr_t ptr;
1172 u32 length;
1173 compat_int_t transmit;
1175 #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
1177 struct ppp_idle32 {
1178 compat_time_t xmit_idle;
1179 compat_time_t recv_idle;
1181 #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
1183 static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg)
1185 struct ppp_idle __user *idle;
1186 struct ppp_idle32 __user *idle32;
1187 __kernel_time_t xmit, recv;
1188 int err;
1190 idle = compat_alloc_user_space(sizeof(*idle));
1191 idle32 = compat_ptr(arg);
1193 err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle);
1195 if (!err) {
1196 if (get_user(xmit, &idle->xmit_idle) ||
1197 get_user(recv, &idle->recv_idle) ||
1198 put_user(xmit, &idle32->xmit_idle) ||
1199 put_user(recv, &idle32->recv_idle))
1200 err = -EFAULT;
1202 return err;
1205 static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg)
1207 struct ppp_option_data __user *odata;
1208 struct ppp_option_data32 __user *odata32;
1209 __u32 data;
1210 void __user *datap;
1212 odata = compat_alloc_user_space(sizeof(*odata));
1213 odata32 = compat_ptr(arg);
1215 if (get_user(data, &odata32->ptr))
1216 return -EFAULT;
1218 datap = compat_ptr(data);
1219 if (put_user(datap, &odata->ptr))
1220 return -EFAULT;
1222 if (copy_in_user(&odata->length, &odata32->length,
1223 sizeof(__u32) + sizeof(int)))
1224 return -EFAULT;
1226 return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata);
1229 static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1231 int err;
1233 switch (cmd) {
1234 case PPPIOCGIDLE32:
1235 err = ppp_gidle(fd, cmd, arg);
1236 break;
1238 case PPPIOCSCOMPRESS32:
1239 err = ppp_scompress(fd, cmd, arg);
1240 break;
1242 default:
1243 do {
1244 static int count;
1245 if (++count <= 20)
1246 printk("ppp_ioctl: Unknown cmd fd(%d) "
1247 "cmd(%08x) arg(%08x)\n",
1248 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1249 } while(0);
1250 err = -EINVAL;
1251 break;
1254 return err;
1258 struct mtget32 {
1259 compat_long_t mt_type;
1260 compat_long_t mt_resid;
1261 compat_long_t mt_dsreg;
1262 compat_long_t mt_gstat;
1263 compat_long_t mt_erreg;
1264 compat_daddr_t mt_fileno;
1265 compat_daddr_t mt_blkno;
1267 #define MTIOCGET32 _IOR('m', 2, struct mtget32)
1269 struct mtpos32 {
1270 compat_long_t mt_blkno;
1272 #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
1274 static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1276 mm_segment_t old_fs = get_fs();
1277 struct mtget get;
1278 struct mtget32 __user *umget32;
1279 struct mtpos pos;
1280 struct mtpos32 __user *upos32;
1281 unsigned long kcmd;
1282 void *karg;
1283 int err = 0;
1285 switch(cmd) {
1286 case MTIOCPOS32:
1287 kcmd = MTIOCPOS;
1288 karg = &pos;
1289 break;
1290 case MTIOCGET32:
1291 kcmd = MTIOCGET;
1292 karg = &get;
1293 break;
1294 default:
1295 do {
1296 static int count;
1297 if (++count <= 20)
1298 printk("mt_ioctl: Unknown cmd fd(%d) "
1299 "cmd(%08x) arg(%08x)\n",
1300 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1301 } while(0);
1302 return -EINVAL;
1304 set_fs (KERNEL_DS);
1305 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1306 set_fs (old_fs);
1307 if (err)
1308 return err;
1309 switch (cmd) {
1310 case MTIOCPOS32:
1311 upos32 = compat_ptr(arg);
1312 err = __put_user(pos.mt_blkno, &upos32->mt_blkno);
1313 break;
1314 case MTIOCGET32:
1315 umget32 = compat_ptr(arg);
1316 err = __put_user(get.mt_type, &umget32->mt_type);
1317 err |= __put_user(get.mt_resid, &umget32->mt_resid);
1318 err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg);
1319 err |= __put_user(get.mt_gstat, &umget32->mt_gstat);
1320 err |= __put_user(get.mt_erreg, &umget32->mt_erreg);
1321 err |= __put_user(get.mt_fileno, &umget32->mt_fileno);
1322 err |= __put_user(get.mt_blkno, &umget32->mt_blkno);
1323 break;
1325 return err ? -EFAULT: 0;
1328 struct cdrom_read_audio32 {
1329 union cdrom_addr addr;
1330 u8 addr_format;
1331 compat_int_t nframes;
1332 compat_caddr_t buf;
1335 struct cdrom_generic_command32 {
1336 unsigned char cmd[CDROM_PACKET_SIZE];
1337 compat_caddr_t buffer;
1338 compat_uint_t buflen;
1339 compat_int_t stat;
1340 compat_caddr_t sense;
1341 unsigned char data_direction;
1342 compat_int_t quiet;
1343 compat_int_t timeout;
1344 compat_caddr_t reserved[1];
1347 static int cdrom_do_read_audio(unsigned int fd, unsigned int cmd, unsigned long arg)
1349 struct cdrom_read_audio __user *cdread_audio;
1350 struct cdrom_read_audio32 __user *cdread_audio32;
1351 __u32 data;
1352 void __user *datap;
1354 cdread_audio = compat_alloc_user_space(sizeof(*cdread_audio));
1355 cdread_audio32 = compat_ptr(arg);
1357 if (copy_in_user(&cdread_audio->addr,
1358 &cdread_audio32->addr,
1359 (sizeof(*cdread_audio32) -
1360 sizeof(compat_caddr_t))))
1361 return -EFAULT;
1363 if (get_user(data, &cdread_audio32->buf))
1364 return -EFAULT;
1365 datap = compat_ptr(data);
1366 if (put_user(datap, &cdread_audio->buf))
1367 return -EFAULT;
1369 return sys_ioctl(fd, cmd, (unsigned long) cdread_audio);
1372 static int cdrom_do_generic_command(unsigned int fd, unsigned int cmd, unsigned long arg)
1374 struct cdrom_generic_command __user *cgc;
1375 struct cdrom_generic_command32 __user *cgc32;
1376 u32 data;
1377 unsigned char dir;
1378 int itmp;
1380 cgc = compat_alloc_user_space(sizeof(*cgc));
1381 cgc32 = compat_ptr(arg);
1383 if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) ||
1384 get_user(data, &cgc32->buffer) ||
1385 put_user(compat_ptr(data), &cgc->buffer) ||
1386 copy_in_user(&cgc->buflen, &cgc32->buflen,
1387 (sizeof(unsigned int) + sizeof(int))) ||
1388 get_user(data, &cgc32->sense) ||
1389 put_user(compat_ptr(data), &cgc->sense) ||
1390 get_user(dir, &cgc32->data_direction) ||
1391 put_user(dir, &cgc->data_direction) ||
1392 get_user(itmp, &cgc32->quiet) ||
1393 put_user(itmp, &cgc->quiet) ||
1394 get_user(itmp, &cgc32->timeout) ||
1395 put_user(itmp, &cgc->timeout) ||
1396 get_user(data, &cgc32->reserved[0]) ||
1397 put_user(compat_ptr(data), &cgc->reserved[0]))
1398 return -EFAULT;
1400 return sys_ioctl(fd, cmd, (unsigned long) cgc);
1403 static int cdrom_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1405 int err;
1407 switch(cmd) {
1408 case CDROMREADAUDIO:
1409 err = cdrom_do_read_audio(fd, cmd, arg);
1410 break;
1412 case CDROM_SEND_PACKET:
1413 err = cdrom_do_generic_command(fd, cmd, arg);
1414 break;
1416 default:
1417 do {
1418 static int count;
1419 if (++count <= 20)
1420 printk("cdrom_ioctl: Unknown cmd fd(%d) "
1421 "cmd(%08x) arg(%08x)\n",
1422 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1423 } while(0);
1424 err = -EINVAL;
1425 break;
1428 return err;
1431 struct loop_info32 {
1432 compat_int_t lo_number; /* ioctl r/o */
1433 compat_dev_t lo_device; /* ioctl r/o */
1434 compat_ulong_t lo_inode; /* ioctl r/o */
1435 compat_dev_t lo_rdevice; /* ioctl r/o */
1436 compat_int_t lo_offset;
1437 compat_int_t lo_encrypt_type;
1438 compat_int_t lo_encrypt_key_size; /* ioctl w/o */
1439 compat_int_t lo_flags; /* ioctl r/o */
1440 char lo_name[LO_NAME_SIZE];
1441 unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
1442 compat_ulong_t lo_init[2];
1443 char reserved[4];
1446 static int loop_status(unsigned int fd, unsigned int cmd, unsigned long arg)
1448 mm_segment_t old_fs = get_fs();
1449 struct loop_info l;
1450 struct loop_info32 __user *ul;
1451 int err = -EINVAL;
1453 ul = compat_ptr(arg);
1454 switch(cmd) {
1455 case LOOP_SET_STATUS:
1456 err = get_user(l.lo_number, &ul->lo_number);
1457 err |= __get_user(l.lo_device, &ul->lo_device);
1458 err |= __get_user(l.lo_inode, &ul->lo_inode);
1459 err |= __get_user(l.lo_rdevice, &ul->lo_rdevice);
1460 err |= __copy_from_user(&l.lo_offset, &ul->lo_offset,
1461 8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1462 if (err) {
1463 err = -EFAULT;
1464 } else {
1465 set_fs (KERNEL_DS);
1466 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1467 set_fs (old_fs);
1469 break;
1470 case LOOP_GET_STATUS:
1471 set_fs (KERNEL_DS);
1472 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1473 set_fs (old_fs);
1474 if (!err) {
1475 err = put_user(l.lo_number, &ul->lo_number);
1476 err |= __put_user(l.lo_device, &ul->lo_device);
1477 err |= __put_user(l.lo_inode, &ul->lo_inode);
1478 err |= __put_user(l.lo_rdevice, &ul->lo_rdevice);
1479 err |= __copy_to_user(&ul->lo_offset, &l.lo_offset,
1480 (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1481 if (err)
1482 err = -EFAULT;
1484 break;
1485 default: {
1486 static int count;
1487 if (++count <= 20)
1488 printk("%s: Unknown loop ioctl cmd, fd(%d) "
1489 "cmd(%08x) arg(%08lx)\n",
1490 __FUNCTION__, fd, cmd, arg);
1493 return err;
1496 extern int tty_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg);
1498 #ifdef CONFIG_VT
1500 static int vt_check(struct file *file)
1502 struct tty_struct *tty;
1503 struct inode *inode = file->f_dentry->d_inode;
1505 if (file->f_op->ioctl != tty_ioctl)
1506 return -EINVAL;
1508 tty = (struct tty_struct *)file->private_data;
1509 if (tty_paranoia_check(tty, inode, "tty_ioctl"))
1510 return -EINVAL;
1512 if (tty->driver->ioctl != vt_ioctl)
1513 return -EINVAL;
1516 * To have permissions to do most of the vt ioctls, we either have
1517 * to be the owner of the tty, or super-user.
1519 if (current->signal->tty == tty || capable(CAP_SYS_ADMIN))
1520 return 1;
1521 return 0;
1524 struct consolefontdesc32 {
1525 unsigned short charcount; /* characters in font (256 or 512) */
1526 unsigned short charheight; /* scan lines per character (1-32) */
1527 compat_caddr_t chardata; /* font data in expanded form */
1530 static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1532 struct consolefontdesc32 __user *user_cfd = compat_ptr(arg);
1533 struct console_font_op op;
1534 compat_caddr_t data;
1535 int i, perm;
1537 perm = vt_check(file);
1538 if (perm < 0) return perm;
1540 switch (cmd) {
1541 case PIO_FONTX:
1542 if (!perm)
1543 return -EPERM;
1544 op.op = KD_FONT_OP_SET;
1545 op.flags = 0;
1546 op.width = 8;
1547 if (get_user(op.height, &user_cfd->charheight) ||
1548 get_user(op.charcount, &user_cfd->charcount) ||
1549 get_user(data, &user_cfd->chardata))
1550 return -EFAULT;
1551 op.data = compat_ptr(data);
1552 return con_font_op(vc_cons[fg_console].d, &op);
1553 case GIO_FONTX:
1554 op.op = KD_FONT_OP_GET;
1555 op.flags = 0;
1556 op.width = 8;
1557 if (get_user(op.height, &user_cfd->charheight) ||
1558 get_user(op.charcount, &user_cfd->charcount) ||
1559 get_user(data, &user_cfd->chardata))
1560 return -EFAULT;
1561 if (!data)
1562 return 0;
1563 op.data = compat_ptr(data);
1564 i = con_font_op(vc_cons[fg_console].d, &op);
1565 if (i)
1566 return i;
1567 if (put_user(op.height, &user_cfd->charheight) ||
1568 put_user(op.charcount, &user_cfd->charcount) ||
1569 put_user((compat_caddr_t)(unsigned long)op.data,
1570 &user_cfd->chardata))
1571 return -EFAULT;
1572 return 0;
1574 return -EINVAL;
1577 struct console_font_op32 {
1578 compat_uint_t op; /* operation code KD_FONT_OP_* */
1579 compat_uint_t flags; /* KD_FONT_FLAG_* */
1580 compat_uint_t width, height; /* font size */
1581 compat_uint_t charcount;
1582 compat_caddr_t data; /* font data with height fixed to 32 */
1585 static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1587 struct console_font_op op;
1588 struct console_font_op32 __user *fontop = compat_ptr(arg);
1589 int perm = vt_check(file), i;
1590 struct vc_data *vc;
1592 if (perm < 0) return perm;
1594 if (copy_from_user(&op, fontop, sizeof(struct console_font_op32)))
1595 return -EFAULT;
1596 if (!perm && op.op != KD_FONT_OP_GET)
1597 return -EPERM;
1598 op.data = compat_ptr(((struct console_font_op32 *)&op)->data);
1599 op.flags |= KD_FONT_FLAG_OLD;
1600 vc = ((struct tty_struct *)file->private_data)->driver_data;
1601 i = con_font_op(vc, &op);
1602 if (i)
1603 return i;
1604 ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
1605 if (copy_to_user(fontop, &op, sizeof(struct console_font_op32)))
1606 return -EFAULT;
1607 return 0;
1610 struct unimapdesc32 {
1611 unsigned short entry_ct;
1612 compat_caddr_t entries;
1615 static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1617 struct unimapdesc32 tmp;
1618 struct unimapdesc32 __user *user_ud = compat_ptr(arg);
1619 int perm = vt_check(file);
1621 if (perm < 0) return perm;
1622 if (copy_from_user(&tmp, user_ud, sizeof tmp))
1623 return -EFAULT;
1624 switch (cmd) {
1625 case PIO_UNIMAP:
1626 if (!perm) return -EPERM;
1627 return con_set_unimap(vc_cons[fg_console].d, tmp.entry_ct, compat_ptr(tmp.entries));
1628 case GIO_UNIMAP:
1629 return con_get_unimap(vc_cons[fg_console].d, tmp.entry_ct, &(user_ud->entry_ct), compat_ptr(tmp.entries));
1631 return 0;
1634 #endif /* CONFIG_VT */
1636 static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg)
1638 mm_segment_t old_fs = get_fs();
1639 __kernel_uid_t kuid;
1640 int err;
1642 cmd = SMB_IOC_GETMOUNTUID;
1644 set_fs(KERNEL_DS);
1645 err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
1646 set_fs(old_fs);
1648 if (err >= 0)
1649 err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg));
1651 return err;
1654 struct atmif_sioc32 {
1655 compat_int_t number;
1656 compat_int_t length;
1657 compat_caddr_t arg;
1660 struct atm_iobuf32 {
1661 compat_int_t length;
1662 compat_caddr_t buffer;
1665 #define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32)
1666 #define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32)
1667 #define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32)
1668 #define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32)
1669 #define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32)
1670 #define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32)
1671 #define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32)
1672 #define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32)
1673 #define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32)
1674 #define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32)
1675 #define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32)
1676 #define ATM_SETESIF32 _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32)
1677 #define ATM_GETSTAT32 _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32)
1678 #define ATM_GETSTATZ32 _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32)
1679 #define ATM_GETLOOP32 _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32)
1680 #define ATM_SETLOOP32 _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32)
1681 #define ATM_QUERYLOOP32 _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32)
1683 static struct {
1684 unsigned int cmd32;
1685 unsigned int cmd;
1686 } atm_ioctl_map[] = {
1687 { ATM_GETLINKRATE32, ATM_GETLINKRATE },
1688 { ATM_GETNAMES32, ATM_GETNAMES },
1689 { ATM_GETTYPE32, ATM_GETTYPE },
1690 { ATM_GETESI32, ATM_GETESI },
1691 { ATM_GETADDR32, ATM_GETADDR },
1692 { ATM_RSTADDR32, ATM_RSTADDR },
1693 { ATM_ADDADDR32, ATM_ADDADDR },
1694 { ATM_DELADDR32, ATM_DELADDR },
1695 { ATM_GETCIRANGE32, ATM_GETCIRANGE },
1696 { ATM_SETCIRANGE32, ATM_SETCIRANGE },
1697 { ATM_SETESI32, ATM_SETESI },
1698 { ATM_SETESIF32, ATM_SETESIF },
1699 { ATM_GETSTAT32, ATM_GETSTAT },
1700 { ATM_GETSTATZ32, ATM_GETSTATZ },
1701 { ATM_GETLOOP32, ATM_GETLOOP },
1702 { ATM_SETLOOP32, ATM_SETLOOP },
1703 { ATM_QUERYLOOP32, ATM_QUERYLOOP }
1706 #define NR_ATM_IOCTL (sizeof(atm_ioctl_map)/sizeof(atm_ioctl_map[0]))
1709 static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg)
1711 struct atm_iobuf __user *iobuf;
1712 struct atm_iobuf32 __user *iobuf32;
1713 u32 data;
1714 void __user *datap;
1715 int len, err;
1717 iobuf = compat_alloc_user_space(sizeof(*iobuf));
1718 iobuf32 = compat_ptr(arg);
1720 if (get_user(len, &iobuf32->length) ||
1721 get_user(data, &iobuf32->buffer))
1722 return -EFAULT;
1723 datap = compat_ptr(data);
1724 if (put_user(len, &iobuf->length) ||
1725 put_user(datap, &iobuf->buffer))
1726 return -EFAULT;
1728 err = sys_ioctl(fd, cmd, (unsigned long)iobuf);
1730 if (!err) {
1731 if (copy_in_user(&iobuf32->length, &iobuf->length,
1732 sizeof(int)))
1733 err = -EFAULT;
1736 return err;
1739 static int do_atmif_sioc(unsigned int fd, unsigned int cmd, unsigned long arg)
1741 struct atmif_sioc __user *sioc;
1742 struct atmif_sioc32 __user *sioc32;
1743 u32 data;
1744 void __user *datap;
1745 int err;
1747 sioc = compat_alloc_user_space(sizeof(*sioc));
1748 sioc32 = compat_ptr(arg);
1750 if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) ||
1751 get_user(data, &sioc32->arg))
1752 return -EFAULT;
1753 datap = compat_ptr(data);
1754 if (put_user(datap, &sioc->arg))
1755 return -EFAULT;
1757 err = sys_ioctl(fd, cmd, (unsigned long) sioc);
1759 if (!err) {
1760 if (copy_in_user(&sioc32->length, &sioc->length,
1761 sizeof(int)))
1762 err = -EFAULT;
1764 return err;
1767 static int do_atm_ioctl(unsigned int fd, unsigned int cmd32, unsigned long arg)
1769 int i;
1770 unsigned int cmd = 0;
1772 switch (cmd32) {
1773 case SONET_GETSTAT:
1774 case SONET_GETSTATZ:
1775 case SONET_GETDIAG:
1776 case SONET_SETDIAG:
1777 case SONET_CLRDIAG:
1778 case SONET_SETFRAMING:
1779 case SONET_GETFRAMING:
1780 case SONET_GETFRSENSE:
1781 return do_atmif_sioc(fd, cmd32, arg);
1784 for (i = 0; i < NR_ATM_IOCTL; i++) {
1785 if (cmd32 == atm_ioctl_map[i].cmd32) {
1786 cmd = atm_ioctl_map[i].cmd;
1787 break;
1790 if (i == NR_ATM_IOCTL)
1791 return -EINVAL;
1793 switch (cmd) {
1794 case ATM_GETNAMES:
1795 return do_atm_iobuf(fd, cmd, arg);
1797 case ATM_GETLINKRATE:
1798 case ATM_GETTYPE:
1799 case ATM_GETESI:
1800 case ATM_GETADDR:
1801 case ATM_RSTADDR:
1802 case ATM_ADDADDR:
1803 case ATM_DELADDR:
1804 case ATM_GETCIRANGE:
1805 case ATM_SETCIRANGE:
1806 case ATM_SETESI:
1807 case ATM_SETESIF:
1808 case ATM_GETSTAT:
1809 case ATM_GETSTATZ:
1810 case ATM_GETLOOP:
1811 case ATM_SETLOOP:
1812 case ATM_QUERYLOOP:
1813 return do_atmif_sioc(fd, cmd, arg);
1816 return -EINVAL;
1819 static __attribute_used__ int
1820 ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
1822 return -EINVAL;
1825 static int broken_blkgetsize(unsigned int fd, unsigned int cmd, unsigned long arg)
1827 /* The mkswap binary hard codes it to Intel value :-((( */
1828 return w_long(fd, BLKGETSIZE, arg);
1831 struct blkpg_ioctl_arg32 {
1832 compat_int_t op;
1833 compat_int_t flags;
1834 compat_int_t datalen;
1835 compat_caddr_t data;
1838 static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1840 struct blkpg_ioctl_arg32 __user *ua32 = compat_ptr(arg);
1841 struct blkpg_ioctl_arg __user *a = compat_alloc_user_space(sizeof(*a));
1842 compat_caddr_t udata;
1843 compat_int_t n;
1844 int err;
1846 err = get_user(n, &ua32->op);
1847 err |= put_user(n, &a->op);
1848 err |= get_user(n, &ua32->flags);
1849 err |= put_user(n, &a->flags);
1850 err |= get_user(n, &ua32->datalen);
1851 err |= put_user(n, &a->datalen);
1852 err |= get_user(udata, &ua32->data);
1853 err |= put_user(compat_ptr(udata), &a->data);
1854 if (err)
1855 return err;
1857 return sys_ioctl(fd, cmd, (unsigned long)a);
1860 static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
1862 return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
1865 /* Fix sizeof(sizeof()) breakage */
1866 #define BLKBSZGET_32 _IOR(0x12,112,int)
1867 #define BLKBSZSET_32 _IOW(0x12,113,int)
1868 #define BLKGETSIZE64_32 _IOR(0x12,114,int)
1870 static int do_blkbszget(unsigned int fd, unsigned int cmd, unsigned long arg)
1872 return sys_ioctl(fd, BLKBSZGET, (unsigned long)compat_ptr(arg));
1875 static int do_blkbszset(unsigned int fd, unsigned int cmd, unsigned long arg)
1877 return sys_ioctl(fd, BLKBSZSET, (unsigned long)compat_ptr(arg));
1880 static int do_blkgetsize64(unsigned int fd, unsigned int cmd,
1881 unsigned long arg)
1883 return sys_ioctl(fd, BLKGETSIZE64, (unsigned long)compat_ptr(arg));
1886 /* Bluetooth ioctls */
1887 #define HCIUARTSETPROTO _IOW('U', 200, int)
1888 #define HCIUARTGETPROTO _IOR('U', 201, int)
1890 #define BNEPCONNADD _IOW('B', 200, int)
1891 #define BNEPCONNDEL _IOW('B', 201, int)
1892 #define BNEPGETCONNLIST _IOR('B', 210, int)
1893 #define BNEPGETCONNINFO _IOR('B', 211, int)
1895 #define CMTPCONNADD _IOW('C', 200, int)
1896 #define CMTPCONNDEL _IOW('C', 201, int)
1897 #define CMTPGETCONNLIST _IOR('C', 210, int)
1898 #define CMTPGETCONNINFO _IOR('C', 211, int)
1900 #define HIDPCONNADD _IOW('H', 200, int)
1901 #define HIDPCONNDEL _IOW('H', 201, int)
1902 #define HIDPGETCONNLIST _IOR('H', 210, int)
1903 #define HIDPGETCONNINFO _IOR('H', 211, int)
1905 struct floppy_struct32 {
1906 compat_uint_t size;
1907 compat_uint_t sect;
1908 compat_uint_t head;
1909 compat_uint_t track;
1910 compat_uint_t stretch;
1911 unsigned char gap;
1912 unsigned char rate;
1913 unsigned char spec1;
1914 unsigned char fmt_gap;
1915 const compat_caddr_t name;
1918 struct floppy_drive_params32 {
1919 char cmos;
1920 compat_ulong_t max_dtr;
1921 compat_ulong_t hlt;
1922 compat_ulong_t hut;
1923 compat_ulong_t srt;
1924 compat_ulong_t spinup;
1925 compat_ulong_t spindown;
1926 unsigned char spindown_offset;
1927 unsigned char select_delay;
1928 unsigned char rps;
1929 unsigned char tracks;
1930 compat_ulong_t timeout;
1931 unsigned char interleave_sect;
1932 struct floppy_max_errors max_errors;
1933 char flags;
1934 char read_track;
1935 short autodetect[8];
1936 compat_int_t checkfreq;
1937 compat_int_t native_format;
1940 struct floppy_drive_struct32 {
1941 signed char flags;
1942 compat_ulong_t spinup_date;
1943 compat_ulong_t select_date;
1944 compat_ulong_t first_read_date;
1945 short probed_format;
1946 short track;
1947 short maxblock;
1948 short maxtrack;
1949 compat_int_t generation;
1950 compat_int_t keep_data;
1951 compat_int_t fd_ref;
1952 compat_int_t fd_device;
1953 compat_int_t last_checked;
1954 compat_caddr_t dmabuf;
1955 compat_int_t bufblocks;
1958 struct floppy_fdc_state32 {
1959 compat_int_t spec1;
1960 compat_int_t spec2;
1961 compat_int_t dtr;
1962 unsigned char version;
1963 unsigned char dor;
1964 compat_ulong_t address;
1965 unsigned int rawcmd:2;
1966 unsigned int reset:1;
1967 unsigned int need_configure:1;
1968 unsigned int perp_mode:2;
1969 unsigned int has_fifo:1;
1970 unsigned int driver_version;
1971 unsigned char track[4];
1974 struct floppy_write_errors32 {
1975 unsigned int write_errors;
1976 compat_ulong_t first_error_sector;
1977 compat_int_t first_error_generation;
1978 compat_ulong_t last_error_sector;
1979 compat_int_t last_error_generation;
1980 compat_uint_t badness;
1983 #define FDSETPRM32 _IOW(2, 0x42, struct floppy_struct32)
1984 #define FDDEFPRM32 _IOW(2, 0x43, struct floppy_struct32)
1985 #define FDGETPRM32 _IOR(2, 0x04, struct floppy_struct32)
1986 #define FDSETDRVPRM32 _IOW(2, 0x90, struct floppy_drive_params32)
1987 #define FDGETDRVPRM32 _IOR(2, 0x11, struct floppy_drive_params32)
1988 #define FDGETDRVSTAT32 _IOR(2, 0x12, struct floppy_drive_struct32)
1989 #define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct floppy_drive_struct32)
1990 #define FDGETFDCSTAT32 _IOR(2, 0x15, struct floppy_fdc_state32)
1991 #define FDWERRORGET32 _IOR(2, 0x17, struct floppy_write_errors32)
1993 static struct {
1994 unsigned int cmd32;
1995 unsigned int cmd;
1996 } fd_ioctl_trans_table[] = {
1997 { FDSETPRM32, FDSETPRM },
1998 { FDDEFPRM32, FDDEFPRM },
1999 { FDGETPRM32, FDGETPRM },
2000 { FDSETDRVPRM32, FDSETDRVPRM },
2001 { FDGETDRVPRM32, FDGETDRVPRM },
2002 { FDGETDRVSTAT32, FDGETDRVSTAT },
2003 { FDPOLLDRVSTAT32, FDPOLLDRVSTAT },
2004 { FDGETFDCSTAT32, FDGETFDCSTAT },
2005 { FDWERRORGET32, FDWERRORGET }
2008 #define NR_FD_IOCTL_TRANS (sizeof(fd_ioctl_trans_table)/sizeof(fd_ioctl_trans_table[0]))
2010 static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
2012 mm_segment_t old_fs = get_fs();
2013 void *karg = NULL;
2014 unsigned int kcmd = 0;
2015 int i, err;
2017 for (i = 0; i < NR_FD_IOCTL_TRANS; i++)
2018 if (cmd == fd_ioctl_trans_table[i].cmd32) {
2019 kcmd = fd_ioctl_trans_table[i].cmd;
2020 break;
2022 if (!kcmd)
2023 return -EINVAL;
2025 switch (cmd) {
2026 case FDSETPRM32:
2027 case FDDEFPRM32:
2028 case FDGETPRM32:
2030 compat_uptr_t name;
2031 struct floppy_struct32 __user *uf;
2032 struct floppy_struct *f;
2034 uf = compat_ptr(arg);
2035 f = karg = kmalloc(sizeof(struct floppy_struct), GFP_KERNEL);
2036 if (!karg)
2037 return -ENOMEM;
2038 if (cmd == FDGETPRM32)
2039 break;
2040 err = __get_user(f->size, &uf->size);
2041 err |= __get_user(f->sect, &uf->sect);
2042 err |= __get_user(f->head, &uf->head);
2043 err |= __get_user(f->track, &uf->track);
2044 err |= __get_user(f->stretch, &uf->stretch);
2045 err |= __get_user(f->gap, &uf->gap);
2046 err |= __get_user(f->rate, &uf->rate);
2047 err |= __get_user(f->spec1, &uf->spec1);
2048 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
2049 err |= __get_user(name, &uf->name);
2050 f->name = compat_ptr(name);
2051 if (err) {
2052 err = -EFAULT;
2053 goto out;
2055 break;
2057 case FDSETDRVPRM32:
2058 case FDGETDRVPRM32:
2060 struct floppy_drive_params32 __user *uf;
2061 struct floppy_drive_params *f;
2063 uf = compat_ptr(arg);
2064 f = karg = kmalloc(sizeof(struct floppy_drive_params), GFP_KERNEL);
2065 if (!karg)
2066 return -ENOMEM;
2067 if (cmd == FDGETDRVPRM32)
2068 break;
2069 err = __get_user(f->cmos, &uf->cmos);
2070 err |= __get_user(f->max_dtr, &uf->max_dtr);
2071 err |= __get_user(f->hlt, &uf->hlt);
2072 err |= __get_user(f->hut, &uf->hut);
2073 err |= __get_user(f->srt, &uf->srt);
2074 err |= __get_user(f->spinup, &uf->spinup);
2075 err |= __get_user(f->spindown, &uf->spindown);
2076 err |= __get_user(f->spindown_offset, &uf->spindown_offset);
2077 err |= __get_user(f->select_delay, &uf->select_delay);
2078 err |= __get_user(f->rps, &uf->rps);
2079 err |= __get_user(f->tracks, &uf->tracks);
2080 err |= __get_user(f->timeout, &uf->timeout);
2081 err |= __get_user(f->interleave_sect, &uf->interleave_sect);
2082 err |= __copy_from_user(&f->max_errors, &uf->max_errors, sizeof(f->max_errors));
2083 err |= __get_user(f->flags, &uf->flags);
2084 err |= __get_user(f->read_track, &uf->read_track);
2085 err |= __copy_from_user(f->autodetect, uf->autodetect, sizeof(f->autodetect));
2086 err |= __get_user(f->checkfreq, &uf->checkfreq);
2087 err |= __get_user(f->native_format, &uf->native_format);
2088 if (err) {
2089 err = -EFAULT;
2090 goto out;
2092 break;
2094 case FDGETDRVSTAT32:
2095 case FDPOLLDRVSTAT32:
2096 karg = kmalloc(sizeof(struct floppy_drive_struct), GFP_KERNEL);
2097 if (!karg)
2098 return -ENOMEM;
2099 break;
2100 case FDGETFDCSTAT32:
2101 karg = kmalloc(sizeof(struct floppy_fdc_state), GFP_KERNEL);
2102 if (!karg)
2103 return -ENOMEM;
2104 break;
2105 case FDWERRORGET32:
2106 karg = kmalloc(sizeof(struct floppy_write_errors), GFP_KERNEL);
2107 if (!karg)
2108 return -ENOMEM;
2109 break;
2110 default:
2111 return -EINVAL;
2113 set_fs (KERNEL_DS);
2114 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
2115 set_fs (old_fs);
2116 if (err)
2117 goto out;
2118 switch (cmd) {
2119 case FDGETPRM32:
2121 struct floppy_struct *f = karg;
2122 struct floppy_struct32 __user *uf = compat_ptr(arg);
2124 err = __put_user(f->size, &uf->size);
2125 err |= __put_user(f->sect, &uf->sect);
2126 err |= __put_user(f->head, &uf->head);
2127 err |= __put_user(f->track, &uf->track);
2128 err |= __put_user(f->stretch, &uf->stretch);
2129 err |= __put_user(f->gap, &uf->gap);
2130 err |= __put_user(f->rate, &uf->rate);
2131 err |= __put_user(f->spec1, &uf->spec1);
2132 err |= __put_user(f->fmt_gap, &uf->fmt_gap);
2133 err |= __put_user((u64)f->name, (compat_caddr_t __user *)&uf->name);
2134 break;
2136 case FDGETDRVPRM32:
2138 struct floppy_drive_params32 __user *uf;
2139 struct floppy_drive_params *f = karg;
2141 uf = compat_ptr(arg);
2142 err = __put_user(f->cmos, &uf->cmos);
2143 err |= __put_user(f->max_dtr, &uf->max_dtr);
2144 err |= __put_user(f->hlt, &uf->hlt);
2145 err |= __put_user(f->hut, &uf->hut);
2146 err |= __put_user(f->srt, &uf->srt);
2147 err |= __put_user(f->spinup, &uf->spinup);
2148 err |= __put_user(f->spindown, &uf->spindown);
2149 err |= __put_user(f->spindown_offset, &uf->spindown_offset);
2150 err |= __put_user(f->select_delay, &uf->select_delay);
2151 err |= __put_user(f->rps, &uf->rps);
2152 err |= __put_user(f->tracks, &uf->tracks);
2153 err |= __put_user(f->timeout, &uf->timeout);
2154 err |= __put_user(f->interleave_sect, &uf->interleave_sect);
2155 err |= __copy_to_user(&uf->max_errors, &f->max_errors, sizeof(f->max_errors));
2156 err |= __put_user(f->flags, &uf->flags);
2157 err |= __put_user(f->read_track, &uf->read_track);
2158 err |= __copy_to_user(uf->autodetect, f->autodetect, sizeof(f->autodetect));
2159 err |= __put_user(f->checkfreq, &uf->checkfreq);
2160 err |= __put_user(f->native_format, &uf->native_format);
2161 break;
2163 case FDGETDRVSTAT32:
2164 case FDPOLLDRVSTAT32:
2166 struct floppy_drive_struct32 __user *uf;
2167 struct floppy_drive_struct *f = karg;
2169 uf = compat_ptr(arg);
2170 err = __put_user(f->flags, &uf->flags);
2171 err |= __put_user(f->spinup_date, &uf->spinup_date);
2172 err |= __put_user(f->select_date, &uf->select_date);
2173 err |= __put_user(f->first_read_date, &uf->first_read_date);
2174 err |= __put_user(f->probed_format, &uf->probed_format);
2175 err |= __put_user(f->track, &uf->track);
2176 err |= __put_user(f->maxblock, &uf->maxblock);
2177 err |= __put_user(f->maxtrack, &uf->maxtrack);
2178 err |= __put_user(f->generation, &uf->generation);
2179 err |= __put_user(f->keep_data, &uf->keep_data);
2180 err |= __put_user(f->fd_ref, &uf->fd_ref);
2181 err |= __put_user(f->fd_device, &uf->fd_device);
2182 err |= __put_user(f->last_checked, &uf->last_checked);
2183 err |= __put_user((u64)f->dmabuf, &uf->dmabuf);
2184 err |= __put_user((u64)f->bufblocks, &uf->bufblocks);
2185 break;
2187 case FDGETFDCSTAT32:
2189 struct floppy_fdc_state32 __user *uf;
2190 struct floppy_fdc_state *f = karg;
2192 uf = compat_ptr(arg);
2193 err = __put_user(f->spec1, &uf->spec1);
2194 err |= __put_user(f->spec2, &uf->spec2);
2195 err |= __put_user(f->dtr, &uf->dtr);
2196 err |= __put_user(f->version, &uf->version);
2197 err |= __put_user(f->dor, &uf->dor);
2198 err |= __put_user(f->address, &uf->address);
2199 err |= __copy_to_user((char __user *)&uf->address + sizeof(uf->address),
2200 (char *)&f->address + sizeof(f->address), sizeof(int));
2201 err |= __put_user(f->driver_version, &uf->driver_version);
2202 err |= __copy_to_user(uf->track, f->track, sizeof(f->track));
2203 break;
2205 case FDWERRORGET32:
2207 struct floppy_write_errors32 __user *uf;
2208 struct floppy_write_errors *f = karg;
2210 uf = compat_ptr(arg);
2211 err = __put_user(f->write_errors, &uf->write_errors);
2212 err |= __put_user(f->first_error_sector, &uf->first_error_sector);
2213 err |= __put_user(f->first_error_generation, &uf->first_error_generation);
2214 err |= __put_user(f->last_error_sector, &uf->last_error_sector);
2215 err |= __put_user(f->last_error_generation, &uf->last_error_generation);
2216 err |= __put_user(f->badness, &uf->badness);
2217 break;
2219 default:
2220 break;
2222 if (err)
2223 err = -EFAULT;
2225 out:
2226 kfree(karg);
2227 return err;
2230 struct mtd_oob_buf32 {
2231 u_int32_t start;
2232 u_int32_t length;
2233 compat_caddr_t ptr; /* unsigned char* */
2236 #define MEMWRITEOOB32 _IOWR('M',3,struct mtd_oob_buf32)
2237 #define MEMREADOOB32 _IOWR('M',4,struct mtd_oob_buf32)
2239 static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg)
2241 struct mtd_oob_buf __user *buf = compat_alloc_user_space(sizeof(*buf));
2242 struct mtd_oob_buf32 __user *buf32 = compat_ptr(arg);
2243 u32 data;
2244 char __user *datap;
2245 unsigned int real_cmd;
2246 int err;
2248 real_cmd = (cmd == MEMREADOOB32) ?
2249 MEMREADOOB : MEMWRITEOOB;
2251 if (copy_in_user(&buf->start, &buf32->start,
2252 2 * sizeof(u32)) ||
2253 get_user(data, &buf32->ptr))
2254 return -EFAULT;
2255 datap = compat_ptr(data);
2256 if (put_user(datap, &buf->ptr))
2257 return -EFAULT;
2259 err = sys_ioctl(fd, real_cmd, (unsigned long) buf);
2261 if (!err) {
2262 if (copy_in_user(&buf32->start, &buf->start,
2263 2 * sizeof(u32)))
2264 err = -EFAULT;
2267 return err;
2270 #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
2271 #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
2273 static long
2274 put_dirent32 (struct dirent *d, struct compat_dirent __user *d32)
2276 if (!access_ok(VERIFY_WRITE, d32, sizeof(struct compat_dirent)))
2277 return -EFAULT;
2279 __put_user(d->d_ino, &d32->d_ino);
2280 __put_user(d->d_off, &d32->d_off);
2281 __put_user(d->d_reclen, &d32->d_reclen);
2282 if (__copy_to_user(d32->d_name, d->d_name, d->d_reclen))
2283 return -EFAULT;
2285 return 0;
2288 static int vfat_ioctl32(unsigned fd, unsigned cmd, unsigned long arg)
2290 struct compat_dirent __user *p = compat_ptr(arg);
2291 int ret;
2292 mm_segment_t oldfs = get_fs();
2293 struct dirent d[2];
2295 switch(cmd)
2297 case VFAT_IOCTL_READDIR_BOTH32:
2298 cmd = VFAT_IOCTL_READDIR_BOTH;
2299 break;
2300 case VFAT_IOCTL_READDIR_SHORT32:
2301 cmd = VFAT_IOCTL_READDIR_SHORT;
2302 break;
2305 set_fs(KERNEL_DS);
2306 ret = sys_ioctl(fd,cmd,(unsigned long)&d);
2307 set_fs(oldfs);
2308 if (ret >= 0) {
2309 ret |= put_dirent32(&d[0], p);
2310 ret |= put_dirent32(&d[1], p + 1);
2312 return ret;
2315 #define REISERFS_IOC_UNPACK32 _IOW(0xCD,1,int)
2317 static int reiserfs_ioctl32(unsigned fd, unsigned cmd, unsigned long ptr)
2319 if (cmd == REISERFS_IOC_UNPACK32)
2320 cmd = REISERFS_IOC_UNPACK;
2322 return sys_ioctl(fd,cmd,ptr);
2325 struct raw32_config_request
2327 compat_int_t raw_minor;
2328 __u64 block_major;
2329 __u64 block_minor;
2330 } __attribute__((packed));
2332 static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
2334 int ret;
2336 if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request)))
2337 return -EFAULT;
2339 ret = __get_user(req->raw_minor, &user_req->raw_minor);
2340 ret |= __get_user(req->block_major, &user_req->block_major);
2341 ret |= __get_user(req->block_minor, &user_req->block_minor);
2343 return ret ? -EFAULT : 0;
2346 static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
2348 int ret;
2350 if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request)))
2351 return -EFAULT;
2353 ret = __put_user(req->raw_minor, &user_req->raw_minor);
2354 ret |= __put_user(req->block_major, &user_req->block_major);
2355 ret |= __put_user(req->block_minor, &user_req->block_minor);
2357 return ret ? -EFAULT : 0;
2360 static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2362 int ret;
2364 switch (cmd) {
2365 case RAW_SETBIND:
2366 case RAW_GETBIND: {
2367 struct raw_config_request req;
2368 struct raw32_config_request __user *user_req = compat_ptr(arg);
2369 mm_segment_t oldfs = get_fs();
2371 if ((ret = get_raw32_request(&req, user_req)))
2372 return ret;
2374 set_fs(KERNEL_DS);
2375 ret = sys_ioctl(fd,cmd,(unsigned long)&req);
2376 set_fs(oldfs);
2378 if ((!ret) && (cmd == RAW_GETBIND)) {
2379 ret = set_raw32_request(&req, user_req);
2381 break;
2383 default:
2384 ret = sys_ioctl(fd, cmd, arg);
2385 break;
2387 return ret;
2390 struct serial_struct32 {
2391 compat_int_t type;
2392 compat_int_t line;
2393 compat_uint_t port;
2394 compat_int_t irq;
2395 compat_int_t flags;
2396 compat_int_t xmit_fifo_size;
2397 compat_int_t custom_divisor;
2398 compat_int_t baud_base;
2399 unsigned short close_delay;
2400 char io_type;
2401 char reserved_char[1];
2402 compat_int_t hub6;
2403 unsigned short closing_wait; /* time to wait before closing */
2404 unsigned short closing_wait2; /* no longer used... */
2405 compat_uint_t iomem_base;
2406 unsigned short iomem_reg_shift;
2407 unsigned int port_high;
2408 /* compat_ulong_t iomap_base FIXME */
2409 compat_int_t reserved[1];
2412 static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2414 typedef struct serial_struct SS;
2415 typedef struct serial_struct32 SS32;
2416 struct serial_struct32 __user *ss32 = compat_ptr(arg);
2417 int err;
2418 struct serial_struct ss;
2419 mm_segment_t oldseg = get_fs();
2420 __u32 udata;
2422 if (cmd == TIOCSSERIAL) {
2423 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
2424 return -EFAULT;
2425 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
2426 return -EFAULT;
2427 __get_user(udata, &ss32->iomem_base);
2428 ss.iomem_base = compat_ptr(udata);
2429 __get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift);
2430 __get_user(ss.port_high, &ss32->port_high);
2431 ss.iomap_base = 0UL;
2433 set_fs(KERNEL_DS);
2434 err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
2435 set_fs(oldseg);
2436 if (cmd == TIOCGSERIAL && err >= 0) {
2437 if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32)))
2438 return -EFAULT;
2439 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
2440 return -EFAULT;
2441 __put_user((unsigned long)ss.iomem_base >> 32 ?
2442 0xffffffff : (unsigned)(unsigned long)ss.iomem_base,
2443 &ss32->iomem_base);
2444 __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift);
2445 __put_user(ss.port_high, &ss32->port_high);
2448 return err;
2451 struct usbdevfs_ctrltransfer32 {
2452 u8 bRequestType;
2453 u8 bRequest;
2454 u16 wValue;
2455 u16 wIndex;
2456 u16 wLength;
2457 u32 timeout; /* in milliseconds */
2458 compat_caddr_t data;
2461 #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
2463 static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
2465 struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg);
2466 struct usbdevfs_ctrltransfer __user *p;
2467 __u32 udata;
2468 p = compat_alloc_user_space(sizeof(*p));
2469 if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
2470 get_user(udata, &p32->data) ||
2471 put_user(compat_ptr(udata), &p->data))
2472 return -EFAULT;
2473 return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p);
2477 struct usbdevfs_bulktransfer32 {
2478 compat_uint_t ep;
2479 compat_uint_t len;
2480 compat_uint_t timeout; /* in milliseconds */
2481 compat_caddr_t data;
2484 #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
2486 static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
2488 struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg);
2489 struct usbdevfs_bulktransfer __user *p;
2490 compat_uint_t n;
2491 compat_caddr_t addr;
2493 p = compat_alloc_user_space(sizeof(*p));
2495 if (get_user(n, &p32->ep) || put_user(n, &p->ep) ||
2496 get_user(n, &p32->len) || put_user(n, &p->len) ||
2497 get_user(n, &p32->timeout) || put_user(n, &p->timeout) ||
2498 get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data))
2499 return -EFAULT;
2501 return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p);
2506 * USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY
2507 * are handled in usbdevfs core. -Christopher Li
2510 struct usbdevfs_disconnectsignal32 {
2511 compat_int_t signr;
2512 compat_caddr_t context;
2515 #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
2517 static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
2519 struct usbdevfs_disconnectsignal kdis;
2520 struct usbdevfs_disconnectsignal32 __user *udis;
2521 mm_segment_t old_fs;
2522 u32 uctx;
2523 int err;
2525 udis = compat_ptr(arg);
2527 if (get_user(kdis.signr, &udis->signr) ||
2528 __get_user(uctx, &udis->context))
2529 return -EFAULT;
2531 kdis.context = compat_ptr(uctx);
2533 old_fs = get_fs();
2534 set_fs(KERNEL_DS);
2535 err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
2536 set_fs(old_fs);
2538 return err;
2542 * I2C layer ioctls
2545 struct i2c_msg32 {
2546 u16 addr;
2547 u16 flags;
2548 u16 len;
2549 compat_caddr_t buf;
2552 struct i2c_rdwr_ioctl_data32 {
2553 compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
2554 u32 nmsgs;
2557 struct i2c_smbus_ioctl_data32 {
2558 u8 read_write;
2559 u8 command;
2560 u32 size;
2561 compat_caddr_t data; /* union i2c_smbus_data *data */
2564 struct i2c_rdwr_aligned {
2565 struct i2c_rdwr_ioctl_data cmd;
2566 struct i2c_msg msgs[0];
2569 static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2571 struct i2c_rdwr_ioctl_data32 __user *udata = compat_ptr(arg);
2572 struct i2c_rdwr_aligned __user *tdata;
2573 struct i2c_msg __user *tmsgs;
2574 struct i2c_msg32 __user *umsgs;
2575 compat_caddr_t datap;
2576 int nmsgs, i;
2578 if (get_user(nmsgs, &udata->nmsgs))
2579 return -EFAULT;
2580 if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
2581 return -EINVAL;
2583 if (get_user(datap, &udata->msgs))
2584 return -EFAULT;
2585 umsgs = compat_ptr(datap);
2587 tdata = compat_alloc_user_space(sizeof(*tdata) +
2588 nmsgs * sizeof(struct i2c_msg));
2589 tmsgs = &tdata->msgs[0];
2591 if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
2592 put_user(tmsgs, &tdata->cmd.msgs))
2593 return -EFAULT;
2595 for (i = 0; i < nmsgs; i++) {
2596 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
2597 return -EFAULT;
2598 if (get_user(datap, &umsgs[i].buf) ||
2599 put_user(compat_ptr(datap), &tmsgs[i].buf))
2600 return -EFAULT;
2602 return sys_ioctl(fd, cmd, (unsigned long)tdata);
2605 static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2607 struct i2c_smbus_ioctl_data __user *tdata;
2608 struct i2c_smbus_ioctl_data32 __user *udata;
2609 compat_caddr_t datap;
2611 tdata = compat_alloc_user_space(sizeof(*tdata));
2612 if (tdata == NULL)
2613 return -ENOMEM;
2614 if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
2615 return -EFAULT;
2617 udata = compat_ptr(arg);
2618 if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
2619 return -EFAULT;
2621 if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
2622 return -EFAULT;
2623 if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
2624 return -EFAULT;
2625 if (__get_user(datap, &udata->data) ||
2626 __put_user(compat_ptr(datap), &tdata->data))
2627 return -EFAULT;
2629 return sys_ioctl(fd, cmd, (unsigned long)tdata);
2632 struct compat_iw_point {
2633 compat_caddr_t pointer;
2634 __u16 length;
2635 __u16 flags;
2638 static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2640 struct iwreq __user *iwr;
2641 struct iwreq __user *iwr_u;
2642 struct iw_point __user *iwp;
2643 struct compat_iw_point __user *iwp_u;
2644 compat_caddr_t pointer;
2645 __u16 length, flags;
2647 iwr_u = compat_ptr(arg);
2648 iwp_u = (struct compat_iw_point __user *) &iwr_u->u.data;
2649 iwr = compat_alloc_user_space(sizeof(*iwr));
2650 if (iwr == NULL)
2651 return -ENOMEM;
2653 iwp = &iwr->u.data;
2655 if (!access_ok(VERIFY_WRITE, iwr, sizeof(*iwr)))
2656 return -EFAULT;
2658 if (__copy_in_user(&iwr->ifr_ifrn.ifrn_name[0],
2659 &iwr_u->ifr_ifrn.ifrn_name[0],
2660 sizeof(iwr->ifr_ifrn.ifrn_name)))
2661 return -EFAULT;
2663 if (__get_user(pointer, &iwp_u->pointer) ||
2664 __get_user(length, &iwp_u->length) ||
2665 __get_user(flags, &iwp_u->flags))
2666 return -EFAULT;
2668 if (__put_user(compat_ptr(pointer), &iwp->pointer) ||
2669 __put_user(length, &iwp->length) ||
2670 __put_user(flags, &iwp->flags))
2671 return -EFAULT;
2673 return sys_ioctl(fd, cmd, (unsigned long) iwr);
2676 /* Since old style bridge ioctl's endup using SIOCDEVPRIVATE
2677 * for some operations; this forces use of the newer bridge-utils that
2678 * use compatiable ioctls
2680 static int old_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2682 u32 tmp;
2684 if (get_user(tmp, (u32 __user *) arg))
2685 return -EFAULT;
2686 if (tmp == BRCTL_GET_VERSION)
2687 return BRCTL_VERSION + 1;
2688 return -EINVAL;
2691 #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
2692 struct ncp_ioctl_request_32 {
2693 u32 function;
2694 u32 size;
2695 compat_caddr_t data;
2698 struct ncp_fs_info_v2_32 {
2699 s32 version;
2700 u32 mounted_uid;
2701 u32 connection;
2702 u32 buffer_size;
2704 u32 volume_number;
2705 u32 directory_id;
2707 u32 dummy1;
2708 u32 dummy2;
2709 u32 dummy3;
2712 struct ncp_objectname_ioctl_32
2714 s32 auth_type;
2715 u32 object_name_len;
2716 compat_caddr_t object_name; /* an userspace data, in most cases user name */
2719 struct ncp_privatedata_ioctl_32
2721 u32 len;
2722 compat_caddr_t data; /* ~1000 for NDS */
2725 #define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct ncp_ioctl_request_32)
2726 #define NCP_IOC_GETMOUNTUID2_32 _IOW('n', 2, u32)
2727 #define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct ncp_fs_info_v2_32)
2728 #define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct ncp_objectname_ioctl_32)
2729 #define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct ncp_objectname_ioctl_32)
2730 #define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct ncp_privatedata_ioctl_32)
2731 #define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct ncp_privatedata_ioctl_32)
2733 static int do_ncp_ncprequest(unsigned int fd, unsigned int cmd, unsigned long arg)
2735 struct ncp_ioctl_request_32 n32;
2736 struct ncp_ioctl_request __user *p = compat_alloc_user_space(sizeof(*p));
2738 if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)) ||
2739 put_user(n32.function, &p->function) ||
2740 put_user(n32.size, &p->size) ||
2741 put_user(compat_ptr(n32.data), &p->data))
2742 return -EFAULT;
2744 return sys_ioctl(fd, NCP_IOC_NCPREQUEST, (unsigned long)p);
2747 static int do_ncp_getmountuid2(unsigned int fd, unsigned int cmd, unsigned long arg)
2749 mm_segment_t old_fs = get_fs();
2750 __kernel_uid_t kuid;
2751 int err;
2753 cmd = NCP_IOC_GETMOUNTUID2;
2755 set_fs(KERNEL_DS);
2756 err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
2757 set_fs(old_fs);
2759 if (!err)
2760 err = put_user(kuid,
2761 (unsigned int __user *) compat_ptr(arg));
2763 return err;
2766 static int do_ncp_getfsinfo2(unsigned int fd, unsigned int cmd, unsigned long arg)
2768 mm_segment_t old_fs = get_fs();
2769 struct ncp_fs_info_v2_32 n32;
2770 struct ncp_fs_info_v2 n;
2771 int err;
2773 if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)))
2774 return -EFAULT;
2775 if (n32.version != NCP_GET_FS_INFO_VERSION_V2)
2776 return -EINVAL;
2777 n.version = NCP_GET_FS_INFO_VERSION_V2;
2779 set_fs(KERNEL_DS);
2780 err = sys_ioctl(fd, NCP_IOC_GET_FS_INFO_V2, (unsigned long)&n);
2781 set_fs(old_fs);
2783 if (!err) {
2784 n32.version = n.version;
2785 n32.mounted_uid = n.mounted_uid;
2786 n32.connection = n.connection;
2787 n32.buffer_size = n.buffer_size;
2788 n32.volume_number = n.volume_number;
2789 n32.directory_id = n.directory_id;
2790 n32.dummy1 = n.dummy1;
2791 n32.dummy2 = n.dummy2;
2792 n32.dummy3 = n.dummy3;
2793 err = copy_to_user(compat_ptr(arg), &n32, sizeof(n32)) ? -EFAULT : 0;
2795 return err;
2798 static int do_ncp_getobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
2800 struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2801 struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
2802 s32 auth_type;
2803 u32 name_len;
2804 int err;
2806 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2807 put_user(n32.object_name_len, &p->object_name_len) ||
2808 put_user(compat_ptr(n32.object_name), &p->object_name))
2809 return -EFAULT;
2811 err = sys_ioctl(fd, NCP_IOC_GETOBJECTNAME, (unsigned long)p);
2812 if (err)
2813 return err;
2815 if (get_user(auth_type, &p->auth_type) ||
2816 put_user(auth_type, &p32->auth_type) ||
2817 get_user(name_len, &p->object_name_len) ||
2818 put_user(name_len, &p32->object_name_len))
2819 return -EFAULT;
2821 return 0;
2824 static int do_ncp_setobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
2826 struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2827 struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
2829 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2830 put_user(n32.auth_type, &p->auth_type) ||
2831 put_user(n32.object_name_len, &p->object_name_len) ||
2832 put_user(compat_ptr(n32.object_name), &p->object_name))
2833 return -EFAULT;
2835 return sys_ioctl(fd, NCP_IOC_SETOBJECTNAME, (unsigned long)p);
2838 static int do_ncp_getprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
2840 struct ncp_privatedata_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2841 struct ncp_privatedata_ioctl __user *p =
2842 compat_alloc_user_space(sizeof(*p));
2843 u32 len;
2844 int err;
2846 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2847 put_user(n32.len, &p->len) ||
2848 put_user(compat_ptr(n32.data), &p->data))
2849 return -EFAULT;
2851 err = sys_ioctl(fd, NCP_IOC_GETPRIVATEDATA, (unsigned long)p);
2852 if (err)
2853 return err;
2855 if (get_user(len, &p->len) ||
2856 put_user(len, &p32->len))
2857 return -EFAULT;
2859 return 0;
2862 static int do_ncp_setprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
2864 struct ncp_privatedata_ioctl_32 n32;
2865 struct ncp_privatedata_ioctl_32 __user *p32 = compat_ptr(arg);
2866 struct ncp_privatedata_ioctl __user *p =
2867 compat_alloc_user_space(sizeof(*p));
2869 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2870 put_user(n32.len, &p->len) ||
2871 put_user(compat_ptr(n32.data), &p->data))
2872 return -EFAULT;
2874 return sys_ioctl(fd, NCP_IOC_SETPRIVATEDATA, (unsigned long)p);
2876 #endif
2878 #undef CODE
2879 #endif
2881 #ifdef DECLARES
2882 HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob)
2883 HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob)
2884 #ifdef CONFIG_NET
2885 HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
2886 HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)
2887 HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc)
2888 HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc)
2889 HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc)
2890 HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc)
2891 HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc)
2892 HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc)
2893 HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc)
2894 HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc)
2895 HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc)
2896 HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc)
2897 HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc)
2898 HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc)
2899 HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc)
2900 HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc)
2901 HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
2902 HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
2903 HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
2905 /* ioctls used by appletalk ddp.c */
2906 HANDLE_IOCTL(SIOCATALKDIFADDR, dev_ifsioc)
2907 HANDLE_IOCTL(SIOCDIFADDR, dev_ifsioc)
2908 HANDLE_IOCTL(SIOCSARP, dev_ifsioc)
2909 HANDLE_IOCTL(SIOCDARP, dev_ifsioc)
2911 HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc)
2912 HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc)
2913 HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc)
2914 HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc)
2915 HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc)
2916 HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc)
2917 HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc)
2918 HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc)
2919 HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc)
2920 HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc)
2921 HANDLE_IOCTL(TUNSETIFF, dev_ifsioc)
2922 HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl)
2923 HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl)
2924 HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl)
2925 HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl)
2926 HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl)
2927 HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl)
2928 HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl)
2929 HANDLE_IOCTL(SIOCADDRT, routing_ioctl)
2930 HANDLE_IOCTL(SIOCDELRT, routing_ioctl)
2931 HANDLE_IOCTL(SIOCBRADDIF, dev_ifsioc)
2932 HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc)
2933 /* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
2934 HANDLE_IOCTL(SIOCRTMSG, ret_einval)
2935 HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
2936 #endif
2937 HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo)
2938 HANDLE_IOCTL(BLKRAGET, w_long)
2939 HANDLE_IOCTL(BLKGETSIZE, w_long)
2940 HANDLE_IOCTL(0x1260, broken_blkgetsize)
2941 HANDLE_IOCTL(BLKFRAGET, w_long)
2942 HANDLE_IOCTL(BLKSECTGET, w_long)
2943 HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
2944 HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans)
2945 HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans)
2946 HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans)
2947 HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans)
2948 HANDLE_IOCTL(HDIO_GET_MULTCOUNT, hdio_ioctl_trans)
2949 HANDLE_IOCTL(HDIO_GET_NOWERR, hdio_ioctl_trans)
2950 HANDLE_IOCTL(HDIO_GET_NICE, hdio_ioctl_trans)
2951 HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans)
2952 HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans)
2953 HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans)
2954 HANDLE_IOCTL(FDSETDRVPRM32, fd_ioctl_trans)
2955 HANDLE_IOCTL(FDGETDRVPRM32, fd_ioctl_trans)
2956 HANDLE_IOCTL(FDGETDRVSTAT32, fd_ioctl_trans)
2957 HANDLE_IOCTL(FDPOLLDRVSTAT32, fd_ioctl_trans)
2958 HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans)
2959 HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans)
2960 HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
2961 HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans)
2962 HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans)
2963 HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans)
2964 HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans)
2965 HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans)
2966 HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans)
2967 HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans)
2968 HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans)
2969 HANDLE_IOCTL(LOOP_SET_STATUS, loop_status)
2970 HANDLE_IOCTL(LOOP_GET_STATUS, loop_status)
2971 #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
2972 HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout)
2973 #ifdef CONFIG_VT
2974 HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl)
2975 HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl)
2976 HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl)
2977 HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl)
2978 HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl)
2979 #endif
2980 HANDLE_IOCTL(EXT2_IOC32_GETFLAGS, do_ext2_ioctl)
2981 HANDLE_IOCTL(EXT2_IOC32_SETFLAGS, do_ext2_ioctl)
2982 HANDLE_IOCTL(EXT2_IOC32_GETVERSION, do_ext2_ioctl)
2983 HANDLE_IOCTL(EXT2_IOC32_SETVERSION, do_ext2_ioctl)
2984 HANDLE_IOCTL(VIDIOCGTUNER32, do_video_ioctl)
2985 HANDLE_IOCTL(VIDIOCSTUNER32, do_video_ioctl)
2986 HANDLE_IOCTL(VIDIOCGWIN32, do_video_ioctl)
2987 HANDLE_IOCTL(VIDIOCSWIN32, do_set_window)
2988 HANDLE_IOCTL(VIDIOCGFBUF32, do_video_ioctl)
2989 HANDLE_IOCTL(VIDIOCSFBUF32, do_video_ioctl)
2990 HANDLE_IOCTL(VIDIOCGFREQ32, do_video_ioctl)
2991 HANDLE_IOCTL(VIDIOCSFREQ32, do_video_ioctl)
2992 /* One SMB ioctl needs translations. */
2993 #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
2994 HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
2995 HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl)
2996 HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl)
2997 HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl)
2998 HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl)
2999 HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl)
3000 HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl)
3001 HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl)
3002 HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl)
3003 HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl)
3004 HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl)
3005 HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl)
3006 HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl)
3007 HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl)
3008 HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl)
3009 HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl)
3010 HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl)
3011 HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl)
3012 HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl)
3013 HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl)
3014 HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl)
3015 HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl)
3016 HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl)
3017 HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl)
3018 HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl)
3019 HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl)
3020 /* block stuff */
3021 HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget)
3022 HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset)
3023 HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64)
3024 /* vfat */
3025 HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32)
3026 HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32, vfat_ioctl32)
3027 HANDLE_IOCTL(REISERFS_IOC_UNPACK32, reiserfs_ioctl32)
3028 /* Raw devices */
3029 HANDLE_IOCTL(RAW_SETBIND, raw_ioctl)
3030 HANDLE_IOCTL(RAW_GETBIND, raw_ioctl)
3031 /* Serial */
3032 HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl)
3033 HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl)
3034 #ifdef TIOCGLTC
3035 COMPATIBLE_IOCTL(TIOCGLTC)
3036 COMPATIBLE_IOCTL(TIOCSLTC)
3037 #endif
3038 #ifdef TIOCSTART
3040 * For these two we have defintions in ioctls.h and/or termios.h on
3041 * some architectures but no actual implemention. Some applications
3042 * like bash call them if they are defined in the headers, so we provide
3043 * entries here to avoid syslog message spew.
3045 COMPATIBLE_IOCTL(TIOCSTART)
3046 COMPATIBLE_IOCTL(TIOCSTOP)
3047 #endif
3048 /* Usbdevfs */
3049 HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
3050 HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
3051 HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
3052 COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
3053 /* i2c */
3054 HANDLE_IOCTL(I2C_FUNCS, w_long)
3055 HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
3056 HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
3057 /* wireless */
3058 HANDLE_IOCTL(SIOCGIWRANGE, do_wireless_ioctl)
3059 HANDLE_IOCTL(SIOCSIWSPY, do_wireless_ioctl)
3060 HANDLE_IOCTL(SIOCGIWSPY, do_wireless_ioctl)
3061 HANDLE_IOCTL(SIOCSIWTHRSPY, do_wireless_ioctl)
3062 HANDLE_IOCTL(SIOCGIWTHRSPY, do_wireless_ioctl)
3063 HANDLE_IOCTL(SIOCGIWAPLIST, do_wireless_ioctl)
3064 HANDLE_IOCTL(SIOCGIWSCAN, do_wireless_ioctl)
3065 HANDLE_IOCTL(SIOCSIWESSID, do_wireless_ioctl)
3066 HANDLE_IOCTL(SIOCGIWESSID, do_wireless_ioctl)
3067 HANDLE_IOCTL(SIOCSIWNICKN, do_wireless_ioctl)
3068 HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl)
3069 HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl)
3070 HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl)
3071 HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl)
3072 HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl)
3074 #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
3075 HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest)
3076 HANDLE_IOCTL(NCP_IOC_GETMOUNTUID2_32, do_ncp_getmountuid2)
3077 HANDLE_IOCTL(NCP_IOC_GET_FS_INFO_V2_32, do_ncp_getfsinfo2)
3078 HANDLE_IOCTL(NCP_IOC_GETOBJECTNAME_32, do_ncp_getobjectname)
3079 HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32, do_ncp_setobjectname)
3080 HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata)
3081 HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata)
3082 #endif
3084 /* dvb */
3085 HANDLE_IOCTL(DMX_GET_EVENT, do_dmx_get_event)
3086 HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event)
3087 HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture)
3088 HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette)
3090 #undef DECLARES
3091 #endif