[PATCH] USB: Remove USB private semaphore
[linux-2.6/mini2440.git] / fs / compat_ioctl.c
blob43a2508ac69670d972516a0f5d2ad96f8e7bfa02
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/ext3_jbd.h>
53 #include <linux/ext3_fs.h>
54 #include <linux/videodev.h>
55 #include <linux/netdevice.h>
56 #include <linux/raw.h>
57 #include <linux/smb_fs.h>
58 #include <linux/blkpg.h>
59 #include <linux/blkdev.h>
60 #include <linux/elevator.h>
61 #include <linux/rtc.h>
62 #include <linux/pci.h>
63 #include <linux/module.h>
64 #include <linux/serial.h>
65 #include <linux/reiserfs_fs.h>
66 #include <linux/if_tun.h>
67 #include <linux/ctype.h>
68 #include <linux/ioctl32.h>
69 #include <linux/syscalls.h>
70 #include <linux/ncp_fs.h>
71 #include <linux/i2c.h>
72 #include <linux/i2c-dev.h>
73 #include <linux/wireless.h>
74 #include <linux/atalk.h>
76 #include <net/sock.h> /* siocdevprivate_ioctl */
77 #include <net/bluetooth/bluetooth.h>
78 #include <net/bluetooth/hci.h>
79 #include <net/bluetooth/rfcomm.h>
81 #include <linux/capi.h>
83 #include <scsi/scsi.h>
84 /* Ugly hack. */
85 #undef __KERNEL__
86 #include <scsi/scsi_ioctl.h>
87 #define __KERNEL__
88 #include <scsi/sg.h>
90 #include <asm/types.h>
91 #include <asm/uaccess.h>
92 #include <linux/ethtool.h>
93 #include <linux/mii.h>
94 #include <linux/if_bonding.h>
95 #include <linux/watchdog.h>
96 #include <linux/dm-ioctl.h>
98 #include <asm/module.h>
99 #include <linux/soundcard.h>
100 #include <linux/lp.h>
101 #include <linux/ppdev.h>
103 #include <linux/atm.h>
104 #include <linux/atmarp.h>
105 #include <linux/atmclip.h>
106 #include <linux/atmdev.h>
107 #include <linux/atmioc.h>
108 #include <linux/atmlec.h>
109 #include <linux/atmmpc.h>
110 #include <linux/atmsvc.h>
111 #include <linux/atm_tcp.h>
112 #include <linux/sonet.h>
113 #include <linux/atm_suni.h>
114 #include <linux/mtd/mtd.h>
116 #include <linux/usb.h>
117 #include <linux/usbdevice_fs.h>
118 #include <linux/nbd.h>
119 #include <linux/random.h>
120 #include <linux/filter.h>
121 #include <linux/msdos_fs.h>
122 #include <linux/pktcdvd.h>
124 #include <linux/hiddev.h>
126 #include <linux/dvb/audio.h>
127 #include <linux/dvb/dmx.h>
128 #include <linux/dvb/frontend.h>
129 #include <linux/dvb/video.h>
131 #undef INCLUDES
132 #endif
134 #ifdef CODE
136 /* Aiee. Someone does not find a difference between int and long */
137 #define EXT2_IOC32_GETFLAGS _IOR('f', 1, int)
138 #define EXT2_IOC32_SETFLAGS _IOW('f', 2, int)
139 #define EXT3_IOC32_GETVERSION _IOR('f', 3, int)
140 #define EXT3_IOC32_SETVERSION _IOW('f', 4, int)
141 #define EXT3_IOC32_GETRSVSZ _IOR('f', 5, int)
142 #define EXT3_IOC32_SETRSVSZ _IOW('f', 6, int)
143 #define EXT3_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int)
144 #ifdef CONFIG_JBD_DEBUG
145 #define EXT3_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int)
146 #endif
148 #define EXT2_IOC32_GETVERSION _IOR('v', 1, int)
149 #define EXT2_IOC32_SETVERSION _IOW('v', 2, int)
151 static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
153 mm_segment_t old_fs = get_fs();
154 int err;
155 unsigned long val;
157 set_fs (KERNEL_DS);
158 err = sys_ioctl(fd, cmd, (unsigned long)&val);
159 set_fs (old_fs);
160 if (!err && put_user(val, (u32 __user *)compat_ptr(arg)))
161 return -EFAULT;
162 return err;
165 static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg)
167 mm_segment_t old_fs = get_fs();
168 u32 __user *argptr = compat_ptr(arg);
169 int err;
170 unsigned long val;
172 if(get_user(val, argptr))
173 return -EFAULT;
174 set_fs (KERNEL_DS);
175 err = sys_ioctl(fd, cmd, (unsigned long)&val);
176 set_fs (old_fs);
177 if (!err && put_user(val, argptr))
178 return -EFAULT;
179 return err;
182 static int do_ext2_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
184 /* These are just misnamed, they actually get/put from/to user an int */
185 switch (cmd) {
186 case EXT2_IOC32_GETFLAGS: cmd = EXT2_IOC_GETFLAGS; break;
187 case EXT2_IOC32_SETFLAGS: cmd = EXT2_IOC_SETFLAGS; break;
188 case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; break;
189 case EXT2_IOC32_SETVERSION: cmd = EXT2_IOC_SETVERSION; break;
191 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
194 static int do_ext3_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
196 /* These are just misnamed, they actually get/put from/to user an int */
197 switch (cmd) {
198 case EXT3_IOC32_GETVERSION: cmd = EXT3_IOC_GETVERSION; break;
199 case EXT3_IOC32_SETVERSION: cmd = EXT3_IOC_SETVERSION; break;
200 case EXT3_IOC32_GETRSVSZ: cmd = EXT3_IOC_GETRSVSZ; break;
201 case EXT3_IOC32_SETRSVSZ: cmd = EXT3_IOC_SETRSVSZ; break;
202 case EXT3_IOC32_GROUP_EXTEND: cmd = EXT3_IOC_GROUP_EXTEND; break;
203 #ifdef CONFIG_JBD_DEBUG
204 case EXT3_IOC32_WAIT_FOR_READONLY: cmd = EXT3_IOC_WAIT_FOR_READONLY; break;
205 #endif
207 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
210 struct video_tuner32 {
211 compat_int_t tuner;
212 char name[32];
213 compat_ulong_t rangelow, rangehigh;
214 u32 flags; /* It is really u32 in videodev.h */
215 u16 mode, signal;
218 static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up)
220 int i;
222 if(get_user(kp->tuner, &up->tuner))
223 return -EFAULT;
224 for(i = 0; i < 32; i++)
225 __get_user(kp->name[i], &up->name[i]);
226 __get_user(kp->rangelow, &up->rangelow);
227 __get_user(kp->rangehigh, &up->rangehigh);
228 __get_user(kp->flags, &up->flags);
229 __get_user(kp->mode, &up->mode);
230 __get_user(kp->signal, &up->signal);
231 return 0;
234 static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up)
236 int i;
238 if(put_user(kp->tuner, &up->tuner))
239 return -EFAULT;
240 for(i = 0; i < 32; i++)
241 __put_user(kp->name[i], &up->name[i]);
242 __put_user(kp->rangelow, &up->rangelow);
243 __put_user(kp->rangehigh, &up->rangehigh);
244 __put_user(kp->flags, &up->flags);
245 __put_user(kp->mode, &up->mode);
246 __put_user(kp->signal, &up->signal);
247 return 0;
250 struct video_buffer32 {
251 compat_caddr_t base;
252 compat_int_t height, width, depth, bytesperline;
255 static int get_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up)
257 u32 tmp;
259 if (get_user(tmp, &up->base))
260 return -EFAULT;
262 /* This is actually a physical address stored
263 * as a void pointer.
265 kp->base = (void *)(unsigned long) tmp;
267 __get_user(kp->height, &up->height);
268 __get_user(kp->width, &up->width);
269 __get_user(kp->depth, &up->depth);
270 __get_user(kp->bytesperline, &up->bytesperline);
271 return 0;
274 static int put_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up)
276 u32 tmp = (u32)((unsigned long)kp->base);
278 if(put_user(tmp, &up->base))
279 return -EFAULT;
280 __put_user(kp->height, &up->height);
281 __put_user(kp->width, &up->width);
282 __put_user(kp->depth, &up->depth);
283 __put_user(kp->bytesperline, &up->bytesperline);
284 return 0;
287 struct video_clip32 {
288 s32 x, y, width, height; /* Its really s32 in videodev.h */
289 compat_caddr_t next;
292 struct video_window32 {
293 u32 x, y, width, height, chromakey, flags;
294 compat_caddr_t clips;
295 compat_int_t clipcount;
298 /* You get back everything except the clips... */
299 static int put_video_window32(struct video_window *kp, struct video_window32 __user *up)
301 if(put_user(kp->x, &up->x))
302 return -EFAULT;
303 __put_user(kp->y, &up->y);
304 __put_user(kp->width, &up->width);
305 __put_user(kp->height, &up->height);
306 __put_user(kp->chromakey, &up->chromakey);
307 __put_user(kp->flags, &up->flags);
308 __put_user(kp->clipcount, &up->clipcount);
309 return 0;
312 #define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32)
313 #define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32)
314 #define VIDIOCGWIN32 _IOR('v',9, struct video_window32)
315 #define VIDIOCSWIN32 _IOW('v',10, struct video_window32)
316 #define VIDIOCGFBUF32 _IOR('v',11, struct video_buffer32)
317 #define VIDIOCSFBUF32 _IOW('v',12, struct video_buffer32)
318 #define VIDIOCGFREQ32 _IOR('v',14, u32)
319 #define VIDIOCSFREQ32 _IOW('v',15, u32)
321 enum {
322 MaxClips = (~0U-sizeof(struct video_window))/sizeof(struct video_clip)
325 static int do_set_window(unsigned int fd, unsigned int cmd, unsigned long arg)
327 struct video_window32 __user *up = compat_ptr(arg);
328 struct video_window __user *vw;
329 struct video_clip __user *p;
330 int nclips;
331 u32 n;
333 if (get_user(nclips, &up->clipcount))
334 return -EFAULT;
336 /* Peculiar interface... */
337 if (nclips < 0)
338 nclips = VIDEO_CLIPMAP_SIZE;
340 if (nclips > MaxClips)
341 return -ENOMEM;
343 vw = compat_alloc_user_space(sizeof(struct video_window) +
344 nclips * sizeof(struct video_clip));
346 p = nclips ? (struct video_clip __user *)(vw + 1) : NULL;
348 if (get_user(n, &up->x) || put_user(n, &vw->x) ||
349 get_user(n, &up->y) || put_user(n, &vw->y) ||
350 get_user(n, &up->width) || put_user(n, &vw->width) ||
351 get_user(n, &up->height) || put_user(n, &vw->height) ||
352 get_user(n, &up->chromakey) || put_user(n, &vw->chromakey) ||
353 get_user(n, &up->flags) || put_user(n, &vw->flags) ||
354 get_user(n, &up->clipcount) || put_user(n, &vw->clipcount) ||
355 get_user(n, &up->clips) || put_user(p, &vw->clips))
356 return -EFAULT;
358 if (nclips) {
359 struct video_clip32 __user *u = compat_ptr(n);
360 int i;
361 if (!u)
362 return -EINVAL;
363 for (i = 0; i < nclips; i++, u++, p++) {
364 s32 v;
365 if (get_user(v, &u->x) ||
366 put_user(v, &p->x) ||
367 get_user(v, &u->y) ||
368 put_user(v, &p->y) ||
369 get_user(v, &u->width) ||
370 put_user(v, &p->width) ||
371 get_user(v, &u->height) ||
372 put_user(v, &p->height) ||
373 put_user(NULL, &p->next))
374 return -EFAULT;
378 return sys_ioctl(fd, VIDIOCSWIN, (unsigned long)p);
381 static int do_video_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
383 union {
384 struct video_tuner vt;
385 struct video_buffer vb;
386 struct video_window vw;
387 unsigned long vx;
388 } karg;
389 mm_segment_t old_fs = get_fs();
390 void __user *up = compat_ptr(arg);
391 int err = 0;
393 /* First, convert the command. */
394 switch(cmd) {
395 case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break;
396 case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break;
397 case VIDIOCGWIN32: cmd = VIDIOCGWIN; break;
398 case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break;
399 case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break;
400 case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break;
401 case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break;
404 switch(cmd) {
405 case VIDIOCSTUNER:
406 case VIDIOCGTUNER:
407 err = get_video_tuner32(&karg.vt, up);
408 break;
410 case VIDIOCSFBUF:
411 err = get_video_buffer32(&karg.vb, up);
412 break;
414 case VIDIOCSFREQ:
415 err = get_user(karg.vx, (u32 __user *)up);
416 break;
418 if(err)
419 goto out;
421 set_fs(KERNEL_DS);
422 err = sys_ioctl(fd, cmd, (unsigned long)&karg);
423 set_fs(old_fs);
425 if(err == 0) {
426 switch(cmd) {
427 case VIDIOCGTUNER:
428 err = put_video_tuner32(&karg.vt, up);
429 break;
431 case VIDIOCGWIN:
432 err = put_video_window32(&karg.vw, up);
433 break;
435 case VIDIOCGFBUF:
436 err = put_video_buffer32(&karg.vb, up);
437 break;
439 case VIDIOCGFREQ:
440 err = put_user(((u32)karg.vx), (u32 __user *)up);
441 break;
444 out:
445 return err;
448 struct compat_dmx_event {
449 dmx_event_t event;
450 compat_time_t timeStamp;
451 union
453 dmx_scrambling_status_t scrambling;
454 } u;
457 static int do_dmx_get_event(unsigned int fd, unsigned int cmd, unsigned long arg)
459 struct dmx_event kevent;
460 mm_segment_t old_fs = get_fs();
461 int err;
463 set_fs(KERNEL_DS);
464 err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
465 set_fs(old_fs);
467 if (!err) {
468 struct compat_dmx_event __user *up = compat_ptr(arg);
470 err = put_user(kevent.event, &up->event);
471 err |= put_user(kevent.timeStamp, &up->timeStamp);
472 err |= put_user(kevent.u.scrambling, &up->u.scrambling);
473 if (err)
474 err = -EFAULT;
477 return err;
480 struct compat_video_event {
481 int32_t type;
482 compat_time_t timestamp;
483 union {
484 video_size_t size;
485 unsigned int frame_rate;
486 } u;
489 static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long arg)
491 struct video_event kevent;
492 mm_segment_t old_fs = get_fs();
493 int err;
495 set_fs(KERNEL_DS);
496 err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
497 set_fs(old_fs);
499 if (!err) {
500 struct compat_video_event __user *up = compat_ptr(arg);
502 err = put_user(kevent.type, &up->type);
503 err |= put_user(kevent.timestamp, &up->timestamp);
504 err |= put_user(kevent.u.size.w, &up->u.size.w);
505 err |= put_user(kevent.u.size.h, &up->u.size.h);
506 err |= put_user(kevent.u.size.aspect_ratio,
507 &up->u.size.aspect_ratio);
508 if (err)
509 err = -EFAULT;
512 return err;
515 struct compat_video_still_picture {
516 compat_uptr_t iFrame;
517 int32_t size;
520 static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned long arg)
522 struct compat_video_still_picture __user *up;
523 struct video_still_picture __user *up_native;
524 compat_uptr_t fp;
525 int32_t size;
526 int err;
528 up = (struct compat_video_still_picture __user *) arg;
529 err = get_user(fp, &up->iFrame);
530 err |= get_user(size, &up->size);
531 if (err)
532 return -EFAULT;
534 up_native =
535 compat_alloc_user_space(sizeof(struct video_still_picture));
537 put_user(compat_ptr(fp), &up_native->iFrame);
538 put_user(size, &up_native->size);
540 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
542 return err;
545 struct compat_video_spu_palette {
546 int length;
547 compat_uptr_t palette;
550 static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned long arg)
552 struct compat_video_spu_palette __user *up;
553 struct video_spu_palette __user *up_native;
554 compat_uptr_t palp;
555 int length, err;
557 up = (struct compat_video_spu_palette __user *) arg;
558 err = get_user(palp, &up->palette);
559 err |= get_user(length, &up->length);
561 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
562 put_user(compat_ptr(palp), &up_native->palette);
563 put_user(length, &up_native->length);
565 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
567 return err;
570 #ifdef CONFIG_NET
571 static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
573 struct compat_timeval __user *up = compat_ptr(arg);
574 struct timeval ktv;
575 mm_segment_t old_fs = get_fs();
576 int err;
578 set_fs(KERNEL_DS);
579 err = sys_ioctl(fd, cmd, (unsigned long)&ktv);
580 set_fs(old_fs);
581 if(!err) {
582 err = put_user(ktv.tv_sec, &up->tv_sec);
583 err |= __put_user(ktv.tv_usec, &up->tv_usec);
585 return err;
588 struct ifmap32 {
589 compat_ulong_t mem_start;
590 compat_ulong_t mem_end;
591 unsigned short base_addr;
592 unsigned char irq;
593 unsigned char dma;
594 unsigned char port;
597 struct ifreq32 {
598 #define IFHWADDRLEN 6
599 #define IFNAMSIZ 16
600 union {
601 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
602 } ifr_ifrn;
603 union {
604 struct sockaddr ifru_addr;
605 struct sockaddr ifru_dstaddr;
606 struct sockaddr ifru_broadaddr;
607 struct sockaddr ifru_netmask;
608 struct sockaddr ifru_hwaddr;
609 short ifru_flags;
610 compat_int_t ifru_ivalue;
611 compat_int_t ifru_mtu;
612 struct ifmap32 ifru_map;
613 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
614 char ifru_newname[IFNAMSIZ];
615 compat_caddr_t ifru_data;
616 /* XXXX? ifru_settings should be here */
617 } ifr_ifru;
620 struct ifconf32 {
621 compat_int_t ifc_len; /* size of buffer */
622 compat_caddr_t ifcbuf;
625 static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
627 struct net_device *dev;
628 struct ifreq32 ifr32;
629 int err;
631 if (copy_from_user(&ifr32, compat_ptr(arg), sizeof(ifr32)))
632 return -EFAULT;
634 dev = dev_get_by_index(ifr32.ifr_ifindex);
635 if (!dev)
636 return -ENODEV;
638 strlcpy(ifr32.ifr_name, dev->name, sizeof(ifr32.ifr_name));
639 dev_put(dev);
641 err = copy_to_user(compat_ptr(arg), &ifr32, sizeof(ifr32));
642 return (err ? -EFAULT : 0);
645 static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)
647 struct ifconf32 ifc32;
648 struct ifconf ifc;
649 struct ifconf __user *uifc;
650 struct ifreq32 __user *ifr32;
651 struct ifreq __user *ifr;
652 unsigned int i, j;
653 int err;
655 if (copy_from_user(&ifc32, compat_ptr(arg), sizeof(struct ifconf32)))
656 return -EFAULT;
658 if (ifc32.ifcbuf == 0) {
659 ifc32.ifc_len = 0;
660 ifc.ifc_len = 0;
661 ifc.ifc_req = NULL;
662 uifc = compat_alloc_user_space(sizeof(struct ifconf));
663 } else {
664 size_t len =((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) *
665 sizeof (struct ifreq);
666 uifc = compat_alloc_user_space(sizeof(struct ifconf) + len);
667 ifc.ifc_len = len;
668 ifr = ifc.ifc_req = (void __user *)(uifc + 1);
669 ifr32 = compat_ptr(ifc32.ifcbuf);
670 for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) {
671 if (copy_in_user(ifr, ifr32, sizeof(struct ifreq32)))
672 return -EFAULT;
673 ifr++;
674 ifr32++;
677 if (copy_to_user(uifc, &ifc, sizeof(struct ifconf)))
678 return -EFAULT;
680 err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)uifc);
681 if (err)
682 return err;
684 if (copy_from_user(&ifc, uifc, sizeof(struct ifconf)))
685 return -EFAULT;
687 ifr = ifc.ifc_req;
688 ifr32 = compat_ptr(ifc32.ifcbuf);
689 for (i = 0, j = 0;
690 i + sizeof (struct ifreq32) < ifc32.ifc_len && j < ifc.ifc_len;
691 i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
692 if (copy_in_user(ifr32, ifr, sizeof (struct ifreq32)))
693 return -EFAULT;
694 ifr32++;
695 ifr++;
698 if (ifc32.ifcbuf == 0) {
699 /* Translate from 64-bit structure multiple to
700 * a 32-bit one.
702 i = ifc.ifc_len;
703 i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32));
704 ifc32.ifc_len = i;
705 } else {
706 ifc32.ifc_len = i;
708 if (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32)))
709 return -EFAULT;
711 return 0;
714 static int ethtool_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
716 struct ifreq __user *ifr;
717 struct ifreq32 __user *ifr32;
718 u32 data;
719 void __user *datap;
721 ifr = compat_alloc_user_space(sizeof(*ifr));
722 ifr32 = compat_ptr(arg);
724 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
725 return -EFAULT;
727 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
728 return -EFAULT;
730 datap = compat_ptr(data);
731 if (put_user(datap, &ifr->ifr_ifru.ifru_data))
732 return -EFAULT;
734 return sys_ioctl(fd, cmd, (unsigned long) ifr);
737 static int bond_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
739 struct ifreq kifr;
740 struct ifreq __user *uifr;
741 struct ifreq32 __user *ifr32 = compat_ptr(arg);
742 mm_segment_t old_fs;
743 int err;
744 u32 data;
745 void __user *datap;
747 switch (cmd) {
748 case SIOCBONDENSLAVE:
749 case SIOCBONDRELEASE:
750 case SIOCBONDSETHWADDR:
751 case SIOCBONDCHANGEACTIVE:
752 if (copy_from_user(&kifr, ifr32, sizeof(struct ifreq32)))
753 return -EFAULT;
755 old_fs = get_fs();
756 set_fs (KERNEL_DS);
757 err = sys_ioctl (fd, cmd, (unsigned long)&kifr);
758 set_fs (old_fs);
760 return err;
761 case SIOCBONDSLAVEINFOQUERY:
762 case SIOCBONDINFOQUERY:
763 uifr = compat_alloc_user_space(sizeof(*uifr));
764 if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
765 return -EFAULT;
767 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
768 return -EFAULT;
770 datap = compat_ptr(data);
771 if (put_user(datap, &uifr->ifr_ifru.ifru_data))
772 return -EFAULT;
774 return sys_ioctl (fd, cmd, (unsigned long)uifr);
775 default:
776 return -EINVAL;
780 int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
782 struct ifreq __user *u_ifreq64;
783 struct ifreq32 __user *u_ifreq32 = compat_ptr(arg);
784 char tmp_buf[IFNAMSIZ];
785 void __user *data64;
786 u32 data32;
788 if (copy_from_user(&tmp_buf[0], &(u_ifreq32->ifr_ifrn.ifrn_name[0]),
789 IFNAMSIZ))
790 return -EFAULT;
791 if (__get_user(data32, &u_ifreq32->ifr_ifru.ifru_data))
792 return -EFAULT;
793 data64 = compat_ptr(data32);
795 u_ifreq64 = compat_alloc_user_space(sizeof(*u_ifreq64));
797 /* Don't check these user accesses, just let that get trapped
798 * in the ioctl handler instead.
800 if (copy_to_user(&u_ifreq64->ifr_ifrn.ifrn_name[0], &tmp_buf[0],
801 IFNAMSIZ))
802 return -EFAULT;
803 if (__put_user(data64, &u_ifreq64->ifr_ifru.ifru_data))
804 return -EFAULT;
806 return sys_ioctl(fd, cmd, (unsigned long) u_ifreq64);
809 static int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg)
811 struct ifreq ifr;
812 struct ifreq32 __user *uifr32;
813 struct ifmap32 __user *uifmap32;
814 mm_segment_t old_fs;
815 int err;
817 uifr32 = compat_ptr(arg);
818 uifmap32 = &uifr32->ifr_ifru.ifru_map;
819 switch (cmd) {
820 case SIOCSIFMAP:
821 err = copy_from_user(&ifr, uifr32, sizeof(ifr.ifr_name));
822 err |= __get_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
823 err |= __get_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
824 err |= __get_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
825 err |= __get_user(ifr.ifr_map.irq, &uifmap32->irq);
826 err |= __get_user(ifr.ifr_map.dma, &uifmap32->dma);
827 err |= __get_user(ifr.ifr_map.port, &uifmap32->port);
828 if (err)
829 return -EFAULT;
830 break;
831 default:
832 if (copy_from_user(&ifr, uifr32, sizeof(*uifr32)))
833 return -EFAULT;
834 break;
836 old_fs = get_fs();
837 set_fs (KERNEL_DS);
838 err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
839 set_fs (old_fs);
840 if (!err) {
841 switch (cmd) {
842 /* TUNSETIFF is defined as _IOW, it should be _IORW
843 * as the data is copied back to user space, but that
844 * cannot be fixed without breaking all existing apps.
846 case TUNSETIFF:
847 case SIOCGIFFLAGS:
848 case SIOCGIFMETRIC:
849 case SIOCGIFMTU:
850 case SIOCGIFMEM:
851 case SIOCGIFHWADDR:
852 case SIOCGIFINDEX:
853 case SIOCGIFADDR:
854 case SIOCGIFBRDADDR:
855 case SIOCGIFDSTADDR:
856 case SIOCGIFNETMASK:
857 case SIOCGIFTXQLEN:
858 if (copy_to_user(uifr32, &ifr, sizeof(*uifr32)))
859 return -EFAULT;
860 break;
861 case SIOCGIFMAP:
862 err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name));
863 err |= __put_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
864 err |= __put_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
865 err |= __put_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
866 err |= __put_user(ifr.ifr_map.irq, &uifmap32->irq);
867 err |= __put_user(ifr.ifr_map.dma, &uifmap32->dma);
868 err |= __put_user(ifr.ifr_map.port, &uifmap32->port);
869 if (err)
870 err = -EFAULT;
871 break;
874 return err;
877 struct rtentry32 {
878 u32 rt_pad1;
879 struct sockaddr rt_dst; /* target address */
880 struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
881 struct sockaddr rt_genmask; /* target network mask (IP) */
882 unsigned short rt_flags;
883 short rt_pad2;
884 u32 rt_pad3;
885 unsigned char rt_tos;
886 unsigned char rt_class;
887 short rt_pad4;
888 short rt_metric; /* +1 for binary compatibility! */
889 /* char * */ u32 rt_dev; /* forcing the device at add */
890 u32 rt_mtu; /* per route MTU/Window */
891 u32 rt_window; /* Window clamping */
892 unsigned short rt_irtt; /* Initial RTT */
896 struct in6_rtmsg32 {
897 struct in6_addr rtmsg_dst;
898 struct in6_addr rtmsg_src;
899 struct in6_addr rtmsg_gateway;
900 u32 rtmsg_type;
901 u16 rtmsg_dst_len;
902 u16 rtmsg_src_len;
903 u32 rtmsg_metric;
904 u32 rtmsg_info;
905 u32 rtmsg_flags;
906 s32 rtmsg_ifindex;
909 static int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
911 int ret;
912 void *r = NULL;
913 struct in6_rtmsg r6;
914 struct rtentry r4;
915 char devname[16];
916 u32 rtdev;
917 mm_segment_t old_fs = get_fs();
919 struct socket *mysock = sockfd_lookup(fd, &ret);
921 if (mysock && mysock->sk && mysock->sk->sk_family == AF_INET6) { /* ipv6 */
922 struct in6_rtmsg32 __user *ur6 = compat_ptr(arg);
923 ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst),
924 3 * sizeof(struct in6_addr));
925 ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type));
926 ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len));
927 ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len));
928 ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric));
929 ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info));
930 ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags));
931 ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex));
933 r = (void *) &r6;
934 } else { /* ipv4 */
935 struct rtentry32 __user *ur4 = compat_ptr(arg);
936 ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst),
937 3 * sizeof(struct sockaddr));
938 ret |= __get_user (r4.rt_flags, &(ur4->rt_flags));
939 ret |= __get_user (r4.rt_metric, &(ur4->rt_metric));
940 ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu));
941 ret |= __get_user (r4.rt_window, &(ur4->rt_window));
942 ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt));
943 ret |= __get_user (rtdev, &(ur4->rt_dev));
944 if (rtdev) {
945 ret |= copy_from_user (devname, compat_ptr(rtdev), 15);
946 r4.rt_dev = devname; devname[15] = 0;
947 } else
948 r4.rt_dev = NULL;
950 r = (void *) &r4;
953 if (ret) {
954 ret = -EFAULT;
955 goto out;
958 set_fs (KERNEL_DS);
959 ret = sys_ioctl (fd, cmd, (unsigned long) r);
960 set_fs (old_fs);
962 out:
963 if (mysock)
964 sockfd_put(mysock);
966 return ret;
968 #endif
970 struct hd_geometry32 {
971 unsigned char heads;
972 unsigned char sectors;
973 unsigned short cylinders;
974 u32 start;
977 static int hdio_getgeo(unsigned int fd, unsigned int cmd, unsigned long arg)
979 mm_segment_t old_fs = get_fs();
980 struct hd_geometry geo;
981 struct hd_geometry32 __user *ugeo;
982 int err;
984 set_fs (KERNEL_DS);
985 err = sys_ioctl(fd, HDIO_GETGEO, (unsigned long)&geo);
986 set_fs (old_fs);
987 ugeo = compat_ptr(arg);
988 if (!err) {
989 err = copy_to_user (ugeo, &geo, 4);
990 err |= __put_user (geo.start, &ugeo->start);
992 return err ? -EFAULT : 0;
995 static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
997 mm_segment_t old_fs = get_fs();
998 unsigned long kval;
999 unsigned int __user *uvp;
1000 int error;
1002 set_fs(KERNEL_DS);
1003 error = sys_ioctl(fd, cmd, (long)&kval);
1004 set_fs(old_fs);
1006 if(error == 0) {
1007 uvp = compat_ptr(arg);
1008 if(put_user(kval, uvp))
1009 error = -EFAULT;
1011 return error;
1015 typedef struct sg_io_hdr32 {
1016 compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */
1017 compat_int_t dxfer_direction; /* [i] data transfer direction */
1018 unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
1019 unsigned char mx_sb_len; /* [i] max length to write to sbp */
1020 unsigned short iovec_count; /* [i] 0 implies no scatter gather */
1021 compat_uint_t dxfer_len; /* [i] byte count of data transfer */
1022 compat_uint_t dxferp; /* [i], [*io] points to data transfer memory
1023 or scatter gather list */
1024 compat_uptr_t cmdp; /* [i], [*i] points to command to perform */
1025 compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */
1026 compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
1027 compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */
1028 compat_int_t pack_id; /* [i->o] unused internally (normally) */
1029 compat_uptr_t usr_ptr; /* [i->o] unused internally */
1030 unsigned char status; /* [o] scsi status */
1031 unsigned char masked_status; /* [o] shifted, masked scsi status */
1032 unsigned char msg_status; /* [o] messaging level data (optional) */
1033 unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
1034 unsigned short host_status; /* [o] errors from host adapter */
1035 unsigned short driver_status; /* [o] errors from software driver */
1036 compat_int_t resid; /* [o] dxfer_len - actual_transferred */
1037 compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */
1038 compat_uint_t info; /* [o] auxiliary information */
1039 } sg_io_hdr32_t; /* 64 bytes long (on sparc32) */
1041 typedef struct sg_iovec32 {
1042 compat_uint_t iov_base;
1043 compat_uint_t iov_len;
1044 } sg_iovec32_t;
1046 static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count)
1048 sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1);
1049 sg_iovec32_t __user *iov32 = dxferp;
1050 int i;
1052 for (i = 0; i < iovec_count; i++) {
1053 u32 base, len;
1055 if (get_user(base, &iov32[i].iov_base) ||
1056 get_user(len, &iov32[i].iov_len) ||
1057 put_user(compat_ptr(base), &iov[i].iov_base) ||
1058 put_user(len, &iov[i].iov_len))
1059 return -EFAULT;
1062 if (put_user(iov, &sgio->dxferp))
1063 return -EFAULT;
1064 return 0;
1067 static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1069 sg_io_hdr_t __user *sgio;
1070 sg_io_hdr32_t __user *sgio32;
1071 u16 iovec_count;
1072 u32 data;
1073 void __user *dxferp;
1074 int err;
1076 sgio32 = compat_ptr(arg);
1077 if (get_user(iovec_count, &sgio32->iovec_count))
1078 return -EFAULT;
1081 void __user *top = compat_alloc_user_space(0);
1082 void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) +
1083 (iovec_count * sizeof(sg_iovec_t)));
1084 if (new > top)
1085 return -EINVAL;
1087 sgio = new;
1090 /* Ok, now construct. */
1091 if (copy_in_user(&sgio->interface_id, &sgio32->interface_id,
1092 (2 * sizeof(int)) +
1093 (2 * sizeof(unsigned char)) +
1094 (1 * sizeof(unsigned short)) +
1095 (1 * sizeof(unsigned int))))
1096 return -EFAULT;
1098 if (get_user(data, &sgio32->dxferp))
1099 return -EFAULT;
1100 dxferp = compat_ptr(data);
1101 if (iovec_count) {
1102 if (sg_build_iovec(sgio, dxferp, iovec_count))
1103 return -EFAULT;
1104 } else {
1105 if (put_user(dxferp, &sgio->dxferp))
1106 return -EFAULT;
1110 unsigned char __user *cmdp;
1111 unsigned char __user *sbp;
1113 if (get_user(data, &sgio32->cmdp))
1114 return -EFAULT;
1115 cmdp = compat_ptr(data);
1117 if (get_user(data, &sgio32->sbp))
1118 return -EFAULT;
1119 sbp = compat_ptr(data);
1121 if (put_user(cmdp, &sgio->cmdp) ||
1122 put_user(sbp, &sgio->sbp))
1123 return -EFAULT;
1126 if (copy_in_user(&sgio->timeout, &sgio32->timeout,
1127 3 * sizeof(int)))
1128 return -EFAULT;
1130 if (get_user(data, &sgio32->usr_ptr))
1131 return -EFAULT;
1132 if (put_user(compat_ptr(data), &sgio->usr_ptr))
1133 return -EFAULT;
1135 if (copy_in_user(&sgio->status, &sgio32->status,
1136 (4 * sizeof(unsigned char)) +
1137 (2 * sizeof(unsigned (short))) +
1138 (3 * sizeof(int))))
1139 return -EFAULT;
1141 err = sys_ioctl(fd, cmd, (unsigned long) sgio);
1143 if (err >= 0) {
1144 void __user *datap;
1146 if (copy_in_user(&sgio32->pack_id, &sgio->pack_id,
1147 sizeof(int)) ||
1148 get_user(datap, &sgio->usr_ptr) ||
1149 put_user((u32)(unsigned long)datap,
1150 &sgio32->usr_ptr) ||
1151 copy_in_user(&sgio32->status, &sgio->status,
1152 (4 * sizeof(unsigned char)) +
1153 (2 * sizeof(unsigned short)) +
1154 (3 * sizeof(int))))
1155 err = -EFAULT;
1158 return err;
1161 struct sock_fprog32 {
1162 unsigned short len;
1163 compat_caddr_t filter;
1166 #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
1167 #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
1169 static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1171 struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg);
1172 struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
1173 void __user *fptr64;
1174 u32 fptr32;
1175 u16 flen;
1177 if (get_user(flen, &u_fprog32->len) ||
1178 get_user(fptr32, &u_fprog32->filter))
1179 return -EFAULT;
1181 fptr64 = compat_ptr(fptr32);
1183 if (put_user(flen, &u_fprog64->len) ||
1184 put_user(fptr64, &u_fprog64->filter))
1185 return -EFAULT;
1187 if (cmd == PPPIOCSPASS32)
1188 cmd = PPPIOCSPASS;
1189 else
1190 cmd = PPPIOCSACTIVE;
1192 return sys_ioctl(fd, cmd, (unsigned long) u_fprog64);
1195 struct ppp_option_data32 {
1196 compat_caddr_t ptr;
1197 u32 length;
1198 compat_int_t transmit;
1200 #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
1202 struct ppp_idle32 {
1203 compat_time_t xmit_idle;
1204 compat_time_t recv_idle;
1206 #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
1208 static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg)
1210 struct ppp_idle __user *idle;
1211 struct ppp_idle32 __user *idle32;
1212 __kernel_time_t xmit, recv;
1213 int err;
1215 idle = compat_alloc_user_space(sizeof(*idle));
1216 idle32 = compat_ptr(arg);
1218 err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle);
1220 if (!err) {
1221 if (get_user(xmit, &idle->xmit_idle) ||
1222 get_user(recv, &idle->recv_idle) ||
1223 put_user(xmit, &idle32->xmit_idle) ||
1224 put_user(recv, &idle32->recv_idle))
1225 err = -EFAULT;
1227 return err;
1230 static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg)
1232 struct ppp_option_data __user *odata;
1233 struct ppp_option_data32 __user *odata32;
1234 __u32 data;
1235 void __user *datap;
1237 odata = compat_alloc_user_space(sizeof(*odata));
1238 odata32 = compat_ptr(arg);
1240 if (get_user(data, &odata32->ptr))
1241 return -EFAULT;
1243 datap = compat_ptr(data);
1244 if (put_user(datap, &odata->ptr))
1245 return -EFAULT;
1247 if (copy_in_user(&odata->length, &odata32->length,
1248 sizeof(__u32) + sizeof(int)))
1249 return -EFAULT;
1251 return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata);
1254 static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1256 int err;
1258 switch (cmd) {
1259 case PPPIOCGIDLE32:
1260 err = ppp_gidle(fd, cmd, arg);
1261 break;
1263 case PPPIOCSCOMPRESS32:
1264 err = ppp_scompress(fd, cmd, arg);
1265 break;
1267 default:
1268 do {
1269 static int count;
1270 if (++count <= 20)
1271 printk("ppp_ioctl: Unknown cmd fd(%d) "
1272 "cmd(%08x) arg(%08x)\n",
1273 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1274 } while(0);
1275 err = -EINVAL;
1276 break;
1279 return err;
1283 struct mtget32 {
1284 compat_long_t mt_type;
1285 compat_long_t mt_resid;
1286 compat_long_t mt_dsreg;
1287 compat_long_t mt_gstat;
1288 compat_long_t mt_erreg;
1289 compat_daddr_t mt_fileno;
1290 compat_daddr_t mt_blkno;
1292 #define MTIOCGET32 _IOR('m', 2, struct mtget32)
1294 struct mtpos32 {
1295 compat_long_t mt_blkno;
1297 #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
1299 static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1301 mm_segment_t old_fs = get_fs();
1302 struct mtget get;
1303 struct mtget32 __user *umget32;
1304 struct mtpos pos;
1305 struct mtpos32 __user *upos32;
1306 unsigned long kcmd;
1307 void *karg;
1308 int err = 0;
1310 switch(cmd) {
1311 case MTIOCPOS32:
1312 kcmd = MTIOCPOS;
1313 karg = &pos;
1314 break;
1315 case MTIOCGET32:
1316 kcmd = MTIOCGET;
1317 karg = &get;
1318 break;
1319 default:
1320 do {
1321 static int count;
1322 if (++count <= 20)
1323 printk("mt_ioctl: Unknown cmd fd(%d) "
1324 "cmd(%08x) arg(%08x)\n",
1325 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1326 } while(0);
1327 return -EINVAL;
1329 set_fs (KERNEL_DS);
1330 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1331 set_fs (old_fs);
1332 if (err)
1333 return err;
1334 switch (cmd) {
1335 case MTIOCPOS32:
1336 upos32 = compat_ptr(arg);
1337 err = __put_user(pos.mt_blkno, &upos32->mt_blkno);
1338 break;
1339 case MTIOCGET32:
1340 umget32 = compat_ptr(arg);
1341 err = __put_user(get.mt_type, &umget32->mt_type);
1342 err |= __put_user(get.mt_resid, &umget32->mt_resid);
1343 err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg);
1344 err |= __put_user(get.mt_gstat, &umget32->mt_gstat);
1345 err |= __put_user(get.mt_erreg, &umget32->mt_erreg);
1346 err |= __put_user(get.mt_fileno, &umget32->mt_fileno);
1347 err |= __put_user(get.mt_blkno, &umget32->mt_blkno);
1348 break;
1350 return err ? -EFAULT: 0;
1353 struct cdrom_read_audio32 {
1354 union cdrom_addr addr;
1355 u8 addr_format;
1356 compat_int_t nframes;
1357 compat_caddr_t buf;
1360 struct cdrom_generic_command32 {
1361 unsigned char cmd[CDROM_PACKET_SIZE];
1362 compat_caddr_t buffer;
1363 compat_uint_t buflen;
1364 compat_int_t stat;
1365 compat_caddr_t sense;
1366 unsigned char data_direction;
1367 compat_int_t quiet;
1368 compat_int_t timeout;
1369 compat_caddr_t reserved[1];
1372 static int cdrom_do_read_audio(unsigned int fd, unsigned int cmd, unsigned long arg)
1374 struct cdrom_read_audio __user *cdread_audio;
1375 struct cdrom_read_audio32 __user *cdread_audio32;
1376 __u32 data;
1377 void __user *datap;
1379 cdread_audio = compat_alloc_user_space(sizeof(*cdread_audio));
1380 cdread_audio32 = compat_ptr(arg);
1382 if (copy_in_user(&cdread_audio->addr,
1383 &cdread_audio32->addr,
1384 (sizeof(*cdread_audio32) -
1385 sizeof(compat_caddr_t))))
1386 return -EFAULT;
1388 if (get_user(data, &cdread_audio32->buf))
1389 return -EFAULT;
1390 datap = compat_ptr(data);
1391 if (put_user(datap, &cdread_audio->buf))
1392 return -EFAULT;
1394 return sys_ioctl(fd, cmd, (unsigned long) cdread_audio);
1397 static int cdrom_do_generic_command(unsigned int fd, unsigned int cmd, unsigned long arg)
1399 struct cdrom_generic_command __user *cgc;
1400 struct cdrom_generic_command32 __user *cgc32;
1401 u32 data;
1402 unsigned char dir;
1403 int itmp;
1405 cgc = compat_alloc_user_space(sizeof(*cgc));
1406 cgc32 = compat_ptr(arg);
1408 if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) ||
1409 get_user(data, &cgc32->buffer) ||
1410 put_user(compat_ptr(data), &cgc->buffer) ||
1411 copy_in_user(&cgc->buflen, &cgc32->buflen,
1412 (sizeof(unsigned int) + sizeof(int))) ||
1413 get_user(data, &cgc32->sense) ||
1414 put_user(compat_ptr(data), &cgc->sense) ||
1415 get_user(dir, &cgc32->data_direction) ||
1416 put_user(dir, &cgc->data_direction) ||
1417 get_user(itmp, &cgc32->quiet) ||
1418 put_user(itmp, &cgc->quiet) ||
1419 get_user(itmp, &cgc32->timeout) ||
1420 put_user(itmp, &cgc->timeout) ||
1421 get_user(data, &cgc32->reserved[0]) ||
1422 put_user(compat_ptr(data), &cgc->reserved[0]))
1423 return -EFAULT;
1425 return sys_ioctl(fd, cmd, (unsigned long) cgc);
1428 static int cdrom_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1430 int err;
1432 switch(cmd) {
1433 case CDROMREADAUDIO:
1434 err = cdrom_do_read_audio(fd, cmd, arg);
1435 break;
1437 case CDROM_SEND_PACKET:
1438 err = cdrom_do_generic_command(fd, cmd, arg);
1439 break;
1441 default:
1442 do {
1443 static int count;
1444 if (++count <= 20)
1445 printk("cdrom_ioctl: Unknown cmd fd(%d) "
1446 "cmd(%08x) arg(%08x)\n",
1447 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1448 } while(0);
1449 err = -EINVAL;
1450 break;
1453 return err;
1456 struct loop_info32 {
1457 compat_int_t lo_number; /* ioctl r/o */
1458 compat_dev_t lo_device; /* ioctl r/o */
1459 compat_ulong_t lo_inode; /* ioctl r/o */
1460 compat_dev_t lo_rdevice; /* ioctl r/o */
1461 compat_int_t lo_offset;
1462 compat_int_t lo_encrypt_type;
1463 compat_int_t lo_encrypt_key_size; /* ioctl w/o */
1464 compat_int_t lo_flags; /* ioctl r/o */
1465 char lo_name[LO_NAME_SIZE];
1466 unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
1467 compat_ulong_t lo_init[2];
1468 char reserved[4];
1471 static int loop_status(unsigned int fd, unsigned int cmd, unsigned long arg)
1473 mm_segment_t old_fs = get_fs();
1474 struct loop_info l;
1475 struct loop_info32 __user *ul;
1476 int err = -EINVAL;
1478 ul = compat_ptr(arg);
1479 switch(cmd) {
1480 case LOOP_SET_STATUS:
1481 err = get_user(l.lo_number, &ul->lo_number);
1482 err |= __get_user(l.lo_device, &ul->lo_device);
1483 err |= __get_user(l.lo_inode, &ul->lo_inode);
1484 err |= __get_user(l.lo_rdevice, &ul->lo_rdevice);
1485 err |= __copy_from_user(&l.lo_offset, &ul->lo_offset,
1486 8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1487 if (err) {
1488 err = -EFAULT;
1489 } else {
1490 set_fs (KERNEL_DS);
1491 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1492 set_fs (old_fs);
1494 break;
1495 case LOOP_GET_STATUS:
1496 set_fs (KERNEL_DS);
1497 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1498 set_fs (old_fs);
1499 if (!err) {
1500 err = put_user(l.lo_number, &ul->lo_number);
1501 err |= __put_user(l.lo_device, &ul->lo_device);
1502 err |= __put_user(l.lo_inode, &ul->lo_inode);
1503 err |= __put_user(l.lo_rdevice, &ul->lo_rdevice);
1504 err |= __copy_to_user(&ul->lo_offset, &l.lo_offset,
1505 (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1506 if (err)
1507 err = -EFAULT;
1509 break;
1510 default: {
1511 static int count;
1512 if (++count <= 20)
1513 printk("%s: Unknown loop ioctl cmd, fd(%d) "
1514 "cmd(%08x) arg(%08lx)\n",
1515 __FUNCTION__, fd, cmd, arg);
1518 return err;
1521 extern int tty_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg);
1523 #ifdef CONFIG_VT
1525 static int vt_check(struct file *file)
1527 struct tty_struct *tty;
1528 struct inode *inode = file->f_dentry->d_inode;
1530 if (file->f_op->ioctl != tty_ioctl)
1531 return -EINVAL;
1533 tty = (struct tty_struct *)file->private_data;
1534 if (tty_paranoia_check(tty, inode, "tty_ioctl"))
1535 return -EINVAL;
1537 if (tty->driver->ioctl != vt_ioctl)
1538 return -EINVAL;
1541 * To have permissions to do most of the vt ioctls, we either have
1542 * to be the owner of the tty, or super-user.
1544 if (current->signal->tty == tty || capable(CAP_SYS_ADMIN))
1545 return 1;
1546 return 0;
1549 struct consolefontdesc32 {
1550 unsigned short charcount; /* characters in font (256 or 512) */
1551 unsigned short charheight; /* scan lines per character (1-32) */
1552 compat_caddr_t chardata; /* font data in expanded form */
1555 static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1557 struct consolefontdesc32 __user *user_cfd = compat_ptr(arg);
1558 struct console_font_op op;
1559 compat_caddr_t data;
1560 int i, perm;
1562 perm = vt_check(file);
1563 if (perm < 0) return perm;
1565 switch (cmd) {
1566 case PIO_FONTX:
1567 if (!perm)
1568 return -EPERM;
1569 op.op = KD_FONT_OP_SET;
1570 op.flags = 0;
1571 op.width = 8;
1572 if (get_user(op.height, &user_cfd->charheight) ||
1573 get_user(op.charcount, &user_cfd->charcount) ||
1574 get_user(data, &user_cfd->chardata))
1575 return -EFAULT;
1576 op.data = compat_ptr(data);
1577 return con_font_op(vc_cons[fg_console].d, &op);
1578 case GIO_FONTX:
1579 op.op = KD_FONT_OP_GET;
1580 op.flags = 0;
1581 op.width = 8;
1582 if (get_user(op.height, &user_cfd->charheight) ||
1583 get_user(op.charcount, &user_cfd->charcount) ||
1584 get_user(data, &user_cfd->chardata))
1585 return -EFAULT;
1586 if (!data)
1587 return 0;
1588 op.data = compat_ptr(data);
1589 i = con_font_op(vc_cons[fg_console].d, &op);
1590 if (i)
1591 return i;
1592 if (put_user(op.height, &user_cfd->charheight) ||
1593 put_user(op.charcount, &user_cfd->charcount) ||
1594 put_user((compat_caddr_t)(unsigned long)op.data,
1595 &user_cfd->chardata))
1596 return -EFAULT;
1597 return 0;
1599 return -EINVAL;
1602 struct console_font_op32 {
1603 compat_uint_t op; /* operation code KD_FONT_OP_* */
1604 compat_uint_t flags; /* KD_FONT_FLAG_* */
1605 compat_uint_t width, height; /* font size */
1606 compat_uint_t charcount;
1607 compat_caddr_t data; /* font data with height fixed to 32 */
1610 static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1612 struct console_font_op op;
1613 struct console_font_op32 __user *fontop = compat_ptr(arg);
1614 int perm = vt_check(file), i;
1615 struct vc_data *vc;
1617 if (perm < 0) return perm;
1619 if (copy_from_user(&op, fontop, sizeof(struct console_font_op32)))
1620 return -EFAULT;
1621 if (!perm && op.op != KD_FONT_OP_GET)
1622 return -EPERM;
1623 op.data = compat_ptr(((struct console_font_op32 *)&op)->data);
1624 op.flags |= KD_FONT_FLAG_OLD;
1625 vc = ((struct tty_struct *)file->private_data)->driver_data;
1626 i = con_font_op(vc, &op);
1627 if (i)
1628 return i;
1629 ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
1630 if (copy_to_user(fontop, &op, sizeof(struct console_font_op32)))
1631 return -EFAULT;
1632 return 0;
1635 struct unimapdesc32 {
1636 unsigned short entry_ct;
1637 compat_caddr_t entries;
1640 static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1642 struct unimapdesc32 tmp;
1643 struct unimapdesc32 __user *user_ud = compat_ptr(arg);
1644 int perm = vt_check(file);
1646 if (perm < 0) return perm;
1647 if (copy_from_user(&tmp, user_ud, sizeof tmp))
1648 return -EFAULT;
1649 switch (cmd) {
1650 case PIO_UNIMAP:
1651 if (!perm) return -EPERM;
1652 return con_set_unimap(vc_cons[fg_console].d, tmp.entry_ct, compat_ptr(tmp.entries));
1653 case GIO_UNIMAP:
1654 return con_get_unimap(vc_cons[fg_console].d, tmp.entry_ct, &(user_ud->entry_ct), compat_ptr(tmp.entries));
1656 return 0;
1659 #endif /* CONFIG_VT */
1661 static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg)
1663 mm_segment_t old_fs = get_fs();
1664 __kernel_uid_t kuid;
1665 int err;
1667 cmd = SMB_IOC_GETMOUNTUID;
1669 set_fs(KERNEL_DS);
1670 err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
1671 set_fs(old_fs);
1673 if (err >= 0)
1674 err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg));
1676 return err;
1679 struct atmif_sioc32 {
1680 compat_int_t number;
1681 compat_int_t length;
1682 compat_caddr_t arg;
1685 struct atm_iobuf32 {
1686 compat_int_t length;
1687 compat_caddr_t buffer;
1690 #define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32)
1691 #define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32)
1692 #define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32)
1693 #define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32)
1694 #define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32)
1695 #define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32)
1696 #define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32)
1697 #define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32)
1698 #define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32)
1699 #define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32)
1700 #define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32)
1701 #define ATM_SETESIF32 _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32)
1702 #define ATM_GETSTAT32 _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32)
1703 #define ATM_GETSTATZ32 _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32)
1704 #define ATM_GETLOOP32 _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32)
1705 #define ATM_SETLOOP32 _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32)
1706 #define ATM_QUERYLOOP32 _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32)
1708 static struct {
1709 unsigned int cmd32;
1710 unsigned int cmd;
1711 } atm_ioctl_map[] = {
1712 { ATM_GETLINKRATE32, ATM_GETLINKRATE },
1713 { ATM_GETNAMES32, ATM_GETNAMES },
1714 { ATM_GETTYPE32, ATM_GETTYPE },
1715 { ATM_GETESI32, ATM_GETESI },
1716 { ATM_GETADDR32, ATM_GETADDR },
1717 { ATM_RSTADDR32, ATM_RSTADDR },
1718 { ATM_ADDADDR32, ATM_ADDADDR },
1719 { ATM_DELADDR32, ATM_DELADDR },
1720 { ATM_GETCIRANGE32, ATM_GETCIRANGE },
1721 { ATM_SETCIRANGE32, ATM_SETCIRANGE },
1722 { ATM_SETESI32, ATM_SETESI },
1723 { ATM_SETESIF32, ATM_SETESIF },
1724 { ATM_GETSTAT32, ATM_GETSTAT },
1725 { ATM_GETSTATZ32, ATM_GETSTATZ },
1726 { ATM_GETLOOP32, ATM_GETLOOP },
1727 { ATM_SETLOOP32, ATM_SETLOOP },
1728 { ATM_QUERYLOOP32, ATM_QUERYLOOP }
1731 #define NR_ATM_IOCTL (sizeof(atm_ioctl_map)/sizeof(atm_ioctl_map[0]))
1734 static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg)
1736 struct atm_iobuf __user *iobuf;
1737 struct atm_iobuf32 __user *iobuf32;
1738 u32 data;
1739 void __user *datap;
1740 int len, err;
1742 iobuf = compat_alloc_user_space(sizeof(*iobuf));
1743 iobuf32 = compat_ptr(arg);
1745 if (get_user(len, &iobuf32->length) ||
1746 get_user(data, &iobuf32->buffer))
1747 return -EFAULT;
1748 datap = compat_ptr(data);
1749 if (put_user(len, &iobuf->length) ||
1750 put_user(datap, &iobuf->buffer))
1751 return -EFAULT;
1753 err = sys_ioctl(fd, cmd, (unsigned long)iobuf);
1755 if (!err) {
1756 if (copy_in_user(&iobuf32->length, &iobuf->length,
1757 sizeof(int)))
1758 err = -EFAULT;
1761 return err;
1764 static int do_atmif_sioc(unsigned int fd, unsigned int cmd, unsigned long arg)
1766 struct atmif_sioc __user *sioc;
1767 struct atmif_sioc32 __user *sioc32;
1768 u32 data;
1769 void __user *datap;
1770 int err;
1772 sioc = compat_alloc_user_space(sizeof(*sioc));
1773 sioc32 = compat_ptr(arg);
1775 if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) ||
1776 get_user(data, &sioc32->arg))
1777 return -EFAULT;
1778 datap = compat_ptr(data);
1779 if (put_user(datap, &sioc->arg))
1780 return -EFAULT;
1782 err = sys_ioctl(fd, cmd, (unsigned long) sioc);
1784 if (!err) {
1785 if (copy_in_user(&sioc32->length, &sioc->length,
1786 sizeof(int)))
1787 err = -EFAULT;
1789 return err;
1792 static int do_atm_ioctl(unsigned int fd, unsigned int cmd32, unsigned long arg)
1794 int i;
1795 unsigned int cmd = 0;
1797 switch (cmd32) {
1798 case SONET_GETSTAT:
1799 case SONET_GETSTATZ:
1800 case SONET_GETDIAG:
1801 case SONET_SETDIAG:
1802 case SONET_CLRDIAG:
1803 case SONET_SETFRAMING:
1804 case SONET_GETFRAMING:
1805 case SONET_GETFRSENSE:
1806 return do_atmif_sioc(fd, cmd32, arg);
1809 for (i = 0; i < NR_ATM_IOCTL; i++) {
1810 if (cmd32 == atm_ioctl_map[i].cmd32) {
1811 cmd = atm_ioctl_map[i].cmd;
1812 break;
1815 if (i == NR_ATM_IOCTL)
1816 return -EINVAL;
1818 switch (cmd) {
1819 case ATM_GETNAMES:
1820 return do_atm_iobuf(fd, cmd, arg);
1822 case ATM_GETLINKRATE:
1823 case ATM_GETTYPE:
1824 case ATM_GETESI:
1825 case ATM_GETADDR:
1826 case ATM_RSTADDR:
1827 case ATM_ADDADDR:
1828 case ATM_DELADDR:
1829 case ATM_GETCIRANGE:
1830 case ATM_SETCIRANGE:
1831 case ATM_SETESI:
1832 case ATM_SETESIF:
1833 case ATM_GETSTAT:
1834 case ATM_GETSTATZ:
1835 case ATM_GETLOOP:
1836 case ATM_SETLOOP:
1837 case ATM_QUERYLOOP:
1838 return do_atmif_sioc(fd, cmd, arg);
1841 return -EINVAL;
1844 static __attribute_used__ int
1845 ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
1847 return -EINVAL;
1850 static int broken_blkgetsize(unsigned int fd, unsigned int cmd, unsigned long arg)
1852 /* The mkswap binary hard codes it to Intel value :-((( */
1853 return w_long(fd, BLKGETSIZE, arg);
1856 struct blkpg_ioctl_arg32 {
1857 compat_int_t op;
1858 compat_int_t flags;
1859 compat_int_t datalen;
1860 compat_caddr_t data;
1863 static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1865 struct blkpg_ioctl_arg32 __user *ua32 = compat_ptr(arg);
1866 struct blkpg_ioctl_arg __user *a = compat_alloc_user_space(sizeof(*a));
1867 compat_caddr_t udata;
1868 compat_int_t n;
1869 int err;
1871 err = get_user(n, &ua32->op);
1872 err |= put_user(n, &a->op);
1873 err |= get_user(n, &ua32->flags);
1874 err |= put_user(n, &a->flags);
1875 err |= get_user(n, &ua32->datalen);
1876 err |= put_user(n, &a->datalen);
1877 err |= get_user(udata, &ua32->data);
1878 err |= put_user(compat_ptr(udata), &a->data);
1879 if (err)
1880 return err;
1882 return sys_ioctl(fd, cmd, (unsigned long)a);
1885 static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
1887 return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
1890 /* Fix sizeof(sizeof()) breakage */
1891 #define BLKBSZGET_32 _IOR(0x12,112,int)
1892 #define BLKBSZSET_32 _IOW(0x12,113,int)
1893 #define BLKGETSIZE64_32 _IOR(0x12,114,int)
1895 static int do_blkbszget(unsigned int fd, unsigned int cmd, unsigned long arg)
1897 return sys_ioctl(fd, BLKBSZGET, (unsigned long)compat_ptr(arg));
1900 static int do_blkbszset(unsigned int fd, unsigned int cmd, unsigned long arg)
1902 return sys_ioctl(fd, BLKBSZSET, (unsigned long)compat_ptr(arg));
1905 static int do_blkgetsize64(unsigned int fd, unsigned int cmd,
1906 unsigned long arg)
1908 return sys_ioctl(fd, BLKGETSIZE64, (unsigned long)compat_ptr(arg));
1911 /* Bluetooth ioctls */
1912 #define HCIUARTSETPROTO _IOW('U', 200, int)
1913 #define HCIUARTGETPROTO _IOR('U', 201, int)
1915 #define BNEPCONNADD _IOW('B', 200, int)
1916 #define BNEPCONNDEL _IOW('B', 201, int)
1917 #define BNEPGETCONNLIST _IOR('B', 210, int)
1918 #define BNEPGETCONNINFO _IOR('B', 211, int)
1920 #define CMTPCONNADD _IOW('C', 200, int)
1921 #define CMTPCONNDEL _IOW('C', 201, int)
1922 #define CMTPGETCONNLIST _IOR('C', 210, int)
1923 #define CMTPGETCONNINFO _IOR('C', 211, int)
1925 #define HIDPCONNADD _IOW('H', 200, int)
1926 #define HIDPCONNDEL _IOW('H', 201, int)
1927 #define HIDPGETCONNLIST _IOR('H', 210, int)
1928 #define HIDPGETCONNINFO _IOR('H', 211, int)
1930 struct floppy_struct32 {
1931 compat_uint_t size;
1932 compat_uint_t sect;
1933 compat_uint_t head;
1934 compat_uint_t track;
1935 compat_uint_t stretch;
1936 unsigned char gap;
1937 unsigned char rate;
1938 unsigned char spec1;
1939 unsigned char fmt_gap;
1940 const compat_caddr_t name;
1943 struct floppy_drive_params32 {
1944 char cmos;
1945 compat_ulong_t max_dtr;
1946 compat_ulong_t hlt;
1947 compat_ulong_t hut;
1948 compat_ulong_t srt;
1949 compat_ulong_t spinup;
1950 compat_ulong_t spindown;
1951 unsigned char spindown_offset;
1952 unsigned char select_delay;
1953 unsigned char rps;
1954 unsigned char tracks;
1955 compat_ulong_t timeout;
1956 unsigned char interleave_sect;
1957 struct floppy_max_errors max_errors;
1958 char flags;
1959 char read_track;
1960 short autodetect[8];
1961 compat_int_t checkfreq;
1962 compat_int_t native_format;
1965 struct floppy_drive_struct32 {
1966 signed char flags;
1967 compat_ulong_t spinup_date;
1968 compat_ulong_t select_date;
1969 compat_ulong_t first_read_date;
1970 short probed_format;
1971 short track;
1972 short maxblock;
1973 short maxtrack;
1974 compat_int_t generation;
1975 compat_int_t keep_data;
1976 compat_int_t fd_ref;
1977 compat_int_t fd_device;
1978 compat_int_t last_checked;
1979 compat_caddr_t dmabuf;
1980 compat_int_t bufblocks;
1983 struct floppy_fdc_state32 {
1984 compat_int_t spec1;
1985 compat_int_t spec2;
1986 compat_int_t dtr;
1987 unsigned char version;
1988 unsigned char dor;
1989 compat_ulong_t address;
1990 unsigned int rawcmd:2;
1991 unsigned int reset:1;
1992 unsigned int need_configure:1;
1993 unsigned int perp_mode:2;
1994 unsigned int has_fifo:1;
1995 unsigned int driver_version;
1996 unsigned char track[4];
1999 struct floppy_write_errors32 {
2000 unsigned int write_errors;
2001 compat_ulong_t first_error_sector;
2002 compat_int_t first_error_generation;
2003 compat_ulong_t last_error_sector;
2004 compat_int_t last_error_generation;
2005 compat_uint_t badness;
2008 #define FDSETPRM32 _IOW(2, 0x42, struct floppy_struct32)
2009 #define FDDEFPRM32 _IOW(2, 0x43, struct floppy_struct32)
2010 #define FDGETPRM32 _IOR(2, 0x04, struct floppy_struct32)
2011 #define FDSETDRVPRM32 _IOW(2, 0x90, struct floppy_drive_params32)
2012 #define FDGETDRVPRM32 _IOR(2, 0x11, struct floppy_drive_params32)
2013 #define FDGETDRVSTAT32 _IOR(2, 0x12, struct floppy_drive_struct32)
2014 #define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct floppy_drive_struct32)
2015 #define FDGETFDCSTAT32 _IOR(2, 0x15, struct floppy_fdc_state32)
2016 #define FDWERRORGET32 _IOR(2, 0x17, struct floppy_write_errors32)
2018 static struct {
2019 unsigned int cmd32;
2020 unsigned int cmd;
2021 } fd_ioctl_trans_table[] = {
2022 { FDSETPRM32, FDSETPRM },
2023 { FDDEFPRM32, FDDEFPRM },
2024 { FDGETPRM32, FDGETPRM },
2025 { FDSETDRVPRM32, FDSETDRVPRM },
2026 { FDGETDRVPRM32, FDGETDRVPRM },
2027 { FDGETDRVSTAT32, FDGETDRVSTAT },
2028 { FDPOLLDRVSTAT32, FDPOLLDRVSTAT },
2029 { FDGETFDCSTAT32, FDGETFDCSTAT },
2030 { FDWERRORGET32, FDWERRORGET }
2033 #define NR_FD_IOCTL_TRANS (sizeof(fd_ioctl_trans_table)/sizeof(fd_ioctl_trans_table[0]))
2035 static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
2037 mm_segment_t old_fs = get_fs();
2038 void *karg = NULL;
2039 unsigned int kcmd = 0;
2040 int i, err;
2042 for (i = 0; i < NR_FD_IOCTL_TRANS; i++)
2043 if (cmd == fd_ioctl_trans_table[i].cmd32) {
2044 kcmd = fd_ioctl_trans_table[i].cmd;
2045 break;
2047 if (!kcmd)
2048 return -EINVAL;
2050 switch (cmd) {
2051 case FDSETPRM32:
2052 case FDDEFPRM32:
2053 case FDGETPRM32:
2055 compat_uptr_t name;
2056 struct floppy_struct32 __user *uf;
2057 struct floppy_struct *f;
2059 uf = compat_ptr(arg);
2060 f = karg = kmalloc(sizeof(struct floppy_struct), GFP_KERNEL);
2061 if (!karg)
2062 return -ENOMEM;
2063 if (cmd == FDGETPRM32)
2064 break;
2065 err = __get_user(f->size, &uf->size);
2066 err |= __get_user(f->sect, &uf->sect);
2067 err |= __get_user(f->head, &uf->head);
2068 err |= __get_user(f->track, &uf->track);
2069 err |= __get_user(f->stretch, &uf->stretch);
2070 err |= __get_user(f->gap, &uf->gap);
2071 err |= __get_user(f->rate, &uf->rate);
2072 err |= __get_user(f->spec1, &uf->spec1);
2073 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
2074 err |= __get_user(name, &uf->name);
2075 f->name = compat_ptr(name);
2076 if (err) {
2077 err = -EFAULT;
2078 goto out;
2080 break;
2082 case FDSETDRVPRM32:
2083 case FDGETDRVPRM32:
2085 struct floppy_drive_params32 __user *uf;
2086 struct floppy_drive_params *f;
2088 uf = compat_ptr(arg);
2089 f = karg = kmalloc(sizeof(struct floppy_drive_params), GFP_KERNEL);
2090 if (!karg)
2091 return -ENOMEM;
2092 if (cmd == FDGETDRVPRM32)
2093 break;
2094 err = __get_user(f->cmos, &uf->cmos);
2095 err |= __get_user(f->max_dtr, &uf->max_dtr);
2096 err |= __get_user(f->hlt, &uf->hlt);
2097 err |= __get_user(f->hut, &uf->hut);
2098 err |= __get_user(f->srt, &uf->srt);
2099 err |= __get_user(f->spinup, &uf->spinup);
2100 err |= __get_user(f->spindown, &uf->spindown);
2101 err |= __get_user(f->spindown_offset, &uf->spindown_offset);
2102 err |= __get_user(f->select_delay, &uf->select_delay);
2103 err |= __get_user(f->rps, &uf->rps);
2104 err |= __get_user(f->tracks, &uf->tracks);
2105 err |= __get_user(f->timeout, &uf->timeout);
2106 err |= __get_user(f->interleave_sect, &uf->interleave_sect);
2107 err |= __copy_from_user(&f->max_errors, &uf->max_errors, sizeof(f->max_errors));
2108 err |= __get_user(f->flags, &uf->flags);
2109 err |= __get_user(f->read_track, &uf->read_track);
2110 err |= __copy_from_user(f->autodetect, uf->autodetect, sizeof(f->autodetect));
2111 err |= __get_user(f->checkfreq, &uf->checkfreq);
2112 err |= __get_user(f->native_format, &uf->native_format);
2113 if (err) {
2114 err = -EFAULT;
2115 goto out;
2117 break;
2119 case FDGETDRVSTAT32:
2120 case FDPOLLDRVSTAT32:
2121 karg = kmalloc(sizeof(struct floppy_drive_struct), GFP_KERNEL);
2122 if (!karg)
2123 return -ENOMEM;
2124 break;
2125 case FDGETFDCSTAT32:
2126 karg = kmalloc(sizeof(struct floppy_fdc_state), GFP_KERNEL);
2127 if (!karg)
2128 return -ENOMEM;
2129 break;
2130 case FDWERRORGET32:
2131 karg = kmalloc(sizeof(struct floppy_write_errors), GFP_KERNEL);
2132 if (!karg)
2133 return -ENOMEM;
2134 break;
2135 default:
2136 return -EINVAL;
2138 set_fs (KERNEL_DS);
2139 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
2140 set_fs (old_fs);
2141 if (err)
2142 goto out;
2143 switch (cmd) {
2144 case FDGETPRM32:
2146 struct floppy_struct *f = karg;
2147 struct floppy_struct32 __user *uf = compat_ptr(arg);
2149 err = __put_user(f->size, &uf->size);
2150 err |= __put_user(f->sect, &uf->sect);
2151 err |= __put_user(f->head, &uf->head);
2152 err |= __put_user(f->track, &uf->track);
2153 err |= __put_user(f->stretch, &uf->stretch);
2154 err |= __put_user(f->gap, &uf->gap);
2155 err |= __put_user(f->rate, &uf->rate);
2156 err |= __put_user(f->spec1, &uf->spec1);
2157 err |= __put_user(f->fmt_gap, &uf->fmt_gap);
2158 err |= __put_user((u64)f->name, (compat_caddr_t __user *)&uf->name);
2159 break;
2161 case FDGETDRVPRM32:
2163 struct floppy_drive_params32 __user *uf;
2164 struct floppy_drive_params *f = karg;
2166 uf = compat_ptr(arg);
2167 err = __put_user(f->cmos, &uf->cmos);
2168 err |= __put_user(f->max_dtr, &uf->max_dtr);
2169 err |= __put_user(f->hlt, &uf->hlt);
2170 err |= __put_user(f->hut, &uf->hut);
2171 err |= __put_user(f->srt, &uf->srt);
2172 err |= __put_user(f->spinup, &uf->spinup);
2173 err |= __put_user(f->spindown, &uf->spindown);
2174 err |= __put_user(f->spindown_offset, &uf->spindown_offset);
2175 err |= __put_user(f->select_delay, &uf->select_delay);
2176 err |= __put_user(f->rps, &uf->rps);
2177 err |= __put_user(f->tracks, &uf->tracks);
2178 err |= __put_user(f->timeout, &uf->timeout);
2179 err |= __put_user(f->interleave_sect, &uf->interleave_sect);
2180 err |= __copy_to_user(&uf->max_errors, &f->max_errors, sizeof(f->max_errors));
2181 err |= __put_user(f->flags, &uf->flags);
2182 err |= __put_user(f->read_track, &uf->read_track);
2183 err |= __copy_to_user(uf->autodetect, f->autodetect, sizeof(f->autodetect));
2184 err |= __put_user(f->checkfreq, &uf->checkfreq);
2185 err |= __put_user(f->native_format, &uf->native_format);
2186 break;
2188 case FDGETDRVSTAT32:
2189 case FDPOLLDRVSTAT32:
2191 struct floppy_drive_struct32 __user *uf;
2192 struct floppy_drive_struct *f = karg;
2194 uf = compat_ptr(arg);
2195 err = __put_user(f->flags, &uf->flags);
2196 err |= __put_user(f->spinup_date, &uf->spinup_date);
2197 err |= __put_user(f->select_date, &uf->select_date);
2198 err |= __put_user(f->first_read_date, &uf->first_read_date);
2199 err |= __put_user(f->probed_format, &uf->probed_format);
2200 err |= __put_user(f->track, &uf->track);
2201 err |= __put_user(f->maxblock, &uf->maxblock);
2202 err |= __put_user(f->maxtrack, &uf->maxtrack);
2203 err |= __put_user(f->generation, &uf->generation);
2204 err |= __put_user(f->keep_data, &uf->keep_data);
2205 err |= __put_user(f->fd_ref, &uf->fd_ref);
2206 err |= __put_user(f->fd_device, &uf->fd_device);
2207 err |= __put_user(f->last_checked, &uf->last_checked);
2208 err |= __put_user((u64)f->dmabuf, &uf->dmabuf);
2209 err |= __put_user((u64)f->bufblocks, &uf->bufblocks);
2210 break;
2212 case FDGETFDCSTAT32:
2214 struct floppy_fdc_state32 __user *uf;
2215 struct floppy_fdc_state *f = karg;
2217 uf = compat_ptr(arg);
2218 err = __put_user(f->spec1, &uf->spec1);
2219 err |= __put_user(f->spec2, &uf->spec2);
2220 err |= __put_user(f->dtr, &uf->dtr);
2221 err |= __put_user(f->version, &uf->version);
2222 err |= __put_user(f->dor, &uf->dor);
2223 err |= __put_user(f->address, &uf->address);
2224 err |= __copy_to_user((char __user *)&uf->address + sizeof(uf->address),
2225 (char *)&f->address + sizeof(f->address), sizeof(int));
2226 err |= __put_user(f->driver_version, &uf->driver_version);
2227 err |= __copy_to_user(uf->track, f->track, sizeof(f->track));
2228 break;
2230 case FDWERRORGET32:
2232 struct floppy_write_errors32 __user *uf;
2233 struct floppy_write_errors *f = karg;
2235 uf = compat_ptr(arg);
2236 err = __put_user(f->write_errors, &uf->write_errors);
2237 err |= __put_user(f->first_error_sector, &uf->first_error_sector);
2238 err |= __put_user(f->first_error_generation, &uf->first_error_generation);
2239 err |= __put_user(f->last_error_sector, &uf->last_error_sector);
2240 err |= __put_user(f->last_error_generation, &uf->last_error_generation);
2241 err |= __put_user(f->badness, &uf->badness);
2242 break;
2244 default:
2245 break;
2247 if (err)
2248 err = -EFAULT;
2250 out:
2251 kfree(karg);
2252 return err;
2255 struct mtd_oob_buf32 {
2256 u_int32_t start;
2257 u_int32_t length;
2258 compat_caddr_t ptr; /* unsigned char* */
2261 #define MEMWRITEOOB32 _IOWR('M',3,struct mtd_oob_buf32)
2262 #define MEMREADOOB32 _IOWR('M',4,struct mtd_oob_buf32)
2264 static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg)
2266 struct mtd_oob_buf __user *buf = compat_alloc_user_space(sizeof(*buf));
2267 struct mtd_oob_buf32 __user *buf32 = compat_ptr(arg);
2268 u32 data;
2269 char __user *datap;
2270 unsigned int real_cmd;
2271 int err;
2273 real_cmd = (cmd == MEMREADOOB32) ?
2274 MEMREADOOB : MEMWRITEOOB;
2276 if (copy_in_user(&buf->start, &buf32->start,
2277 2 * sizeof(u32)) ||
2278 get_user(data, &buf32->ptr))
2279 return -EFAULT;
2280 datap = compat_ptr(data);
2281 if (put_user(datap, &buf->ptr))
2282 return -EFAULT;
2284 err = sys_ioctl(fd, real_cmd, (unsigned long) buf);
2286 if (!err) {
2287 if (copy_in_user(&buf32->start, &buf->start,
2288 2 * sizeof(u32)))
2289 err = -EFAULT;
2292 return err;
2295 #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
2296 #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
2298 static long
2299 put_dirent32 (struct dirent *d, struct compat_dirent __user *d32)
2301 if (!access_ok(VERIFY_WRITE, d32, sizeof(struct compat_dirent)))
2302 return -EFAULT;
2304 __put_user(d->d_ino, &d32->d_ino);
2305 __put_user(d->d_off, &d32->d_off);
2306 __put_user(d->d_reclen, &d32->d_reclen);
2307 if (__copy_to_user(d32->d_name, d->d_name, d->d_reclen))
2308 return -EFAULT;
2310 return 0;
2313 static int vfat_ioctl32(unsigned fd, unsigned cmd, unsigned long arg)
2315 struct compat_dirent __user *p = compat_ptr(arg);
2316 int ret;
2317 mm_segment_t oldfs = get_fs();
2318 struct dirent d[2];
2320 switch(cmd)
2322 case VFAT_IOCTL_READDIR_BOTH32:
2323 cmd = VFAT_IOCTL_READDIR_BOTH;
2324 break;
2325 case VFAT_IOCTL_READDIR_SHORT32:
2326 cmd = VFAT_IOCTL_READDIR_SHORT;
2327 break;
2330 set_fs(KERNEL_DS);
2331 ret = sys_ioctl(fd,cmd,(unsigned long)&d);
2332 set_fs(oldfs);
2333 if (ret >= 0) {
2334 ret |= put_dirent32(&d[0], p);
2335 ret |= put_dirent32(&d[1], p + 1);
2337 return ret;
2340 #define REISERFS_IOC_UNPACK32 _IOW(0xCD,1,int)
2342 static int reiserfs_ioctl32(unsigned fd, unsigned cmd, unsigned long ptr)
2344 if (cmd == REISERFS_IOC_UNPACK32)
2345 cmd = REISERFS_IOC_UNPACK;
2347 return sys_ioctl(fd,cmd,ptr);
2350 struct raw32_config_request
2352 compat_int_t raw_minor;
2353 __u64 block_major;
2354 __u64 block_minor;
2355 } __attribute__((packed));
2357 static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
2359 int ret;
2361 if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request)))
2362 return -EFAULT;
2364 ret = __get_user(req->raw_minor, &user_req->raw_minor);
2365 ret |= __get_user(req->block_major, &user_req->block_major);
2366 ret |= __get_user(req->block_minor, &user_req->block_minor);
2368 return ret ? -EFAULT : 0;
2371 static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
2373 int ret;
2375 if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request)))
2376 return -EFAULT;
2378 ret = __put_user(req->raw_minor, &user_req->raw_minor);
2379 ret |= __put_user(req->block_major, &user_req->block_major);
2380 ret |= __put_user(req->block_minor, &user_req->block_minor);
2382 return ret ? -EFAULT : 0;
2385 static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2387 int ret;
2389 switch (cmd) {
2390 case RAW_SETBIND:
2391 case RAW_GETBIND: {
2392 struct raw_config_request req;
2393 struct raw32_config_request __user *user_req = compat_ptr(arg);
2394 mm_segment_t oldfs = get_fs();
2396 if ((ret = get_raw32_request(&req, user_req)))
2397 return ret;
2399 set_fs(KERNEL_DS);
2400 ret = sys_ioctl(fd,cmd,(unsigned long)&req);
2401 set_fs(oldfs);
2403 if ((!ret) && (cmd == RAW_GETBIND)) {
2404 ret = set_raw32_request(&req, user_req);
2406 break;
2408 default:
2409 ret = sys_ioctl(fd, cmd, arg);
2410 break;
2412 return ret;
2415 struct serial_struct32 {
2416 compat_int_t type;
2417 compat_int_t line;
2418 compat_uint_t port;
2419 compat_int_t irq;
2420 compat_int_t flags;
2421 compat_int_t xmit_fifo_size;
2422 compat_int_t custom_divisor;
2423 compat_int_t baud_base;
2424 unsigned short close_delay;
2425 char io_type;
2426 char reserved_char[1];
2427 compat_int_t hub6;
2428 unsigned short closing_wait; /* time to wait before closing */
2429 unsigned short closing_wait2; /* no longer used... */
2430 compat_uint_t iomem_base;
2431 unsigned short iomem_reg_shift;
2432 unsigned int port_high;
2433 /* compat_ulong_t iomap_base FIXME */
2434 compat_int_t reserved[1];
2437 static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2439 typedef struct serial_struct SS;
2440 typedef struct serial_struct32 SS32;
2441 struct serial_struct32 __user *ss32 = compat_ptr(arg);
2442 int err;
2443 struct serial_struct ss;
2444 mm_segment_t oldseg = get_fs();
2445 __u32 udata;
2447 if (cmd == TIOCSSERIAL) {
2448 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
2449 return -EFAULT;
2450 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
2451 return -EFAULT;
2452 __get_user(udata, &ss32->iomem_base);
2453 ss.iomem_base = compat_ptr(udata);
2454 __get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift);
2455 __get_user(ss.port_high, &ss32->port_high);
2456 ss.iomap_base = 0UL;
2458 set_fs(KERNEL_DS);
2459 err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
2460 set_fs(oldseg);
2461 if (cmd == TIOCGSERIAL && err >= 0) {
2462 if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32)))
2463 return -EFAULT;
2464 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
2465 return -EFAULT;
2466 __put_user((unsigned long)ss.iomem_base >> 32 ?
2467 0xffffffff : (unsigned)(unsigned long)ss.iomem_base,
2468 &ss32->iomem_base);
2469 __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift);
2470 __put_user(ss.port_high, &ss32->port_high);
2473 return err;
2476 struct usbdevfs_ctrltransfer32 {
2477 u8 bRequestType;
2478 u8 bRequest;
2479 u16 wValue;
2480 u16 wIndex;
2481 u16 wLength;
2482 u32 timeout; /* in milliseconds */
2483 compat_caddr_t data;
2486 #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
2488 static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
2490 struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg);
2491 struct usbdevfs_ctrltransfer __user *p;
2492 __u32 udata;
2493 p = compat_alloc_user_space(sizeof(*p));
2494 if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
2495 get_user(udata, &p32->data) ||
2496 put_user(compat_ptr(udata), &p->data))
2497 return -EFAULT;
2498 return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p);
2502 struct usbdevfs_bulktransfer32 {
2503 compat_uint_t ep;
2504 compat_uint_t len;
2505 compat_uint_t timeout; /* in milliseconds */
2506 compat_caddr_t data;
2509 #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
2511 static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
2513 struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg);
2514 struct usbdevfs_bulktransfer __user *p;
2515 compat_uint_t n;
2516 compat_caddr_t addr;
2518 p = compat_alloc_user_space(sizeof(*p));
2520 if (get_user(n, &p32->ep) || put_user(n, &p->ep) ||
2521 get_user(n, &p32->len) || put_user(n, &p->len) ||
2522 get_user(n, &p32->timeout) || put_user(n, &p->timeout) ||
2523 get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data))
2524 return -EFAULT;
2526 return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p);
2531 * USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY
2532 * are handled in usbdevfs core. -Christopher Li
2535 struct usbdevfs_disconnectsignal32 {
2536 compat_int_t signr;
2537 compat_caddr_t context;
2540 #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
2542 static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
2544 struct usbdevfs_disconnectsignal kdis;
2545 struct usbdevfs_disconnectsignal32 __user *udis;
2546 mm_segment_t old_fs;
2547 u32 uctx;
2548 int err;
2550 udis = compat_ptr(arg);
2552 if (get_user(kdis.signr, &udis->signr) ||
2553 __get_user(uctx, &udis->context))
2554 return -EFAULT;
2556 kdis.context = compat_ptr(uctx);
2558 old_fs = get_fs();
2559 set_fs(KERNEL_DS);
2560 err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
2561 set_fs(old_fs);
2563 return err;
2567 * I2C layer ioctls
2570 struct i2c_msg32 {
2571 u16 addr;
2572 u16 flags;
2573 u16 len;
2574 compat_caddr_t buf;
2577 struct i2c_rdwr_ioctl_data32 {
2578 compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
2579 u32 nmsgs;
2582 struct i2c_smbus_ioctl_data32 {
2583 u8 read_write;
2584 u8 command;
2585 u32 size;
2586 compat_caddr_t data; /* union i2c_smbus_data *data */
2589 struct i2c_rdwr_aligned {
2590 struct i2c_rdwr_ioctl_data cmd;
2591 struct i2c_msg msgs[0];
2594 static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2596 struct i2c_rdwr_ioctl_data32 __user *udata = compat_ptr(arg);
2597 struct i2c_rdwr_aligned __user *tdata;
2598 struct i2c_msg __user *tmsgs;
2599 struct i2c_msg32 __user *umsgs;
2600 compat_caddr_t datap;
2601 int nmsgs, i;
2603 if (get_user(nmsgs, &udata->nmsgs))
2604 return -EFAULT;
2605 if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
2606 return -EINVAL;
2608 if (get_user(datap, &udata->msgs))
2609 return -EFAULT;
2610 umsgs = compat_ptr(datap);
2612 tdata = compat_alloc_user_space(sizeof(*tdata) +
2613 nmsgs * sizeof(struct i2c_msg));
2614 tmsgs = &tdata->msgs[0];
2616 if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
2617 put_user(tmsgs, &tdata->cmd.msgs))
2618 return -EFAULT;
2620 for (i = 0; i < nmsgs; i++) {
2621 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
2622 return -EFAULT;
2623 if (get_user(datap, &umsgs[i].buf) ||
2624 put_user(compat_ptr(datap), &tmsgs[i].buf))
2625 return -EFAULT;
2627 return sys_ioctl(fd, cmd, (unsigned long)tdata);
2630 static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2632 struct i2c_smbus_ioctl_data __user *tdata;
2633 struct i2c_smbus_ioctl_data32 __user *udata;
2634 compat_caddr_t datap;
2636 tdata = compat_alloc_user_space(sizeof(*tdata));
2637 if (tdata == NULL)
2638 return -ENOMEM;
2639 if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
2640 return -EFAULT;
2642 udata = compat_ptr(arg);
2643 if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
2644 return -EFAULT;
2646 if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
2647 return -EFAULT;
2648 if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
2649 return -EFAULT;
2650 if (__get_user(datap, &udata->data) ||
2651 __put_user(compat_ptr(datap), &tdata->data))
2652 return -EFAULT;
2654 return sys_ioctl(fd, cmd, (unsigned long)tdata);
2657 struct compat_iw_point {
2658 compat_caddr_t pointer;
2659 __u16 length;
2660 __u16 flags;
2663 static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2665 struct iwreq __user *iwr;
2666 struct iwreq __user *iwr_u;
2667 struct iw_point __user *iwp;
2668 struct compat_iw_point __user *iwp_u;
2669 compat_caddr_t pointer;
2670 __u16 length, flags;
2672 iwr_u = compat_ptr(arg);
2673 iwp_u = (struct compat_iw_point __user *) &iwr_u->u.data;
2674 iwr = compat_alloc_user_space(sizeof(*iwr));
2675 if (iwr == NULL)
2676 return -ENOMEM;
2678 iwp = &iwr->u.data;
2680 if (!access_ok(VERIFY_WRITE, iwr, sizeof(*iwr)))
2681 return -EFAULT;
2683 if (__copy_in_user(&iwr->ifr_ifrn.ifrn_name[0],
2684 &iwr_u->ifr_ifrn.ifrn_name[0],
2685 sizeof(iwr->ifr_ifrn.ifrn_name)))
2686 return -EFAULT;
2688 if (__get_user(pointer, &iwp_u->pointer) ||
2689 __get_user(length, &iwp_u->length) ||
2690 __get_user(flags, &iwp_u->flags))
2691 return -EFAULT;
2693 if (__put_user(compat_ptr(pointer), &iwp->pointer) ||
2694 __put_user(length, &iwp->length) ||
2695 __put_user(flags, &iwp->flags))
2696 return -EFAULT;
2698 return sys_ioctl(fd, cmd, (unsigned long) iwr);
2701 /* Since old style bridge ioctl's endup using SIOCDEVPRIVATE
2702 * for some operations; this forces use of the newer bridge-utils that
2703 * use compatiable ioctls
2705 static int old_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2707 u32 tmp;
2709 if (get_user(tmp, (u32 __user *) arg))
2710 return -EFAULT;
2711 if (tmp == BRCTL_GET_VERSION)
2712 return BRCTL_VERSION + 1;
2713 return -EINVAL;
2716 #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
2717 struct ncp_ioctl_request_32 {
2718 u32 function;
2719 u32 size;
2720 compat_caddr_t data;
2723 struct ncp_fs_info_v2_32 {
2724 s32 version;
2725 u32 mounted_uid;
2726 u32 connection;
2727 u32 buffer_size;
2729 u32 volume_number;
2730 u32 directory_id;
2732 u32 dummy1;
2733 u32 dummy2;
2734 u32 dummy3;
2737 struct ncp_objectname_ioctl_32
2739 s32 auth_type;
2740 u32 object_name_len;
2741 compat_caddr_t object_name; /* an userspace data, in most cases user name */
2744 struct ncp_privatedata_ioctl_32
2746 u32 len;
2747 compat_caddr_t data; /* ~1000 for NDS */
2750 #define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct ncp_ioctl_request_32)
2751 #define NCP_IOC_GETMOUNTUID2_32 _IOW('n', 2, u32)
2752 #define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct ncp_fs_info_v2_32)
2753 #define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct ncp_objectname_ioctl_32)
2754 #define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct ncp_objectname_ioctl_32)
2755 #define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct ncp_privatedata_ioctl_32)
2756 #define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct ncp_privatedata_ioctl_32)
2758 static int do_ncp_ncprequest(unsigned int fd, unsigned int cmd, unsigned long arg)
2760 struct ncp_ioctl_request_32 n32;
2761 struct ncp_ioctl_request __user *p = compat_alloc_user_space(sizeof(*p));
2763 if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)) ||
2764 put_user(n32.function, &p->function) ||
2765 put_user(n32.size, &p->size) ||
2766 put_user(compat_ptr(n32.data), &p->data))
2767 return -EFAULT;
2769 return sys_ioctl(fd, NCP_IOC_NCPREQUEST, (unsigned long)p);
2772 static int do_ncp_getmountuid2(unsigned int fd, unsigned int cmd, unsigned long arg)
2774 mm_segment_t old_fs = get_fs();
2775 __kernel_uid_t kuid;
2776 int err;
2778 cmd = NCP_IOC_GETMOUNTUID2;
2780 set_fs(KERNEL_DS);
2781 err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
2782 set_fs(old_fs);
2784 if (!err)
2785 err = put_user(kuid,
2786 (unsigned int __user *) compat_ptr(arg));
2788 return err;
2791 static int do_ncp_getfsinfo2(unsigned int fd, unsigned int cmd, unsigned long arg)
2793 mm_segment_t old_fs = get_fs();
2794 struct ncp_fs_info_v2_32 n32;
2795 struct ncp_fs_info_v2 n;
2796 int err;
2798 if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)))
2799 return -EFAULT;
2800 if (n32.version != NCP_GET_FS_INFO_VERSION_V2)
2801 return -EINVAL;
2802 n.version = NCP_GET_FS_INFO_VERSION_V2;
2804 set_fs(KERNEL_DS);
2805 err = sys_ioctl(fd, NCP_IOC_GET_FS_INFO_V2, (unsigned long)&n);
2806 set_fs(old_fs);
2808 if (!err) {
2809 n32.version = n.version;
2810 n32.mounted_uid = n.mounted_uid;
2811 n32.connection = n.connection;
2812 n32.buffer_size = n.buffer_size;
2813 n32.volume_number = n.volume_number;
2814 n32.directory_id = n.directory_id;
2815 n32.dummy1 = n.dummy1;
2816 n32.dummy2 = n.dummy2;
2817 n32.dummy3 = n.dummy3;
2818 err = copy_to_user(compat_ptr(arg), &n32, sizeof(n32)) ? -EFAULT : 0;
2820 return err;
2823 static int do_ncp_getobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
2825 struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2826 struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
2827 s32 auth_type;
2828 u32 name_len;
2829 int err;
2831 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2832 put_user(n32.object_name_len, &p->object_name_len) ||
2833 put_user(compat_ptr(n32.object_name), &p->object_name))
2834 return -EFAULT;
2836 err = sys_ioctl(fd, NCP_IOC_GETOBJECTNAME, (unsigned long)p);
2837 if (err)
2838 return err;
2840 if (get_user(auth_type, &p->auth_type) ||
2841 put_user(auth_type, &p32->auth_type) ||
2842 get_user(name_len, &p->object_name_len) ||
2843 put_user(name_len, &p32->object_name_len))
2844 return -EFAULT;
2846 return 0;
2849 static int do_ncp_setobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
2851 struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2852 struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
2854 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2855 put_user(n32.auth_type, &p->auth_type) ||
2856 put_user(n32.object_name_len, &p->object_name_len) ||
2857 put_user(compat_ptr(n32.object_name), &p->object_name))
2858 return -EFAULT;
2860 return sys_ioctl(fd, NCP_IOC_SETOBJECTNAME, (unsigned long)p);
2863 static int do_ncp_getprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
2865 struct ncp_privatedata_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2866 struct ncp_privatedata_ioctl __user *p =
2867 compat_alloc_user_space(sizeof(*p));
2868 u32 len;
2869 int err;
2871 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2872 put_user(n32.len, &p->len) ||
2873 put_user(compat_ptr(n32.data), &p->data))
2874 return -EFAULT;
2876 err = sys_ioctl(fd, NCP_IOC_GETPRIVATEDATA, (unsigned long)p);
2877 if (err)
2878 return err;
2880 if (get_user(len, &p->len) ||
2881 put_user(len, &p32->len))
2882 return -EFAULT;
2884 return 0;
2887 static int do_ncp_setprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
2889 struct ncp_privatedata_ioctl_32 n32;
2890 struct ncp_privatedata_ioctl_32 __user *p32 = compat_ptr(arg);
2891 struct ncp_privatedata_ioctl __user *p =
2892 compat_alloc_user_space(sizeof(*p));
2894 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2895 put_user(n32.len, &p->len) ||
2896 put_user(compat_ptr(n32.data), &p->data))
2897 return -EFAULT;
2899 return sys_ioctl(fd, NCP_IOC_SETPRIVATEDATA, (unsigned long)p);
2901 #endif
2903 #undef CODE
2904 #endif
2906 #ifdef DECLARES
2907 HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob)
2908 HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob)
2909 #ifdef CONFIG_NET
2910 HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
2911 HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)
2912 HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc)
2913 HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc)
2914 HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc)
2915 HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc)
2916 HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc)
2917 HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc)
2918 HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc)
2919 HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc)
2920 HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc)
2921 HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc)
2922 HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc)
2923 HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc)
2924 HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc)
2925 HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc)
2926 HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
2927 HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
2928 HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
2930 /* ioctls used by appletalk ddp.c */
2931 HANDLE_IOCTL(SIOCATALKDIFADDR, dev_ifsioc)
2932 HANDLE_IOCTL(SIOCDIFADDR, dev_ifsioc)
2933 HANDLE_IOCTL(SIOCSARP, dev_ifsioc)
2934 HANDLE_IOCTL(SIOCDARP, dev_ifsioc)
2936 HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc)
2937 HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc)
2938 HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc)
2939 HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc)
2940 HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc)
2941 HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc)
2942 HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc)
2943 HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc)
2944 HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc)
2945 HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc)
2946 HANDLE_IOCTL(TUNSETIFF, dev_ifsioc)
2947 HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl)
2948 HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl)
2949 HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl)
2950 HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl)
2951 HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl)
2952 HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl)
2953 HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl)
2954 HANDLE_IOCTL(SIOCADDRT, routing_ioctl)
2955 HANDLE_IOCTL(SIOCDELRT, routing_ioctl)
2956 HANDLE_IOCTL(SIOCBRADDIF, dev_ifsioc)
2957 HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc)
2958 /* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
2959 HANDLE_IOCTL(SIOCRTMSG, ret_einval)
2960 HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
2961 #endif
2962 HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo)
2963 HANDLE_IOCTL(BLKRAGET, w_long)
2964 HANDLE_IOCTL(BLKGETSIZE, w_long)
2965 HANDLE_IOCTL(0x1260, broken_blkgetsize)
2966 HANDLE_IOCTL(BLKFRAGET, w_long)
2967 HANDLE_IOCTL(BLKSECTGET, w_long)
2968 HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
2969 HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans)
2970 HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans)
2971 HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans)
2972 HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans)
2973 HANDLE_IOCTL(HDIO_GET_MULTCOUNT, hdio_ioctl_trans)
2974 HANDLE_IOCTL(HDIO_GET_NOWERR, hdio_ioctl_trans)
2975 HANDLE_IOCTL(HDIO_GET_NICE, hdio_ioctl_trans)
2976 HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans)
2977 HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans)
2978 HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans)
2979 HANDLE_IOCTL(FDSETDRVPRM32, fd_ioctl_trans)
2980 HANDLE_IOCTL(FDGETDRVPRM32, fd_ioctl_trans)
2981 HANDLE_IOCTL(FDGETDRVSTAT32, fd_ioctl_trans)
2982 HANDLE_IOCTL(FDPOLLDRVSTAT32, fd_ioctl_trans)
2983 HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans)
2984 HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans)
2985 HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
2986 HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans)
2987 HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans)
2988 HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans)
2989 HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans)
2990 HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans)
2991 HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans)
2992 HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans)
2993 HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans)
2994 HANDLE_IOCTL(LOOP_SET_STATUS, loop_status)
2995 HANDLE_IOCTL(LOOP_GET_STATUS, loop_status)
2996 #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
2997 HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout)
2998 #ifdef CONFIG_VT
2999 HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl)
3000 HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl)
3001 HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl)
3002 HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl)
3003 HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl)
3004 #endif
3005 HANDLE_IOCTL(EXT2_IOC32_GETFLAGS, do_ext2_ioctl)
3006 HANDLE_IOCTL(EXT2_IOC32_SETFLAGS, do_ext2_ioctl)
3007 HANDLE_IOCTL(EXT2_IOC32_GETVERSION, do_ext2_ioctl)
3008 HANDLE_IOCTL(EXT2_IOC32_SETVERSION, do_ext2_ioctl)
3009 HANDLE_IOCTL(EXT3_IOC32_GETVERSION, do_ext3_ioctl)
3010 HANDLE_IOCTL(EXT3_IOC32_SETVERSION, do_ext3_ioctl)
3011 HANDLE_IOCTL(EXT3_IOC32_GETRSVSZ, do_ext3_ioctl)
3012 HANDLE_IOCTL(EXT3_IOC32_SETRSVSZ, do_ext3_ioctl)
3013 HANDLE_IOCTL(EXT3_IOC32_GROUP_EXTEND, do_ext3_ioctl)
3014 COMPATIBLE_IOCTL(EXT3_IOC_GROUP_ADD)
3015 #ifdef CONFIG_JBD_DEBUG
3016 HANDLE_IOCTL(EXT3_IOC32_WAIT_FOR_READONLY, do_ext3_ioctl)
3017 #endif
3018 HANDLE_IOCTL(VIDIOCGTUNER32, do_video_ioctl)
3019 HANDLE_IOCTL(VIDIOCSTUNER32, do_video_ioctl)
3020 HANDLE_IOCTL(VIDIOCGWIN32, do_video_ioctl)
3021 HANDLE_IOCTL(VIDIOCSWIN32, do_set_window)
3022 HANDLE_IOCTL(VIDIOCGFBUF32, do_video_ioctl)
3023 HANDLE_IOCTL(VIDIOCSFBUF32, do_video_ioctl)
3024 HANDLE_IOCTL(VIDIOCGFREQ32, do_video_ioctl)
3025 HANDLE_IOCTL(VIDIOCSFREQ32, do_video_ioctl)
3026 /* One SMB ioctl needs translations. */
3027 #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
3028 HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
3029 HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl)
3030 HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl)
3031 HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl)
3032 HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl)
3033 HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl)
3034 HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl)
3035 HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl)
3036 HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl)
3037 HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl)
3038 HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl)
3039 HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl)
3040 HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl)
3041 HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl)
3042 HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl)
3043 HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl)
3044 HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl)
3045 HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl)
3046 HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl)
3047 HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl)
3048 HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl)
3049 HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl)
3050 HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl)
3051 HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl)
3052 HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl)
3053 HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl)
3054 /* block stuff */
3055 HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget)
3056 HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset)
3057 HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64)
3058 /* vfat */
3059 HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32)
3060 HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32, vfat_ioctl32)
3061 HANDLE_IOCTL(REISERFS_IOC_UNPACK32, reiserfs_ioctl32)
3062 /* Raw devices */
3063 HANDLE_IOCTL(RAW_SETBIND, raw_ioctl)
3064 HANDLE_IOCTL(RAW_GETBIND, raw_ioctl)
3065 /* Serial */
3066 HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl)
3067 HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl)
3068 #ifdef TIOCGLTC
3069 COMPATIBLE_IOCTL(TIOCGLTC)
3070 COMPATIBLE_IOCTL(TIOCSLTC)
3071 #endif
3072 #ifdef TIOCSTART
3074 * For these two we have defintions in ioctls.h and/or termios.h on
3075 * some architectures but no actual implemention. Some applications
3076 * like bash call them if they are defined in the headers, so we provide
3077 * entries here to avoid syslog message spew.
3079 COMPATIBLE_IOCTL(TIOCSTART)
3080 COMPATIBLE_IOCTL(TIOCSTOP)
3081 #endif
3082 /* Usbdevfs */
3083 HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
3084 HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
3085 HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
3086 COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
3087 /* i2c */
3088 HANDLE_IOCTL(I2C_FUNCS, w_long)
3089 HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
3090 HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
3091 /* wireless */
3092 HANDLE_IOCTL(SIOCGIWRANGE, do_wireless_ioctl)
3093 HANDLE_IOCTL(SIOCSIWSPY, do_wireless_ioctl)
3094 HANDLE_IOCTL(SIOCGIWSPY, do_wireless_ioctl)
3095 HANDLE_IOCTL(SIOCSIWTHRSPY, do_wireless_ioctl)
3096 HANDLE_IOCTL(SIOCGIWTHRSPY, do_wireless_ioctl)
3097 HANDLE_IOCTL(SIOCGIWAPLIST, do_wireless_ioctl)
3098 HANDLE_IOCTL(SIOCGIWSCAN, do_wireless_ioctl)
3099 HANDLE_IOCTL(SIOCSIWESSID, do_wireless_ioctl)
3100 HANDLE_IOCTL(SIOCGIWESSID, do_wireless_ioctl)
3101 HANDLE_IOCTL(SIOCSIWNICKN, do_wireless_ioctl)
3102 HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl)
3103 HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl)
3104 HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl)
3105 HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl)
3106 HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl)
3108 #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
3109 HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest)
3110 HANDLE_IOCTL(NCP_IOC_GETMOUNTUID2_32, do_ncp_getmountuid2)
3111 HANDLE_IOCTL(NCP_IOC_GET_FS_INFO_V2_32, do_ncp_getfsinfo2)
3112 HANDLE_IOCTL(NCP_IOC_GETOBJECTNAME_32, do_ncp_getobjectname)
3113 HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32, do_ncp_setobjectname)
3114 HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata)
3115 HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata)
3116 #endif
3118 /* dvb */
3119 HANDLE_IOCTL(DMX_GET_EVENT, do_dmx_get_event)
3120 HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event)
3121 HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture)
3122 HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette)
3124 #undef DECLARES
3125 #endif