[PATCH] driver core: restore event order for device_add()
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / fs / compat_ioctl.c
blob155e612635f1341e1711f2546c638fa6da9dc0c5
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 #undef INCLUDES
125 #endif
127 #ifdef CODE
129 /* Aiee. Someone does not find a difference between int and long */
130 #define EXT2_IOC32_GETFLAGS _IOR('f', 1, int)
131 #define EXT2_IOC32_SETFLAGS _IOW('f', 2, int)
132 #define EXT2_IOC32_GETVERSION _IOR('v', 1, int)
133 #define EXT2_IOC32_SETVERSION _IOW('v', 2, int)
135 static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
137 mm_segment_t old_fs = get_fs();
138 int err;
139 unsigned long val;
141 set_fs (KERNEL_DS);
142 err = sys_ioctl(fd, cmd, (unsigned long)&val);
143 set_fs (old_fs);
144 if (!err && put_user(val, (u32 __user *)compat_ptr(arg)))
145 return -EFAULT;
146 return err;
149 static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg)
151 mm_segment_t old_fs = get_fs();
152 u32 __user *argptr = compat_ptr(arg);
153 int err;
154 unsigned long val;
156 if(get_user(val, argptr))
157 return -EFAULT;
158 set_fs (KERNEL_DS);
159 err = sys_ioctl(fd, cmd, (unsigned long)&val);
160 set_fs (old_fs);
161 if (!err && put_user(val, argptr))
162 return -EFAULT;
163 return err;
166 static int do_ext2_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
168 /* These are just misnamed, they actually get/put from/to user an int */
169 switch (cmd) {
170 case EXT2_IOC32_GETFLAGS: cmd = EXT2_IOC_GETFLAGS; break;
171 case EXT2_IOC32_SETFLAGS: cmd = EXT2_IOC_SETFLAGS; break;
172 case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; break;
173 case EXT2_IOC32_SETVERSION: cmd = EXT2_IOC_SETVERSION; break;
175 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
178 struct video_tuner32 {
179 compat_int_t tuner;
180 char name[32];
181 compat_ulong_t rangelow, rangehigh;
182 u32 flags; /* It is really u32 in videodev.h */
183 u16 mode, signal;
186 static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up)
188 int i;
190 if(get_user(kp->tuner, &up->tuner))
191 return -EFAULT;
192 for(i = 0; i < 32; i++)
193 __get_user(kp->name[i], &up->name[i]);
194 __get_user(kp->rangelow, &up->rangelow);
195 __get_user(kp->rangehigh, &up->rangehigh);
196 __get_user(kp->flags, &up->flags);
197 __get_user(kp->mode, &up->mode);
198 __get_user(kp->signal, &up->signal);
199 return 0;
202 static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up)
204 int i;
206 if(put_user(kp->tuner, &up->tuner))
207 return -EFAULT;
208 for(i = 0; i < 32; i++)
209 __put_user(kp->name[i], &up->name[i]);
210 __put_user(kp->rangelow, &up->rangelow);
211 __put_user(kp->rangehigh, &up->rangehigh);
212 __put_user(kp->flags, &up->flags);
213 __put_user(kp->mode, &up->mode);
214 __put_user(kp->signal, &up->signal);
215 return 0;
218 struct video_buffer32 {
219 compat_caddr_t base;
220 compat_int_t height, width, depth, bytesperline;
223 static int get_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up)
225 u32 tmp;
227 if (get_user(tmp, &up->base))
228 return -EFAULT;
230 /* This is actually a physical address stored
231 * as a void pointer.
233 kp->base = (void *)(unsigned long) tmp;
235 __get_user(kp->height, &up->height);
236 __get_user(kp->width, &up->width);
237 __get_user(kp->depth, &up->depth);
238 __get_user(kp->bytesperline, &up->bytesperline);
239 return 0;
242 static int put_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up)
244 u32 tmp = (u32)((unsigned long)kp->base);
246 if(put_user(tmp, &up->base))
247 return -EFAULT;
248 __put_user(kp->height, &up->height);
249 __put_user(kp->width, &up->width);
250 __put_user(kp->depth, &up->depth);
251 __put_user(kp->bytesperline, &up->bytesperline);
252 return 0;
255 struct video_clip32 {
256 s32 x, y, width, height; /* Its really s32 in videodev.h */
257 compat_caddr_t next;
260 struct video_window32 {
261 u32 x, y, width, height, chromakey, flags;
262 compat_caddr_t clips;
263 compat_int_t clipcount;
266 /* You get back everything except the clips... */
267 static int put_video_window32(struct video_window *kp, struct video_window32 __user *up)
269 if(put_user(kp->x, &up->x))
270 return -EFAULT;
271 __put_user(kp->y, &up->y);
272 __put_user(kp->width, &up->width);
273 __put_user(kp->height, &up->height);
274 __put_user(kp->chromakey, &up->chromakey);
275 __put_user(kp->flags, &up->flags);
276 __put_user(kp->clipcount, &up->clipcount);
277 return 0;
280 #define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32)
281 #define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32)
282 #define VIDIOCGWIN32 _IOR('v',9, struct video_window32)
283 #define VIDIOCSWIN32 _IOW('v',10, struct video_window32)
284 #define VIDIOCGFBUF32 _IOR('v',11, struct video_buffer32)
285 #define VIDIOCSFBUF32 _IOW('v',12, struct video_buffer32)
286 #define VIDIOCGFREQ32 _IOR('v',14, u32)
287 #define VIDIOCSFREQ32 _IOW('v',15, u32)
289 enum {
290 MaxClips = (~0U-sizeof(struct video_window))/sizeof(struct video_clip)
293 static int do_set_window(unsigned int fd, unsigned int cmd, unsigned long arg)
295 struct video_window32 __user *up = compat_ptr(arg);
296 struct video_window __user *vw;
297 struct video_clip __user *p;
298 int nclips;
299 u32 n;
301 if (get_user(nclips, &up->clipcount))
302 return -EFAULT;
304 /* Peculiar interface... */
305 if (nclips < 0)
306 nclips = VIDEO_CLIPMAP_SIZE;
308 if (nclips > MaxClips)
309 return -ENOMEM;
311 vw = compat_alloc_user_space(sizeof(struct video_window) +
312 nclips * sizeof(struct video_clip));
314 p = nclips ? (struct video_clip __user *)(vw + 1) : NULL;
316 if (get_user(n, &up->x) || put_user(n, &vw->x) ||
317 get_user(n, &up->y) || put_user(n, &vw->y) ||
318 get_user(n, &up->width) || put_user(n, &vw->width) ||
319 get_user(n, &up->height) || put_user(n, &vw->height) ||
320 get_user(n, &up->chromakey) || put_user(n, &vw->chromakey) ||
321 get_user(n, &up->flags) || put_user(n, &vw->flags) ||
322 get_user(n, &up->clipcount) || put_user(n, &vw->clipcount) ||
323 get_user(n, &up->clips) || put_user(p, &vw->clips))
324 return -EFAULT;
326 if (nclips) {
327 struct video_clip32 __user *u = compat_ptr(n);
328 int i;
329 if (!u)
330 return -EINVAL;
331 for (i = 0; i < nclips; i++, u++, p++) {
332 s32 v;
333 if (get_user(v, &u->x) ||
334 put_user(v, &p->x) ||
335 get_user(v, &u->y) ||
336 put_user(v, &p->y) ||
337 get_user(v, &u->width) ||
338 put_user(v, &p->width) ||
339 get_user(v, &u->height) ||
340 put_user(v, &p->height) ||
341 put_user(NULL, &p->next))
342 return -EFAULT;
346 return sys_ioctl(fd, VIDIOCSWIN, (unsigned long)p);
349 static int do_video_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
351 union {
352 struct video_tuner vt;
353 struct video_buffer vb;
354 struct video_window vw;
355 unsigned long vx;
356 } karg;
357 mm_segment_t old_fs = get_fs();
358 void __user *up = compat_ptr(arg);
359 int err = 0;
361 /* First, convert the command. */
362 switch(cmd) {
363 case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break;
364 case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break;
365 case VIDIOCGWIN32: cmd = VIDIOCGWIN; break;
366 case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break;
367 case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break;
368 case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break;
369 case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break;
372 switch(cmd) {
373 case VIDIOCSTUNER:
374 case VIDIOCGTUNER:
375 err = get_video_tuner32(&karg.vt, up);
376 break;
378 case VIDIOCSFBUF:
379 err = get_video_buffer32(&karg.vb, up);
380 break;
382 case VIDIOCSFREQ:
383 err = get_user(karg.vx, (u32 __user *)up);
384 break;
386 if(err)
387 goto out;
389 set_fs(KERNEL_DS);
390 err = sys_ioctl(fd, cmd, (unsigned long)&karg);
391 set_fs(old_fs);
393 if(err == 0) {
394 switch(cmd) {
395 case VIDIOCGTUNER:
396 err = put_video_tuner32(&karg.vt, up);
397 break;
399 case VIDIOCGWIN:
400 err = put_video_window32(&karg.vw, up);
401 break;
403 case VIDIOCGFBUF:
404 err = put_video_buffer32(&karg.vb, up);
405 break;
407 case VIDIOCGFREQ:
408 err = put_user(((u32)karg.vx), (u32 __user *)up);
409 break;
412 out:
413 return err;
416 #ifdef CONFIG_NET
417 static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
419 struct compat_timeval __user *up = compat_ptr(arg);
420 struct timeval ktv;
421 mm_segment_t old_fs = get_fs();
422 int err;
424 set_fs(KERNEL_DS);
425 err = sys_ioctl(fd, cmd, (unsigned long)&ktv);
426 set_fs(old_fs);
427 if(!err) {
428 err = put_user(ktv.tv_sec, &up->tv_sec);
429 err |= __put_user(ktv.tv_usec, &up->tv_usec);
431 return err;
434 struct ifmap32 {
435 compat_ulong_t mem_start;
436 compat_ulong_t mem_end;
437 unsigned short base_addr;
438 unsigned char irq;
439 unsigned char dma;
440 unsigned char port;
443 struct ifreq32 {
444 #define IFHWADDRLEN 6
445 #define IFNAMSIZ 16
446 union {
447 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
448 } ifr_ifrn;
449 union {
450 struct sockaddr ifru_addr;
451 struct sockaddr ifru_dstaddr;
452 struct sockaddr ifru_broadaddr;
453 struct sockaddr ifru_netmask;
454 struct sockaddr ifru_hwaddr;
455 short ifru_flags;
456 compat_int_t ifru_ivalue;
457 compat_int_t ifru_mtu;
458 struct ifmap32 ifru_map;
459 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
460 char ifru_newname[IFNAMSIZ];
461 compat_caddr_t ifru_data;
462 /* XXXX? ifru_settings should be here */
463 } ifr_ifru;
466 struct ifconf32 {
467 compat_int_t ifc_len; /* size of buffer */
468 compat_caddr_t ifcbuf;
471 static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
473 struct net_device *dev;
474 struct ifreq32 ifr32;
475 int err;
477 if (copy_from_user(&ifr32, compat_ptr(arg), sizeof(ifr32)))
478 return -EFAULT;
480 dev = dev_get_by_index(ifr32.ifr_ifindex);
481 if (!dev)
482 return -ENODEV;
484 strlcpy(ifr32.ifr_name, dev->name, sizeof(ifr32.ifr_name));
485 dev_put(dev);
487 err = copy_to_user(compat_ptr(arg), &ifr32, sizeof(ifr32));
488 return (err ? -EFAULT : 0);
491 static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)
493 struct ifconf32 ifc32;
494 struct ifconf ifc;
495 struct ifconf __user *uifc;
496 struct ifreq32 __user *ifr32;
497 struct ifreq __user *ifr;
498 unsigned int i, j;
499 int err;
501 if (copy_from_user(&ifc32, compat_ptr(arg), sizeof(struct ifconf32)))
502 return -EFAULT;
504 if (ifc32.ifcbuf == 0) {
505 ifc32.ifc_len = 0;
506 ifc.ifc_len = 0;
507 ifc.ifc_req = NULL;
508 uifc = compat_alloc_user_space(sizeof(struct ifconf));
509 } else {
510 size_t len =((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) *
511 sizeof (struct ifreq);
512 uifc = compat_alloc_user_space(sizeof(struct ifconf) + len);
513 ifc.ifc_len = len;
514 ifr = ifc.ifc_req = (void __user *)(uifc + 1);
515 ifr32 = compat_ptr(ifc32.ifcbuf);
516 for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) {
517 if (copy_in_user(ifr, ifr32, sizeof(struct ifreq32)))
518 return -EFAULT;
519 ifr++;
520 ifr32++;
523 if (copy_to_user(uifc, &ifc, sizeof(struct ifconf)))
524 return -EFAULT;
526 err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)uifc);
527 if (err)
528 return err;
530 if (copy_from_user(&ifc, uifc, sizeof(struct ifconf)))
531 return -EFAULT;
533 ifr = ifc.ifc_req;
534 ifr32 = compat_ptr(ifc32.ifcbuf);
535 for (i = 0, j = 0; i < ifc32.ifc_len && j < ifc.ifc_len;
536 i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
537 if (copy_in_user(ifr32, ifr, sizeof (struct ifreq32)))
538 return -EFAULT;
539 ifr32++;
540 ifr++;
543 if (ifc32.ifcbuf == 0) {
544 /* Translate from 64-bit structure multiple to
545 * a 32-bit one.
547 i = ifc.ifc_len;
548 i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32));
549 ifc32.ifc_len = i;
550 } else {
551 if (i <= ifc32.ifc_len)
552 ifc32.ifc_len = i;
553 else
554 ifc32.ifc_len = i - sizeof (struct ifreq32);
556 if (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32)))
557 return -EFAULT;
559 return 0;
562 static int ethtool_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
564 struct ifreq __user *ifr;
565 struct ifreq32 __user *ifr32;
566 u32 data;
567 void __user *datap;
569 ifr = compat_alloc_user_space(sizeof(*ifr));
570 ifr32 = compat_ptr(arg);
572 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
573 return -EFAULT;
575 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
576 return -EFAULT;
578 datap = compat_ptr(data);
579 if (put_user(datap, &ifr->ifr_ifru.ifru_data))
580 return -EFAULT;
582 return sys_ioctl(fd, cmd, (unsigned long) ifr);
585 static int bond_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
587 struct ifreq kifr;
588 struct ifreq __user *uifr;
589 struct ifreq32 __user *ifr32 = compat_ptr(arg);
590 mm_segment_t old_fs;
591 int err;
592 u32 data;
593 void __user *datap;
595 switch (cmd) {
596 case SIOCBONDENSLAVE:
597 case SIOCBONDRELEASE:
598 case SIOCBONDSETHWADDR:
599 case SIOCBONDCHANGEACTIVE:
600 if (copy_from_user(&kifr, ifr32, sizeof(struct ifreq32)))
601 return -EFAULT;
603 old_fs = get_fs();
604 set_fs (KERNEL_DS);
605 err = sys_ioctl (fd, cmd, (unsigned long)&kifr);
606 set_fs (old_fs);
608 return err;
609 case SIOCBONDSLAVEINFOQUERY:
610 case SIOCBONDINFOQUERY:
611 uifr = compat_alloc_user_space(sizeof(*uifr));
612 if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
613 return -EFAULT;
615 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
616 return -EFAULT;
618 datap = compat_ptr(data);
619 if (put_user(datap, &uifr->ifr_ifru.ifru_data))
620 return -EFAULT;
622 return sys_ioctl (fd, cmd, (unsigned long)uifr);
623 default:
624 return -EINVAL;
628 int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
630 struct ifreq __user *u_ifreq64;
631 struct ifreq32 __user *u_ifreq32 = compat_ptr(arg);
632 char tmp_buf[IFNAMSIZ];
633 void __user *data64;
634 u32 data32;
636 if (copy_from_user(&tmp_buf[0], &(u_ifreq32->ifr_ifrn.ifrn_name[0]),
637 IFNAMSIZ))
638 return -EFAULT;
639 if (__get_user(data32, &u_ifreq32->ifr_ifru.ifru_data))
640 return -EFAULT;
641 data64 = compat_ptr(data32);
643 u_ifreq64 = compat_alloc_user_space(sizeof(*u_ifreq64));
645 /* Don't check these user accesses, just let that get trapped
646 * in the ioctl handler instead.
648 if (copy_to_user(&u_ifreq64->ifr_ifrn.ifrn_name[0], &tmp_buf[0],
649 IFNAMSIZ))
650 return -EFAULT;
651 if (__put_user(data64, &u_ifreq64->ifr_ifru.ifru_data))
652 return -EFAULT;
654 return sys_ioctl(fd, cmd, (unsigned long) u_ifreq64);
657 static int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg)
659 struct ifreq ifr;
660 struct ifreq32 __user *uifr32;
661 struct ifmap32 __user *uifmap32;
662 mm_segment_t old_fs;
663 int err;
665 uifr32 = compat_ptr(arg);
666 uifmap32 = &uifr32->ifr_ifru.ifru_map;
667 switch (cmd) {
668 case SIOCSIFMAP:
669 err = copy_from_user(&ifr, uifr32, sizeof(ifr.ifr_name));
670 err |= __get_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
671 err |= __get_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
672 err |= __get_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
673 err |= __get_user(ifr.ifr_map.irq, &uifmap32->irq);
674 err |= __get_user(ifr.ifr_map.dma, &uifmap32->dma);
675 err |= __get_user(ifr.ifr_map.port, &uifmap32->port);
676 if (err)
677 return -EFAULT;
678 break;
679 default:
680 if (copy_from_user(&ifr, uifr32, sizeof(*uifr32)))
681 return -EFAULT;
682 break;
684 old_fs = get_fs();
685 set_fs (KERNEL_DS);
686 err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
687 set_fs (old_fs);
688 if (!err) {
689 switch (cmd) {
690 /* TUNSETIFF is defined as _IOW, it should be _IORW
691 * as the data is copied back to user space, but that
692 * cannot be fixed without breaking all existing apps.
694 case TUNSETIFF:
695 case SIOCGIFFLAGS:
696 case SIOCGIFMETRIC:
697 case SIOCGIFMTU:
698 case SIOCGIFMEM:
699 case SIOCGIFHWADDR:
700 case SIOCGIFINDEX:
701 case SIOCGIFADDR:
702 case SIOCGIFBRDADDR:
703 case SIOCGIFDSTADDR:
704 case SIOCGIFNETMASK:
705 case SIOCGIFTXQLEN:
706 if (copy_to_user(uifr32, &ifr, sizeof(*uifr32)))
707 return -EFAULT;
708 break;
709 case SIOCGIFMAP:
710 err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name));
711 err |= __put_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
712 err |= __put_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
713 err |= __put_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
714 err |= __put_user(ifr.ifr_map.irq, &uifmap32->irq);
715 err |= __put_user(ifr.ifr_map.dma, &uifmap32->dma);
716 err |= __put_user(ifr.ifr_map.port, &uifmap32->port);
717 if (err)
718 err = -EFAULT;
719 break;
722 return err;
725 struct rtentry32 {
726 u32 rt_pad1;
727 struct sockaddr rt_dst; /* target address */
728 struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
729 struct sockaddr rt_genmask; /* target network mask (IP) */
730 unsigned short rt_flags;
731 short rt_pad2;
732 u32 rt_pad3;
733 unsigned char rt_tos;
734 unsigned char rt_class;
735 short rt_pad4;
736 short rt_metric; /* +1 for binary compatibility! */
737 /* char * */ u32 rt_dev; /* forcing the device at add */
738 u32 rt_mtu; /* per route MTU/Window */
739 u32 rt_window; /* Window clamping */
740 unsigned short rt_irtt; /* Initial RTT */
744 struct in6_rtmsg32 {
745 struct in6_addr rtmsg_dst;
746 struct in6_addr rtmsg_src;
747 struct in6_addr rtmsg_gateway;
748 u32 rtmsg_type;
749 u16 rtmsg_dst_len;
750 u16 rtmsg_src_len;
751 u32 rtmsg_metric;
752 u32 rtmsg_info;
753 u32 rtmsg_flags;
754 s32 rtmsg_ifindex;
757 static int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
759 int ret;
760 void *r = NULL;
761 struct in6_rtmsg r6;
762 struct rtentry r4;
763 char devname[16];
764 u32 rtdev;
765 mm_segment_t old_fs = get_fs();
767 struct socket *mysock = sockfd_lookup(fd, &ret);
769 if (mysock && mysock->sk && mysock->sk->sk_family == AF_INET6) { /* ipv6 */
770 struct in6_rtmsg32 __user *ur6 = compat_ptr(arg);
771 ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst),
772 3 * sizeof(struct in6_addr));
773 ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type));
774 ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len));
775 ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len));
776 ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric));
777 ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info));
778 ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags));
779 ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex));
781 r = (void *) &r6;
782 } else { /* ipv4 */
783 struct rtentry32 __user *ur4 = compat_ptr(arg);
784 ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst),
785 3 * sizeof(struct sockaddr));
786 ret |= __get_user (r4.rt_flags, &(ur4->rt_flags));
787 ret |= __get_user (r4.rt_metric, &(ur4->rt_metric));
788 ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu));
789 ret |= __get_user (r4.rt_window, &(ur4->rt_window));
790 ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt));
791 ret |= __get_user (rtdev, &(ur4->rt_dev));
792 if (rtdev) {
793 ret |= copy_from_user (devname, compat_ptr(rtdev), 15);
794 r4.rt_dev = devname; devname[15] = 0;
795 } else
796 r4.rt_dev = NULL;
798 r = (void *) &r4;
801 if (ret)
802 return -EFAULT;
804 set_fs (KERNEL_DS);
805 ret = sys_ioctl (fd, cmd, (unsigned long) r);
806 set_fs (old_fs);
808 if (mysock)
809 sockfd_put(mysock);
811 return ret;
813 #endif
815 struct hd_geometry32 {
816 unsigned char heads;
817 unsigned char sectors;
818 unsigned short cylinders;
819 u32 start;
822 static int hdio_getgeo(unsigned int fd, unsigned int cmd, unsigned long arg)
824 mm_segment_t old_fs = get_fs();
825 struct hd_geometry geo;
826 struct hd_geometry32 __user *ugeo;
827 int err;
829 set_fs (KERNEL_DS);
830 err = sys_ioctl(fd, HDIO_GETGEO, (unsigned long)&geo);
831 set_fs (old_fs);
832 ugeo = compat_ptr(arg);
833 if (!err) {
834 err = copy_to_user (ugeo, &geo, 4);
835 err |= __put_user (geo.start, &ugeo->start);
837 return err ? -EFAULT : 0;
840 struct fb_fix_screeninfo32 {
841 char id[16];
842 compat_caddr_t smem_start;
843 u32 smem_len;
844 u32 type;
845 u32 type_aux;
846 u32 visual;
847 u16 xpanstep;
848 u16 ypanstep;
849 u16 ywrapstep;
850 u32 line_length;
851 compat_caddr_t mmio_start;
852 u32 mmio_len;
853 u32 accel;
854 u16 reserved[3];
857 struct fb_cmap32 {
858 u32 start;
859 u32 len;
860 compat_caddr_t red;
861 compat_caddr_t green;
862 compat_caddr_t blue;
863 compat_caddr_t transp;
866 static int fb_getput_cmap(unsigned int fd, unsigned int cmd, unsigned long arg)
868 struct fb_cmap_user __user *cmap;
869 struct fb_cmap32 __user *cmap32;
870 __u32 data;
871 int err;
873 cmap = compat_alloc_user_space(sizeof(*cmap));
874 cmap32 = compat_ptr(arg);
876 if (copy_in_user(&cmap->start, &cmap32->start, 2 * sizeof(__u32)))
877 return -EFAULT;
879 if (get_user(data, &cmap32->red) ||
880 put_user(compat_ptr(data), &cmap->red) ||
881 get_user(data, &cmap32->green) ||
882 put_user(compat_ptr(data), &cmap->green) ||
883 get_user(data, &cmap32->blue) ||
884 put_user(compat_ptr(data), &cmap->blue) ||
885 get_user(data, &cmap32->transp) ||
886 put_user(compat_ptr(data), &cmap->transp))
887 return -EFAULT;
889 err = sys_ioctl(fd, cmd, (unsigned long) cmap);
891 if (!err) {
892 if (copy_in_user(&cmap32->start,
893 &cmap->start,
894 2 * sizeof(__u32)))
895 err = -EFAULT;
897 return err;
900 static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix,
901 struct fb_fix_screeninfo32 __user *fix32)
903 __u32 data;
904 int err;
906 err = copy_to_user(&fix32->id, &fix->id, sizeof(fix32->id));
908 data = (__u32) (unsigned long) fix->smem_start;
909 err |= put_user(data, &fix32->smem_start);
911 err |= put_user(fix->smem_len, &fix32->smem_len);
912 err |= put_user(fix->type, &fix32->type);
913 err |= put_user(fix->type_aux, &fix32->type_aux);
914 err |= put_user(fix->visual, &fix32->visual);
915 err |= put_user(fix->xpanstep, &fix32->xpanstep);
916 err |= put_user(fix->ypanstep, &fix32->ypanstep);
917 err |= put_user(fix->ywrapstep, &fix32->ywrapstep);
918 err |= put_user(fix->line_length, &fix32->line_length);
920 data = (__u32) (unsigned long) fix->mmio_start;
921 err |= put_user(data, &fix32->mmio_start);
923 err |= put_user(fix->mmio_len, &fix32->mmio_len);
924 err |= put_user(fix->accel, &fix32->accel);
925 err |= copy_to_user(fix32->reserved, fix->reserved,
926 sizeof(fix->reserved));
928 return err;
931 static int fb_get_fscreeninfo(unsigned int fd, unsigned int cmd, unsigned long arg)
933 mm_segment_t old_fs;
934 struct fb_fix_screeninfo fix;
935 struct fb_fix_screeninfo32 __user *fix32;
936 int err;
938 fix32 = compat_ptr(arg);
940 old_fs = get_fs();
941 set_fs(KERNEL_DS);
942 err = sys_ioctl(fd, cmd, (unsigned long) &fix);
943 set_fs(old_fs);
945 if (!err)
946 err = do_fscreeninfo_to_user(&fix, fix32);
948 return err;
951 static int fb_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
953 int err;
955 switch (cmd) {
956 case FBIOGET_FSCREENINFO:
957 err = fb_get_fscreeninfo(fd,cmd, arg);
958 break;
960 case FBIOGETCMAP:
961 case FBIOPUTCMAP:
962 err = fb_getput_cmap(fd, cmd, arg);
963 break;
965 default:
966 do {
967 static int count;
968 if (++count <= 20)
969 printk("%s: Unknown fb ioctl cmd fd(%d) "
970 "cmd(%08x) arg(%08lx)\n",
971 __FUNCTION__, fd, cmd, arg);
972 } while(0);
973 err = -ENOSYS;
974 break;
977 return err;
980 static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
982 mm_segment_t old_fs = get_fs();
983 unsigned long kval;
984 unsigned int __user *uvp;
985 int error;
987 set_fs(KERNEL_DS);
988 error = sys_ioctl(fd, cmd, (long)&kval);
989 set_fs(old_fs);
991 if(error == 0) {
992 uvp = compat_ptr(arg);
993 if(put_user(kval, uvp))
994 error = -EFAULT;
996 return error;
1000 typedef struct sg_io_hdr32 {
1001 compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */
1002 compat_int_t dxfer_direction; /* [i] data transfer direction */
1003 unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
1004 unsigned char mx_sb_len; /* [i] max length to write to sbp */
1005 unsigned short iovec_count; /* [i] 0 implies no scatter gather */
1006 compat_uint_t dxfer_len; /* [i] byte count of data transfer */
1007 compat_uint_t dxferp; /* [i], [*io] points to data transfer memory
1008 or scatter gather list */
1009 compat_uptr_t cmdp; /* [i], [*i] points to command to perform */
1010 compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */
1011 compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
1012 compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */
1013 compat_int_t pack_id; /* [i->o] unused internally (normally) */
1014 compat_uptr_t usr_ptr; /* [i->o] unused internally */
1015 unsigned char status; /* [o] scsi status */
1016 unsigned char masked_status; /* [o] shifted, masked scsi status */
1017 unsigned char msg_status; /* [o] messaging level data (optional) */
1018 unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
1019 unsigned short host_status; /* [o] errors from host adapter */
1020 unsigned short driver_status; /* [o] errors from software driver */
1021 compat_int_t resid; /* [o] dxfer_len - actual_transferred */
1022 compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */
1023 compat_uint_t info; /* [o] auxiliary information */
1024 } sg_io_hdr32_t; /* 64 bytes long (on sparc32) */
1026 typedef struct sg_iovec32 {
1027 compat_uint_t iov_base;
1028 compat_uint_t iov_len;
1029 } sg_iovec32_t;
1031 static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count)
1033 sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1);
1034 sg_iovec32_t __user *iov32 = dxferp;
1035 int i;
1037 for (i = 0; i < iovec_count; i++) {
1038 u32 base, len;
1040 if (get_user(base, &iov32[i].iov_base) ||
1041 get_user(len, &iov32[i].iov_len) ||
1042 put_user(compat_ptr(base), &iov[i].iov_base) ||
1043 put_user(len, &iov[i].iov_len))
1044 return -EFAULT;
1047 if (put_user(iov, &sgio->dxferp))
1048 return -EFAULT;
1049 return 0;
1052 static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1054 sg_io_hdr_t __user *sgio;
1055 sg_io_hdr32_t __user *sgio32;
1056 u16 iovec_count;
1057 u32 data;
1058 void __user *dxferp;
1059 int err;
1061 sgio32 = compat_ptr(arg);
1062 if (get_user(iovec_count, &sgio32->iovec_count))
1063 return -EFAULT;
1066 void __user *top = compat_alloc_user_space(0);
1067 void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) +
1068 (iovec_count * sizeof(sg_iovec_t)));
1069 if (new > top)
1070 return -EINVAL;
1072 sgio = new;
1075 /* Ok, now construct. */
1076 if (copy_in_user(&sgio->interface_id, &sgio32->interface_id,
1077 (2 * sizeof(int)) +
1078 (2 * sizeof(unsigned char)) +
1079 (1 * sizeof(unsigned short)) +
1080 (1 * sizeof(unsigned int))))
1081 return -EFAULT;
1083 if (get_user(data, &sgio32->dxferp))
1084 return -EFAULT;
1085 dxferp = compat_ptr(data);
1086 if (iovec_count) {
1087 if (sg_build_iovec(sgio, dxferp, iovec_count))
1088 return -EFAULT;
1089 } else {
1090 if (put_user(dxferp, &sgio->dxferp))
1091 return -EFAULT;
1095 unsigned char __user *cmdp;
1096 unsigned char __user *sbp;
1098 if (get_user(data, &sgio32->cmdp))
1099 return -EFAULT;
1100 cmdp = compat_ptr(data);
1102 if (get_user(data, &sgio32->sbp))
1103 return -EFAULT;
1104 sbp = compat_ptr(data);
1106 if (put_user(cmdp, &sgio->cmdp) ||
1107 put_user(sbp, &sgio->sbp))
1108 return -EFAULT;
1111 if (copy_in_user(&sgio->timeout, &sgio32->timeout,
1112 3 * sizeof(int)))
1113 return -EFAULT;
1115 if (get_user(data, &sgio32->usr_ptr))
1116 return -EFAULT;
1117 if (put_user(compat_ptr(data), &sgio->usr_ptr))
1118 return -EFAULT;
1120 if (copy_in_user(&sgio->status, &sgio32->status,
1121 (4 * sizeof(unsigned char)) +
1122 (2 * sizeof(unsigned (short))) +
1123 (3 * sizeof(int))))
1124 return -EFAULT;
1126 err = sys_ioctl(fd, cmd, (unsigned long) sgio);
1128 if (err >= 0) {
1129 void __user *datap;
1131 if (copy_in_user(&sgio32->pack_id, &sgio->pack_id,
1132 sizeof(int)) ||
1133 get_user(datap, &sgio->usr_ptr) ||
1134 put_user((u32)(unsigned long)datap,
1135 &sgio32->usr_ptr) ||
1136 copy_in_user(&sgio32->status, &sgio->status,
1137 (4 * sizeof(unsigned char)) +
1138 (2 * sizeof(unsigned short)) +
1139 (3 * sizeof(int))))
1140 err = -EFAULT;
1143 return err;
1146 struct sock_fprog32 {
1147 unsigned short len;
1148 compat_caddr_t filter;
1151 #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
1152 #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
1154 static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1156 struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg);
1157 struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
1158 void __user *fptr64;
1159 u32 fptr32;
1160 u16 flen;
1162 if (get_user(flen, &u_fprog32->len) ||
1163 get_user(fptr32, &u_fprog32->filter))
1164 return -EFAULT;
1166 fptr64 = compat_ptr(fptr32);
1168 if (put_user(flen, &u_fprog64->len) ||
1169 put_user(fptr64, &u_fprog64->filter))
1170 return -EFAULT;
1172 if (cmd == PPPIOCSPASS32)
1173 cmd = PPPIOCSPASS;
1174 else
1175 cmd = PPPIOCSACTIVE;
1177 return sys_ioctl(fd, cmd, (unsigned long) u_fprog64);
1180 struct ppp_option_data32 {
1181 compat_caddr_t ptr;
1182 u32 length;
1183 compat_int_t transmit;
1185 #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
1187 struct ppp_idle32 {
1188 compat_time_t xmit_idle;
1189 compat_time_t recv_idle;
1191 #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
1193 static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg)
1195 struct ppp_idle __user *idle;
1196 struct ppp_idle32 __user *idle32;
1197 __kernel_time_t xmit, recv;
1198 int err;
1200 idle = compat_alloc_user_space(sizeof(*idle));
1201 idle32 = compat_ptr(arg);
1203 err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle);
1205 if (!err) {
1206 if (get_user(xmit, &idle->xmit_idle) ||
1207 get_user(recv, &idle->recv_idle) ||
1208 put_user(xmit, &idle32->xmit_idle) ||
1209 put_user(recv, &idle32->recv_idle))
1210 err = -EFAULT;
1212 return err;
1215 static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg)
1217 struct ppp_option_data __user *odata;
1218 struct ppp_option_data32 __user *odata32;
1219 __u32 data;
1220 void __user *datap;
1222 odata = compat_alloc_user_space(sizeof(*odata));
1223 odata32 = compat_ptr(arg);
1225 if (get_user(data, &odata32->ptr))
1226 return -EFAULT;
1228 datap = compat_ptr(data);
1229 if (put_user(datap, &odata->ptr))
1230 return -EFAULT;
1232 if (copy_in_user(&odata->length, &odata32->length,
1233 sizeof(__u32) + sizeof(int)))
1234 return -EFAULT;
1236 return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata);
1239 static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1241 int err;
1243 switch (cmd) {
1244 case PPPIOCGIDLE32:
1245 err = ppp_gidle(fd, cmd, arg);
1246 break;
1248 case PPPIOCSCOMPRESS32:
1249 err = ppp_scompress(fd, cmd, arg);
1250 break;
1252 default:
1253 do {
1254 static int count;
1255 if (++count <= 20)
1256 printk("ppp_ioctl: Unknown cmd fd(%d) "
1257 "cmd(%08x) arg(%08x)\n",
1258 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1259 } while(0);
1260 err = -EINVAL;
1261 break;
1264 return err;
1268 struct mtget32 {
1269 compat_long_t mt_type;
1270 compat_long_t mt_resid;
1271 compat_long_t mt_dsreg;
1272 compat_long_t mt_gstat;
1273 compat_long_t mt_erreg;
1274 compat_daddr_t mt_fileno;
1275 compat_daddr_t mt_blkno;
1277 #define MTIOCGET32 _IOR('m', 2, struct mtget32)
1279 struct mtpos32 {
1280 compat_long_t mt_blkno;
1282 #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
1284 static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1286 mm_segment_t old_fs = get_fs();
1287 struct mtget get;
1288 struct mtget32 __user *umget32;
1289 struct mtpos pos;
1290 struct mtpos32 __user *upos32;
1291 unsigned long kcmd;
1292 void *karg;
1293 int err = 0;
1295 switch(cmd) {
1296 case MTIOCPOS32:
1297 kcmd = MTIOCPOS;
1298 karg = &pos;
1299 break;
1300 case MTIOCGET32:
1301 kcmd = MTIOCGET;
1302 karg = &get;
1303 break;
1304 default:
1305 do {
1306 static int count;
1307 if (++count <= 20)
1308 printk("mt_ioctl: Unknown cmd fd(%d) "
1309 "cmd(%08x) arg(%08x)\n",
1310 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1311 } while(0);
1312 return -EINVAL;
1314 set_fs (KERNEL_DS);
1315 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1316 set_fs (old_fs);
1317 if (err)
1318 return err;
1319 switch (cmd) {
1320 case MTIOCPOS32:
1321 upos32 = compat_ptr(arg);
1322 err = __put_user(pos.mt_blkno, &upos32->mt_blkno);
1323 break;
1324 case MTIOCGET32:
1325 umget32 = compat_ptr(arg);
1326 err = __put_user(get.mt_type, &umget32->mt_type);
1327 err |= __put_user(get.mt_resid, &umget32->mt_resid);
1328 err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg);
1329 err |= __put_user(get.mt_gstat, &umget32->mt_gstat);
1330 err |= __put_user(get.mt_erreg, &umget32->mt_erreg);
1331 err |= __put_user(get.mt_fileno, &umget32->mt_fileno);
1332 err |= __put_user(get.mt_blkno, &umget32->mt_blkno);
1333 break;
1335 return err ? -EFAULT: 0;
1338 struct cdrom_read_audio32 {
1339 union cdrom_addr addr;
1340 u8 addr_format;
1341 compat_int_t nframes;
1342 compat_caddr_t buf;
1345 struct cdrom_generic_command32 {
1346 unsigned char cmd[CDROM_PACKET_SIZE];
1347 compat_caddr_t buffer;
1348 compat_uint_t buflen;
1349 compat_int_t stat;
1350 compat_caddr_t sense;
1351 unsigned char data_direction;
1352 compat_int_t quiet;
1353 compat_int_t timeout;
1354 compat_caddr_t reserved[1];
1357 static int cdrom_do_read_audio(unsigned int fd, unsigned int cmd, unsigned long arg)
1359 struct cdrom_read_audio __user *cdread_audio;
1360 struct cdrom_read_audio32 __user *cdread_audio32;
1361 __u32 data;
1362 void __user *datap;
1364 cdread_audio = compat_alloc_user_space(sizeof(*cdread_audio));
1365 cdread_audio32 = compat_ptr(arg);
1367 if (copy_in_user(&cdread_audio->addr,
1368 &cdread_audio32->addr,
1369 (sizeof(*cdread_audio32) -
1370 sizeof(compat_caddr_t))))
1371 return -EFAULT;
1373 if (get_user(data, &cdread_audio32->buf))
1374 return -EFAULT;
1375 datap = compat_ptr(data);
1376 if (put_user(datap, &cdread_audio->buf))
1377 return -EFAULT;
1379 return sys_ioctl(fd, cmd, (unsigned long) cdread_audio);
1382 static int cdrom_do_generic_command(unsigned int fd, unsigned int cmd, unsigned long arg)
1384 struct cdrom_generic_command __user *cgc;
1385 struct cdrom_generic_command32 __user *cgc32;
1386 u32 data;
1387 unsigned char dir;
1388 int itmp;
1390 cgc = compat_alloc_user_space(sizeof(*cgc));
1391 cgc32 = compat_ptr(arg);
1393 if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) ||
1394 get_user(data, &cgc32->buffer) ||
1395 put_user(compat_ptr(data), &cgc->buffer) ||
1396 copy_in_user(&cgc->buflen, &cgc32->buflen,
1397 (sizeof(unsigned int) + sizeof(int))) ||
1398 get_user(data, &cgc32->sense) ||
1399 put_user(compat_ptr(data), &cgc->sense) ||
1400 get_user(dir, &cgc32->data_direction) ||
1401 put_user(dir, &cgc->data_direction) ||
1402 get_user(itmp, &cgc32->quiet) ||
1403 put_user(itmp, &cgc->quiet) ||
1404 get_user(itmp, &cgc32->timeout) ||
1405 put_user(itmp, &cgc->timeout) ||
1406 get_user(data, &cgc32->reserved[0]) ||
1407 put_user(compat_ptr(data), &cgc->reserved[0]))
1408 return -EFAULT;
1410 return sys_ioctl(fd, cmd, (unsigned long) cgc);
1413 static int cdrom_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1415 int err;
1417 switch(cmd) {
1418 case CDROMREADAUDIO:
1419 err = cdrom_do_read_audio(fd, cmd, arg);
1420 break;
1422 case CDROM_SEND_PACKET:
1423 err = cdrom_do_generic_command(fd, cmd, arg);
1424 break;
1426 default:
1427 do {
1428 static int count;
1429 if (++count <= 20)
1430 printk("cdrom_ioctl: Unknown cmd fd(%d) "
1431 "cmd(%08x) arg(%08x)\n",
1432 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1433 } while(0);
1434 err = -EINVAL;
1435 break;
1438 return err;
1441 struct loop_info32 {
1442 compat_int_t lo_number; /* ioctl r/o */
1443 compat_dev_t lo_device; /* ioctl r/o */
1444 compat_ulong_t lo_inode; /* ioctl r/o */
1445 compat_dev_t lo_rdevice; /* ioctl r/o */
1446 compat_int_t lo_offset;
1447 compat_int_t lo_encrypt_type;
1448 compat_int_t lo_encrypt_key_size; /* ioctl w/o */
1449 compat_int_t lo_flags; /* ioctl r/o */
1450 char lo_name[LO_NAME_SIZE];
1451 unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
1452 compat_ulong_t lo_init[2];
1453 char reserved[4];
1456 static int loop_status(unsigned int fd, unsigned int cmd, unsigned long arg)
1458 mm_segment_t old_fs = get_fs();
1459 struct loop_info l;
1460 struct loop_info32 __user *ul;
1461 int err = -EINVAL;
1463 ul = compat_ptr(arg);
1464 switch(cmd) {
1465 case LOOP_SET_STATUS:
1466 err = get_user(l.lo_number, &ul->lo_number);
1467 err |= __get_user(l.lo_device, &ul->lo_device);
1468 err |= __get_user(l.lo_inode, &ul->lo_inode);
1469 err |= __get_user(l.lo_rdevice, &ul->lo_rdevice);
1470 err |= __copy_from_user(&l.lo_offset, &ul->lo_offset,
1471 8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1472 if (err) {
1473 err = -EFAULT;
1474 } else {
1475 set_fs (KERNEL_DS);
1476 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1477 set_fs (old_fs);
1479 break;
1480 case LOOP_GET_STATUS:
1481 set_fs (KERNEL_DS);
1482 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1483 set_fs (old_fs);
1484 if (!err) {
1485 err = put_user(l.lo_number, &ul->lo_number);
1486 err |= __put_user(l.lo_device, &ul->lo_device);
1487 err |= __put_user(l.lo_inode, &ul->lo_inode);
1488 err |= __put_user(l.lo_rdevice, &ul->lo_rdevice);
1489 err |= __copy_to_user(&ul->lo_offset, &l.lo_offset,
1490 (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1491 if (err)
1492 err = -EFAULT;
1494 break;
1495 default: {
1496 static int count;
1497 if (++count <= 20)
1498 printk("%s: Unknown loop ioctl cmd, fd(%d) "
1499 "cmd(%08x) arg(%08lx)\n",
1500 __FUNCTION__, fd, cmd, arg);
1503 return err;
1506 extern int tty_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg);
1508 #ifdef CONFIG_VT
1510 static int vt_check(struct file *file)
1512 struct tty_struct *tty;
1513 struct inode *inode = file->f_dentry->d_inode;
1515 if (file->f_op->ioctl != tty_ioctl)
1516 return -EINVAL;
1518 tty = (struct tty_struct *)file->private_data;
1519 if (tty_paranoia_check(tty, inode, "tty_ioctl"))
1520 return -EINVAL;
1522 if (tty->driver->ioctl != vt_ioctl)
1523 return -EINVAL;
1526 * To have permissions to do most of the vt ioctls, we either have
1527 * to be the owner of the tty, or super-user.
1529 if (current->signal->tty == tty || capable(CAP_SYS_ADMIN))
1530 return 1;
1531 return 0;
1534 struct consolefontdesc32 {
1535 unsigned short charcount; /* characters in font (256 or 512) */
1536 unsigned short charheight; /* scan lines per character (1-32) */
1537 compat_caddr_t chardata; /* font data in expanded form */
1540 static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1542 struct consolefontdesc32 __user *user_cfd = compat_ptr(arg);
1543 struct console_font_op op;
1544 compat_caddr_t data;
1545 int i, perm;
1547 perm = vt_check(file);
1548 if (perm < 0) return perm;
1550 switch (cmd) {
1551 case PIO_FONTX:
1552 if (!perm)
1553 return -EPERM;
1554 op.op = KD_FONT_OP_SET;
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 op.data = compat_ptr(data);
1562 return con_font_op(vc_cons[fg_console].d, &op);
1563 case GIO_FONTX:
1564 op.op = KD_FONT_OP_GET;
1565 op.flags = 0;
1566 op.width = 8;
1567 if (get_user(op.height, &user_cfd->charheight) ||
1568 get_user(op.charcount, &user_cfd->charcount) ||
1569 get_user(data, &user_cfd->chardata))
1570 return -EFAULT;
1571 if (!data)
1572 return 0;
1573 op.data = compat_ptr(data);
1574 i = con_font_op(vc_cons[fg_console].d, &op);
1575 if (i)
1576 return i;
1577 if (put_user(op.height, &user_cfd->charheight) ||
1578 put_user(op.charcount, &user_cfd->charcount) ||
1579 put_user((compat_caddr_t)(unsigned long)op.data,
1580 &user_cfd->chardata))
1581 return -EFAULT;
1582 return 0;
1584 return -EINVAL;
1587 struct console_font_op32 {
1588 compat_uint_t op; /* operation code KD_FONT_OP_* */
1589 compat_uint_t flags; /* KD_FONT_FLAG_* */
1590 compat_uint_t width, height; /* font size */
1591 compat_uint_t charcount;
1592 compat_caddr_t data; /* font data with height fixed to 32 */
1595 static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1597 struct console_font_op op;
1598 struct console_font_op32 __user *fontop = compat_ptr(arg);
1599 int perm = vt_check(file), i;
1600 struct vc_data *vc;
1602 if (perm < 0) return perm;
1604 if (copy_from_user(&op, fontop, sizeof(struct console_font_op32)))
1605 return -EFAULT;
1606 if (!perm && op.op != KD_FONT_OP_GET)
1607 return -EPERM;
1608 op.data = compat_ptr(((struct console_font_op32 *)&op)->data);
1609 op.flags |= KD_FONT_FLAG_OLD;
1610 vc = ((struct tty_struct *)file->private_data)->driver_data;
1611 i = con_font_op(vc, &op);
1612 if (i)
1613 return i;
1614 ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
1615 if (copy_to_user(fontop, &op, sizeof(struct console_font_op32)))
1616 return -EFAULT;
1617 return 0;
1620 struct unimapdesc32 {
1621 unsigned short entry_ct;
1622 compat_caddr_t entries;
1625 static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1627 struct unimapdesc32 tmp;
1628 struct unimapdesc32 __user *user_ud = compat_ptr(arg);
1629 int perm = vt_check(file);
1631 if (perm < 0) return perm;
1632 if (copy_from_user(&tmp, user_ud, sizeof tmp))
1633 return -EFAULT;
1634 switch (cmd) {
1635 case PIO_UNIMAP:
1636 if (!perm) return -EPERM;
1637 return con_set_unimap(vc_cons[fg_console].d, tmp.entry_ct, compat_ptr(tmp.entries));
1638 case GIO_UNIMAP:
1639 return con_get_unimap(vc_cons[fg_console].d, tmp.entry_ct, &(user_ud->entry_ct), compat_ptr(tmp.entries));
1641 return 0;
1644 #endif /* CONFIG_VT */
1646 static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg)
1648 mm_segment_t old_fs = get_fs();
1649 __kernel_uid_t kuid;
1650 int err;
1652 cmd = SMB_IOC_GETMOUNTUID;
1654 set_fs(KERNEL_DS);
1655 err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
1656 set_fs(old_fs);
1658 if (err >= 0)
1659 err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg));
1661 return err;
1664 struct atmif_sioc32 {
1665 compat_int_t number;
1666 compat_int_t length;
1667 compat_caddr_t arg;
1670 struct atm_iobuf32 {
1671 compat_int_t length;
1672 compat_caddr_t buffer;
1675 #define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32)
1676 #define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32)
1677 #define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32)
1678 #define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32)
1679 #define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32)
1680 #define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32)
1681 #define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32)
1682 #define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32)
1683 #define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32)
1684 #define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32)
1685 #define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32)
1686 #define ATM_SETESIF32 _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32)
1687 #define ATM_GETSTAT32 _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32)
1688 #define ATM_GETSTATZ32 _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32)
1689 #define ATM_GETLOOP32 _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32)
1690 #define ATM_SETLOOP32 _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32)
1691 #define ATM_QUERYLOOP32 _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32)
1693 static struct {
1694 unsigned int cmd32;
1695 unsigned int cmd;
1696 } atm_ioctl_map[] = {
1697 { ATM_GETLINKRATE32, ATM_GETLINKRATE },
1698 { ATM_GETNAMES32, ATM_GETNAMES },
1699 { ATM_GETTYPE32, ATM_GETTYPE },
1700 { ATM_GETESI32, ATM_GETESI },
1701 { ATM_GETADDR32, ATM_GETADDR },
1702 { ATM_RSTADDR32, ATM_RSTADDR },
1703 { ATM_ADDADDR32, ATM_ADDADDR },
1704 { ATM_DELADDR32, ATM_DELADDR },
1705 { ATM_GETCIRANGE32, ATM_GETCIRANGE },
1706 { ATM_SETCIRANGE32, ATM_SETCIRANGE },
1707 { ATM_SETESI32, ATM_SETESI },
1708 { ATM_SETESIF32, ATM_SETESIF },
1709 { ATM_GETSTAT32, ATM_GETSTAT },
1710 { ATM_GETSTATZ32, ATM_GETSTATZ },
1711 { ATM_GETLOOP32, ATM_GETLOOP },
1712 { ATM_SETLOOP32, ATM_SETLOOP },
1713 { ATM_QUERYLOOP32, ATM_QUERYLOOP }
1716 #define NR_ATM_IOCTL (sizeof(atm_ioctl_map)/sizeof(atm_ioctl_map[0]))
1719 static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg)
1721 struct atm_iobuf __user *iobuf;
1722 struct atm_iobuf32 __user *iobuf32;
1723 u32 data;
1724 void __user *datap;
1725 int len, err;
1727 iobuf = compat_alloc_user_space(sizeof(*iobuf));
1728 iobuf32 = compat_ptr(arg);
1730 if (get_user(len, &iobuf32->length) ||
1731 get_user(data, &iobuf32->buffer))
1732 return -EFAULT;
1733 datap = compat_ptr(data);
1734 if (put_user(len, &iobuf->length) ||
1735 put_user(datap, &iobuf->buffer))
1736 return -EFAULT;
1738 err = sys_ioctl(fd, cmd, (unsigned long)iobuf);
1740 if (!err) {
1741 if (copy_in_user(&iobuf32->length, &iobuf->length,
1742 sizeof(int)))
1743 err = -EFAULT;
1746 return err;
1749 static int do_atmif_sioc(unsigned int fd, unsigned int cmd, unsigned long arg)
1751 struct atmif_sioc __user *sioc;
1752 struct atmif_sioc32 __user *sioc32;
1753 u32 data;
1754 void __user *datap;
1755 int err;
1757 sioc = compat_alloc_user_space(sizeof(*sioc));
1758 sioc32 = compat_ptr(arg);
1760 if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) ||
1761 get_user(data, &sioc32->arg))
1762 return -EFAULT;
1763 datap = compat_ptr(data);
1764 if (put_user(datap, &sioc->arg))
1765 return -EFAULT;
1767 err = sys_ioctl(fd, cmd, (unsigned long) sioc);
1769 if (!err) {
1770 if (copy_in_user(&sioc32->length, &sioc->length,
1771 sizeof(int)))
1772 err = -EFAULT;
1774 return err;
1777 static int do_atm_ioctl(unsigned int fd, unsigned int cmd32, unsigned long arg)
1779 int i;
1780 unsigned int cmd = 0;
1782 switch (cmd32) {
1783 case SONET_GETSTAT:
1784 case SONET_GETSTATZ:
1785 case SONET_GETDIAG:
1786 case SONET_SETDIAG:
1787 case SONET_CLRDIAG:
1788 case SONET_SETFRAMING:
1789 case SONET_GETFRAMING:
1790 case SONET_GETFRSENSE:
1791 return do_atmif_sioc(fd, cmd32, arg);
1794 for (i = 0; i < NR_ATM_IOCTL; i++) {
1795 if (cmd32 == atm_ioctl_map[i].cmd32) {
1796 cmd = atm_ioctl_map[i].cmd;
1797 break;
1800 if (i == NR_ATM_IOCTL)
1801 return -EINVAL;
1803 switch (cmd) {
1804 case ATM_GETNAMES:
1805 return do_atm_iobuf(fd, cmd, arg);
1807 case ATM_GETLINKRATE:
1808 case ATM_GETTYPE:
1809 case ATM_GETESI:
1810 case ATM_GETADDR:
1811 case ATM_RSTADDR:
1812 case ATM_ADDADDR:
1813 case ATM_DELADDR:
1814 case ATM_GETCIRANGE:
1815 case ATM_SETCIRANGE:
1816 case ATM_SETESI:
1817 case ATM_SETESIF:
1818 case ATM_GETSTAT:
1819 case ATM_GETSTATZ:
1820 case ATM_GETLOOP:
1821 case ATM_SETLOOP:
1822 case ATM_QUERYLOOP:
1823 return do_atmif_sioc(fd, cmd, arg);
1826 return -EINVAL;
1829 static __attribute_used__ int
1830 ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
1832 return -EINVAL;
1835 static int broken_blkgetsize(unsigned int fd, unsigned int cmd, unsigned long arg)
1837 /* The mkswap binary hard codes it to Intel value :-((( */
1838 return w_long(fd, BLKGETSIZE, arg);
1841 struct blkpg_ioctl_arg32 {
1842 compat_int_t op;
1843 compat_int_t flags;
1844 compat_int_t datalen;
1845 compat_caddr_t data;
1848 static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1850 struct blkpg_ioctl_arg32 __user *ua32 = compat_ptr(arg);
1851 struct blkpg_ioctl_arg __user *a = compat_alloc_user_space(sizeof(*a));
1852 compat_caddr_t udata;
1853 compat_int_t n;
1854 int err;
1856 err = get_user(n, &ua32->op);
1857 err |= put_user(n, &a->op);
1858 err |= get_user(n, &ua32->flags);
1859 err |= put_user(n, &a->flags);
1860 err |= get_user(n, &ua32->datalen);
1861 err |= put_user(n, &a->datalen);
1862 err |= get_user(udata, &ua32->data);
1863 err |= put_user(compat_ptr(udata), &a->data);
1864 if (err)
1865 return err;
1867 return sys_ioctl(fd, cmd, (unsigned long)a);
1870 static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
1872 return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
1875 /* Fix sizeof(sizeof()) breakage */
1876 #define BLKBSZGET_32 _IOR(0x12,112,int)
1877 #define BLKBSZSET_32 _IOW(0x12,113,int)
1878 #define BLKGETSIZE64_32 _IOR(0x12,114,int)
1880 static int do_blkbszget(unsigned int fd, unsigned int cmd, unsigned long arg)
1882 return sys_ioctl(fd, BLKBSZGET, (unsigned long)compat_ptr(arg));
1885 static int do_blkbszset(unsigned int fd, unsigned int cmd, unsigned long arg)
1887 return sys_ioctl(fd, BLKBSZSET, (unsigned long)compat_ptr(arg));
1890 static int do_blkgetsize64(unsigned int fd, unsigned int cmd,
1891 unsigned long arg)
1893 return sys_ioctl(fd, BLKGETSIZE64, (unsigned long)compat_ptr(arg));
1896 /* Bluetooth ioctls */
1897 #define HCIUARTSETPROTO _IOW('U', 200, int)
1898 #define HCIUARTGETPROTO _IOR('U', 201, int)
1900 #define BNEPCONNADD _IOW('B', 200, int)
1901 #define BNEPCONNDEL _IOW('B', 201, int)
1902 #define BNEPGETCONNLIST _IOR('B', 210, int)
1903 #define BNEPGETCONNINFO _IOR('B', 211, int)
1905 #define CMTPCONNADD _IOW('C', 200, int)
1906 #define CMTPCONNDEL _IOW('C', 201, int)
1907 #define CMTPGETCONNLIST _IOR('C', 210, int)
1908 #define CMTPGETCONNINFO _IOR('C', 211, int)
1910 #define HIDPCONNADD _IOW('H', 200, int)
1911 #define HIDPCONNDEL _IOW('H', 201, int)
1912 #define HIDPGETCONNLIST _IOR('H', 210, int)
1913 #define HIDPGETCONNINFO _IOR('H', 211, int)
1915 struct floppy_struct32 {
1916 compat_uint_t size;
1917 compat_uint_t sect;
1918 compat_uint_t head;
1919 compat_uint_t track;
1920 compat_uint_t stretch;
1921 unsigned char gap;
1922 unsigned char rate;
1923 unsigned char spec1;
1924 unsigned char fmt_gap;
1925 const compat_caddr_t name;
1928 struct floppy_drive_params32 {
1929 char cmos;
1930 compat_ulong_t max_dtr;
1931 compat_ulong_t hlt;
1932 compat_ulong_t hut;
1933 compat_ulong_t srt;
1934 compat_ulong_t spinup;
1935 compat_ulong_t spindown;
1936 unsigned char spindown_offset;
1937 unsigned char select_delay;
1938 unsigned char rps;
1939 unsigned char tracks;
1940 compat_ulong_t timeout;
1941 unsigned char interleave_sect;
1942 struct floppy_max_errors max_errors;
1943 char flags;
1944 char read_track;
1945 short autodetect[8];
1946 compat_int_t checkfreq;
1947 compat_int_t native_format;
1950 struct floppy_drive_struct32 {
1951 signed char flags;
1952 compat_ulong_t spinup_date;
1953 compat_ulong_t select_date;
1954 compat_ulong_t first_read_date;
1955 short probed_format;
1956 short track;
1957 short maxblock;
1958 short maxtrack;
1959 compat_int_t generation;
1960 compat_int_t keep_data;
1961 compat_int_t fd_ref;
1962 compat_int_t fd_device;
1963 compat_int_t last_checked;
1964 compat_caddr_t dmabuf;
1965 compat_int_t bufblocks;
1968 struct floppy_fdc_state32 {
1969 compat_int_t spec1;
1970 compat_int_t spec2;
1971 compat_int_t dtr;
1972 unsigned char version;
1973 unsigned char dor;
1974 compat_ulong_t address;
1975 unsigned int rawcmd:2;
1976 unsigned int reset:1;
1977 unsigned int need_configure:1;
1978 unsigned int perp_mode:2;
1979 unsigned int has_fifo:1;
1980 unsigned int driver_version;
1981 unsigned char track[4];
1984 struct floppy_write_errors32 {
1985 unsigned int write_errors;
1986 compat_ulong_t first_error_sector;
1987 compat_int_t first_error_generation;
1988 compat_ulong_t last_error_sector;
1989 compat_int_t last_error_generation;
1990 compat_uint_t badness;
1993 #define FDSETPRM32 _IOW(2, 0x42, struct floppy_struct32)
1994 #define FDDEFPRM32 _IOW(2, 0x43, struct floppy_struct32)
1995 #define FDGETPRM32 _IOR(2, 0x04, struct floppy_struct32)
1996 #define FDSETDRVPRM32 _IOW(2, 0x90, struct floppy_drive_params32)
1997 #define FDGETDRVPRM32 _IOR(2, 0x11, struct floppy_drive_params32)
1998 #define FDGETDRVSTAT32 _IOR(2, 0x12, struct floppy_drive_struct32)
1999 #define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct floppy_drive_struct32)
2000 #define FDGETFDCSTAT32 _IOR(2, 0x15, struct floppy_fdc_state32)
2001 #define FDWERRORGET32 _IOR(2, 0x17, struct floppy_write_errors32)
2003 static struct {
2004 unsigned int cmd32;
2005 unsigned int cmd;
2006 } fd_ioctl_trans_table[] = {
2007 { FDSETPRM32, FDSETPRM },
2008 { FDDEFPRM32, FDDEFPRM },
2009 { FDGETPRM32, FDGETPRM },
2010 { FDSETDRVPRM32, FDSETDRVPRM },
2011 { FDGETDRVPRM32, FDGETDRVPRM },
2012 { FDGETDRVSTAT32, FDGETDRVSTAT },
2013 { FDPOLLDRVSTAT32, FDPOLLDRVSTAT },
2014 { FDGETFDCSTAT32, FDGETFDCSTAT },
2015 { FDWERRORGET32, FDWERRORGET }
2018 #define NR_FD_IOCTL_TRANS (sizeof(fd_ioctl_trans_table)/sizeof(fd_ioctl_trans_table[0]))
2020 static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
2022 mm_segment_t old_fs = get_fs();
2023 void *karg = NULL;
2024 unsigned int kcmd = 0;
2025 int i, err;
2027 for (i = 0; i < NR_FD_IOCTL_TRANS; i++)
2028 if (cmd == fd_ioctl_trans_table[i].cmd32) {
2029 kcmd = fd_ioctl_trans_table[i].cmd;
2030 break;
2032 if (!kcmd)
2033 return -EINVAL;
2035 switch (cmd) {
2036 case FDSETPRM32:
2037 case FDDEFPRM32:
2038 case FDGETPRM32:
2040 compat_uptr_t name;
2041 struct floppy_struct32 __user *uf;
2042 struct floppy_struct *f;
2044 uf = compat_ptr(arg);
2045 f = karg = kmalloc(sizeof(struct floppy_struct), GFP_KERNEL);
2046 if (!karg)
2047 return -ENOMEM;
2048 if (cmd == FDGETPRM32)
2049 break;
2050 err = __get_user(f->size, &uf->size);
2051 err |= __get_user(f->sect, &uf->sect);
2052 err |= __get_user(f->head, &uf->head);
2053 err |= __get_user(f->track, &uf->track);
2054 err |= __get_user(f->stretch, &uf->stretch);
2055 err |= __get_user(f->gap, &uf->gap);
2056 err |= __get_user(f->rate, &uf->rate);
2057 err |= __get_user(f->spec1, &uf->spec1);
2058 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
2059 err |= __get_user(name, &uf->name);
2060 f->name = compat_ptr(name);
2061 if (err) {
2062 err = -EFAULT;
2063 goto out;
2065 break;
2067 case FDSETDRVPRM32:
2068 case FDGETDRVPRM32:
2070 struct floppy_drive_params32 __user *uf;
2071 struct floppy_drive_params *f;
2073 uf = compat_ptr(arg);
2074 f = karg = kmalloc(sizeof(struct floppy_drive_params), GFP_KERNEL);
2075 if (!karg)
2076 return -ENOMEM;
2077 if (cmd == FDGETDRVPRM32)
2078 break;
2079 err = __get_user(f->cmos, &uf->cmos);
2080 err |= __get_user(f->max_dtr, &uf->max_dtr);
2081 err |= __get_user(f->hlt, &uf->hlt);
2082 err |= __get_user(f->hut, &uf->hut);
2083 err |= __get_user(f->srt, &uf->srt);
2084 err |= __get_user(f->spinup, &uf->spinup);
2085 err |= __get_user(f->spindown, &uf->spindown);
2086 err |= __get_user(f->spindown_offset, &uf->spindown_offset);
2087 err |= __get_user(f->select_delay, &uf->select_delay);
2088 err |= __get_user(f->rps, &uf->rps);
2089 err |= __get_user(f->tracks, &uf->tracks);
2090 err |= __get_user(f->timeout, &uf->timeout);
2091 err |= __get_user(f->interleave_sect, &uf->interleave_sect);
2092 err |= __copy_from_user(&f->max_errors, &uf->max_errors, sizeof(f->max_errors));
2093 err |= __get_user(f->flags, &uf->flags);
2094 err |= __get_user(f->read_track, &uf->read_track);
2095 err |= __copy_from_user(f->autodetect, uf->autodetect, sizeof(f->autodetect));
2096 err |= __get_user(f->checkfreq, &uf->checkfreq);
2097 err |= __get_user(f->native_format, &uf->native_format);
2098 if (err) {
2099 err = -EFAULT;
2100 goto out;
2102 break;
2104 case FDGETDRVSTAT32:
2105 case FDPOLLDRVSTAT32:
2106 karg = kmalloc(sizeof(struct floppy_drive_struct), GFP_KERNEL);
2107 if (!karg)
2108 return -ENOMEM;
2109 break;
2110 case FDGETFDCSTAT32:
2111 karg = kmalloc(sizeof(struct floppy_fdc_state), GFP_KERNEL);
2112 if (!karg)
2113 return -ENOMEM;
2114 break;
2115 case FDWERRORGET32:
2116 karg = kmalloc(sizeof(struct floppy_write_errors), GFP_KERNEL);
2117 if (!karg)
2118 return -ENOMEM;
2119 break;
2120 default:
2121 return -EINVAL;
2123 set_fs (KERNEL_DS);
2124 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
2125 set_fs (old_fs);
2126 if (err)
2127 goto out;
2128 switch (cmd) {
2129 case FDGETPRM32:
2131 struct floppy_struct *f = karg;
2132 struct floppy_struct32 __user *uf = compat_ptr(arg);
2134 err = __put_user(f->size, &uf->size);
2135 err |= __put_user(f->sect, &uf->sect);
2136 err |= __put_user(f->head, &uf->head);
2137 err |= __put_user(f->track, &uf->track);
2138 err |= __put_user(f->stretch, &uf->stretch);
2139 err |= __put_user(f->gap, &uf->gap);
2140 err |= __put_user(f->rate, &uf->rate);
2141 err |= __put_user(f->spec1, &uf->spec1);
2142 err |= __put_user(f->fmt_gap, &uf->fmt_gap);
2143 err |= __put_user((u64)f->name, (compat_caddr_t __user *)&uf->name);
2144 break;
2146 case FDGETDRVPRM32:
2148 struct floppy_drive_params32 __user *uf;
2149 struct floppy_drive_params *f = karg;
2151 uf = compat_ptr(arg);
2152 err = __put_user(f->cmos, &uf->cmos);
2153 err |= __put_user(f->max_dtr, &uf->max_dtr);
2154 err |= __put_user(f->hlt, &uf->hlt);
2155 err |= __put_user(f->hut, &uf->hut);
2156 err |= __put_user(f->srt, &uf->srt);
2157 err |= __put_user(f->spinup, &uf->spinup);
2158 err |= __put_user(f->spindown, &uf->spindown);
2159 err |= __put_user(f->spindown_offset, &uf->spindown_offset);
2160 err |= __put_user(f->select_delay, &uf->select_delay);
2161 err |= __put_user(f->rps, &uf->rps);
2162 err |= __put_user(f->tracks, &uf->tracks);
2163 err |= __put_user(f->timeout, &uf->timeout);
2164 err |= __put_user(f->interleave_sect, &uf->interleave_sect);
2165 err |= __copy_to_user(&uf->max_errors, &f->max_errors, sizeof(f->max_errors));
2166 err |= __put_user(f->flags, &uf->flags);
2167 err |= __put_user(f->read_track, &uf->read_track);
2168 err |= __copy_to_user(uf->autodetect, f->autodetect, sizeof(f->autodetect));
2169 err |= __put_user(f->checkfreq, &uf->checkfreq);
2170 err |= __put_user(f->native_format, &uf->native_format);
2171 break;
2173 case FDGETDRVSTAT32:
2174 case FDPOLLDRVSTAT32:
2176 struct floppy_drive_struct32 __user *uf;
2177 struct floppy_drive_struct *f = karg;
2179 uf = compat_ptr(arg);
2180 err = __put_user(f->flags, &uf->flags);
2181 err |= __put_user(f->spinup_date, &uf->spinup_date);
2182 err |= __put_user(f->select_date, &uf->select_date);
2183 err |= __put_user(f->first_read_date, &uf->first_read_date);
2184 err |= __put_user(f->probed_format, &uf->probed_format);
2185 err |= __put_user(f->track, &uf->track);
2186 err |= __put_user(f->maxblock, &uf->maxblock);
2187 err |= __put_user(f->maxtrack, &uf->maxtrack);
2188 err |= __put_user(f->generation, &uf->generation);
2189 err |= __put_user(f->keep_data, &uf->keep_data);
2190 err |= __put_user(f->fd_ref, &uf->fd_ref);
2191 err |= __put_user(f->fd_device, &uf->fd_device);
2192 err |= __put_user(f->last_checked, &uf->last_checked);
2193 err |= __put_user((u64)f->dmabuf, &uf->dmabuf);
2194 err |= __put_user((u64)f->bufblocks, &uf->bufblocks);
2195 break;
2197 case FDGETFDCSTAT32:
2199 struct floppy_fdc_state32 __user *uf;
2200 struct floppy_fdc_state *f = karg;
2202 uf = compat_ptr(arg);
2203 err = __put_user(f->spec1, &uf->spec1);
2204 err |= __put_user(f->spec2, &uf->spec2);
2205 err |= __put_user(f->dtr, &uf->dtr);
2206 err |= __put_user(f->version, &uf->version);
2207 err |= __put_user(f->dor, &uf->dor);
2208 err |= __put_user(f->address, &uf->address);
2209 err |= __copy_to_user((char __user *)&uf->address + sizeof(uf->address),
2210 (char *)&f->address + sizeof(f->address), sizeof(int));
2211 err |= __put_user(f->driver_version, &uf->driver_version);
2212 err |= __copy_to_user(uf->track, f->track, sizeof(f->track));
2213 break;
2215 case FDWERRORGET32:
2217 struct floppy_write_errors32 __user *uf;
2218 struct floppy_write_errors *f = karg;
2220 uf = compat_ptr(arg);
2221 err = __put_user(f->write_errors, &uf->write_errors);
2222 err |= __put_user(f->first_error_sector, &uf->first_error_sector);
2223 err |= __put_user(f->first_error_generation, &uf->first_error_generation);
2224 err |= __put_user(f->last_error_sector, &uf->last_error_sector);
2225 err |= __put_user(f->last_error_generation, &uf->last_error_generation);
2226 err |= __put_user(f->badness, &uf->badness);
2227 break;
2229 default:
2230 break;
2232 if (err)
2233 err = -EFAULT;
2235 out: if (karg) kfree(karg);
2236 return err;
2239 struct mtd_oob_buf32 {
2240 u_int32_t start;
2241 u_int32_t length;
2242 compat_caddr_t ptr; /* unsigned char* */
2245 #define MEMWRITEOOB32 _IOWR('M',3,struct mtd_oob_buf32)
2246 #define MEMREADOOB32 _IOWR('M',4,struct mtd_oob_buf32)
2248 static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg)
2250 struct mtd_oob_buf __user *buf = compat_alloc_user_space(sizeof(*buf));
2251 struct mtd_oob_buf32 __user *buf32 = compat_ptr(arg);
2252 u32 data;
2253 char __user *datap;
2254 unsigned int real_cmd;
2255 int err;
2257 real_cmd = (cmd == MEMREADOOB32) ?
2258 MEMREADOOB : MEMWRITEOOB;
2260 if (copy_in_user(&buf->start, &buf32->start,
2261 2 * sizeof(u32)) ||
2262 get_user(data, &buf32->ptr))
2263 return -EFAULT;
2264 datap = compat_ptr(data);
2265 if (put_user(datap, &buf->ptr))
2266 return -EFAULT;
2268 err = sys_ioctl(fd, real_cmd, (unsigned long) buf);
2270 if (!err) {
2271 if (copy_in_user(&buf32->start, &buf->start,
2272 2 * sizeof(u32)))
2273 err = -EFAULT;
2276 return err;
2279 #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
2280 #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
2282 static long
2283 put_dirent32 (struct dirent *d, struct compat_dirent __user *d32)
2285 if (!access_ok(VERIFY_WRITE, d32, sizeof(struct compat_dirent)))
2286 return -EFAULT;
2288 __put_user(d->d_ino, &d32->d_ino);
2289 __put_user(d->d_off, &d32->d_off);
2290 __put_user(d->d_reclen, &d32->d_reclen);
2291 if (__copy_to_user(d32->d_name, d->d_name, d->d_reclen))
2292 return -EFAULT;
2294 return 0;
2297 static int vfat_ioctl32(unsigned fd, unsigned cmd, unsigned long arg)
2299 struct compat_dirent __user *p = compat_ptr(arg);
2300 int ret;
2301 mm_segment_t oldfs = get_fs();
2302 struct dirent d[2];
2304 switch(cmd)
2306 case VFAT_IOCTL_READDIR_BOTH32:
2307 cmd = VFAT_IOCTL_READDIR_BOTH;
2308 break;
2309 case VFAT_IOCTL_READDIR_SHORT32:
2310 cmd = VFAT_IOCTL_READDIR_SHORT;
2311 break;
2314 set_fs(KERNEL_DS);
2315 ret = sys_ioctl(fd,cmd,(unsigned long)&d);
2316 set_fs(oldfs);
2317 if (ret >= 0) {
2318 ret |= put_dirent32(&d[0], p);
2319 ret |= put_dirent32(&d[1], p + 1);
2321 return ret;
2324 #define REISERFS_IOC_UNPACK32 _IOW(0xCD,1,int)
2326 static int reiserfs_ioctl32(unsigned fd, unsigned cmd, unsigned long ptr)
2328 if (cmd == REISERFS_IOC_UNPACK32)
2329 cmd = REISERFS_IOC_UNPACK;
2331 return sys_ioctl(fd,cmd,ptr);
2334 struct raw32_config_request
2336 compat_int_t raw_minor;
2337 __u64 block_major;
2338 __u64 block_minor;
2339 } __attribute__((packed));
2341 static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
2343 int ret;
2345 if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request)))
2346 return -EFAULT;
2348 ret = __get_user(req->raw_minor, &user_req->raw_minor);
2349 ret |= __get_user(req->block_major, &user_req->block_major);
2350 ret |= __get_user(req->block_minor, &user_req->block_minor);
2352 return ret ? -EFAULT : 0;
2355 static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
2357 int ret;
2359 if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request)))
2360 return -EFAULT;
2362 ret = __put_user(req->raw_minor, &user_req->raw_minor);
2363 ret |= __put_user(req->block_major, &user_req->block_major);
2364 ret |= __put_user(req->block_minor, &user_req->block_minor);
2366 return ret ? -EFAULT : 0;
2369 static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2371 int ret;
2373 switch (cmd) {
2374 case RAW_SETBIND:
2375 case RAW_GETBIND: {
2376 struct raw_config_request req;
2377 struct raw32_config_request __user *user_req = compat_ptr(arg);
2378 mm_segment_t oldfs = get_fs();
2380 if ((ret = get_raw32_request(&req, user_req)))
2381 return ret;
2383 set_fs(KERNEL_DS);
2384 ret = sys_ioctl(fd,cmd,(unsigned long)&req);
2385 set_fs(oldfs);
2387 if ((!ret) && (cmd == RAW_GETBIND)) {
2388 ret = set_raw32_request(&req, user_req);
2390 break;
2392 default:
2393 ret = sys_ioctl(fd, cmd, arg);
2394 break;
2396 return ret;
2399 struct serial_struct32 {
2400 compat_int_t type;
2401 compat_int_t line;
2402 compat_uint_t port;
2403 compat_int_t irq;
2404 compat_int_t flags;
2405 compat_int_t xmit_fifo_size;
2406 compat_int_t custom_divisor;
2407 compat_int_t baud_base;
2408 unsigned short close_delay;
2409 char io_type;
2410 char reserved_char[1];
2411 compat_int_t hub6;
2412 unsigned short closing_wait; /* time to wait before closing */
2413 unsigned short closing_wait2; /* no longer used... */
2414 compat_uint_t iomem_base;
2415 unsigned short iomem_reg_shift;
2416 unsigned int port_high;
2417 /* compat_ulong_t iomap_base FIXME */
2418 compat_int_t reserved[1];
2421 static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2423 typedef struct serial_struct SS;
2424 typedef struct serial_struct32 SS32;
2425 struct serial_struct32 __user *ss32 = compat_ptr(arg);
2426 int err;
2427 struct serial_struct ss;
2428 mm_segment_t oldseg = get_fs();
2429 __u32 udata;
2431 if (cmd == TIOCSSERIAL) {
2432 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
2433 return -EFAULT;
2434 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
2435 return -EFAULT;
2436 __get_user(udata, &ss32->iomem_base);
2437 ss.iomem_base = compat_ptr(udata);
2438 __get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift);
2439 __get_user(ss.port_high, &ss32->port_high);
2440 ss.iomap_base = 0UL;
2442 set_fs(KERNEL_DS);
2443 err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
2444 set_fs(oldseg);
2445 if (cmd == TIOCGSERIAL && err >= 0) {
2446 if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32)))
2447 return -EFAULT;
2448 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
2449 return -EFAULT;
2450 __put_user((unsigned long)ss.iomem_base >> 32 ?
2451 0xffffffff : (unsigned)(unsigned long)ss.iomem_base,
2452 &ss32->iomem_base);
2453 __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift);
2454 __put_user(ss.port_high, &ss32->port_high);
2457 return err;
2460 struct usbdevfs_ctrltransfer32 {
2461 u8 bRequestType;
2462 u8 bRequest;
2463 u16 wValue;
2464 u16 wIndex;
2465 u16 wLength;
2466 u32 timeout; /* in milliseconds */
2467 compat_caddr_t data;
2470 #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
2472 static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
2474 struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg);
2475 struct usbdevfs_ctrltransfer __user *p;
2476 __u32 udata;
2477 p = compat_alloc_user_space(sizeof(*p));
2478 if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
2479 get_user(udata, &p32->data) ||
2480 put_user(compat_ptr(udata), &p->data))
2481 return -EFAULT;
2482 return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p);
2486 struct usbdevfs_bulktransfer32 {
2487 compat_uint_t ep;
2488 compat_uint_t len;
2489 compat_uint_t timeout; /* in milliseconds */
2490 compat_caddr_t data;
2493 #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
2495 static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
2497 struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg);
2498 struct usbdevfs_bulktransfer __user *p;
2499 compat_uint_t n;
2500 compat_caddr_t addr;
2502 p = compat_alloc_user_space(sizeof(*p));
2504 if (get_user(n, &p32->ep) || put_user(n, &p->ep) ||
2505 get_user(n, &p32->len) || put_user(n, &p->len) ||
2506 get_user(n, &p32->timeout) || put_user(n, &p->timeout) ||
2507 get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data))
2508 return -EFAULT;
2510 return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p);
2515 * USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY
2516 * are handled in usbdevfs core. -Christopher Li
2519 struct usbdevfs_disconnectsignal32 {
2520 compat_int_t signr;
2521 compat_caddr_t context;
2524 #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
2526 static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
2528 struct usbdevfs_disconnectsignal kdis;
2529 struct usbdevfs_disconnectsignal32 __user *udis;
2530 mm_segment_t old_fs;
2531 u32 uctx;
2532 int err;
2534 udis = compat_ptr(arg);
2536 if (get_user(kdis.signr, &udis->signr) ||
2537 __get_user(uctx, &udis->context))
2538 return -EFAULT;
2540 kdis.context = compat_ptr(uctx);
2542 old_fs = get_fs();
2543 set_fs(KERNEL_DS);
2544 err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
2545 set_fs(old_fs);
2547 return err;
2551 * I2C layer ioctls
2554 struct i2c_msg32 {
2555 u16 addr;
2556 u16 flags;
2557 u16 len;
2558 compat_caddr_t buf;
2561 struct i2c_rdwr_ioctl_data32 {
2562 compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
2563 u32 nmsgs;
2566 struct i2c_smbus_ioctl_data32 {
2567 u8 read_write;
2568 u8 command;
2569 u32 size;
2570 compat_caddr_t data; /* union i2c_smbus_data *data */
2573 struct i2c_rdwr_aligned {
2574 struct i2c_rdwr_ioctl_data cmd;
2575 struct i2c_msg msgs[0];
2578 static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2580 struct i2c_rdwr_ioctl_data32 __user *udata = compat_ptr(arg);
2581 struct i2c_rdwr_aligned __user *tdata;
2582 struct i2c_msg __user *tmsgs;
2583 struct i2c_msg32 __user *umsgs;
2584 compat_caddr_t datap;
2585 int nmsgs, i;
2587 if (get_user(nmsgs, &udata->nmsgs))
2588 return -EFAULT;
2589 if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
2590 return -EINVAL;
2592 if (get_user(datap, &udata->msgs))
2593 return -EFAULT;
2594 umsgs = compat_ptr(datap);
2596 tdata = compat_alloc_user_space(sizeof(*tdata) +
2597 nmsgs * sizeof(struct i2c_msg));
2598 tmsgs = &tdata->msgs[0];
2600 if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
2601 put_user(tmsgs, &tdata->cmd.msgs))
2602 return -EFAULT;
2604 for (i = 0; i < nmsgs; i++) {
2605 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
2606 return -EFAULT;
2607 if (get_user(datap, &umsgs[i].buf) ||
2608 put_user(compat_ptr(datap), &tmsgs[i].buf))
2609 return -EFAULT;
2611 return sys_ioctl(fd, cmd, (unsigned long)tdata);
2614 static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2616 struct i2c_smbus_ioctl_data __user *tdata;
2617 struct i2c_smbus_ioctl_data32 __user *udata;
2618 compat_caddr_t datap;
2620 tdata = compat_alloc_user_space(sizeof(*tdata));
2621 if (tdata == NULL)
2622 return -ENOMEM;
2623 if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
2624 return -EFAULT;
2626 udata = compat_ptr(arg);
2627 if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
2628 return -EFAULT;
2630 if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
2631 return -EFAULT;
2632 if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
2633 return -EFAULT;
2634 if (__get_user(datap, &udata->data) ||
2635 __put_user(compat_ptr(datap), &tdata->data))
2636 return -EFAULT;
2638 return sys_ioctl(fd, cmd, (unsigned long)tdata);
2641 struct compat_iw_point {
2642 compat_caddr_t pointer;
2643 __u16 length;
2644 __u16 flags;
2647 static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2649 struct iwreq __user *iwr;
2650 struct iwreq __user *iwr_u;
2651 struct iw_point __user *iwp;
2652 struct compat_iw_point __user *iwp_u;
2653 compat_caddr_t pointer;
2654 __u16 length, flags;
2656 iwr_u = compat_ptr(arg);
2657 iwp_u = (struct compat_iw_point __user *) &iwr_u->u.data;
2658 iwr = compat_alloc_user_space(sizeof(*iwr));
2659 if (iwr == NULL)
2660 return -ENOMEM;
2662 iwp = &iwr->u.data;
2664 if (!access_ok(VERIFY_WRITE, iwr, sizeof(*iwr)))
2665 return -EFAULT;
2667 if (__copy_in_user(&iwr->ifr_ifrn.ifrn_name[0],
2668 &iwr_u->ifr_ifrn.ifrn_name[0],
2669 sizeof(iwr->ifr_ifrn.ifrn_name)))
2670 return -EFAULT;
2672 if (__get_user(pointer, &iwp_u->pointer) ||
2673 __get_user(length, &iwp_u->length) ||
2674 __get_user(flags, &iwp_u->flags))
2675 return -EFAULT;
2677 if (__put_user(compat_ptr(pointer), &iwp->pointer) ||
2678 __put_user(length, &iwp->length) ||
2679 __put_user(flags, &iwp->flags))
2680 return -EFAULT;
2682 return sys_ioctl(fd, cmd, (unsigned long) iwr);
2685 /* Since old style bridge ioctl's endup using SIOCDEVPRIVATE
2686 * for some operations; this forces use of the newer bridge-utils that
2687 * use compatiable ioctls
2689 static int old_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2691 u32 tmp;
2693 if (get_user(tmp, (u32 __user *) arg))
2694 return -EFAULT;
2695 if (tmp == BRCTL_GET_VERSION)
2696 return BRCTL_VERSION + 1;
2697 return -EINVAL;
2700 #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
2701 struct ncp_ioctl_request_32 {
2702 u32 function;
2703 u32 size;
2704 compat_caddr_t data;
2707 struct ncp_fs_info_v2_32 {
2708 s32 version;
2709 u32 mounted_uid;
2710 u32 connection;
2711 u32 buffer_size;
2713 u32 volume_number;
2714 u32 directory_id;
2716 u32 dummy1;
2717 u32 dummy2;
2718 u32 dummy3;
2721 struct ncp_objectname_ioctl_32
2723 s32 auth_type;
2724 u32 object_name_len;
2725 compat_caddr_t object_name; /* an userspace data, in most cases user name */
2728 struct ncp_privatedata_ioctl_32
2730 u32 len;
2731 compat_caddr_t data; /* ~1000 for NDS */
2734 #define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct ncp_ioctl_request_32)
2735 #define NCP_IOC_GETMOUNTUID2_32 _IOW('n', 2, u32)
2736 #define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct ncp_fs_info_v2_32)
2737 #define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct ncp_objectname_ioctl_32)
2738 #define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct ncp_objectname_ioctl_32)
2739 #define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct ncp_privatedata_ioctl_32)
2740 #define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct ncp_privatedata_ioctl_32)
2742 static int do_ncp_ncprequest(unsigned int fd, unsigned int cmd, unsigned long arg)
2744 struct ncp_ioctl_request_32 n32;
2745 struct ncp_ioctl_request __user *p = compat_alloc_user_space(sizeof(*p));
2747 if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)) ||
2748 put_user(n32.function, &p->function) ||
2749 put_user(n32.size, &p->size) ||
2750 put_user(compat_ptr(n32.data), &p->data))
2751 return -EFAULT;
2753 return sys_ioctl(fd, NCP_IOC_NCPREQUEST, (unsigned long)p);
2756 static int do_ncp_getmountuid2(unsigned int fd, unsigned int cmd, unsigned long arg)
2758 mm_segment_t old_fs = get_fs();
2759 __kernel_uid_t kuid;
2760 int err;
2762 cmd = NCP_IOC_GETMOUNTUID2;
2764 set_fs(KERNEL_DS);
2765 err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
2766 set_fs(old_fs);
2768 if (!err)
2769 err = put_user(kuid,
2770 (unsigned int __user *) compat_ptr(arg));
2772 return err;
2775 static int do_ncp_getfsinfo2(unsigned int fd, unsigned int cmd, unsigned long arg)
2777 mm_segment_t old_fs = get_fs();
2778 struct ncp_fs_info_v2_32 n32;
2779 struct ncp_fs_info_v2 n;
2780 int err;
2782 if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)))
2783 return -EFAULT;
2784 if (n32.version != NCP_GET_FS_INFO_VERSION_V2)
2785 return -EINVAL;
2786 n.version = NCP_GET_FS_INFO_VERSION_V2;
2788 set_fs(KERNEL_DS);
2789 err = sys_ioctl(fd, NCP_IOC_GET_FS_INFO_V2, (unsigned long)&n);
2790 set_fs(old_fs);
2792 if (!err) {
2793 n32.version = n.version;
2794 n32.mounted_uid = n.mounted_uid;
2795 n32.connection = n.connection;
2796 n32.buffer_size = n.buffer_size;
2797 n32.volume_number = n.volume_number;
2798 n32.directory_id = n.directory_id;
2799 n32.dummy1 = n.dummy1;
2800 n32.dummy2 = n.dummy2;
2801 n32.dummy3 = n.dummy3;
2802 err = copy_to_user(compat_ptr(arg), &n32, sizeof(n32)) ? -EFAULT : 0;
2804 return err;
2807 static int do_ncp_getobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
2809 struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2810 struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
2811 s32 auth_type;
2812 u32 name_len;
2813 int err;
2815 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2816 put_user(n32.object_name_len, &p->object_name_len) ||
2817 put_user(compat_ptr(n32.object_name), &p->object_name))
2818 return -EFAULT;
2820 err = sys_ioctl(fd, NCP_IOC_GETOBJECTNAME, (unsigned long)p);
2821 if (err)
2822 return err;
2824 if (get_user(auth_type, &p->auth_type) ||
2825 put_user(auth_type, &p32->auth_type) ||
2826 get_user(name_len, &p->object_name_len) ||
2827 put_user(name_len, &p32->object_name_len))
2828 return -EFAULT;
2830 return 0;
2833 static int do_ncp_setobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
2835 struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2836 struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
2838 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2839 put_user(n32.auth_type, &p->auth_type) ||
2840 put_user(n32.object_name_len, &p->object_name_len) ||
2841 put_user(compat_ptr(n32.object_name), &p->object_name))
2842 return -EFAULT;
2844 return sys_ioctl(fd, NCP_IOC_SETOBJECTNAME, (unsigned long)p);
2847 static int do_ncp_getprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
2849 struct ncp_privatedata_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2850 struct ncp_privatedata_ioctl __user *p =
2851 compat_alloc_user_space(sizeof(*p));
2852 u32 len;
2853 int err;
2855 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2856 put_user(n32.len, &p->len) ||
2857 put_user(compat_ptr(n32.data), &p->data))
2858 return -EFAULT;
2860 err = sys_ioctl(fd, NCP_IOC_GETPRIVATEDATA, (unsigned long)p);
2861 if (err)
2862 return err;
2864 if (get_user(len, &p->len) ||
2865 put_user(len, &p32->len))
2866 return -EFAULT;
2868 return 0;
2871 static int do_ncp_setprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
2873 struct ncp_privatedata_ioctl_32 n32;
2874 struct ncp_privatedata_ioctl_32 __user *p32 = compat_ptr(arg);
2875 struct ncp_privatedata_ioctl __user *p =
2876 compat_alloc_user_space(sizeof(*p));
2878 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2879 put_user(n32.len, &p->len) ||
2880 put_user(compat_ptr(n32.data), &p->data))
2881 return -EFAULT;
2883 return sys_ioctl(fd, NCP_IOC_SETPRIVATEDATA, (unsigned long)p);
2885 #endif
2887 #undef CODE
2888 #endif
2890 #ifdef DECLARES
2891 HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob)
2892 HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob)
2893 #ifdef CONFIG_NET
2894 HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
2895 HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)
2896 HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc)
2897 HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc)
2898 HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc)
2899 HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc)
2900 HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc)
2901 HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc)
2902 HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc)
2903 HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc)
2904 HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc)
2905 HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc)
2906 HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc)
2907 HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc)
2908 HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc)
2909 HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc)
2910 HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
2911 HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
2912 HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
2914 /* ioctls used by appletalk ddp.c */
2915 HANDLE_IOCTL(SIOCATALKDIFADDR, dev_ifsioc)
2916 HANDLE_IOCTL(SIOCDIFADDR, dev_ifsioc)
2917 HANDLE_IOCTL(SIOCSARP, dev_ifsioc)
2918 HANDLE_IOCTL(SIOCDARP, dev_ifsioc)
2920 HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc)
2921 HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc)
2922 HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc)
2923 HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc)
2924 HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc)
2925 HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc)
2926 HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc)
2927 HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc)
2928 HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc)
2929 HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc)
2930 HANDLE_IOCTL(TUNSETIFF, dev_ifsioc)
2931 HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl)
2932 HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl)
2933 HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl)
2934 HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl)
2935 HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl)
2936 HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl)
2937 HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl)
2938 HANDLE_IOCTL(SIOCADDRT, routing_ioctl)
2939 HANDLE_IOCTL(SIOCDELRT, routing_ioctl)
2940 HANDLE_IOCTL(SIOCBRADDIF, dev_ifsioc)
2941 HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc)
2942 /* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
2943 HANDLE_IOCTL(SIOCRTMSG, ret_einval)
2944 HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
2945 #endif
2946 HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo)
2947 HANDLE_IOCTL(BLKRAGET, w_long)
2948 HANDLE_IOCTL(BLKGETSIZE, w_long)
2949 HANDLE_IOCTL(0x1260, broken_blkgetsize)
2950 HANDLE_IOCTL(BLKFRAGET, w_long)
2951 HANDLE_IOCTL(BLKSECTGET, w_long)
2952 HANDLE_IOCTL(FBIOGET_FSCREENINFO, fb_ioctl_trans)
2953 HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
2954 HANDLE_IOCTL(FBIOGETCMAP, fb_ioctl_trans)
2955 HANDLE_IOCTL(FBIOPUTCMAP, fb_ioctl_trans)
2956 HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans)
2957 HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans)
2958 HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans)
2959 HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans)
2960 HANDLE_IOCTL(HDIO_GET_MULTCOUNT, hdio_ioctl_trans)
2961 HANDLE_IOCTL(HDIO_GET_NOWERR, hdio_ioctl_trans)
2962 HANDLE_IOCTL(HDIO_GET_NICE, hdio_ioctl_trans)
2963 HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans)
2964 HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans)
2965 HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans)
2966 HANDLE_IOCTL(FDSETDRVPRM32, fd_ioctl_trans)
2967 HANDLE_IOCTL(FDGETDRVPRM32, fd_ioctl_trans)
2968 HANDLE_IOCTL(FDGETDRVSTAT32, fd_ioctl_trans)
2969 HANDLE_IOCTL(FDPOLLDRVSTAT32, fd_ioctl_trans)
2970 HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans)
2971 HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans)
2972 HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
2973 HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans)
2974 HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans)
2975 HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans)
2976 HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans)
2977 HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans)
2978 HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans)
2979 HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans)
2980 HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans)
2981 HANDLE_IOCTL(LOOP_SET_STATUS, loop_status)
2982 HANDLE_IOCTL(LOOP_GET_STATUS, loop_status)
2983 #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
2984 HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout)
2985 #ifdef CONFIG_VT
2986 HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl)
2987 HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl)
2988 HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl)
2989 HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl)
2990 HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl)
2991 #endif
2992 HANDLE_IOCTL(EXT2_IOC32_GETFLAGS, do_ext2_ioctl)
2993 HANDLE_IOCTL(EXT2_IOC32_SETFLAGS, do_ext2_ioctl)
2994 HANDLE_IOCTL(EXT2_IOC32_GETVERSION, do_ext2_ioctl)
2995 HANDLE_IOCTL(EXT2_IOC32_SETVERSION, do_ext2_ioctl)
2996 HANDLE_IOCTL(VIDIOCGTUNER32, do_video_ioctl)
2997 HANDLE_IOCTL(VIDIOCSTUNER32, do_video_ioctl)
2998 HANDLE_IOCTL(VIDIOCGWIN32, do_video_ioctl)
2999 HANDLE_IOCTL(VIDIOCSWIN32, do_set_window)
3000 HANDLE_IOCTL(VIDIOCGFBUF32, do_video_ioctl)
3001 HANDLE_IOCTL(VIDIOCSFBUF32, do_video_ioctl)
3002 HANDLE_IOCTL(VIDIOCGFREQ32, do_video_ioctl)
3003 HANDLE_IOCTL(VIDIOCSFREQ32, do_video_ioctl)
3004 /* One SMB ioctl needs translations. */
3005 #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
3006 HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
3007 HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl)
3008 HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl)
3009 HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl)
3010 HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl)
3011 HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl)
3012 HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl)
3013 HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl)
3014 HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl)
3015 HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl)
3016 HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl)
3017 HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl)
3018 HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl)
3019 HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl)
3020 HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl)
3021 HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl)
3022 HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl)
3023 HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl)
3024 HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl)
3025 HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl)
3026 HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl)
3027 HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl)
3028 HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl)
3029 HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl)
3030 HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl)
3031 HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl)
3032 /* block stuff */
3033 HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget)
3034 HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset)
3035 HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64)
3036 /* vfat */
3037 HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32)
3038 HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32, vfat_ioctl32)
3039 HANDLE_IOCTL(REISERFS_IOC_UNPACK32, reiserfs_ioctl32)
3040 /* Raw devices */
3041 HANDLE_IOCTL(RAW_SETBIND, raw_ioctl)
3042 HANDLE_IOCTL(RAW_GETBIND, raw_ioctl)
3043 /* Serial */
3044 HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl)
3045 HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl)
3046 /* Usbdevfs */
3047 HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
3048 HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
3049 HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
3050 /* i2c */
3051 HANDLE_IOCTL(I2C_FUNCS, w_long)
3052 HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
3053 HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
3054 /* wireless */
3055 HANDLE_IOCTL(SIOCGIWRANGE, do_wireless_ioctl)
3056 HANDLE_IOCTL(SIOCSIWSPY, do_wireless_ioctl)
3057 HANDLE_IOCTL(SIOCGIWSPY, do_wireless_ioctl)
3058 HANDLE_IOCTL(SIOCSIWTHRSPY, do_wireless_ioctl)
3059 HANDLE_IOCTL(SIOCGIWTHRSPY, do_wireless_ioctl)
3060 HANDLE_IOCTL(SIOCGIWAPLIST, do_wireless_ioctl)
3061 HANDLE_IOCTL(SIOCGIWSCAN, do_wireless_ioctl)
3062 HANDLE_IOCTL(SIOCSIWESSID, do_wireless_ioctl)
3063 HANDLE_IOCTL(SIOCGIWESSID, do_wireless_ioctl)
3064 HANDLE_IOCTL(SIOCSIWNICKN, do_wireless_ioctl)
3065 HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl)
3066 HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl)
3067 HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl)
3068 HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl)
3069 HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl)
3071 #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
3072 HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest)
3073 HANDLE_IOCTL(NCP_IOC_GETMOUNTUID2_32, do_ncp_getmountuid2)
3074 HANDLE_IOCTL(NCP_IOC_GET_FS_INFO_V2_32, do_ncp_getfsinfo2)
3075 HANDLE_IOCTL(NCP_IOC_GETOBJECTNAME_32, do_ncp_getobjectname)
3076 HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32, do_ncp_setobjectname)
3077 HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata)
3078 HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata)
3079 #endif
3081 #undef DECLARES
3082 #endif