cleanup compat ioctl handling
[linux-2.6] / fs / compat_ioctl.c
1 /*
2  * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
3  *
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)
8  *
9  * These routines maintain argument size conversion between 32bit and 64bit
10  * ioctls.
11  */
12
13 #include <linux/types.h>
14 #include <linux/compat.h>
15 #include <linux/kernel.h>
16 #include <linux/capability.h>
17 #include <linux/compiler.h>
18 #include <linux/sched.h>
19 #include <linux/smp.h>
20 #include <linux/ioctl.h>
21 #include <linux/if.h>
22 #include <linux/if_bridge.h>
23 #include <linux/slab.h>
24 #include <linux/hdreg.h>
25 #include <linux/raid/md.h>
26 #include <linux/kd.h>
27 #include <linux/dirent.h>
28 #include <linux/route.h>
29 #include <linux/in6.h>
30 #include <linux/ipv6_route.h>
31 #include <linux/skbuff.h>
32 #include <linux/netlink.h>
33 #include <linux/vt.h>
34 #include <linux/fs.h>
35 #include <linux/file.h>
36 #include <linux/fd.h>
37 #include <linux/ppp_defs.h>
38 #include <linux/if_ppp.h>
39 #include <linux/if_pppox.h>
40 #include <linux/mtio.h>
41 #include <linux/cdrom.h>
42 #include <linux/auto_fs.h>
43 #include <linux/auto_fs4.h>
44 #include <linux/tty.h>
45 #include <linux/vt_kern.h>
46 #include <linux/fb.h>
47 #include <linux/videodev.h>
48 #include <linux/netdevice.h>
49 #include <linux/raw.h>
50 #include <linux/smb_fs.h>
51 #include <linux/blkpg.h>
52 #include <linux/blkdev.h>
53 #include <linux/elevator.h>
54 #include <linux/rtc.h>
55 #include <linux/pci.h>
56 #include <linux/module.h>
57 #include <linux/serial.h>
58 #include <linux/if_tun.h>
59 #include <linux/ctype.h>
60 #include <linux/syscalls.h>
61 #include <linux/i2c.h>
62 #include <linux/i2c-dev.h>
63 #include <linux/wireless.h>
64 #include <linux/atalk.h>
65 #include <linux/blktrace_api.h>
66
67 #include <net/bluetooth/bluetooth.h>
68 #include <net/bluetooth/hci.h>
69 #include <net/bluetooth/rfcomm.h>
70
71 #include <linux/capi.h>
72 #include <linux/gigaset_dev.h>
73
74 #include <scsi/scsi.h>
75 #include <scsi/scsi_ioctl.h>
76 #include <scsi/sg.h>
77
78 #include <asm/uaccess.h>
79 #include <linux/ethtool.h>
80 #include <linux/mii.h>
81 #include <linux/if_bonding.h>
82 #include <linux/watchdog.h>
83 #include <linux/dm-ioctl.h>
84
85 #include <linux/soundcard.h>
86 #include <linux/lp.h>
87 #include <linux/ppdev.h>
88
89 #include <linux/atm.h>
90 #include <linux/atmarp.h>
91 #include <linux/atmclip.h>
92 #include <linux/atmdev.h>
93 #include <linux/atmioc.h>
94 #include <linux/atmlec.h>
95 #include <linux/atmmpc.h>
96 #include <linux/atmsvc.h>
97 #include <linux/atm_tcp.h>
98 #include <linux/sonet.h>
99 #include <linux/atm_suni.h>
100 #include <linux/mtd/mtd.h>
101
102 #include <linux/usb.h>
103 #include <linux/usbdevice_fs.h>
104 #include <linux/nbd.h>
105 #include <linux/random.h>
106 #include <linux/filter.h>
107 #include <linux/pktcdvd.h>
108
109 #include <linux/hiddev.h>
110
111 #include <linux/dvb/audio.h>
112 #include <linux/dvb/dmx.h>
113 #include <linux/dvb/frontend.h>
114 #include <linux/dvb/video.h>
115 #include <linux/lp.h>
116
117 static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
118                               unsigned long arg, struct file *f)
119 {
120         return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
121 }
122
123 static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
124 {
125         mm_segment_t old_fs = get_fs();
126         int err;
127         unsigned long val;
128         
129         set_fs (KERNEL_DS);
130         err = sys_ioctl(fd, cmd, (unsigned long)&val);
131         set_fs (old_fs);
132         if (!err && put_user(val, (u32 __user *)compat_ptr(arg)))
133                 return -EFAULT;
134         return err;
135 }
136  
137 static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg)
138 {
139         mm_segment_t old_fs = get_fs();
140         u32 __user *argptr = compat_ptr(arg);
141         int err;
142         unsigned long val;
143         
144         if(get_user(val, argptr))
145                 return -EFAULT;
146         set_fs (KERNEL_DS);
147         err = sys_ioctl(fd, cmd, (unsigned long)&val);
148         set_fs (old_fs);
149         if (!err && put_user(val, argptr))
150                 return -EFAULT;
151         return err;
152 }
153
154 struct compat_video_event {
155         int32_t         type;
156         compat_time_t   timestamp;
157         union {
158                 video_size_t size;
159                 unsigned int frame_rate;
160         } u;
161 };
162
163 static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long arg)
164 {
165         struct video_event kevent;
166         mm_segment_t old_fs = get_fs();
167         int err;
168
169         set_fs(KERNEL_DS);
170         err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
171         set_fs(old_fs);
172
173         if (!err) {
174                 struct compat_video_event __user *up = compat_ptr(arg);
175
176                 err  = put_user(kevent.type, &up->type);
177                 err |= put_user(kevent.timestamp, &up->timestamp);
178                 err |= put_user(kevent.u.size.w, &up->u.size.w);
179                 err |= put_user(kevent.u.size.h, &up->u.size.h);
180                 err |= put_user(kevent.u.size.aspect_ratio,
181                                 &up->u.size.aspect_ratio);
182                 if (err)
183                         err = -EFAULT;
184         }
185
186         return err;
187 }
188
189 struct compat_video_still_picture {
190         compat_uptr_t iFrame;
191         int32_t size;
192 };
193
194 static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned long arg)
195 {
196         struct compat_video_still_picture __user *up;
197         struct video_still_picture __user *up_native;
198         compat_uptr_t fp;
199         int32_t size;
200         int err;
201
202         up = (struct compat_video_still_picture __user *) arg;
203         err  = get_user(fp, &up->iFrame);
204         err |= get_user(size, &up->size);
205         if (err)
206                 return -EFAULT;
207
208         up_native =
209                 compat_alloc_user_space(sizeof(struct video_still_picture));
210
211         err =  put_user(compat_ptr(fp), &up_native->iFrame);
212         err |= put_user(size, &up_native->size);
213         if (err)
214                 return -EFAULT;
215
216         err = sys_ioctl(fd, cmd, (unsigned long) up_native);
217
218         return err;
219 }
220
221 struct compat_video_spu_palette {
222         int length;
223         compat_uptr_t palette;
224 };
225
226 static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned long arg)
227 {
228         struct compat_video_spu_palette __user *up;
229         struct video_spu_palette __user *up_native;
230         compat_uptr_t palp;
231         int length, err;
232
233         up = (struct compat_video_spu_palette __user *) arg;
234         err  = get_user(palp, &up->palette);
235         err |= get_user(length, &up->length);
236
237         up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
238         err  = put_user(compat_ptr(palp), &up_native->palette);
239         err |= put_user(length, &up_native->length);
240         if (err)
241                 return -EFAULT;
242
243         err = sys_ioctl(fd, cmd, (unsigned long) up_native);
244
245         return err;
246 }
247
248 #ifdef CONFIG_NET
249 static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
250 {
251         struct compat_timeval __user *up = compat_ptr(arg);
252         struct timeval ktv;
253         mm_segment_t old_fs = get_fs();
254         int err;
255
256         set_fs(KERNEL_DS);
257         err = sys_ioctl(fd, cmd, (unsigned long)&ktv);
258         set_fs(old_fs);
259         if(!err) {
260                 err = put_user(ktv.tv_sec, &up->tv_sec);
261                 err |= __put_user(ktv.tv_usec, &up->tv_usec);
262         }
263         return err;
264 }
265
266 static int do_siocgstampns(unsigned int fd, unsigned int cmd, unsigned long arg)
267 {
268         struct compat_timespec __user *up = compat_ptr(arg);
269         struct timespec kts;
270         mm_segment_t old_fs = get_fs();
271         int err;
272
273         set_fs(KERNEL_DS);
274         err = sys_ioctl(fd, cmd, (unsigned long)&kts);
275         set_fs(old_fs);
276         if (!err) {
277                 err = put_user(kts.tv_sec, &up->tv_sec);
278                 err |= __put_user(kts.tv_nsec, &up->tv_nsec);
279         }
280         return err;
281 }
282
283 struct ifmap32 {
284         compat_ulong_t mem_start;
285         compat_ulong_t mem_end;
286         unsigned short base_addr;
287         unsigned char irq;
288         unsigned char dma;
289         unsigned char port;
290 };
291
292 struct ifreq32 {
293 #define IFHWADDRLEN     6
294 #define IFNAMSIZ        16
295         union {
296                 char    ifrn_name[IFNAMSIZ];            /* if name, e.g. "en0" */
297         } ifr_ifrn;
298         union {
299                 struct  sockaddr ifru_addr;
300                 struct  sockaddr ifru_dstaddr;
301                 struct  sockaddr ifru_broadaddr;
302                 struct  sockaddr ifru_netmask;
303                 struct  sockaddr ifru_hwaddr;
304                 short   ifru_flags;
305                 compat_int_t     ifru_ivalue;
306                 compat_int_t     ifru_mtu;
307                 struct  ifmap32 ifru_map;
308                 char    ifru_slave[IFNAMSIZ];   /* Just fits the size */
309                 char    ifru_newname[IFNAMSIZ];
310                 compat_caddr_t ifru_data;
311             /* XXXX? ifru_settings should be here */
312         } ifr_ifru;
313 };
314
315 struct ifconf32 {
316         compat_int_t    ifc_len;                        /* size of buffer       */
317         compat_caddr_t  ifcbuf;
318 };
319
320 static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
321 {
322         struct net_device *dev;
323         struct ifreq32 ifr32;
324         int err;
325
326         if (copy_from_user(&ifr32, compat_ptr(arg), sizeof(ifr32)))
327                 return -EFAULT;
328
329         dev = dev_get_by_index(ifr32.ifr_ifindex);
330         if (!dev)
331                 return -ENODEV;
332
333         strlcpy(ifr32.ifr_name, dev->name, sizeof(ifr32.ifr_name));
334         dev_put(dev);
335         
336         err = copy_to_user(compat_ptr(arg), &ifr32, sizeof(ifr32));
337         return (err ? -EFAULT : 0);
338 }
339
340 static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)
341 {
342         struct ifconf32 ifc32;
343         struct ifconf ifc;
344         struct ifconf __user *uifc;
345         struct ifreq32 __user *ifr32;
346         struct ifreq __user *ifr;
347         unsigned int i, j;
348         int err;
349
350         if (copy_from_user(&ifc32, compat_ptr(arg), sizeof(struct ifconf32)))
351                 return -EFAULT;
352
353         if (ifc32.ifcbuf == 0) {
354                 ifc32.ifc_len = 0;
355                 ifc.ifc_len = 0;
356                 ifc.ifc_req = NULL;
357                 uifc = compat_alloc_user_space(sizeof(struct ifconf));
358         } else {
359                 size_t len =((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) *
360                         sizeof (struct ifreq);
361                 uifc = compat_alloc_user_space(sizeof(struct ifconf) + len);
362                 ifc.ifc_len = len;
363                 ifr = ifc.ifc_req = (void __user *)(uifc + 1);
364                 ifr32 = compat_ptr(ifc32.ifcbuf);
365                 for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) {
366                         if (copy_in_user(ifr, ifr32, sizeof(struct ifreq32)))
367                                 return -EFAULT;
368                         ifr++;
369                         ifr32++; 
370                 }
371         }
372         if (copy_to_user(uifc, &ifc, sizeof(struct ifconf)))
373                 return -EFAULT;
374
375         err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)uifc); 
376         if (err)
377                 return err;
378
379         if (copy_from_user(&ifc, uifc, sizeof(struct ifconf))) 
380                 return -EFAULT;
381
382         ifr = ifc.ifc_req;
383         ifr32 = compat_ptr(ifc32.ifcbuf);
384         for (i = 0, j = 0;
385              i + sizeof (struct ifreq32) <= ifc32.ifc_len && j < ifc.ifc_len;
386              i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
387                 if (copy_in_user(ifr32, ifr, sizeof (struct ifreq32)))
388                         return -EFAULT;
389                 ifr32++;
390                 ifr++;
391         }
392
393         if (ifc32.ifcbuf == 0) {
394                 /* Translate from 64-bit structure multiple to
395                  * a 32-bit one.
396                  */
397                 i = ifc.ifc_len;
398                 i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32));
399                 ifc32.ifc_len = i;
400         } else {
401                 ifc32.ifc_len = i;
402         }
403         if (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32)))
404                 return -EFAULT;
405
406         return 0;
407 }
408
409 static int ethtool_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
410 {
411         struct ifreq __user *ifr;
412         struct ifreq32 __user *ifr32;
413         u32 data;
414         void __user *datap;
415         
416         ifr = compat_alloc_user_space(sizeof(*ifr));
417         ifr32 = compat_ptr(arg);
418
419         if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
420                 return -EFAULT;
421
422         if (get_user(data, &ifr32->ifr_ifru.ifru_data))
423                 return -EFAULT;
424
425         datap = compat_ptr(data);
426         if (put_user(datap, &ifr->ifr_ifru.ifru_data))
427                 return -EFAULT;
428
429         return sys_ioctl(fd, cmd, (unsigned long) ifr);
430 }
431
432 static int bond_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
433 {
434         struct ifreq kifr;
435         struct ifreq __user *uifr;
436         struct ifreq32 __user *ifr32 = compat_ptr(arg);
437         mm_segment_t old_fs;
438         int err;
439         u32 data;
440         void __user *datap;
441
442         switch (cmd) {
443         case SIOCBONDENSLAVE:
444         case SIOCBONDRELEASE:
445         case SIOCBONDSETHWADDR:
446         case SIOCBONDCHANGEACTIVE:
447                 if (copy_from_user(&kifr, ifr32, sizeof(struct ifreq32)))
448                         return -EFAULT;
449
450                 old_fs = get_fs();
451                 set_fs (KERNEL_DS);
452                 err = sys_ioctl (fd, cmd, (unsigned long)&kifr);
453                 set_fs (old_fs);
454
455                 return err;
456         case SIOCBONDSLAVEINFOQUERY:
457         case SIOCBONDINFOQUERY:
458                 uifr = compat_alloc_user_space(sizeof(*uifr));
459                 if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
460                         return -EFAULT;
461
462                 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
463                         return -EFAULT;
464
465                 datap = compat_ptr(data);
466                 if (put_user(datap, &uifr->ifr_ifru.ifru_data))
467                         return -EFAULT;
468
469                 return sys_ioctl (fd, cmd, (unsigned long)uifr);
470         default:
471                 return -EINVAL;
472         };
473 }
474
475 static int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
476 {
477         struct ifreq __user *u_ifreq64;
478         struct ifreq32 __user *u_ifreq32 = compat_ptr(arg);
479         char tmp_buf[IFNAMSIZ];
480         void __user *data64;
481         u32 data32;
482
483         if (copy_from_user(&tmp_buf[0], &(u_ifreq32->ifr_ifrn.ifrn_name[0]),
484                            IFNAMSIZ))
485                 return -EFAULT;
486         if (__get_user(data32, &u_ifreq32->ifr_ifru.ifru_data))
487                 return -EFAULT;
488         data64 = compat_ptr(data32);
489
490         u_ifreq64 = compat_alloc_user_space(sizeof(*u_ifreq64));
491
492         /* Don't check these user accesses, just let that get trapped
493          * in the ioctl handler instead.
494          */
495         if (copy_to_user(&u_ifreq64->ifr_ifrn.ifrn_name[0], &tmp_buf[0],
496                          IFNAMSIZ))
497                 return -EFAULT;
498         if (__put_user(data64, &u_ifreq64->ifr_ifru.ifru_data))
499                 return -EFAULT;
500
501         return sys_ioctl(fd, cmd, (unsigned long) u_ifreq64);
502 }
503
504 static int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg)
505 {
506         struct ifreq ifr;
507         struct ifreq32 __user *uifr32;
508         struct ifmap32 __user *uifmap32;
509         mm_segment_t old_fs;
510         int err;
511         
512         uifr32 = compat_ptr(arg);
513         uifmap32 = &uifr32->ifr_ifru.ifru_map;
514         switch (cmd) {
515         case SIOCSIFMAP:
516                 err = copy_from_user(&ifr, uifr32, sizeof(ifr.ifr_name));
517                 err |= __get_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
518                 err |= __get_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
519                 err |= __get_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
520                 err |= __get_user(ifr.ifr_map.irq, &uifmap32->irq);
521                 err |= __get_user(ifr.ifr_map.dma, &uifmap32->dma);
522                 err |= __get_user(ifr.ifr_map.port, &uifmap32->port);
523                 if (err)
524                         return -EFAULT;
525                 break;
526         default:
527                 if (copy_from_user(&ifr, uifr32, sizeof(*uifr32)))
528                         return -EFAULT;
529                 break;
530         }
531         old_fs = get_fs();
532         set_fs (KERNEL_DS);
533         err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
534         set_fs (old_fs);
535         if (!err) {
536                 switch (cmd) {
537                 /* TUNSETIFF is defined as _IOW, it should be _IORW
538                  * as the data is copied back to user space, but that
539                  * cannot be fixed without breaking all existing apps.
540                  */
541                 case TUNSETIFF:
542                 case SIOCGIFFLAGS:
543                 case SIOCGIFMETRIC:
544                 case SIOCGIFMTU:
545                 case SIOCGIFMEM:
546                 case SIOCGIFHWADDR:
547                 case SIOCGIFINDEX:
548                 case SIOCGIFADDR:
549                 case SIOCGIFBRDADDR:
550                 case SIOCGIFDSTADDR:
551                 case SIOCGIFNETMASK:
552                 case SIOCGIFTXQLEN:
553                         if (copy_to_user(uifr32, &ifr, sizeof(*uifr32)))
554                                 return -EFAULT;
555                         break;
556                 case SIOCGIFMAP:
557                         err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name));
558                         err |= __put_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
559                         err |= __put_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
560                         err |= __put_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
561                         err |= __put_user(ifr.ifr_map.irq, &uifmap32->irq);
562                         err |= __put_user(ifr.ifr_map.dma, &uifmap32->dma);
563                         err |= __put_user(ifr.ifr_map.port, &uifmap32->port);
564                         if (err)
565                                 err = -EFAULT;
566                         break;
567                 }
568         }
569         return err;
570 }
571
572 struct rtentry32 {
573         u32             rt_pad1;
574         struct sockaddr rt_dst;         /* target address               */
575         struct sockaddr rt_gateway;     /* gateway addr (RTF_GATEWAY)   */
576         struct sockaddr rt_genmask;     /* target network mask (IP)     */
577         unsigned short  rt_flags;
578         short           rt_pad2;
579         u32             rt_pad3;
580         unsigned char   rt_tos;
581         unsigned char   rt_class;
582         short           rt_pad4;
583         short           rt_metric;      /* +1 for binary compatibility! */
584         /* char * */ u32 rt_dev;        /* forcing the device at add    */
585         u32             rt_mtu;         /* per route MTU/Window         */
586         u32             rt_window;      /* Window clamping              */
587         unsigned short  rt_irtt;        /* Initial RTT                  */
588
589 };
590
591 struct in6_rtmsg32 {
592         struct in6_addr         rtmsg_dst;
593         struct in6_addr         rtmsg_src;
594         struct in6_addr         rtmsg_gateway;
595         u32                     rtmsg_type;
596         u16                     rtmsg_dst_len;
597         u16                     rtmsg_src_len;
598         u32                     rtmsg_metric;
599         u32                     rtmsg_info;
600         u32                     rtmsg_flags;
601         s32                     rtmsg_ifindex;
602 };
603
604 static int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
605 {
606         int ret;
607         void *r = NULL;
608         struct in6_rtmsg r6;
609         struct rtentry r4;
610         char devname[16];
611         u32 rtdev;
612         mm_segment_t old_fs = get_fs();
613         
614         struct socket *mysock = sockfd_lookup(fd, &ret);
615
616         if (mysock && mysock->sk && mysock->sk->sk_family == AF_INET6) { /* ipv6 */
617                 struct in6_rtmsg32 __user *ur6 = compat_ptr(arg);
618                 ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst),
619                         3 * sizeof(struct in6_addr));
620                 ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type));
621                 ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len));
622                 ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len));
623                 ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric));
624                 ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info));
625                 ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags));
626                 ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex));
627                 
628                 r = (void *) &r6;
629         } else { /* ipv4 */
630                 struct rtentry32 __user *ur4 = compat_ptr(arg);
631                 ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst),
632                                         3 * sizeof(struct sockaddr));
633                 ret |= __get_user (r4.rt_flags, &(ur4->rt_flags));
634                 ret |= __get_user (r4.rt_metric, &(ur4->rt_metric));
635                 ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu));
636                 ret |= __get_user (r4.rt_window, &(ur4->rt_window));
637                 ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt));
638                 ret |= __get_user (rtdev, &(ur4->rt_dev));
639                 if (rtdev) {
640                         ret |= copy_from_user (devname, compat_ptr(rtdev), 15);
641                         r4.rt_dev = devname; devname[15] = 0;
642                 } else
643                         r4.rt_dev = NULL;
644
645                 r = (void *) &r4;
646         }
647
648         if (ret) {
649                 ret = -EFAULT;
650                 goto out;
651         }
652
653         set_fs (KERNEL_DS);
654         ret = sys_ioctl (fd, cmd, (unsigned long) r);
655         set_fs (old_fs);
656
657 out:
658         if (mysock)
659                 sockfd_put(mysock);
660
661         return ret;
662 }
663 #endif
664
665 #ifdef CONFIG_BLOCK
666 struct hd_geometry32 {
667         unsigned char heads;
668         unsigned char sectors;
669         unsigned short cylinders;
670         u32 start;
671 };
672                         
673 static int hdio_getgeo(unsigned int fd, unsigned int cmd, unsigned long arg)
674 {
675         mm_segment_t old_fs = get_fs();
676         struct hd_geometry geo;
677         struct hd_geometry32 __user *ugeo;
678         int err;
679         
680         set_fs (KERNEL_DS);
681         err = sys_ioctl(fd, HDIO_GETGEO, (unsigned long)&geo);
682         set_fs (old_fs);
683         ugeo = compat_ptr(arg);
684         if (!err) {
685                 err = copy_to_user (ugeo, &geo, 4);
686                 err |= __put_user (geo.start, &ugeo->start);
687         }
688         return err ? -EFAULT : 0;
689 }
690
691 static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
692 {
693         mm_segment_t old_fs = get_fs();
694         unsigned long kval;
695         unsigned int __user *uvp;
696         int error;
697
698         set_fs(KERNEL_DS);
699         error = sys_ioctl(fd, cmd, (long)&kval);
700         set_fs(old_fs);
701
702         if(error == 0) {
703                 uvp = compat_ptr(arg);
704                 if(put_user(kval, uvp))
705                         error = -EFAULT;
706         }
707         return error;
708 }
709
710
711 typedef struct sg_io_hdr32 {
712         compat_int_t interface_id;      /* [i] 'S' for SCSI generic (required) */
713         compat_int_t dxfer_direction;   /* [i] data transfer direction  */
714         unsigned char cmd_len;          /* [i] SCSI command length ( <= 16 bytes) */
715         unsigned char mx_sb_len;                /* [i] max length to write to sbp */
716         unsigned short iovec_count;     /* [i] 0 implies no scatter gather */
717         compat_uint_t dxfer_len;                /* [i] byte count of data transfer */
718         compat_uint_t dxferp;           /* [i], [*io] points to data transfer memory
719                                               or scatter gather list */
720         compat_uptr_t cmdp;             /* [i], [*i] points to command to perform */
721         compat_uptr_t sbp;              /* [i], [*o] points to sense_buffer memory */
722         compat_uint_t timeout;          /* [i] MAX_UINT->no timeout (unit: millisec) */
723         compat_uint_t flags;            /* [i] 0 -> default, see SG_FLAG... */
724         compat_int_t pack_id;           /* [i->o] unused internally (normally) */
725         compat_uptr_t usr_ptr;          /* [i->o] unused internally */
726         unsigned char status;           /* [o] scsi status */
727         unsigned char masked_status;    /* [o] shifted, masked scsi status */
728         unsigned char msg_status;               /* [o] messaging level data (optional) */
729         unsigned char sb_len_wr;                /* [o] byte count actually written to sbp */
730         unsigned short host_status;     /* [o] errors from host adapter */
731         unsigned short driver_status;   /* [o] errors from software driver */
732         compat_int_t resid;             /* [o] dxfer_len - actual_transferred */
733         compat_uint_t duration;         /* [o] time taken by cmd (unit: millisec) */
734         compat_uint_t info;             /* [o] auxiliary information */
735 } sg_io_hdr32_t;  /* 64 bytes long (on sparc32) */
736
737 typedef struct sg_iovec32 {
738         compat_uint_t iov_base;
739         compat_uint_t iov_len;
740 } sg_iovec32_t;
741
742 static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count)
743 {
744         sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1);
745         sg_iovec32_t __user *iov32 = dxferp;
746         int i;
747
748         for (i = 0; i < iovec_count; i++) {
749                 u32 base, len;
750
751                 if (get_user(base, &iov32[i].iov_base) ||
752                     get_user(len, &iov32[i].iov_len) ||
753                     put_user(compat_ptr(base), &iov[i].iov_base) ||
754                     put_user(len, &iov[i].iov_len))
755                         return -EFAULT;
756         }
757
758         if (put_user(iov, &sgio->dxferp))
759                 return -EFAULT;
760         return 0;
761 }
762
763 static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
764 {
765         sg_io_hdr_t __user *sgio;
766         sg_io_hdr32_t __user *sgio32;
767         u16 iovec_count;
768         u32 data;
769         void __user *dxferp;
770         int err;
771
772         sgio32 = compat_ptr(arg);
773         if (get_user(iovec_count, &sgio32->iovec_count))
774                 return -EFAULT;
775
776         {
777                 void __user *top = compat_alloc_user_space(0);
778                 void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) +
779                                        (iovec_count * sizeof(sg_iovec_t)));
780                 if (new > top)
781                         return -EINVAL;
782
783                 sgio = new;
784         }
785
786         /* Ok, now construct.  */
787         if (copy_in_user(&sgio->interface_id, &sgio32->interface_id,
788                          (2 * sizeof(int)) +
789                          (2 * sizeof(unsigned char)) +
790                          (1 * sizeof(unsigned short)) +
791                          (1 * sizeof(unsigned int))))
792                 return -EFAULT;
793
794         if (get_user(data, &sgio32->dxferp))
795                 return -EFAULT;
796         dxferp = compat_ptr(data);
797         if (iovec_count) {
798                 if (sg_build_iovec(sgio, dxferp, iovec_count))
799                         return -EFAULT;
800         } else {
801                 if (put_user(dxferp, &sgio->dxferp))
802                         return -EFAULT;
803         }
804
805         {
806                 unsigned char __user *cmdp;
807                 unsigned char __user *sbp;
808
809                 if (get_user(data, &sgio32->cmdp))
810                         return -EFAULT;
811                 cmdp = compat_ptr(data);
812
813                 if (get_user(data, &sgio32->sbp))
814                         return -EFAULT;
815                 sbp = compat_ptr(data);
816
817                 if (put_user(cmdp, &sgio->cmdp) ||
818                     put_user(sbp, &sgio->sbp))
819                         return -EFAULT;
820         }
821
822         if (copy_in_user(&sgio->timeout, &sgio32->timeout,
823                          3 * sizeof(int)))
824                 return -EFAULT;
825
826         if (get_user(data, &sgio32->usr_ptr))
827                 return -EFAULT;
828         if (put_user(compat_ptr(data), &sgio->usr_ptr))
829                 return -EFAULT;
830
831         if (copy_in_user(&sgio->status, &sgio32->status,
832                          (4 * sizeof(unsigned char)) +
833                          (2 * sizeof(unsigned (short))) +
834                          (3 * sizeof(int))))
835                 return -EFAULT;
836
837         err = sys_ioctl(fd, cmd, (unsigned long) sgio);
838
839         if (err >= 0) {
840                 void __user *datap;
841
842                 if (copy_in_user(&sgio32->pack_id, &sgio->pack_id,
843                                  sizeof(int)) ||
844                     get_user(datap, &sgio->usr_ptr) ||
845                     put_user((u32)(unsigned long)datap,
846                              &sgio32->usr_ptr) ||
847                     copy_in_user(&sgio32->status, &sgio->status,
848                                  (4 * sizeof(unsigned char)) +
849                                  (2 * sizeof(unsigned short)) +
850                                  (3 * sizeof(int))))
851                         err = -EFAULT;
852         }
853
854         return err;
855 }
856
857 struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
858         char req_state;
859         char orphan;
860         char sg_io_owned;
861         char problem;
862         int pack_id;
863         compat_uptr_t usr_ptr;
864         unsigned int duration;
865         int unused;
866 };
867
868 static int sg_grt_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
869 {
870         int err, i;
871         sg_req_info_t __user *r;
872         struct compat_sg_req_info __user *o = (void __user *)arg;
873         r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE);
874         err = sys_ioctl(fd,cmd,(unsigned long)r);
875         if (err < 0)
876                 return err;
877         for (i = 0; i < SG_MAX_QUEUE; i++) {
878                 void __user *ptr;
879                 int d;
880
881                 if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) ||
882                     get_user(ptr, &r[i].usr_ptr) ||
883                     get_user(d, &r[i].duration) ||
884                     put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) ||
885                     put_user(d, &o[i].duration))
886                         return -EFAULT;
887         }
888         return err;
889 }
890 #endif /* CONFIG_BLOCK */
891
892 struct sock_fprog32 {
893         unsigned short  len;
894         compat_caddr_t  filter;
895 };
896
897 #define PPPIOCSPASS32   _IOW('t', 71, struct sock_fprog32)
898 #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
899
900 static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
901 {
902         struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg);
903         struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
904         void __user *fptr64;
905         u32 fptr32;
906         u16 flen;
907
908         if (get_user(flen, &u_fprog32->len) ||
909             get_user(fptr32, &u_fprog32->filter))
910                 return -EFAULT;
911
912         fptr64 = compat_ptr(fptr32);
913
914         if (put_user(flen, &u_fprog64->len) ||
915             put_user(fptr64, &u_fprog64->filter))
916                 return -EFAULT;
917
918         if (cmd == PPPIOCSPASS32)
919                 cmd = PPPIOCSPASS;
920         else
921                 cmd = PPPIOCSACTIVE;
922
923         return sys_ioctl(fd, cmd, (unsigned long) u_fprog64);
924 }
925
926 struct ppp_option_data32 {
927         compat_caddr_t  ptr;
928         u32                     length;
929         compat_int_t            transmit;
930 };
931 #define PPPIOCSCOMPRESS32       _IOW('t', 77, struct ppp_option_data32)
932
933 struct ppp_idle32 {
934         compat_time_t xmit_idle;
935         compat_time_t recv_idle;
936 };
937 #define PPPIOCGIDLE32           _IOR('t', 63, struct ppp_idle32)
938
939 static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg)
940 {
941         struct ppp_idle __user *idle;
942         struct ppp_idle32 __user *idle32;
943         __kernel_time_t xmit, recv;
944         int err;
945
946         idle = compat_alloc_user_space(sizeof(*idle));
947         idle32 = compat_ptr(arg);
948
949         err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle);
950
951         if (!err) {
952                 if (get_user(xmit, &idle->xmit_idle) ||
953                     get_user(recv, &idle->recv_idle) ||
954                     put_user(xmit, &idle32->xmit_idle) ||
955                     put_user(recv, &idle32->recv_idle))
956                         err = -EFAULT;
957         }
958         return err;
959 }
960
961 static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg)
962 {
963         struct ppp_option_data __user *odata;
964         struct ppp_option_data32 __user *odata32;
965         __u32 data;
966         void __user *datap;
967
968         odata = compat_alloc_user_space(sizeof(*odata));
969         odata32 = compat_ptr(arg);
970
971         if (get_user(data, &odata32->ptr))
972                 return -EFAULT;
973
974         datap = compat_ptr(data);
975         if (put_user(datap, &odata->ptr))
976                 return -EFAULT;
977
978         if (copy_in_user(&odata->length, &odata32->length,
979                          sizeof(__u32) + sizeof(int)))
980                 return -EFAULT;
981
982         return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata);
983 }
984
985 static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
986 {
987         int err;
988
989         switch (cmd) {
990         case PPPIOCGIDLE32:
991                 err = ppp_gidle(fd, cmd, arg);
992                 break;
993
994         case PPPIOCSCOMPRESS32:
995                 err = ppp_scompress(fd, cmd, arg);
996                 break;
997
998         default:
999                 do {
1000                         static int count;
1001                         if (++count <= 20)
1002                                 printk("ppp_ioctl: Unknown cmd fd(%d) "
1003                                        "cmd(%08x) arg(%08x)\n",
1004                                        (int)fd, (unsigned int)cmd, (unsigned int)arg);
1005                 } while(0);
1006                 err = -EINVAL;
1007                 break;
1008         };
1009
1010         return err;
1011 }
1012
1013
1014 #ifdef CONFIG_BLOCK
1015 struct mtget32 {
1016         compat_long_t   mt_type;
1017         compat_long_t   mt_resid;
1018         compat_long_t   mt_dsreg;
1019         compat_long_t   mt_gstat;
1020         compat_long_t   mt_erreg;
1021         compat_daddr_t  mt_fileno;
1022         compat_daddr_t  mt_blkno;
1023 };
1024 #define MTIOCGET32      _IOR('m', 2, struct mtget32)
1025
1026 struct mtpos32 {
1027         compat_long_t   mt_blkno;
1028 };
1029 #define MTIOCPOS32      _IOR('m', 3, struct mtpos32)
1030
1031 static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1032 {
1033         mm_segment_t old_fs = get_fs();
1034         struct mtget get;
1035         struct mtget32 __user *umget32;
1036         struct mtpos pos;
1037         struct mtpos32 __user *upos32;
1038         unsigned long kcmd;
1039         void *karg;
1040         int err = 0;
1041
1042         switch(cmd) {
1043         case MTIOCPOS32:
1044                 kcmd = MTIOCPOS;
1045                 karg = &pos;
1046                 break;
1047         case MTIOCGET32:
1048                 kcmd = MTIOCGET;
1049                 karg = &get;
1050                 break;
1051         default:
1052                 do {
1053                         static int count;
1054                         if (++count <= 20)
1055                                 printk("mt_ioctl: Unknown cmd fd(%d) "
1056                                        "cmd(%08x) arg(%08x)\n",
1057                                        (int)fd, (unsigned int)cmd, (unsigned int)arg);
1058                 } while(0);
1059                 return -EINVAL;
1060         }
1061         set_fs (KERNEL_DS);
1062         err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1063         set_fs (old_fs);
1064         if (err)
1065                 return err;
1066         switch (cmd) {
1067         case MTIOCPOS32:
1068                 upos32 = compat_ptr(arg);
1069                 err = __put_user(pos.mt_blkno, &upos32->mt_blkno);
1070                 break;
1071         case MTIOCGET32:
1072                 umget32 = compat_ptr(arg);
1073                 err = __put_user(get.mt_type, &umget32->mt_type);
1074                 err |= __put_user(get.mt_resid, &umget32->mt_resid);
1075                 err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg);
1076                 err |= __put_user(get.mt_gstat, &umget32->mt_gstat);
1077                 err |= __put_user(get.mt_erreg, &umget32->mt_erreg);
1078                 err |= __put_user(get.mt_fileno, &umget32->mt_fileno);
1079                 err |= __put_user(get.mt_blkno, &umget32->mt_blkno);
1080                 break;
1081         }
1082         return err ? -EFAULT: 0;
1083 }
1084
1085 struct cdrom_read_audio32 {
1086         union cdrom_addr        addr;
1087         u8                      addr_format;
1088         compat_int_t            nframes;
1089         compat_caddr_t          buf;
1090 };
1091
1092 struct cdrom_generic_command32 {
1093         unsigned char   cmd[CDROM_PACKET_SIZE];
1094         compat_caddr_t  buffer;
1095         compat_uint_t   buflen;
1096         compat_int_t    stat;
1097         compat_caddr_t  sense;
1098         unsigned char   data_direction;
1099         compat_int_t    quiet;
1100         compat_int_t    timeout;
1101         compat_caddr_t  reserved[1];
1102 };
1103   
1104 static int cdrom_do_read_audio(unsigned int fd, unsigned int cmd, unsigned long arg)
1105 {
1106         struct cdrom_read_audio __user *cdread_audio;
1107         struct cdrom_read_audio32 __user *cdread_audio32;
1108         __u32 data;
1109         void __user *datap;
1110
1111         cdread_audio = compat_alloc_user_space(sizeof(*cdread_audio));
1112         cdread_audio32 = compat_ptr(arg);
1113
1114         if (copy_in_user(&cdread_audio->addr,
1115                          &cdread_audio32->addr,
1116                          (sizeof(*cdread_audio32) -
1117                           sizeof(compat_caddr_t))))
1118                 return -EFAULT;
1119
1120         if (get_user(data, &cdread_audio32->buf))
1121                 return -EFAULT;
1122         datap = compat_ptr(data);
1123         if (put_user(datap, &cdread_audio->buf))
1124                 return -EFAULT;
1125
1126         return sys_ioctl(fd, cmd, (unsigned long) cdread_audio);
1127 }
1128
1129 static int cdrom_do_generic_command(unsigned int fd, unsigned int cmd, unsigned long arg)
1130 {
1131         struct cdrom_generic_command __user *cgc;
1132         struct cdrom_generic_command32 __user *cgc32;
1133         u32 data;
1134         unsigned char dir;
1135         int itmp;
1136
1137         cgc = compat_alloc_user_space(sizeof(*cgc));
1138         cgc32 = compat_ptr(arg);
1139
1140         if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) ||
1141             get_user(data, &cgc32->buffer) ||
1142             put_user(compat_ptr(data), &cgc->buffer) ||
1143             copy_in_user(&cgc->buflen, &cgc32->buflen,
1144                          (sizeof(unsigned int) + sizeof(int))) ||
1145             get_user(data, &cgc32->sense) ||
1146             put_user(compat_ptr(data), &cgc->sense) ||
1147             get_user(dir, &cgc32->data_direction) ||
1148             put_user(dir, &cgc->data_direction) ||
1149             get_user(itmp, &cgc32->quiet) ||
1150             put_user(itmp, &cgc->quiet) ||
1151             get_user(itmp, &cgc32->timeout) ||
1152             put_user(itmp, &cgc->timeout) ||
1153             get_user(data, &cgc32->reserved[0]) ||
1154             put_user(compat_ptr(data), &cgc->reserved[0]))
1155                 return -EFAULT;
1156
1157         return sys_ioctl(fd, cmd, (unsigned long) cgc);
1158 }
1159
1160 static int cdrom_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1161 {
1162         int err;
1163
1164         switch(cmd) {
1165         case CDROMREADAUDIO:
1166                 err = cdrom_do_read_audio(fd, cmd, arg);
1167                 break;
1168
1169         case CDROM_SEND_PACKET:
1170                 err = cdrom_do_generic_command(fd, cmd, arg);
1171                 break;
1172
1173         default:
1174                 do {
1175                         static int count;
1176                         if (++count <= 20)
1177                                 printk("cdrom_ioctl: Unknown cmd fd(%d) "
1178                                        "cmd(%08x) arg(%08x)\n",
1179                                        (int)fd, (unsigned int)cmd, (unsigned int)arg);
1180                 } while(0);
1181                 err = -EINVAL;
1182                 break;
1183         };
1184
1185         return err;
1186 }
1187 #endif /* CONFIG_BLOCK */
1188
1189 #ifdef CONFIG_VT
1190
1191 static int vt_check(struct file *file)
1192 {
1193         struct tty_struct *tty;
1194         struct inode *inode = file->f_path.dentry->d_inode;
1195         
1196         if (file->f_op->ioctl != tty_ioctl)
1197                 return -EINVAL;
1198                         
1199         tty = (struct tty_struct *)file->private_data;
1200         if (tty_paranoia_check(tty, inode, "tty_ioctl"))
1201                 return -EINVAL;
1202                                                         
1203         if (tty->driver->ioctl != vt_ioctl)
1204                 return -EINVAL;
1205         
1206         /*
1207          * To have permissions to do most of the vt ioctls, we either have
1208          * to be the owner of the tty, or super-user.
1209          */
1210         if (current->signal->tty == tty || capable(CAP_SYS_ADMIN))
1211                 return 1;
1212         return 0;                                                    
1213 }
1214
1215 struct consolefontdesc32 {
1216         unsigned short charcount;       /* characters in font (256 or 512) */
1217         unsigned short charheight;      /* scan lines per character (1-32) */
1218         compat_caddr_t chardata;        /* font data in expanded form */
1219 };
1220
1221 static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1222 {
1223         struct consolefontdesc32 __user *user_cfd = compat_ptr(arg);
1224         struct console_font_op op;
1225         compat_caddr_t data;
1226         int i, perm;
1227
1228         perm = vt_check(file);
1229         if (perm < 0) return perm;
1230         
1231         switch (cmd) {
1232         case PIO_FONTX:
1233                 if (!perm)
1234                         return -EPERM;
1235                 op.op = KD_FONT_OP_SET;
1236                 op.flags = 0;
1237                 op.width = 8;
1238                 if (get_user(op.height, &user_cfd->charheight) ||
1239                     get_user(op.charcount, &user_cfd->charcount) ||
1240                     get_user(data, &user_cfd->chardata))
1241                         return -EFAULT;
1242                 op.data = compat_ptr(data);
1243                 return con_font_op(vc_cons[fg_console].d, &op);
1244         case GIO_FONTX:
1245                 op.op = KD_FONT_OP_GET;
1246                 op.flags = 0;
1247                 op.width = 8;
1248                 if (get_user(op.height, &user_cfd->charheight) ||
1249                     get_user(op.charcount, &user_cfd->charcount) ||
1250                     get_user(data, &user_cfd->chardata))
1251                         return -EFAULT;
1252                 if (!data)
1253                         return 0;
1254                 op.data = compat_ptr(data);
1255                 i = con_font_op(vc_cons[fg_console].d, &op);
1256                 if (i)
1257                         return i;
1258                 if (put_user(op.height, &user_cfd->charheight) ||
1259                     put_user(op.charcount, &user_cfd->charcount) ||
1260                     put_user((compat_caddr_t)(unsigned long)op.data,
1261                                 &user_cfd->chardata))
1262                         return -EFAULT;
1263                 return 0;
1264         }
1265         return -EINVAL;
1266 }
1267
1268 struct console_font_op32 {
1269         compat_uint_t op;        /* operation code KD_FONT_OP_* */
1270         compat_uint_t flags;     /* KD_FONT_FLAG_* */
1271         compat_uint_t width, height;     /* font size */
1272         compat_uint_t charcount;
1273         compat_caddr_t data;    /* font data with height fixed to 32 */
1274 };
1275                                         
1276 static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1277 {
1278         struct console_font_op op;
1279         struct console_font_op32 __user *fontop = compat_ptr(arg);
1280         int perm = vt_check(file), i;
1281         struct vc_data *vc;
1282         
1283         if (perm < 0) return perm;
1284         
1285         if (copy_from_user(&op, fontop, sizeof(struct console_font_op32)))
1286                 return -EFAULT;
1287         if (!perm && op.op != KD_FONT_OP_GET)
1288                 return -EPERM;
1289         op.data = compat_ptr(((struct console_font_op32 *)&op)->data);
1290         op.flags |= KD_FONT_FLAG_OLD;
1291         vc = ((struct tty_struct *)file->private_data)->driver_data;
1292         i = con_font_op(vc, &op);
1293         if (i)
1294                 return i;
1295         ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
1296         if (copy_to_user(fontop, &op, sizeof(struct console_font_op32)))
1297                 return -EFAULT;
1298         return 0;
1299 }
1300
1301 struct unimapdesc32 {
1302         unsigned short entry_ct;
1303         compat_caddr_t entries;
1304 };
1305
1306 static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1307 {
1308         struct unimapdesc32 tmp;
1309         struct unimapdesc32 __user *user_ud = compat_ptr(arg);
1310         int perm = vt_check(file);
1311         
1312         if (perm < 0) return perm;
1313         if (copy_from_user(&tmp, user_ud, sizeof tmp))
1314                 return -EFAULT;
1315         switch (cmd) {
1316         case PIO_UNIMAP:
1317                 if (!perm) return -EPERM;
1318                 return con_set_unimap(vc_cons[fg_console].d, tmp.entry_ct, compat_ptr(tmp.entries));
1319         case GIO_UNIMAP:
1320                 return con_get_unimap(vc_cons[fg_console].d, tmp.entry_ct, &(user_ud->entry_ct), compat_ptr(tmp.entries));
1321         }
1322         return 0;
1323 }
1324
1325 #endif /* CONFIG_VT */
1326
1327 static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg)
1328 {
1329         mm_segment_t old_fs = get_fs();
1330         __kernel_uid_t kuid;
1331         int err;
1332
1333         cmd = SMB_IOC_GETMOUNTUID;
1334
1335         set_fs(KERNEL_DS);
1336         err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
1337         set_fs(old_fs);
1338
1339         if (err >= 0)
1340                 err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg));
1341
1342         return err;
1343 }
1344
1345 struct atmif_sioc32 {
1346         compat_int_t    number;
1347         compat_int_t    length;
1348         compat_caddr_t  arg;
1349 };
1350
1351 struct atm_iobuf32 {
1352         compat_int_t    length;
1353         compat_caddr_t  buffer;
1354 };
1355
1356 #define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32)
1357 #define ATM_GETNAMES32    _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32)
1358 #define ATM_GETTYPE32     _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32)
1359 #define ATM_GETESI32      _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32)
1360 #define ATM_GETADDR32     _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32)
1361 #define ATM_RSTADDR32     _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32)
1362 #define ATM_ADDADDR32     _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32)
1363 #define ATM_DELADDR32     _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32)
1364 #define ATM_GETCIRANGE32  _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32)
1365 #define ATM_SETCIRANGE32  _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32)
1366 #define ATM_SETESI32      _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32)
1367 #define ATM_SETESIF32     _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32)
1368 #define ATM_GETSTAT32     _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32)
1369 #define ATM_GETSTATZ32    _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32)
1370 #define ATM_GETLOOP32     _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32)
1371 #define ATM_SETLOOP32     _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32)
1372 #define ATM_QUERYLOOP32   _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32)
1373
1374 static struct {
1375         unsigned int cmd32;
1376         unsigned int cmd;
1377 } atm_ioctl_map[] = {
1378         { ATM_GETLINKRATE32, ATM_GETLINKRATE },
1379         { ATM_GETNAMES32,    ATM_GETNAMES },
1380         { ATM_GETTYPE32,     ATM_GETTYPE },
1381         { ATM_GETESI32,      ATM_GETESI },
1382         { ATM_GETADDR32,     ATM_GETADDR },
1383         { ATM_RSTADDR32,     ATM_RSTADDR },
1384         { ATM_ADDADDR32,     ATM_ADDADDR },
1385         { ATM_DELADDR32,     ATM_DELADDR },
1386         { ATM_GETCIRANGE32,  ATM_GETCIRANGE },
1387         { ATM_SETCIRANGE32,  ATM_SETCIRANGE },
1388         { ATM_SETESI32,      ATM_SETESI },
1389         { ATM_SETESIF32,     ATM_SETESIF },
1390         { ATM_GETSTAT32,     ATM_GETSTAT },
1391         { ATM_GETSTATZ32,    ATM_GETSTATZ },
1392         { ATM_GETLOOP32,     ATM_GETLOOP },
1393         { ATM_SETLOOP32,     ATM_SETLOOP },
1394         { ATM_QUERYLOOP32,   ATM_QUERYLOOP }
1395 };
1396
1397 #define NR_ATM_IOCTL ARRAY_SIZE(atm_ioctl_map)
1398
1399 static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg)
1400 {
1401         struct atm_iobuf   __user *iobuf;
1402         struct atm_iobuf32 __user *iobuf32;
1403         u32 data;
1404         void __user *datap;
1405         int len, err;
1406
1407         iobuf = compat_alloc_user_space(sizeof(*iobuf));
1408         iobuf32 = compat_ptr(arg);
1409
1410         if (get_user(len, &iobuf32->length) ||
1411             get_user(data, &iobuf32->buffer))
1412                 return -EFAULT;
1413         datap = compat_ptr(data);
1414         if (put_user(len, &iobuf->length) ||
1415             put_user(datap, &iobuf->buffer))
1416                 return -EFAULT;
1417
1418         err = sys_ioctl(fd, cmd, (unsigned long)iobuf);
1419
1420         if (!err) {
1421                 if (copy_in_user(&iobuf32->length, &iobuf->length,
1422                                  sizeof(int)))
1423                         err = -EFAULT;
1424         }
1425
1426         return err;
1427 }
1428
1429 static int do_atmif_sioc(unsigned int fd, unsigned int cmd, unsigned long arg)
1430 {
1431         struct atmif_sioc   __user *sioc;
1432         struct atmif_sioc32 __user *sioc32;
1433         u32 data;
1434         void __user *datap;
1435         int err;
1436         
1437         sioc = compat_alloc_user_space(sizeof(*sioc));
1438         sioc32 = compat_ptr(arg);
1439
1440         if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) ||
1441             get_user(data, &sioc32->arg))
1442                 return -EFAULT;
1443         datap = compat_ptr(data);
1444         if (put_user(datap, &sioc->arg))
1445                 return -EFAULT;
1446
1447         err = sys_ioctl(fd, cmd, (unsigned long) sioc);
1448
1449         if (!err) {
1450                 if (copy_in_user(&sioc32->length, &sioc->length,
1451                                  sizeof(int)))
1452                         err = -EFAULT;
1453         }
1454         return err;
1455 }
1456
1457 static int do_atm_ioctl(unsigned int fd, unsigned int cmd32, unsigned long arg)
1458 {
1459         int i;
1460         unsigned int cmd = 0;
1461         
1462         switch (cmd32) {
1463         case SONET_GETSTAT:
1464         case SONET_GETSTATZ:
1465         case SONET_GETDIAG:
1466         case SONET_SETDIAG:
1467         case SONET_CLRDIAG:
1468         case SONET_SETFRAMING:
1469         case SONET_GETFRAMING:
1470         case SONET_GETFRSENSE:
1471                 return do_atmif_sioc(fd, cmd32, arg);
1472         }
1473
1474         for (i = 0; i < NR_ATM_IOCTL; i++) {
1475                 if (cmd32 == atm_ioctl_map[i].cmd32) {
1476                         cmd = atm_ioctl_map[i].cmd;
1477                         break;
1478                 }
1479         }
1480         if (i == NR_ATM_IOCTL)
1481                 return -EINVAL;
1482         
1483         switch (cmd) {
1484         case ATM_GETNAMES:
1485                 return do_atm_iobuf(fd, cmd, arg);
1486             
1487         case ATM_GETLINKRATE:
1488         case ATM_GETTYPE:
1489         case ATM_GETESI:
1490         case ATM_GETADDR:
1491         case ATM_RSTADDR:
1492         case ATM_ADDADDR:
1493         case ATM_DELADDR:
1494         case ATM_GETCIRANGE:
1495         case ATM_SETCIRANGE:
1496         case ATM_SETESI:
1497         case ATM_SETESIF:
1498         case ATM_GETSTAT:
1499         case ATM_GETSTATZ:
1500         case ATM_GETLOOP:
1501         case ATM_SETLOOP:
1502         case ATM_QUERYLOOP:
1503                 return do_atmif_sioc(fd, cmd, arg);
1504         }
1505
1506         return -EINVAL;
1507 }
1508
1509 static __attribute_used__ int 
1510 ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
1511 {
1512         return -EINVAL;
1513 }
1514
1515 #ifdef CONFIG_BLOCK
1516 static int broken_blkgetsize(unsigned int fd, unsigned int cmd, unsigned long arg)
1517 {
1518         /* The mkswap binary hard codes it to Intel value :-((( */
1519         return w_long(fd, BLKGETSIZE, arg);
1520 }
1521
1522 struct blkpg_ioctl_arg32 {
1523         compat_int_t op;
1524         compat_int_t flags;
1525         compat_int_t datalen;
1526         compat_caddr_t data;
1527 };
1528
1529 static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1530 {
1531         struct blkpg_ioctl_arg32 __user *ua32 = compat_ptr(arg);
1532         struct blkpg_ioctl_arg __user *a = compat_alloc_user_space(sizeof(*a));
1533         compat_caddr_t udata;
1534         compat_int_t n;
1535         int err;
1536         
1537         err = get_user(n, &ua32->op);
1538         err |= put_user(n, &a->op);
1539         err |= get_user(n, &ua32->flags);
1540         err |= put_user(n, &a->flags);
1541         err |= get_user(n, &ua32->datalen);
1542         err |= put_user(n, &a->datalen);
1543         err |= get_user(udata, &ua32->data);
1544         err |= put_user(compat_ptr(udata), &a->data);
1545         if (err)
1546                 return err;
1547
1548         return sys_ioctl(fd, cmd, (unsigned long)a);
1549 }
1550 #endif
1551
1552 static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
1553 {
1554         return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
1555 }
1556
1557 #ifdef CONFIG_BLOCK
1558 /* Fix sizeof(sizeof()) breakage */
1559 #define BLKBSZGET_32   _IOR(0x12,112,int)
1560 #define BLKBSZSET_32   _IOW(0x12,113,int)
1561 #define BLKGETSIZE64_32        _IOR(0x12,114,int)
1562
1563 static int do_blkbszget(unsigned int fd, unsigned int cmd, unsigned long arg)
1564 {
1565        return sys_ioctl(fd, BLKBSZGET, (unsigned long)compat_ptr(arg));
1566 }
1567
1568 static int do_blkbszset(unsigned int fd, unsigned int cmd, unsigned long arg)
1569 {
1570        return sys_ioctl(fd, BLKBSZSET, (unsigned long)compat_ptr(arg));
1571 }
1572
1573 static int do_blkgetsize64(unsigned int fd, unsigned int cmd,
1574                           unsigned long arg)
1575 {
1576        return sys_ioctl(fd, BLKGETSIZE64, (unsigned long)compat_ptr(arg));
1577 }
1578 #endif
1579
1580 /* Bluetooth ioctls */
1581 #define HCIUARTSETPROTO _IOW('U', 200, int)
1582 #define HCIUARTGETPROTO _IOR('U', 201, int)
1583
1584 #define BNEPCONNADD     _IOW('B', 200, int)
1585 #define BNEPCONNDEL     _IOW('B', 201, int)
1586 #define BNEPGETCONNLIST _IOR('B', 210, int)
1587 #define BNEPGETCONNINFO _IOR('B', 211, int)
1588
1589 #define CMTPCONNADD     _IOW('C', 200, int)
1590 #define CMTPCONNDEL     _IOW('C', 201, int)
1591 #define CMTPGETCONNLIST _IOR('C', 210, int)
1592 #define CMTPGETCONNINFO _IOR('C', 211, int)
1593
1594 #define HIDPCONNADD     _IOW('H', 200, int)
1595 #define HIDPCONNDEL     _IOW('H', 201, int)
1596 #define HIDPGETCONNLIST _IOR('H', 210, int)
1597 #define HIDPGETCONNINFO _IOR('H', 211, int)
1598
1599 #ifdef CONFIG_BLOCK
1600 struct floppy_struct32 {
1601         compat_uint_t   size;
1602         compat_uint_t   sect;
1603         compat_uint_t   head;
1604         compat_uint_t   track;
1605         compat_uint_t   stretch;
1606         unsigned char   gap;
1607         unsigned char   rate;
1608         unsigned char   spec1;
1609         unsigned char   fmt_gap;
1610         const compat_caddr_t name;
1611 };
1612
1613 struct floppy_drive_params32 {
1614         char            cmos;
1615         compat_ulong_t  max_dtr;
1616         compat_ulong_t  hlt;
1617         compat_ulong_t  hut;
1618         compat_ulong_t  srt;
1619         compat_ulong_t  spinup;
1620         compat_ulong_t  spindown;
1621         unsigned char   spindown_offset;
1622         unsigned char   select_delay;
1623         unsigned char   rps;
1624         unsigned char   tracks;
1625         compat_ulong_t  timeout;
1626         unsigned char   interleave_sect;
1627         struct floppy_max_errors max_errors;
1628         char            flags;
1629         char            read_track;
1630         short           autodetect[8];
1631         compat_int_t    checkfreq;
1632         compat_int_t    native_format;
1633 };
1634
1635 struct floppy_drive_struct32 {
1636         signed char     flags;
1637         compat_ulong_t  spinup_date;
1638         compat_ulong_t  select_date;
1639         compat_ulong_t  first_read_date;
1640         short           probed_format;
1641         short           track;
1642         short           maxblock;
1643         short           maxtrack;
1644         compat_int_t    generation;
1645         compat_int_t    keep_data;
1646         compat_int_t    fd_ref;
1647         compat_int_t    fd_device;
1648         compat_int_t    last_checked;
1649         compat_caddr_t dmabuf;
1650         compat_int_t    bufblocks;
1651 };
1652
1653 struct floppy_fdc_state32 {
1654         compat_int_t    spec1;
1655         compat_int_t    spec2;
1656         compat_int_t    dtr;
1657         unsigned char   version;
1658         unsigned char   dor;
1659         compat_ulong_t  address;
1660         unsigned int    rawcmd:2;
1661         unsigned int    reset:1;
1662         unsigned int    need_configure:1;
1663         unsigned int    perp_mode:2;
1664         unsigned int    has_fifo:1;
1665         unsigned int    driver_version;
1666         unsigned char   track[4];
1667 };
1668
1669 struct floppy_write_errors32 {
1670         unsigned int    write_errors;
1671         compat_ulong_t  first_error_sector;
1672         compat_int_t    first_error_generation;
1673         compat_ulong_t  last_error_sector;
1674         compat_int_t    last_error_generation;
1675         compat_uint_t   badness;
1676 };
1677
1678 #define FDSETPRM32 _IOW(2, 0x42, struct floppy_struct32)
1679 #define FDDEFPRM32 _IOW(2, 0x43, struct floppy_struct32)
1680 #define FDGETPRM32 _IOR(2, 0x04, struct floppy_struct32)
1681 #define FDSETDRVPRM32 _IOW(2, 0x90, struct floppy_drive_params32)
1682 #define FDGETDRVPRM32 _IOR(2, 0x11, struct floppy_drive_params32)
1683 #define FDGETDRVSTAT32 _IOR(2, 0x12, struct floppy_drive_struct32)
1684 #define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct floppy_drive_struct32)
1685 #define FDGETFDCSTAT32 _IOR(2, 0x15, struct floppy_fdc_state32)
1686 #define FDWERRORGET32  _IOR(2, 0x17, struct floppy_write_errors32)
1687
1688 static struct {
1689         unsigned int    cmd32;
1690         unsigned int    cmd;
1691 } fd_ioctl_trans_table[] = {
1692         { FDSETPRM32, FDSETPRM },
1693         { FDDEFPRM32, FDDEFPRM },
1694         { FDGETPRM32, FDGETPRM },
1695         { FDSETDRVPRM32, FDSETDRVPRM },
1696         { FDGETDRVPRM32, FDGETDRVPRM },
1697         { FDGETDRVSTAT32, FDGETDRVSTAT },
1698         { FDPOLLDRVSTAT32, FDPOLLDRVSTAT },
1699         { FDGETFDCSTAT32, FDGETFDCSTAT },
1700         { FDWERRORGET32, FDWERRORGET }
1701 };
1702
1703 #define NR_FD_IOCTL_TRANS ARRAY_SIZE(fd_ioctl_trans_table)
1704
1705 static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1706 {
1707         mm_segment_t old_fs = get_fs();
1708         void *karg = NULL;
1709         unsigned int kcmd = 0;
1710         int i, err;
1711
1712         for (i = 0; i < NR_FD_IOCTL_TRANS; i++)
1713                 if (cmd == fd_ioctl_trans_table[i].cmd32) {
1714                         kcmd = fd_ioctl_trans_table[i].cmd;
1715                         break;
1716                 }
1717         if (!kcmd)
1718                 return -EINVAL;
1719
1720         switch (cmd) {
1721                 case FDSETPRM32:
1722                 case FDDEFPRM32:
1723                 case FDGETPRM32:
1724                 {
1725                         compat_uptr_t name;
1726                         struct floppy_struct32 __user *uf;
1727                         struct floppy_struct *f;
1728
1729                         uf = compat_ptr(arg);
1730                         f = karg = kmalloc(sizeof(struct floppy_struct), GFP_KERNEL);
1731                         if (!karg)
1732                                 return -ENOMEM;
1733                         if (cmd == FDGETPRM32)
1734                                 break;
1735                         err = __get_user(f->size, &uf->size);
1736                         err |= __get_user(f->sect, &uf->sect);
1737                         err |= __get_user(f->head, &uf->head);
1738                         err |= __get_user(f->track, &uf->track);
1739                         err |= __get_user(f->stretch, &uf->stretch);
1740                         err |= __get_user(f->gap, &uf->gap);
1741                         err |= __get_user(f->rate, &uf->rate);
1742                         err |= __get_user(f->spec1, &uf->spec1);
1743                         err |= __get_user(f->fmt_gap, &uf->fmt_gap);
1744                         err |= __get_user(name, &uf->name);
1745                         f->name = compat_ptr(name);
1746                         if (err) {
1747                                 err = -EFAULT;
1748                                 goto out;
1749                         }
1750                         break;
1751                 }
1752                 case FDSETDRVPRM32:
1753                 case FDGETDRVPRM32:
1754                 {
1755                         struct floppy_drive_params32 __user *uf;
1756                         struct floppy_drive_params *f;
1757
1758                         uf = compat_ptr(arg);
1759                         f = karg = kmalloc(sizeof(struct floppy_drive_params), GFP_KERNEL);
1760                         if (!karg)
1761                                 return -ENOMEM;
1762                         if (cmd == FDGETDRVPRM32)
1763                                 break;
1764                         err = __get_user(f->cmos, &uf->cmos);
1765                         err |= __get_user(f->max_dtr, &uf->max_dtr);
1766                         err |= __get_user(f->hlt, &uf->hlt);
1767                         err |= __get_user(f->hut, &uf->hut);
1768                         err |= __get_user(f->srt, &uf->srt);
1769                         err |= __get_user(f->spinup, &uf->spinup);
1770                         err |= __get_user(f->spindown, &uf->spindown);
1771                         err |= __get_user(f->spindown_offset, &uf->spindown_offset);
1772                         err |= __get_user(f->select_delay, &uf->select_delay);
1773                         err |= __get_user(f->rps, &uf->rps);
1774                         err |= __get_user(f->tracks, &uf->tracks);
1775                         err |= __get_user(f->timeout, &uf->timeout);
1776                         err |= __get_user(f->interleave_sect, &uf->interleave_sect);
1777                         err |= __copy_from_user(&f->max_errors, &uf->max_errors, sizeof(f->max_errors));
1778                         err |= __get_user(f->flags, &uf->flags);
1779                         err |= __get_user(f->read_track, &uf->read_track);
1780                         err |= __copy_from_user(f->autodetect, uf->autodetect, sizeof(f->autodetect));
1781                         err |= __get_user(f->checkfreq, &uf->checkfreq);
1782                         err |= __get_user(f->native_format, &uf->native_format);
1783                         if (err) {
1784                                 err = -EFAULT;
1785                                 goto out;
1786                         }
1787                         break;
1788                 }
1789                 case FDGETDRVSTAT32:
1790                 case FDPOLLDRVSTAT32:
1791                         karg = kmalloc(sizeof(struct floppy_drive_struct), GFP_KERNEL);
1792                         if (!karg)
1793                                 return -ENOMEM;
1794                         break;
1795                 case FDGETFDCSTAT32:
1796                         karg = kmalloc(sizeof(struct floppy_fdc_state), GFP_KERNEL);
1797                         if (!karg)
1798                                 return -ENOMEM;
1799                         break;
1800                 case FDWERRORGET32:
1801                         karg = kmalloc(sizeof(struct floppy_write_errors), GFP_KERNEL);
1802                         if (!karg)
1803                                 return -ENOMEM;
1804                         break;
1805                 default:
1806                         return -EINVAL;
1807         }
1808         set_fs (KERNEL_DS);
1809         err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1810         set_fs (old_fs);
1811         if (err)
1812                 goto out;
1813         switch (cmd) {
1814                 case FDGETPRM32:
1815                 {
1816                         struct floppy_struct *f = karg;
1817                         struct floppy_struct32 __user *uf = compat_ptr(arg);
1818
1819                         err = __put_user(f->size, &uf->size);
1820                         err |= __put_user(f->sect, &uf->sect);
1821                         err |= __put_user(f->head, &uf->head);
1822                         err |= __put_user(f->track, &uf->track);
1823                         err |= __put_user(f->stretch, &uf->stretch);
1824                         err |= __put_user(f->gap, &uf->gap);
1825                         err |= __put_user(f->rate, &uf->rate);
1826                         err |= __put_user(f->spec1, &uf->spec1);
1827                         err |= __put_user(f->fmt_gap, &uf->fmt_gap);
1828                         err |= __put_user((u64)f->name, (compat_caddr_t __user *)&uf->name);
1829                         break;
1830                 }
1831                 case FDGETDRVPRM32:
1832                 {
1833                         struct floppy_drive_params32 __user *uf;
1834                         struct floppy_drive_params *f = karg;
1835
1836                         uf = compat_ptr(arg);
1837                         err = __put_user(f->cmos, &uf->cmos);
1838                         err |= __put_user(f->max_dtr, &uf->max_dtr);
1839                         err |= __put_user(f->hlt, &uf->hlt);
1840                         err |= __put_user(f->hut, &uf->hut);
1841                         err |= __put_user(f->srt, &uf->srt);
1842                         err |= __put_user(f->spinup, &uf->spinup);
1843                         err |= __put_user(f->spindown, &uf->spindown);
1844                         err |= __put_user(f->spindown_offset, &uf->spindown_offset);
1845                         err |= __put_user(f->select_delay, &uf->select_delay);
1846                         err |= __put_user(f->rps, &uf->rps);
1847                         err |= __put_user(f->tracks, &uf->tracks);
1848                         err |= __put_user(f->timeout, &uf->timeout);
1849                         err |= __put_user(f->interleave_sect, &uf->interleave_sect);
1850                         err |= __copy_to_user(&uf->max_errors, &f->max_errors, sizeof(f->max_errors));
1851                         err |= __put_user(f->flags, &uf->flags);
1852                         err |= __put_user(f->read_track, &uf->read_track);
1853                         err |= __copy_to_user(uf->autodetect, f->autodetect, sizeof(f->autodetect));
1854                         err |= __put_user(f->checkfreq, &uf->checkfreq);
1855                         err |= __put_user(f->native_format, &uf->native_format);
1856                         break;
1857                 }
1858                 case FDGETDRVSTAT32:
1859                 case FDPOLLDRVSTAT32:
1860                 {
1861                         struct floppy_drive_struct32 __user *uf;
1862                         struct floppy_drive_struct *f = karg;
1863
1864                         uf = compat_ptr(arg);
1865                         err = __put_user(f->flags, &uf->flags);
1866                         err |= __put_user(f->spinup_date, &uf->spinup_date);
1867                         err |= __put_user(f->select_date, &uf->select_date);
1868                         err |= __put_user(f->first_read_date, &uf->first_read_date);
1869                         err |= __put_user(f->probed_format, &uf->probed_format);
1870                         err |= __put_user(f->track, &uf->track);
1871                         err |= __put_user(f->maxblock, &uf->maxblock);
1872                         err |= __put_user(f->maxtrack, &uf->maxtrack);
1873                         err |= __put_user(f->generation, &uf->generation);
1874                         err |= __put_user(f->keep_data, &uf->keep_data);
1875                         err |= __put_user(f->fd_ref, &uf->fd_ref);
1876                         err |= __put_user(f->fd_device, &uf->fd_device);
1877                         err |= __put_user(f->last_checked, &uf->last_checked);
1878                         err |= __put_user((u64)f->dmabuf, &uf->dmabuf);
1879                         err |= __put_user((u64)f->bufblocks, &uf->bufblocks);
1880                         break;
1881                 }
1882                 case FDGETFDCSTAT32:
1883                 {
1884                         struct floppy_fdc_state32 __user *uf;
1885                         struct floppy_fdc_state *f = karg;
1886
1887                         uf = compat_ptr(arg);
1888                         err = __put_user(f->spec1, &uf->spec1);
1889                         err |= __put_user(f->spec2, &uf->spec2);
1890                         err |= __put_user(f->dtr, &uf->dtr);
1891                         err |= __put_user(f->version, &uf->version);
1892                         err |= __put_user(f->dor, &uf->dor);
1893                         err |= __put_user(f->address, &uf->address);
1894                         err |= __copy_to_user((char __user *)&uf->address + sizeof(uf->address),
1895                                            (char *)&f->address + sizeof(f->address), sizeof(int));
1896                         err |= __put_user(f->driver_version, &uf->driver_version);
1897                         err |= __copy_to_user(uf->track, f->track, sizeof(f->track));
1898                         break;
1899                 }
1900                 case FDWERRORGET32:
1901                 {
1902                         struct floppy_write_errors32 __user *uf;
1903                         struct floppy_write_errors *f = karg;
1904
1905                         uf = compat_ptr(arg);
1906                         err = __put_user(f->write_errors, &uf->write_errors);
1907                         err |= __put_user(f->first_error_sector, &uf->first_error_sector);
1908                         err |= __put_user(f->first_error_generation, &uf->first_error_generation);
1909                         err |= __put_user(f->last_error_sector, &uf->last_error_sector);
1910                         err |= __put_user(f->last_error_generation, &uf->last_error_generation);
1911                         err |= __put_user(f->badness, &uf->badness);
1912                         break;
1913                 }
1914                 default:
1915                         break;
1916         }
1917         if (err)
1918                 err = -EFAULT;
1919
1920 out:
1921         kfree(karg);
1922         return err;
1923 }
1924 #endif
1925
1926 struct mtd_oob_buf32 {
1927         u_int32_t start;
1928         u_int32_t length;
1929         compat_caddr_t ptr;     /* unsigned char* */
1930 };
1931
1932 #define MEMWRITEOOB32   _IOWR('M',3,struct mtd_oob_buf32)
1933 #define MEMREADOOB32    _IOWR('M',4,struct mtd_oob_buf32)
1934
1935 static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg)
1936 {
1937         struct mtd_oob_buf __user *buf = compat_alloc_user_space(sizeof(*buf));
1938         struct mtd_oob_buf32 __user *buf32 = compat_ptr(arg);
1939         u32 data;
1940         char __user *datap;
1941         unsigned int real_cmd;
1942         int err;
1943
1944         real_cmd = (cmd == MEMREADOOB32) ?
1945                 MEMREADOOB : MEMWRITEOOB;
1946
1947         if (copy_in_user(&buf->start, &buf32->start,
1948                          2 * sizeof(u32)) ||
1949             get_user(data, &buf32->ptr))
1950                 return -EFAULT;
1951         datap = compat_ptr(data);
1952         if (put_user(datap, &buf->ptr))
1953                 return -EFAULT;
1954
1955         err = sys_ioctl(fd, real_cmd, (unsigned long) buf);
1956
1957         if (!err) {
1958                 if (copy_in_user(&buf32->start, &buf->start,
1959                                  2 * sizeof(u32)))
1960                         err = -EFAULT;
1961         }
1962
1963         return err;
1964 }       
1965
1966 #ifdef CONFIG_BLOCK
1967 struct raw32_config_request
1968 {
1969         compat_int_t    raw_minor;
1970         __u64   block_major;
1971         __u64   block_minor;
1972 } __attribute__((packed));
1973
1974 static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
1975 {
1976         int ret;
1977
1978         if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request)))
1979                 return -EFAULT;
1980
1981         ret = __get_user(req->raw_minor, &user_req->raw_minor);
1982         ret |= __get_user(req->block_major, &user_req->block_major);
1983         ret |= __get_user(req->block_minor, &user_req->block_minor);
1984
1985         return ret ? -EFAULT : 0;
1986 }
1987
1988 static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
1989 {
1990         int ret;
1991
1992         if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request)))
1993                 return -EFAULT;
1994
1995         ret = __put_user(req->raw_minor, &user_req->raw_minor);
1996         ret |= __put_user(req->block_major, &user_req->block_major);
1997         ret |= __put_user(req->block_minor, &user_req->block_minor);
1998
1999         return ret ? -EFAULT : 0;
2000 }
2001
2002 static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2003 {
2004         int ret;
2005
2006         switch (cmd) {
2007         case RAW_SETBIND:
2008         case RAW_GETBIND: {
2009                 struct raw_config_request req;
2010                 struct raw32_config_request __user *user_req = compat_ptr(arg);
2011                 mm_segment_t oldfs = get_fs();
2012
2013                 if ((ret = get_raw32_request(&req, user_req)))
2014                         return ret;
2015
2016                 set_fs(KERNEL_DS);
2017                 ret = sys_ioctl(fd,cmd,(unsigned long)&req);
2018                 set_fs(oldfs);
2019
2020                 if ((!ret) && (cmd == RAW_GETBIND)) {
2021                         ret = set_raw32_request(&req, user_req);
2022                 }
2023                 break;
2024         }
2025         default:
2026                 ret = sys_ioctl(fd, cmd, arg);
2027                 break;
2028         }
2029         return ret;
2030 }
2031 #endif /* CONFIG_BLOCK */
2032
2033 struct serial_struct32 {
2034         compat_int_t    type;
2035         compat_int_t    line;
2036         compat_uint_t   port;
2037         compat_int_t    irq;
2038         compat_int_t    flags;
2039         compat_int_t    xmit_fifo_size;
2040         compat_int_t    custom_divisor;
2041         compat_int_t    baud_base;
2042         unsigned short  close_delay;
2043         char    io_type;
2044         char    reserved_char[1];
2045         compat_int_t    hub6;
2046         unsigned short  closing_wait; /* time to wait before closing */
2047         unsigned short  closing_wait2; /* no longer used... */
2048         compat_uint_t   iomem_base;
2049         unsigned short  iomem_reg_shift;
2050         unsigned int    port_high;
2051      /* compat_ulong_t  iomap_base FIXME */
2052         compat_int_t    reserved[1];
2053 };
2054
2055 static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2056 {
2057         typedef struct serial_struct SS;
2058         typedef struct serial_struct32 SS32;
2059         struct serial_struct32 __user *ss32 = compat_ptr(arg);
2060         int err;
2061         struct serial_struct ss;
2062         mm_segment_t oldseg = get_fs();
2063         __u32 udata;
2064         unsigned int base;
2065
2066         if (cmd == TIOCSSERIAL) {
2067                 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
2068                         return -EFAULT;
2069                 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
2070                         return -EFAULT;
2071                 if (__get_user(udata, &ss32->iomem_base))
2072                         return -EFAULT;
2073                 ss.iomem_base = compat_ptr(udata);
2074                 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
2075                     __get_user(ss.port_high, &ss32->port_high))
2076                         return -EFAULT;
2077                 ss.iomap_base = 0UL;
2078         }
2079         set_fs(KERNEL_DS);
2080                 err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
2081         set_fs(oldseg);
2082         if (cmd == TIOCGSERIAL && err >= 0) {
2083                 if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32)))
2084                         return -EFAULT;
2085                 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
2086                         return -EFAULT;
2087                 base = (unsigned long)ss.iomem_base  >> 32 ?
2088                         0xffffffff : (unsigned)(unsigned long)ss.iomem_base;
2089                 if (__put_user(base, &ss32->iomem_base) ||
2090                     __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
2091                     __put_user(ss.port_high, &ss32->port_high))
2092                         return -EFAULT;
2093         }
2094         return err;
2095 }
2096
2097 struct usbdevfs_ctrltransfer32 {
2098         u8 bRequestType;
2099         u8 bRequest;
2100         u16 wValue;
2101         u16 wIndex;
2102         u16 wLength;
2103         u32 timeout;  /* in milliseconds */
2104         compat_caddr_t data;
2105 };
2106
2107 #define USBDEVFS_CONTROL32           _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
2108
2109 static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
2110 {
2111         struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg);
2112         struct usbdevfs_ctrltransfer __user *p;
2113         __u32 udata;
2114         p = compat_alloc_user_space(sizeof(*p));
2115         if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
2116             get_user(udata, &p32->data) ||
2117             put_user(compat_ptr(udata), &p->data))
2118                 return -EFAULT;
2119         return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p);
2120 }
2121
2122
2123 struct usbdevfs_bulktransfer32 {
2124         compat_uint_t ep;
2125         compat_uint_t len;
2126         compat_uint_t timeout; /* in milliseconds */
2127         compat_caddr_t data;
2128 };
2129
2130 #define USBDEVFS_BULK32              _IOWR('U', 2, struct usbdevfs_bulktransfer32)
2131
2132 static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
2133 {
2134         struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg);
2135         struct usbdevfs_bulktransfer __user *p;
2136         compat_uint_t n;
2137         compat_caddr_t addr;
2138
2139         p = compat_alloc_user_space(sizeof(*p));
2140
2141         if (get_user(n, &p32->ep) || put_user(n, &p->ep) ||
2142             get_user(n, &p32->len) || put_user(n, &p->len) ||
2143             get_user(n, &p32->timeout) || put_user(n, &p->timeout) ||
2144             get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data))
2145                 return -EFAULT;
2146
2147         return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p);
2148 }
2149
2150
2151 /*
2152  *  USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY
2153  *  are handled in usbdevfs core.                       -Christopher Li
2154  */
2155
2156 struct usbdevfs_disconnectsignal32 {
2157         compat_int_t signr;
2158         compat_caddr_t context;
2159 };
2160
2161 #define USBDEVFS_DISCSIGNAL32      _IOR('U', 14, struct usbdevfs_disconnectsignal32)
2162
2163 static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
2164 {
2165         struct usbdevfs_disconnectsignal kdis;
2166         struct usbdevfs_disconnectsignal32 __user *udis;
2167         mm_segment_t old_fs;
2168         u32 uctx;
2169         int err;
2170
2171         udis = compat_ptr(arg);
2172
2173         if (get_user(kdis.signr, &udis->signr) ||
2174             __get_user(uctx, &udis->context))
2175                 return -EFAULT;
2176
2177         kdis.context = compat_ptr(uctx);
2178
2179         old_fs = get_fs();
2180         set_fs(KERNEL_DS);
2181         err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
2182         set_fs(old_fs);
2183
2184         return err;
2185 }
2186
2187 /*
2188  * I2C layer ioctls
2189  */
2190
2191 struct i2c_msg32 {
2192         u16 addr;
2193         u16 flags;
2194         u16 len;
2195         compat_caddr_t buf;
2196 };
2197
2198 struct i2c_rdwr_ioctl_data32 {
2199         compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
2200         u32 nmsgs;
2201 };
2202
2203 struct i2c_smbus_ioctl_data32 {
2204         u8 read_write;
2205         u8 command;
2206         u32 size;
2207         compat_caddr_t data; /* union i2c_smbus_data *data */
2208 };
2209
2210 struct i2c_rdwr_aligned {
2211         struct i2c_rdwr_ioctl_data cmd;
2212         struct i2c_msg msgs[0];
2213 };
2214
2215 static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2216 {
2217         struct i2c_rdwr_ioctl_data32    __user *udata = compat_ptr(arg);
2218         struct i2c_rdwr_aligned         __user *tdata;
2219         struct i2c_msg                  __user *tmsgs;
2220         struct i2c_msg32                __user *umsgs;
2221         compat_caddr_t                  datap;
2222         int                             nmsgs, i;
2223
2224         if (get_user(nmsgs, &udata->nmsgs))
2225                 return -EFAULT;
2226         if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
2227                 return -EINVAL;
2228
2229         if (get_user(datap, &udata->msgs))
2230                 return -EFAULT;
2231         umsgs = compat_ptr(datap);
2232
2233         tdata = compat_alloc_user_space(sizeof(*tdata) +
2234                                       nmsgs * sizeof(struct i2c_msg));
2235         tmsgs = &tdata->msgs[0];
2236
2237         if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
2238             put_user(tmsgs, &tdata->cmd.msgs))
2239                 return -EFAULT;
2240
2241         for (i = 0; i < nmsgs; i++) {
2242                 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
2243                         return -EFAULT;
2244                 if (get_user(datap, &umsgs[i].buf) ||
2245                     put_user(compat_ptr(datap), &tmsgs[i].buf))
2246                         return -EFAULT;
2247         }
2248         return sys_ioctl(fd, cmd, (unsigned long)tdata);
2249 }
2250
2251 static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2252 {
2253         struct i2c_smbus_ioctl_data     __user *tdata;
2254         struct i2c_smbus_ioctl_data32   __user *udata;
2255         compat_caddr_t                  datap;
2256
2257         tdata = compat_alloc_user_space(sizeof(*tdata));
2258         if (tdata == NULL)
2259                 return -ENOMEM;
2260         if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
2261                 return -EFAULT;
2262
2263         udata = compat_ptr(arg);
2264         if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
2265                 return -EFAULT;
2266
2267         if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
2268                 return -EFAULT;
2269         if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
2270                 return -EFAULT;
2271         if (__get_user(datap, &udata->data) ||
2272             __put_user(compat_ptr(datap), &tdata->data))
2273                 return -EFAULT;
2274
2275         return sys_ioctl(fd, cmd, (unsigned long)tdata);
2276 }
2277
2278 struct compat_iw_point {
2279         compat_caddr_t pointer;
2280         __u16 length;
2281         __u16 flags;
2282 };
2283
2284 static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2285 {
2286         struct iwreq __user *iwr;
2287         struct iwreq __user *iwr_u;
2288         struct iw_point __user *iwp;
2289         struct compat_iw_point __user *iwp_u;
2290         compat_caddr_t pointer;
2291         __u16 length, flags;
2292
2293         iwr_u = compat_ptr(arg);
2294         iwp_u = (struct compat_iw_point __user *) &iwr_u->u.data;
2295         iwr = compat_alloc_user_space(sizeof(*iwr));
2296         if (iwr == NULL)
2297                 return -ENOMEM;
2298
2299         iwp = &iwr->u.data;
2300
2301         if (!access_ok(VERIFY_WRITE, iwr, sizeof(*iwr)))
2302                 return -EFAULT;
2303
2304         if (__copy_in_user(&iwr->ifr_ifrn.ifrn_name[0],
2305                            &iwr_u->ifr_ifrn.ifrn_name[0],
2306                            sizeof(iwr->ifr_ifrn.ifrn_name)))
2307                 return -EFAULT;
2308
2309         if (__get_user(pointer, &iwp_u->pointer) ||
2310             __get_user(length, &iwp_u->length) ||
2311             __get_user(flags, &iwp_u->flags))
2312                 return -EFAULT;
2313
2314         if (__put_user(compat_ptr(pointer), &iwp->pointer) ||
2315             __put_user(length, &iwp->length) ||
2316             __put_user(flags, &iwp->flags))
2317                 return -EFAULT;
2318
2319         return sys_ioctl(fd, cmd, (unsigned long) iwr);
2320 }
2321
2322 /* Since old style bridge ioctl's endup using SIOCDEVPRIVATE
2323  * for some operations; this forces use of the newer bridge-utils that
2324  * use compatiable ioctls
2325  */
2326 static int old_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2327 {
2328         u32 tmp;
2329
2330         if (get_user(tmp, (u32 __user *) arg))
2331                 return -EFAULT;
2332         if (tmp == BRCTL_GET_VERSION)
2333                 return BRCTL_VERSION + 1;
2334         return -EINVAL;
2335 }
2336
2337 #define RTC_IRQP_READ32         _IOR('p', 0x0b, compat_ulong_t)
2338 #define RTC_IRQP_SET32          _IOW('p', 0x0c, compat_ulong_t)
2339 #define RTC_EPOCH_READ32        _IOR('p', 0x0d, compat_ulong_t)
2340 #define RTC_EPOCH_SET32         _IOW('p', 0x0e, compat_ulong_t)
2341
2342 static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2343 {
2344         mm_segment_t oldfs = get_fs();
2345         compat_ulong_t val32;
2346         unsigned long kval;
2347         int ret;
2348
2349         switch (cmd) {
2350         case RTC_IRQP_READ32:
2351         case RTC_EPOCH_READ32:
2352                 set_fs(KERNEL_DS);
2353                 ret = sys_ioctl(fd, (cmd == RTC_IRQP_READ32) ?
2354                                         RTC_IRQP_READ : RTC_EPOCH_READ,
2355                                         (unsigned long)&kval);
2356                 set_fs(oldfs);
2357                 if (ret)
2358                         return ret;
2359                 val32 = kval;
2360                 return put_user(val32, (unsigned int __user *)arg);
2361         case RTC_IRQP_SET32:
2362                 return sys_ioctl(fd, RTC_IRQP_SET, arg); 
2363         case RTC_EPOCH_SET32:
2364                 return sys_ioctl(fd, RTC_EPOCH_SET, arg);
2365         default:
2366                 /* unreached */
2367                 return -ENOIOCTLCMD;
2368         }
2369 }
2370
2371 static int
2372 lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
2373 {
2374         struct compat_timeval __user *tc = (struct compat_timeval __user *)arg;
2375         struct timeval __user *tn = compat_alloc_user_space(sizeof(struct timeval));
2376         struct timeval ts;
2377         if (get_user(ts.tv_sec, &tc->tv_sec) ||
2378             get_user(ts.tv_usec, &tc->tv_usec) ||
2379             put_user(ts.tv_sec, &tn->tv_sec) ||
2380             put_user(ts.tv_usec, &tn->tv_usec))
2381                 return -EFAULT;
2382         return sys_ioctl(fd, cmd, (unsigned long)tn);
2383 }
2384
2385
2386 typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int,
2387                                         unsigned long, struct file *);
2388
2389 struct ioctl_trans {
2390         unsigned long cmd;
2391         ioctl_trans_handler_t handler;
2392         struct ioctl_trans *next;
2393 };
2394
2395 #define HANDLE_IOCTL(cmd,handler) \
2396         { (cmd), (ioctl_trans_handler_t)(handler) },
2397
2398 /* pointer to compatible structure or no argument */
2399 #define COMPATIBLE_IOCTL(cmd) \
2400         { (cmd), do_ioctl32_pointer },
2401
2402 /* argument is an unsigned long integer, not a pointer */
2403 #define ULONG_IOCTL(cmd) \
2404         { (cmd), (ioctl_trans_handler_t)sys_ioctl },
2405
2406 /* ioctl should not be warned about even if it's not implemented.
2407    Valid reasons to use this:
2408    - It is implemented with ->compat_ioctl on some device, but programs
2409    call it on others too.
2410    - The ioctl is not implemented in the native kernel, but programs
2411    call it commonly anyways.
2412    Most other reasons are not valid. */
2413 #define IGNORE_IOCTL(cmd) COMPATIBLE_IOCTL(cmd)
2414
2415 static struct ioctl_trans ioctl_start[] = {
2416 /* compatible ioctls first */
2417 COMPATIBLE_IOCTL(0x4B50)   /* KDGHWCLK - not in the kernel, but don't complain */
2418 COMPATIBLE_IOCTL(0x4B51)   /* KDSHWCLK - not in the kernel, but don't complain */
2419
2420 /* Big T */
2421 COMPATIBLE_IOCTL(TCGETA)
2422 COMPATIBLE_IOCTL(TCSETA)
2423 COMPATIBLE_IOCTL(TCSETAW)
2424 COMPATIBLE_IOCTL(TCSETAF)
2425 COMPATIBLE_IOCTL(TCSBRK)
2426 ULONG_IOCTL(TCSBRKP)
2427 COMPATIBLE_IOCTL(TCXONC)
2428 COMPATIBLE_IOCTL(TCFLSH)
2429 COMPATIBLE_IOCTL(TCGETS)
2430 COMPATIBLE_IOCTL(TCSETS)
2431 COMPATIBLE_IOCTL(TCSETSW)
2432 COMPATIBLE_IOCTL(TCSETSF)
2433 COMPATIBLE_IOCTL(TIOCLINUX)
2434 COMPATIBLE_IOCTL(TIOCSBRK)
2435 COMPATIBLE_IOCTL(TIOCCBRK)
2436 ULONG_IOCTL(TIOCMIWAIT)
2437 COMPATIBLE_IOCTL(TIOCGICOUNT)
2438 /* Little t */
2439 COMPATIBLE_IOCTL(TIOCGETD)
2440 COMPATIBLE_IOCTL(TIOCSETD)
2441 COMPATIBLE_IOCTL(TIOCEXCL)
2442 COMPATIBLE_IOCTL(TIOCNXCL)
2443 COMPATIBLE_IOCTL(TIOCCONS)
2444 COMPATIBLE_IOCTL(TIOCGSOFTCAR)
2445 COMPATIBLE_IOCTL(TIOCSSOFTCAR)
2446 COMPATIBLE_IOCTL(TIOCSWINSZ)
2447 COMPATIBLE_IOCTL(TIOCGWINSZ)
2448 COMPATIBLE_IOCTL(TIOCMGET)
2449 COMPATIBLE_IOCTL(TIOCMBIC)
2450 COMPATIBLE_IOCTL(TIOCMBIS)
2451 COMPATIBLE_IOCTL(TIOCMSET)
2452 COMPATIBLE_IOCTL(TIOCPKT)
2453 COMPATIBLE_IOCTL(TIOCNOTTY)
2454 COMPATIBLE_IOCTL(TIOCSTI)
2455 COMPATIBLE_IOCTL(TIOCOUTQ)
2456 COMPATIBLE_IOCTL(TIOCSPGRP)
2457 COMPATIBLE_IOCTL(TIOCGPGRP)
2458 ULONG_IOCTL(TIOCSCTTY)
2459 COMPATIBLE_IOCTL(TIOCGPTN)
2460 COMPATIBLE_IOCTL(TIOCSPTLCK)
2461 COMPATIBLE_IOCTL(TIOCSERGETLSR)
2462 /* Little f */
2463 COMPATIBLE_IOCTL(FIOCLEX)
2464 COMPATIBLE_IOCTL(FIONCLEX)
2465 COMPATIBLE_IOCTL(FIOASYNC)
2466 COMPATIBLE_IOCTL(FIONBIO)
2467 COMPATIBLE_IOCTL(FIONREAD)  /* This is also TIOCINQ */
2468 /* 0x00 */
2469 COMPATIBLE_IOCTL(FIBMAP)
2470 COMPATIBLE_IOCTL(FIGETBSZ)
2471 /* 0x03 -- HD/IDE ioctl's used by hdparm and friends.
2472  *         Some need translations, these do not.
2473  */
2474 COMPATIBLE_IOCTL(HDIO_GET_IDENTITY)
2475 COMPATIBLE_IOCTL(HDIO_DRIVE_TASK)
2476 COMPATIBLE_IOCTL(HDIO_DRIVE_CMD)
2477 ULONG_IOCTL(HDIO_SET_MULTCOUNT)
2478 ULONG_IOCTL(HDIO_SET_UNMASKINTR)
2479 ULONG_IOCTL(HDIO_SET_KEEPSETTINGS)
2480 ULONG_IOCTL(HDIO_SET_32BIT)
2481 ULONG_IOCTL(HDIO_SET_NOWERR)
2482 ULONG_IOCTL(HDIO_SET_DMA)
2483 ULONG_IOCTL(HDIO_SET_PIO_MODE)
2484 ULONG_IOCTL(HDIO_SET_NICE)
2485 ULONG_IOCTL(HDIO_SET_WCACHE)
2486 ULONG_IOCTL(HDIO_SET_ACOUSTIC)
2487 ULONG_IOCTL(HDIO_SET_BUSSTATE)
2488 ULONG_IOCTL(HDIO_SET_ADDRESS)
2489 COMPATIBLE_IOCTL(HDIO_SCAN_HWIF)
2490 /* 0x330 is reserved -- it used to be HDIO_GETGEO_BIG */
2491 COMPATIBLE_IOCTL(0x330)
2492 /* 0x02 -- Floppy ioctls */
2493 COMPATIBLE_IOCTL(FDMSGON)
2494 COMPATIBLE_IOCTL(FDMSGOFF)
2495 COMPATIBLE_IOCTL(FDSETEMSGTRESH)
2496 COMPATIBLE_IOCTL(FDFLUSH)
2497 COMPATIBLE_IOCTL(FDWERRORCLR)
2498 COMPATIBLE_IOCTL(FDSETMAXERRS)
2499 COMPATIBLE_IOCTL(FDGETMAXERRS)
2500 COMPATIBLE_IOCTL(FDGETDRVTYP)
2501 COMPATIBLE_IOCTL(FDEJECT)
2502 COMPATIBLE_IOCTL(FDCLRPRM)
2503 COMPATIBLE_IOCTL(FDFMTBEG)
2504 COMPATIBLE_IOCTL(FDFMTEND)
2505 COMPATIBLE_IOCTL(FDRESET)
2506 COMPATIBLE_IOCTL(FDTWADDLE)
2507 COMPATIBLE_IOCTL(FDFMTTRK)
2508 COMPATIBLE_IOCTL(FDRAWCMD)
2509 /* 0x12 */
2510 #ifdef CONFIG_BLOCK
2511 COMPATIBLE_IOCTL(BLKRASET)
2512 COMPATIBLE_IOCTL(BLKROSET)
2513 COMPATIBLE_IOCTL(BLKROGET)
2514 COMPATIBLE_IOCTL(BLKRRPART)
2515 COMPATIBLE_IOCTL(BLKFLSBUF)
2516 COMPATIBLE_IOCTL(BLKSECTSET)
2517 COMPATIBLE_IOCTL(BLKSSZGET)
2518 COMPATIBLE_IOCTL(BLKTRACESTART)
2519 COMPATIBLE_IOCTL(BLKTRACESTOP)
2520 COMPATIBLE_IOCTL(BLKTRACESETUP)
2521 COMPATIBLE_IOCTL(BLKTRACETEARDOWN)
2522 ULONG_IOCTL(BLKRASET)
2523 ULONG_IOCTL(BLKFRASET)
2524 #endif
2525 /* RAID */
2526 COMPATIBLE_IOCTL(RAID_VERSION)
2527 COMPATIBLE_IOCTL(GET_ARRAY_INFO)
2528 COMPATIBLE_IOCTL(GET_DISK_INFO)
2529 COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
2530 COMPATIBLE_IOCTL(RAID_AUTORUN)
2531 COMPATIBLE_IOCTL(CLEAR_ARRAY)
2532 COMPATIBLE_IOCTL(ADD_NEW_DISK)
2533 ULONG_IOCTL(HOT_REMOVE_DISK)
2534 COMPATIBLE_IOCTL(SET_ARRAY_INFO)
2535 COMPATIBLE_IOCTL(SET_DISK_INFO)
2536 COMPATIBLE_IOCTL(WRITE_RAID_INFO)
2537 COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
2538 COMPATIBLE_IOCTL(PROTECT_ARRAY)
2539 ULONG_IOCTL(HOT_ADD_DISK)
2540 ULONG_IOCTL(SET_DISK_FAULTY)
2541 COMPATIBLE_IOCTL(RUN_ARRAY)
2542 COMPATIBLE_IOCTL(STOP_ARRAY)
2543 COMPATIBLE_IOCTL(STOP_ARRAY_RO)
2544 COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
2545 COMPATIBLE_IOCTL(GET_BITMAP_FILE)
2546 ULONG_IOCTL(SET_BITMAP_FILE)
2547 /* DM */
2548 COMPATIBLE_IOCTL(DM_VERSION_32)
2549 COMPATIBLE_IOCTL(DM_REMOVE_ALL_32)
2550 COMPATIBLE_IOCTL(DM_LIST_DEVICES_32)
2551 COMPATIBLE_IOCTL(DM_DEV_CREATE_32)
2552 COMPATIBLE_IOCTL(DM_DEV_REMOVE_32)
2553 COMPATIBLE_IOCTL(DM_DEV_RENAME_32)
2554 COMPATIBLE_IOCTL(DM_DEV_SUSPEND_32)
2555 COMPATIBLE_IOCTL(DM_DEV_STATUS_32)
2556 COMPATIBLE_IOCTL(DM_DEV_WAIT_32)
2557 COMPATIBLE_IOCTL(DM_TABLE_LOAD_32)
2558 COMPATIBLE_IOCTL(DM_TABLE_CLEAR_32)
2559 COMPATIBLE_IOCTL(DM_TABLE_DEPS_32)
2560 COMPATIBLE_IOCTL(DM_TABLE_STATUS_32)
2561 COMPATIBLE_IOCTL(DM_LIST_VERSIONS_32)
2562 COMPATIBLE_IOCTL(DM_TARGET_MSG_32)
2563 COMPATIBLE_IOCTL(DM_DEV_SET_GEOMETRY_32)
2564 COMPATIBLE_IOCTL(DM_VERSION)
2565 COMPATIBLE_IOCTL(DM_REMOVE_ALL)
2566 COMPATIBLE_IOCTL(DM_LIST_DEVICES)
2567 COMPATIBLE_IOCTL(DM_DEV_CREATE)
2568 COMPATIBLE_IOCTL(DM_DEV_REMOVE)
2569 COMPATIBLE_IOCTL(DM_DEV_RENAME)
2570 COMPATIBLE_IOCTL(DM_DEV_SUSPEND)
2571 COMPATIBLE_IOCTL(DM_DEV_STATUS)
2572 COMPATIBLE_IOCTL(DM_DEV_WAIT)
2573 COMPATIBLE_IOCTL(DM_TABLE_LOAD)
2574 COMPATIBLE_IOCTL(DM_TABLE_CLEAR)
2575 COMPATIBLE_IOCTL(DM_TABLE_DEPS)
2576 COMPATIBLE_IOCTL(DM_TABLE_STATUS)
2577 COMPATIBLE_IOCTL(DM_LIST_VERSIONS)
2578 COMPATIBLE_IOCTL(DM_TARGET_MSG)
2579 COMPATIBLE_IOCTL(DM_DEV_SET_GEOMETRY)
2580 /* Big K */
2581 COMPATIBLE_IOCTL(PIO_FONT)
2582 COMPATIBLE_IOCTL(GIO_FONT)
2583 ULONG_IOCTL(KDSIGACCEPT)
2584 COMPATIBLE_IOCTL(KDGETKEYCODE)
2585 COMPATIBLE_IOCTL(KDSETKEYCODE)
2586 ULONG_IOCTL(KIOCSOUND)
2587 ULONG_IOCTL(KDMKTONE)
2588 COMPATIBLE_IOCTL(KDGKBTYPE)
2589 ULONG_IOCTL(KDSETMODE)
2590 COMPATIBLE_IOCTL(KDGETMODE)
2591 ULONG_IOCTL(KDSKBMODE)
2592 COMPATIBLE_IOCTL(KDGKBMODE)
2593 ULONG_IOCTL(KDSKBMETA)
2594 COMPATIBLE_IOCTL(KDGKBMETA)
2595 COMPATIBLE_IOCTL(KDGKBENT)
2596 COMPATIBLE_IOCTL(KDSKBENT)
2597 COMPATIBLE_IOCTL(KDGKBSENT)
2598 COMPATIBLE_IOCTL(KDSKBSENT)
2599 COMPATIBLE_IOCTL(KDGKBDIACR)
2600 COMPATIBLE_IOCTL(KDSKBDIACR)
2601 COMPATIBLE_IOCTL(KDKBDREP)
2602 COMPATIBLE_IOCTL(KDGKBLED)
2603 ULONG_IOCTL(KDSKBLED)
2604 COMPATIBLE_IOCTL(KDGETLED)
2605 ULONG_IOCTL(KDSETLED)
2606 COMPATIBLE_IOCTL(GIO_SCRNMAP)
2607 COMPATIBLE_IOCTL(PIO_SCRNMAP)
2608 COMPATIBLE_IOCTL(GIO_UNISCRNMAP)
2609 COMPATIBLE_IOCTL(PIO_UNISCRNMAP)
2610 COMPATIBLE_IOCTL(PIO_FONTRESET)
2611 COMPATIBLE_IOCTL(PIO_UNIMAPCLR)
2612 /* Big S */
2613 COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
2614 COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
2615 COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
2616 COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
2617 COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
2618 COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
2619 COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
2620 COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
2621 /* Big T */
2622 COMPATIBLE_IOCTL(TUNSETNOCSUM)
2623 COMPATIBLE_IOCTL(TUNSETDEBUG)
2624 COMPATIBLE_IOCTL(TUNSETPERSIST)
2625 COMPATIBLE_IOCTL(TUNSETOWNER)
2626 /* Big V */
2627 COMPATIBLE_IOCTL(VT_SETMODE)
2628 COMPATIBLE_IOCTL(VT_GETMODE)
2629 COMPATIBLE_IOCTL(VT_GETSTATE)
2630 COMPATIBLE_IOCTL(VT_OPENQRY)
2631 ULONG_IOCTL(VT_ACTIVATE)
2632 ULONG_IOCTL(VT_WAITACTIVE)
2633 ULONG_IOCTL(VT_RELDISP)
2634 ULONG_IOCTL(VT_DISALLOCATE)
2635 COMPATIBLE_IOCTL(VT_RESIZE)
2636 COMPATIBLE_IOCTL(VT_RESIZEX)
2637 COMPATIBLE_IOCTL(VT_LOCKSWITCH)
2638 COMPATIBLE_IOCTL(VT_UNLOCKSWITCH)
2639 COMPATIBLE_IOCTL(VT_GETHIFONTMASK)
2640 /* Little p (/dev/rtc, /dev/envctrl, etc.) */
2641 COMPATIBLE_IOCTL(RTC_AIE_ON)
2642 COMPATIBLE_IOCTL(RTC_AIE_OFF)
2643 COMPATIBLE_IOCTL(RTC_UIE_ON)
2644 COMPATIBLE_IOCTL(RTC_UIE_OFF)
2645 COMPATIBLE_IOCTL(RTC_PIE_ON)
2646 COMPATIBLE_IOCTL(RTC_PIE_OFF)
2647 COMPATIBLE_IOCTL(RTC_WIE_ON)
2648 COMPATIBLE_IOCTL(RTC_WIE_OFF)
2649 COMPATIBLE_IOCTL(RTC_ALM_SET)
2650 COMPATIBLE_IOCTL(RTC_ALM_READ)
2651 COMPATIBLE_IOCTL(RTC_RD_TIME)
2652 COMPATIBLE_IOCTL(RTC_SET_TIME)
2653 COMPATIBLE_IOCTL(RTC_WKALM_SET)
2654 COMPATIBLE_IOCTL(RTC_WKALM_RD)
2655 /*
2656  * These two are only for the sbus rtc driver, but
2657  * hwclock tries them on every rtc device first when
2658  * running on sparc.  On other architectures the entries
2659  * are useless but harmless.
2660  */
2661 COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
2662 COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
2663 /* Little m */
2664 COMPATIBLE_IOCTL(MTIOCTOP)
2665 /* Socket level stuff */
2666 COMPATIBLE_IOCTL(FIOQSIZE)
2667 COMPATIBLE_IOCTL(FIOSETOWN)
2668 COMPATIBLE_IOCTL(SIOCSPGRP)
2669 COMPATIBLE_IOCTL(FIOGETOWN)
2670 COMPATIBLE_IOCTL(SIOCGPGRP)
2671 COMPATIBLE_IOCTL(SIOCATMARK)
2672 COMPATIBLE_IOCTL(SIOCSIFLINK)
2673 COMPATIBLE_IOCTL(SIOCSIFENCAP)
2674 COMPATIBLE_IOCTL(SIOCGIFENCAP)
2675 COMPATIBLE_IOCTL(SIOCSIFNAME)
2676 COMPATIBLE_IOCTL(SIOCSARP)
2677 COMPATIBLE_IOCTL(SIOCGARP)
2678 COMPATIBLE_IOCTL(SIOCDARP)
2679 COMPATIBLE_IOCTL(SIOCSRARP)
2680 COMPATIBLE_IOCTL(SIOCGRARP)
2681 COMPATIBLE_IOCTL(SIOCDRARP)
2682 COMPATIBLE_IOCTL(SIOCADDDLCI)
2683 COMPATIBLE_IOCTL(SIOCDELDLCI)
2684 COMPATIBLE_IOCTL(SIOCGMIIPHY)
2685 COMPATIBLE_IOCTL(SIOCGMIIREG)
2686 COMPATIBLE_IOCTL(SIOCSMIIREG)
2687 COMPATIBLE_IOCTL(SIOCGIFVLAN)
2688 COMPATIBLE_IOCTL(SIOCSIFVLAN)
2689 COMPATIBLE_IOCTL(SIOCBRADDBR)
2690 COMPATIBLE_IOCTL(SIOCBRDELBR)
2691 /* SG stuff */
2692 COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
2693 COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
2694 COMPATIBLE_IOCTL(SG_EMULATED_HOST)
2695 ULONG_IOCTL(SG_SET_TRANSFORM)
2696 COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
2697 COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
2698 COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
2699 COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
2700 COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
2701 COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
2702 COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
2703 COMPATIBLE_IOCTL(SG_GET_PACK_ID)
2704 COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
2705 COMPATIBLE_IOCTL(SG_SET_DEBUG)
2706 COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
2707 COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
2708 COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
2709 COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
2710 COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
2711 COMPATIBLE_IOCTL(SG_SCSI_RESET)
2712 COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
2713 COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
2714 COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
2715 /* PPP stuff */
2716 COMPATIBLE_IOCTL(PPPIOCGFLAGS)
2717 COMPATIBLE_IOCTL(PPPIOCSFLAGS)
2718 COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
2719 COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
2720 COMPATIBLE_IOCTL(PPPIOCGUNIT)
2721 COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
2722 COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
2723 COMPATIBLE_IOCTL(PPPIOCGMRU)
2724 COMPATIBLE_IOCTL(PPPIOCSMRU)
2725 COMPATIBLE_IOCTL(PPPIOCSMAXCID)
2726 COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
2727 COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
2728 COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
2729 /* PPPIOCSCOMPRESS is translated */
2730 COMPATIBLE_IOCTL(PPPIOCGNPMODE)
2731 COMPATIBLE_IOCTL(PPPIOCSNPMODE)
2732 COMPATIBLE_IOCTL(PPPIOCGDEBUG)
2733 COMPATIBLE_IOCTL(PPPIOCSDEBUG)
2734 /* PPPIOCSPASS is translated */
2735 /* PPPIOCSACTIVE is translated */
2736 /* PPPIOCGIDLE is translated */
2737 COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
2738 COMPATIBLE_IOCTL(PPPIOCATTACH)
2739 COMPATIBLE_IOCTL(PPPIOCDETACH)
2740 COMPATIBLE_IOCTL(PPPIOCSMRRU)
2741 COMPATIBLE_IOCTL(PPPIOCCONNECT)
2742 COMPATIBLE_IOCTL(PPPIOCDISCONN)
2743 COMPATIBLE_IOCTL(PPPIOCATTCHAN)
2744 COMPATIBLE_IOCTL(PPPIOCGCHAN)
2745 /* PPPOX */
2746 COMPATIBLE_IOCTL(PPPOEIOCSFWD)
2747 COMPATIBLE_IOCTL(PPPOEIOCDFWD)
2748 /* LP */
2749 COMPATIBLE_IOCTL(LPGETSTATUS)
2750 /* ppdev */
2751 COMPATIBLE_IOCTL(PPSETMODE)
2752 COMPATIBLE_IOCTL(PPRSTATUS)
2753 COMPATIBLE_IOCTL(PPRCONTROL)
2754 COMPATIBLE_IOCTL(PPWCONTROL)
2755 COMPATIBLE_IOCTL(PPFCONTROL)
2756 COMPATIBLE_IOCTL(PPRDATA)
2757 COMPATIBLE_IOCTL(PPWDATA)
2758 COMPATIBLE_IOCTL(PPCLAIM)
2759 COMPATIBLE_IOCTL(PPRELEASE)
2760 COMPATIBLE_IOCTL(PPYIELD)
2761 COMPATIBLE_IOCTL(PPEXCL)
2762 COMPATIBLE_IOCTL(PPDATADIR)
2763 COMPATIBLE_IOCTL(PPNEGOT)
2764 COMPATIBLE_IOCTL(PPWCTLONIRQ)
2765 COMPATIBLE_IOCTL(PPCLRIRQ)
2766 COMPATIBLE_IOCTL(PPSETPHASE)
2767 COMPATIBLE_IOCTL(PPGETMODES)
2768 COMPATIBLE_IOCTL(PPGETMODE)
2769 COMPATIBLE_IOCTL(PPGETPHASE)
2770 COMPATIBLE_IOCTL(PPGETFLAGS)
2771 COMPATIBLE_IOCTL(PPSETFLAGS)
2772 /* CDROM stuff */
2773 COMPATIBLE_IOCTL(CDROMPAUSE)
2774 COMPATIBLE_IOCTL(CDROMRESUME)
2775 COMPATIBLE_IOCTL(CDROMPLAYMSF)
2776 COMPATIBLE_IOCTL(CDROMPLAYTRKIND)
2777 COMPATIBLE_IOCTL(CDROMREADTOCHDR)
2778 COMPATIBLE_IOCTL(CDROMREADTOCENTRY)
2779 COMPATIBLE_IOCTL(CDROMSTOP)
2780 COMPATIBLE_IOCTL(CDROMSTART)
2781 COMPATIBLE_IOCTL(CDROMEJECT)
2782 COMPATIBLE_IOCTL(CDROMVOLCTRL)
2783 COMPATIBLE_IOCTL(CDROMSUBCHNL)
2784 ULONG_IOCTL(CDROMEJECT_SW)
2785 COMPATIBLE_IOCTL(CDROMMULTISESSION)
2786 COMPATIBLE_IOCTL(CDROM_GET_MCN)
2787 COMPATIBLE_IOCTL(CDROMRESET)
2788 COMPATIBLE_IOCTL(CDROMVOLREAD)
2789 COMPATIBLE_IOCTL(CDROMSEEK)
2790 COMPATIBLE_IOCTL(CDROMPLAYBLK)
2791 COMPATIBLE_IOCTL(CDROMCLOSETRAY)
2792 ULONG_IOCTL(CDROM_SET_OPTIONS)
2793 ULONG_IOCTL(CDROM_CLEAR_OPTIONS)
2794 ULONG_IOCTL(CDROM_SELECT_SPEED)
2795 ULONG_IOCTL(CDROM_SELECT_DISC)
2796 ULONG_IOCTL(CDROM_MEDIA_CHANGED)
2797 ULONG_IOCTL(CDROM_DRIVE_STATUS)
2798 COMPATIBLE_IOCTL(CDROM_DISC_STATUS)
2799 COMPATIBLE_IOCTL(CDROM_CHANGER_NSLOTS)
2800 ULONG_IOCTL(CDROM_LOCKDOOR)
2801 ULONG_IOCTL(CDROM_DEBUG)
2802 COMPATIBLE_IOCTL(CDROM_GET_CAPABILITY)
2803 /* Ignore cdrom.h about these next 5 ioctls, they absolutely do
2804  * not take a struct cdrom_read, instead they take a struct cdrom_msf
2805  * which is compatible.
2806  */
2807 COMPATIBLE_IOCTL(CDROMREADMODE2)
2808 COMPATIBLE_IOCTL(CDROMREADMODE1)
2809 COMPATIBLE_IOCTL(CDROMREADRAW)
2810 COMPATIBLE_IOCTL(CDROMREADCOOKED)
2811 COMPATIBLE_IOCTL(CDROMREADALL)
2812 /* DVD ioctls */
2813 COMPATIBLE_IOCTL(DVD_READ_STRUCT)
2814 COMPATIBLE_IOCTL(DVD_WRITE_STRUCT)
2815 COMPATIBLE_IOCTL(DVD_AUTH)
2816 /* pktcdvd */
2817 COMPATIBLE_IOCTL(PACKET_CTRL_CMD)
2818 /* Big A */
2819 /* sparc only */
2820 /* Big Q for sound/OSS */
2821 COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
2822 COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
2823 COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
2824 COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
2825 COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
2826 COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
2827 COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
2828 COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
2829 COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
2830 COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
2831 COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
2832 COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
2833 COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
2834 COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
2835 COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
2836 COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
2837 COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
2838 COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
2839 COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
2840 COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
2841 COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
2842 COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
2843 /* Big T for sound/OSS */
2844 COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
2845 COMPATIBLE_IOCTL(SNDCTL_TMR_START)
2846 COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
2847 COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
2848 COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
2849 COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
2850 COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
2851 COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
2852 /* Little m for sound/OSS */
2853 COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
2854 COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
2855 COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
2856 /* Big P for sound/OSS */
2857 COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
2858 COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
2859 COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
2860 COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
2861 COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
2862 COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
2863 COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
2864 COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
2865 COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
2866 COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
2867 COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
2868 COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
2869 COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
2870 COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
2871 COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
2872 COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
2873 COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
2874 COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
2875 COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
2876 COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
2877 /* SNDCTL_DSP_MAPINBUF,  XXX needs translation */
2878 /* SNDCTL_DSP_MAPOUTBUF,  XXX needs translation */
2879 COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
2880 COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
2881 COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
2882 COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
2883 COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
2884 COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
2885 COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
2886 COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
2887 /* Big C for sound/OSS */
2888 COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
2889 COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
2890 COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
2891 COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
2892 COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
2893 COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
2894 COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
2895 COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
2896 COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
2897 COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
2898 /* Big M for sound/OSS */
2899 COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
2900 COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
2901 COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
2902 COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
2903 COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
2904 COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
2905 COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
2906 COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
2907 COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
2908 COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
2909 COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
2910 COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
2911 COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
2912 COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
2913 COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
2914 COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
2915 COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
2916 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
2917 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
2918 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
2919 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
2920 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
2921 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
2922 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
2923 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
2924 COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
2925 /* SOUND_MIXER_READ_ENHANCE,  same value as READ_MUTE */
2926 /* SOUND_MIXER_READ_LOUD,  same value as READ_MUTE */
2927 COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
2928 COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
2929 COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
2930 COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
2931 COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
2932 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
2933 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
2934 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
2935 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
2936 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
2937 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
2938 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
2939 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
2940 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
2941 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
2942 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
2943 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
2944 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
2945 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
2946 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
2947 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
2948 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
2949 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
2950 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
2951 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
2952 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
2953 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
2954 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
2955 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
2956 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
2957 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
2958 /* SOUND_MIXER_WRITE_ENHANCE,  same value as WRITE_MUTE */
2959 /* SOUND_MIXER_WRITE_LOUD,  same value as WRITE_MUTE */
2960 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
2961 COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
2962 COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
2963 COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
2964 COMPATIBLE_IOCTL(SOUND_MIXER_AGC)
2965 COMPATIBLE_IOCTL(SOUND_MIXER_3DSE)
2966 COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
2967 COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
2968 COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
2969 COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
2970 COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
2971 COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
2972 COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
2973 COMPATIBLE_IOCTL(OSS_GETVERSION)
2974 /* AUTOFS */
2975 ULONG_IOCTL(AUTOFS_IOC_READY)
2976 ULONG_IOCTL(AUTOFS_IOC_FAIL)
2977 COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
2978 COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
2979 COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
2980 COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI)
2981 COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOSUBVER)
2982 COMPATIBLE_IOCTL(AUTOFS_IOC_ASKREGHOST)
2983 COMPATIBLE_IOCTL(AUTOFS_IOC_TOGGLEREGHOST)
2984 COMPATIBLE_IOCTL(AUTOFS_IOC_ASKUMOUNT)
2985 /* Raw devices */
2986 COMPATIBLE_IOCTL(RAW_SETBIND)
2987 COMPATIBLE_IOCTL(RAW_GETBIND)
2988 /* SMB ioctls which do not need any translations */
2989 COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
2990 /* Little a */
2991 COMPATIBLE_IOCTL(ATMSIGD_CTRL)
2992 COMPATIBLE_IOCTL(ATMARPD_CTRL)
2993 COMPATIBLE_IOCTL(ATMLEC_CTRL)
2994 COMPATIBLE_IOCTL(ATMLEC_MCAST)
2995 COMPATIBLE_IOCTL(ATMLEC_DATA)
2996 COMPATIBLE_IOCTL(ATM_SETSC)
2997 COMPATIBLE_IOCTL(SIOCSIFATMTCP)
2998 COMPATIBLE_IOCTL(SIOCMKCLIP)
2999 COMPATIBLE_IOCTL(ATMARP_MKIP)
3000 COMPATIBLE_IOCTL(ATMARP_SETENTRY)
3001 COMPATIBLE_IOCTL(ATMARP_ENCAP)
3002 COMPATIBLE_IOCTL(ATMTCP_CREATE)
3003 COMPATIBLE_IOCTL(ATMTCP_REMOVE)
3004 COMPATIBLE_IOCTL(ATMMPC_CTRL)
3005 COMPATIBLE_IOCTL(ATMMPC_DATA)
3006 /* Watchdog */
3007 COMPATIBLE_IOCTL(WDIOC_GETSUPPORT)
3008 COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
3009 COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS)
3010 COMPATIBLE_IOCTL(WDIOC_GETTEMP)
3011 COMPATIBLE_IOCTL(WDIOC_SETOPTIONS)
3012 COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
3013 COMPATIBLE_IOCTL(WDIOC_SETTIMEOUT)
3014 COMPATIBLE_IOCTL(WDIOC_GETTIMEOUT)
3015 /* Big R */
3016 COMPATIBLE_IOCTL(RNDGETENTCNT)
3017 COMPATIBLE_IOCTL(RNDADDTOENTCNT)
3018 COMPATIBLE_IOCTL(RNDGETPOOL)
3019 COMPATIBLE_IOCTL(RNDADDENTROPY)
3020 COMPATIBLE_IOCTL(RNDZAPENTCNT)
3021 COMPATIBLE_IOCTL(RNDCLEARPOOL)
3022 /* Bluetooth */
3023 COMPATIBLE_IOCTL(HCIDEVUP)
3024 COMPATIBLE_IOCTL(HCIDEVDOWN)
3025 COMPATIBLE_IOCTL(HCIDEVRESET)
3026 COMPATIBLE_IOCTL(HCIDEVRESTAT)
3027 COMPATIBLE_IOCTL(HCIGETDEVLIST)
3028 COMPATIBLE_IOCTL(HCIGETDEVINFO)
3029 COMPATIBLE_IOCTL(HCIGETCONNLIST)
3030 COMPATIBLE_IOCTL(HCIGETCONNINFO)
3031 COMPATIBLE_IOCTL(HCISETRAW)
3032 COMPATIBLE_IOCTL(HCISETSCAN)
3033 COMPATIBLE_IOCTL(HCISETAUTH)
3034 COMPATIBLE_IOCTL(HCISETENCRYPT)
3035 COMPATIBLE_IOCTL(HCISETPTYPE)
3036 COMPATIBLE_IOCTL(HCISETLINKPOL)
3037 COMPATIBLE_IOCTL(HCISETLINKMODE)
3038 COMPATIBLE_IOCTL(HCISETACLMTU)
3039 COMPATIBLE_IOCTL(HCISETSCOMTU)
3040 COMPATIBLE_IOCTL(HCIINQUIRY)
3041 COMPATIBLE_IOCTL(HCIUARTSETPROTO)
3042 COMPATIBLE_IOCTL(HCIUARTGETPROTO)
3043 COMPATIBLE_IOCTL(RFCOMMCREATEDEV)
3044 COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
3045 COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
3046 COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
3047 COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
3048 COMPATIBLE_IOCTL(BNEPCONNADD)
3049 COMPATIBLE_IOCTL(BNEPCONNDEL)
3050 COMPATIBLE_IOCTL(BNEPGETCONNLIST)
3051 COMPATIBLE_IOCTL(BNEPGETCONNINFO)
3052 COMPATIBLE_IOCTL(CMTPCONNADD)
3053 COMPATIBLE_IOCTL(CMTPCONNDEL)
3054 COMPATIBLE_IOCTL(CMTPGETCONNLIST)
3055 COMPATIBLE_IOCTL(CMTPGETCONNINFO)
3056 COMPATIBLE_IOCTL(HIDPCONNADD)
3057 COMPATIBLE_IOCTL(HIDPCONNDEL)
3058 COMPATIBLE_IOCTL(HIDPGETCONNLIST)
3059 COMPATIBLE_IOCTL(HIDPGETCONNINFO)
3060 /* CAPI */
3061 COMPATIBLE_IOCTL(CAPI_REGISTER)
3062 COMPATIBLE_IOCTL(CAPI_GET_MANUFACTURER)
3063 COMPATIBLE_IOCTL(CAPI_GET_VERSION)
3064 COMPATIBLE_IOCTL(CAPI_GET_SERIAL)
3065 COMPATIBLE_IOCTL(CAPI_GET_PROFILE)
3066 COMPATIBLE_IOCTL(CAPI_MANUFACTURER_CMD)
3067 COMPATIBLE_IOCTL(CAPI_GET_ERRCODE)
3068 COMPATIBLE_IOCTL(CAPI_INSTALLED)
3069 COMPATIBLE_IOCTL(CAPI_GET_FLAGS)
3070 COMPATIBLE_IOCTL(CAPI_SET_FLAGS)
3071 COMPATIBLE_IOCTL(CAPI_CLR_FLAGS)
3072 COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT)
3073 COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT)
3074 /* Siemens Gigaset */
3075 COMPATIBLE_IOCTL(GIGASET_REDIR)
3076 COMPATIBLE_IOCTL(GIGASET_CONFIG)
3077 COMPATIBLE_IOCTL(GIGASET_BRKCHARS)
3078 COMPATIBLE_IOCTL(GIGASET_VERSION)
3079 /* Misc. */
3080 COMPATIBLE_IOCTL(0x41545900)            /* ATYIO_CLKR */
3081 COMPATIBLE_IOCTL(0x41545901)            /* ATYIO_CLKW */
3082 COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
3083 COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
3084 COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
3085 COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
3086 /* USB */
3087 COMPATIBLE_IOCTL(USBDEVFS_RESETEP)
3088 COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE)
3089 COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION)
3090 COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER)
3091 COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB)
3092 COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE)
3093 COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE)
3094 COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO)
3095 COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO)
3096 COMPATIBLE_IOCTL(USBDEVFS_RESET)
3097 COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32)
3098 COMPATIBLE_IOCTL(USBDEVFS_REAPURB32)
3099 COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32)
3100 COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
3101 /* MTD */
3102 COMPATIBLE_IOCTL(MEMGETINFO)
3103 COMPATIBLE_IOCTL(MEMERASE)
3104 COMPATIBLE_IOCTL(MEMLOCK)
3105 COMPATIBLE_IOCTL(MEMUNLOCK)
3106 COMPATIBLE_IOCTL(MEMGETREGIONCOUNT)
3107 COMPATIBLE_IOCTL(MEMGETREGIONINFO)
3108 COMPATIBLE_IOCTL(MEMGETBADBLOCK)
3109 COMPATIBLE_IOCTL(MEMSETBADBLOCK)
3110 /* NBD */
3111 ULONG_IOCTL(NBD_SET_SOCK)
3112 ULONG_IOCTL(NBD_SET_BLKSIZE)
3113 ULONG_IOCTL(NBD_SET_SIZE)
3114 COMPATIBLE_IOCTL(NBD_DO_IT)
3115 COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
3116 COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
3117 COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
3118 ULONG_IOCTL(NBD_SET_SIZE_BLOCKS)
3119 COMPATIBLE_IOCTL(NBD_DISCONNECT)
3120 /* i2c */
3121 COMPATIBLE_IOCTL(I2C_SLAVE)
3122 COMPATIBLE_IOCTL(I2C_SLAVE_FORCE)
3123 COMPATIBLE_IOCTL(I2C_TENBIT)
3124 COMPATIBLE_IOCTL(I2C_PEC)
3125 COMPATIBLE_IOCTL(I2C_RETRIES)
3126 COMPATIBLE_IOCTL(I2C_TIMEOUT)
3127 /* wireless */
3128 COMPATIBLE_IOCTL(SIOCSIWCOMMIT)
3129 COMPATIBLE_IOCTL(SIOCGIWNAME)
3130 COMPATIBLE_IOCTL(SIOCSIWNWID)
3131 COMPATIBLE_IOCTL(SIOCGIWNWID)
3132 COMPATIBLE_IOCTL(SIOCSIWFREQ)
3133 COMPATIBLE_IOCTL(SIOCGIWFREQ)
3134 COMPATIBLE_IOCTL(SIOCSIWMODE)
3135 COMPATIBLE_IOCTL(SIOCGIWMODE)
3136 COMPATIBLE_IOCTL(SIOCSIWSENS)
3137 COMPATIBLE_IOCTL(SIOCGIWSENS)
3138 COMPATIBLE_IOCTL(SIOCSIWRANGE)
3139 COMPATIBLE_IOCTL(SIOCSIWPRIV)
3140 COMPATIBLE_IOCTL(SIOCGIWPRIV)
3141 COMPATIBLE_IOCTL(SIOCSIWSTATS)
3142 COMPATIBLE_IOCTL(SIOCGIWSTATS)
3143 COMPATIBLE_IOCTL(SIOCSIWAP)
3144 COMPATIBLE_IOCTL(SIOCGIWAP)
3145 COMPATIBLE_IOCTL(SIOCSIWSCAN)
3146 COMPATIBLE_IOCTL(SIOCSIWRATE)
3147 COMPATIBLE_IOCTL(SIOCGIWRATE)
3148 COMPATIBLE_IOCTL(SIOCSIWRTS)
3149 COMPATIBLE_IOCTL(SIOCGIWRTS)
3150 COMPATIBLE_IOCTL(SIOCSIWFRAG)
3151 COMPATIBLE_IOCTL(SIOCGIWFRAG)
3152 COMPATIBLE_IOCTL(SIOCSIWTXPOW)
3153 COMPATIBLE_IOCTL(SIOCGIWTXPOW)
3154 COMPATIBLE_IOCTL(SIOCSIWRETRY)
3155 COMPATIBLE_IOCTL(SIOCGIWRETRY)
3156 COMPATIBLE_IOCTL(SIOCSIWPOWER)
3157 COMPATIBLE_IOCTL(SIOCGIWPOWER)
3158 /* hiddev */
3159 COMPATIBLE_IOCTL(HIDIOCGVERSION)
3160 COMPATIBLE_IOCTL(HIDIOCAPPLICATION)
3161 COMPATIBLE_IOCTL(HIDIOCGDEVINFO)
3162 COMPATIBLE_IOCTL(HIDIOCGSTRING)
3163 COMPATIBLE_IOCTL(HIDIOCINITREPORT)
3164 COMPATIBLE_IOCTL(HIDIOCGREPORT)
3165 COMPATIBLE_IOCTL(HIDIOCSREPORT)
3166 COMPATIBLE_IOCTL(HIDIOCGREPORTINFO)
3167 COMPATIBLE_IOCTL(HIDIOCGFIELDINFO)
3168 COMPATIBLE_IOCTL(HIDIOCGUSAGE)
3169 COMPATIBLE_IOCTL(HIDIOCSUSAGE)
3170 COMPATIBLE_IOCTL(HIDIOCGUCODE)
3171 COMPATIBLE_IOCTL(HIDIOCGFLAG)
3172 COMPATIBLE_IOCTL(HIDIOCSFLAG)
3173 COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINDEX)
3174 COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINFO)
3175 /* dvb */
3176 COMPATIBLE_IOCTL(AUDIO_STOP)
3177 COMPATIBLE_IOCTL(AUDIO_PLAY)
3178 COMPATIBLE_IOCTL(AUDIO_PAUSE)
3179 COMPATIBLE_IOCTL(AUDIO_CONTINUE)
3180 COMPATIBLE_IOCTL(AUDIO_SELECT_SOURCE)
3181 COMPATIBLE_IOCTL(AUDIO_SET_MUTE)
3182 COMPATIBLE_IOCTL(AUDIO_SET_AV_SYNC)
3183 COMPATIBLE_IOCTL(AUDIO_SET_BYPASS_MODE)
3184 COMPATIBLE_IOCTL(AUDIO_CHANNEL_SELECT)
3185 COMPATIBLE_IOCTL(AUDIO_GET_STATUS)
3186 COMPATIBLE_IOCTL(AUDIO_GET_CAPABILITIES)
3187 COMPATIBLE_IOCTL(AUDIO_CLEAR_BUFFER)
3188 COMPATIBLE_IOCTL(AUDIO_SET_ID)
3189 COMPATIBLE_IOCTL(AUDIO_SET_MIXER)
3190 COMPATIBLE_IOCTL(AUDIO_SET_STREAMTYPE)
3191 COMPATIBLE_IOCTL(AUDIO_SET_EXT_ID)
3192 COMPATIBLE_IOCTL(AUDIO_SET_ATTRIBUTES)
3193 COMPATIBLE_IOCTL(AUDIO_SET_KARAOKE)
3194 COMPATIBLE_IOCTL(DMX_START)
3195 COMPATIBLE_IOCTL(DMX_STOP)
3196 COMPATIBLE_IOCTL(DMX_SET_FILTER)
3197 COMPATIBLE_IOCTL(DMX_SET_PES_FILTER)
3198 COMPATIBLE_IOCTL(DMX_SET_BUFFER_SIZE)
3199 COMPATIBLE_IOCTL(DMX_GET_PES_PIDS)
3200 COMPATIBLE_IOCTL(DMX_GET_CAPS)
3201 COMPATIBLE_IOCTL(DMX_SET_SOURCE)
3202 COMPATIBLE_IOCTL(DMX_GET_STC)
3203 COMPATIBLE_IOCTL(FE_GET_INFO)
3204 COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD)
3205 COMPATIBLE_IOCTL(FE_DISEQC_SEND_MASTER_CMD)
3206 COMPATIBLE_IOCTL(FE_DISEQC_RECV_SLAVE_REPLY)
3207 COMPATIBLE_IOCTL(FE_DISEQC_SEND_BURST)
3208 COMPATIBLE_IOCTL(FE_SET_TONE)
3209 COMPATIBLE_IOCTL(FE_SET_VOLTAGE)
3210 COMPATIBLE_IOCTL(FE_ENABLE_HIGH_LNB_VOLTAGE)
3211 COMPATIBLE_IOCTL(FE_READ_STATUS)
3212 COMPATIBLE_IOCTL(FE_READ_BER)
3213 COMPATIBLE_IOCTL(FE_READ_SIGNAL_STRENGTH)
3214 COMPATIBLE_IOCTL(FE_READ_SNR)
3215 COMPATIBLE_IOCTL(FE_READ_UNCORRECTED_BLOCKS)
3216 COMPATIBLE_IOCTL(FE_SET_FRONTEND)
3217 COMPATIBLE_IOCTL(FE_GET_FRONTEND)
3218 COMPATIBLE_IOCTL(FE_GET_EVENT)
3219 COMPATIBLE_IOCTL(FE_DISHNETWORK_SEND_LEGACY_CMD)
3220 COMPATIBLE_IOCTL(VIDEO_STOP)
3221 COMPATIBLE_IOCTL(VIDEO_PLAY)
3222 COMPATIBLE_IOCTL(VIDEO_FREEZE)
3223 COMPATIBLE_IOCTL(VIDEO_CONTINUE)
3224 COMPATIBLE_IOCTL(VIDEO_SELECT_SOURCE)
3225 COMPATIBLE_IOCTL(VIDEO_SET_BLANK)
3226 COMPATIBLE_IOCTL(VIDEO_GET_STATUS)
3227 COMPATIBLE_IOCTL(VIDEO_SET_DISPLAY_FORMAT)
3228 COMPATIBLE_IOCTL(VIDEO_FAST_FORWARD)
3229 COMPATIBLE_IOCTL(VIDEO_SLOWMOTION)
3230 COMPATIBLE_IOCTL(VIDEO_GET_CAPABILITIES)
3231 COMPATIBLE_IOCTL(VIDEO_CLEAR_BUFFER)
3232 COMPATIBLE_IOCTL(VIDEO_SET_ID)
3233 COMPATIBLE_IOCTL(VIDEO_SET_STREAMTYPE)
3234 COMPATIBLE_IOCTL(VIDEO_SET_FORMAT)
3235 COMPATIBLE_IOCTL(VIDEO_SET_SYSTEM)
3236 COMPATIBLE_IOCTL(VIDEO_SET_HIGHLIGHT)
3237 COMPATIBLE_IOCTL(VIDEO_SET_SPU)
3238 COMPATIBLE_IOCTL(VIDEO_GET_NAVI)
3239 COMPATIBLE_IOCTL(VIDEO_SET_ATTRIBUTES)
3240 COMPATIBLE_IOCTL(VIDEO_GET_SIZE)
3241 COMPATIBLE_IOCTL(VIDEO_GET_FRAME_RATE)
3242
3243 /* now things that need handlers */
3244 HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob)
3245 HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob)
3246 #ifdef CONFIG_NET
3247 HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
3248 HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)
3249 HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc)
3250 HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc)
3251 HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc)
3252 HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc)
3253 HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc)
3254 HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc)
3255 HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc)
3256 HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc)
3257 HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc)
3258 HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc)
3259 HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc)
3260 HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc)
3261 HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc)
3262 HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc)
3263 HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
3264 HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
3265 HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
3266 HANDLE_IOCTL(SIOCSIFHWBROADCAST, dev_ifsioc)
3267
3268 /* ioctls used by appletalk ddp.c */
3269 HANDLE_IOCTL(SIOCATALKDIFADDR, dev_ifsioc)
3270 HANDLE_IOCTL(SIOCDIFADDR, dev_ifsioc)
3271 HANDLE_IOCTL(SIOCSARP, dev_ifsioc)
3272 HANDLE_IOCTL(SIOCDARP, dev_ifsioc)
3273
3274 HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc)
3275 HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc)
3276 HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc)
3277 HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc)
3278 HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc)
3279 HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc)
3280 HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc)
3281 HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc)
3282 HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc)
3283 HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc)
3284 HANDLE_IOCTL(TUNSETIFF, dev_ifsioc)
3285 HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl)
3286 HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl)
3287 HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl)
3288 HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl)
3289 HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl)
3290 HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl)
3291 HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl)
3292 HANDLE_IOCTL(SIOCADDRT, routing_ioctl)
3293 HANDLE_IOCTL(SIOCDELRT, routing_ioctl)
3294 HANDLE_IOCTL(SIOCBRADDIF, dev_ifsioc)
3295 HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc)
3296 /* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
3297 HANDLE_IOCTL(SIOCRTMSG, ret_einval)
3298 HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
3299 HANDLE_IOCTL(SIOCGSTAMPNS, do_siocgstampns)
3300 #endif
3301 #ifdef CONFIG_BLOCK
3302 HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo)
3303 HANDLE_IOCTL(BLKRAGET, w_long)
3304 HANDLE_IOCTL(BLKGETSIZE, w_long)
3305 HANDLE_IOCTL(0x1260, broken_blkgetsize)
3306 HANDLE_IOCTL(BLKFRAGET, w_long)
3307 HANDLE_IOCTL(BLKSECTGET, w_long)
3308 HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
3309 HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans)
3310 HANDLE_IOCTL(HDIO_GET_MULTCOUNT, hdio_ioctl_trans)
3311 HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans)
3312 HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans)
3313 HANDLE_IOCTL(HDIO_GET_NOWERR, hdio_ioctl_trans)
3314 HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans)
3315 HANDLE_IOCTL(HDIO_GET_NICE, hdio_ioctl_trans)
3316 HANDLE_IOCTL(HDIO_GET_WCACHE, hdio_ioctl_trans)
3317 HANDLE_IOCTL(HDIO_GET_ACOUSTIC, hdio_ioctl_trans)
3318 HANDLE_IOCTL(HDIO_GET_ADDRESS, hdio_ioctl_trans)
3319 HANDLE_IOCTL(HDIO_GET_BUSSTATE, hdio_ioctl_trans)
3320 HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans)
3321 HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans)
3322 HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans)
3323 HANDLE_IOCTL(FDSETDRVPRM32, fd_ioctl_trans)
3324 HANDLE_IOCTL(FDGETDRVPRM32, fd_ioctl_trans)
3325 HANDLE_IOCTL(FDGETDRVSTAT32, fd_ioctl_trans)
3326 HANDLE_IOCTL(FDPOLLDRVSTAT32, fd_ioctl_trans)
3327 HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans)
3328 HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans)
3329 HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
3330 HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans)
3331 #endif
3332 HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans)
3333 HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans)
3334 HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans)
3335 HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans)
3336 #ifdef CONFIG_BLOCK
3337 HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans)
3338 HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans)
3339 HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans)
3340 HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans)
3341 #endif
3342 #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
3343 HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout)
3344 #ifdef CONFIG_VT
3345 HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl)
3346 HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl)
3347 HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl)
3348 HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl)
3349 HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl)
3350 #endif
3351 /* One SMB ioctl needs translations. */
3352 #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
3353 HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
3354 HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl)
3355 HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl)
3356 HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl)
3357 HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl)
3358 HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl)
3359 HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl)
3360 HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl)
3361 HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl)
3362 HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl)
3363 HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl)
3364 HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl)
3365 HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl)
3366 HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl)
3367 HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl)
3368 HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl)
3369 HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl)
3370 HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl)
3371 HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl)
3372 HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl)
3373 HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl)
3374 HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl)
3375 HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl)
3376 HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl)
3377 HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl)
3378 HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl)
3379 /* block stuff */
3380 #ifdef CONFIG_BLOCK
3381 HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget)
3382 HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset)
3383 HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64)
3384 /* Raw devices */
3385 HANDLE_IOCTL(RAW_SETBIND, raw_ioctl)
3386 HANDLE_IOCTL(RAW_GETBIND, raw_ioctl)
3387 #endif
3388 /* Serial */
3389 HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl)
3390 HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl)
3391 #ifdef TIOCGLTC
3392 COMPATIBLE_IOCTL(TIOCGLTC)
3393 COMPATIBLE_IOCTL(TIOCSLTC)
3394 #endif
3395 #ifdef TIOCSTART
3396 /*
3397  * For these two we have defintions in ioctls.h and/or termios.h on
3398  * some architectures but no actual implemention.  Some applications
3399  * like bash call them if they are defined in the headers, so we provide
3400  * entries here to avoid syslog message spew.
3401  */
3402 COMPATIBLE_IOCTL(TIOCSTART)
3403 COMPATIBLE_IOCTL(TIOCSTOP)
3404 #endif
3405 /* Usbdevfs */
3406 HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
3407 HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
3408 HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
3409 COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
3410 /* i2c */
3411 HANDLE_IOCTL(I2C_FUNCS, w_long)
3412 HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
3413 HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
3414 /* wireless */
3415 HANDLE_IOCTL(SIOCGIWRANGE, do_wireless_ioctl)
3416 HANDLE_IOCTL(SIOCGIWPRIV, do_wireless_ioctl)
3417 HANDLE_IOCTL(SIOCGIWSTATS, do_wireless_ioctl)
3418 HANDLE_IOCTL(SIOCSIWSPY, do_wireless_ioctl)
3419 HANDLE_IOCTL(SIOCGIWSPY, do_wireless_ioctl)
3420 HANDLE_IOCTL(SIOCSIWTHRSPY, do_wireless_ioctl)
3421 HANDLE_IOCTL(SIOCGIWTHRSPY, do_wireless_ioctl)
3422 HANDLE_IOCTL(SIOCSIWMLME, do_wireless_ioctl)
3423 HANDLE_IOCTL(SIOCGIWAPLIST, do_wireless_ioctl)
3424 HANDLE_IOCTL(SIOCSIWSCAN, do_wireless_ioctl)
3425 HANDLE_IOCTL(SIOCGIWSCAN, do_wireless_ioctl)
3426 HANDLE_IOCTL(SIOCSIWESSID, do_wireless_ioctl)
3427 HANDLE_IOCTL(SIOCGIWESSID, do_wireless_ioctl)
3428 HANDLE_IOCTL(SIOCSIWNICKN, do_wireless_ioctl)
3429 HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl)
3430 HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl)
3431 HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl)
3432 HANDLE_IOCTL(SIOCSIWGENIE, do_wireless_ioctl)
3433 HANDLE_IOCTL(SIOCGIWGENIE, do_wireless_ioctl)
3434 HANDLE_IOCTL(SIOCSIWENCODEEXT, do_wireless_ioctl)
3435 HANDLE_IOCTL(SIOCGIWENCODEEXT, do_wireless_ioctl)
3436 HANDLE_IOCTL(SIOCSIWPMKSA, do_wireless_ioctl)
3437 HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl)
3438 HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl)
3439 /* Not implemented in the native kernel */
3440 IGNORE_IOCTL(SIOCGIFCOUNT)
3441 HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl)
3442 HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl)
3443 HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl)
3444 HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl)
3445
3446 /* dvb */
3447 HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event)
3448 HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture)
3449 HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette)
3450
3451 /* parport */
3452 COMPATIBLE_IOCTL(LPTIME)
3453 COMPATIBLE_IOCTL(LPCHAR)
3454 COMPATIBLE_IOCTL(LPABORTOPEN)
3455 COMPATIBLE_IOCTL(LPCAREFUL)
3456 COMPATIBLE_IOCTL(LPWAIT)
3457 COMPATIBLE_IOCTL(LPSETIRQ)
3458 COMPATIBLE_IOCTL(LPGETSTATUS)
3459 COMPATIBLE_IOCTL(LPGETSTATUS)
3460 COMPATIBLE_IOCTL(LPRESET)
3461 /*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/
3462 COMPATIBLE_IOCTL(LPGETFLAGS)
3463 HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans)
3464
3465 /* fat 'r' ioctls. These are handled by fat with ->compat_ioctl,
3466    but we don't want warnings on other file systems. So declare
3467    them as compatible here. */
3468 #define VFAT_IOCTL_READDIR_BOTH32       _IOR('r', 1, struct compat_dirent[2])
3469 #define VFAT_IOCTL_READDIR_SHORT32      _IOR('r', 2, struct compat_dirent[2])
3470
3471 IGNORE_IOCTL(VFAT_IOCTL_READDIR_BOTH32)
3472 IGNORE_IOCTL(VFAT_IOCTL_READDIR_SHORT32)
3473 };
3474
3475 #define IOCTL_HASHSIZE 256
3476 static struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE];
3477
3478 static inline unsigned long ioctl32_hash(unsigned long cmd)
3479 {
3480         return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE;
3481 }
3482
3483 static void compat_ioctl_error(struct file *filp, unsigned int fd,
3484                 unsigned int cmd, unsigned long arg)
3485 {
3486         char buf[10];
3487         char *fn = "?";
3488         char *path;
3489
3490         /* find the name of the device. */
3491         path = (char *)__get_free_page(GFP_KERNEL);
3492         if (path) {
3493                 fn = d_path(filp->f_path.dentry, filp->f_path.mnt, path, PAGE_SIZE);
3494                 if (IS_ERR(fn))
3495                         fn = "?";
3496         }
3497
3498          sprintf(buf,"'%c'", (cmd>>_IOC_TYPESHIFT) & _IOC_TYPEMASK);
3499         if (!isprint(buf[1]))
3500                 sprintf(buf, "%02x", buf[1]);
3501         compat_printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
3502                         "cmd(%08x){t:%s;sz:%u} arg(%08x) on %s\n",
3503                         current->comm, current->pid,
3504                         (int)fd, (unsigned int)cmd, buf,
3505                         (cmd >> _IOC_SIZESHIFT) & _IOC_SIZEMASK,
3506                         (unsigned int)arg, fn);
3507
3508         if (path)
3509                 free_page((unsigned long)path);
3510 }
3511
3512 asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
3513                                 unsigned long arg)
3514 {
3515         struct file *filp;
3516         int error = -EBADF;
3517         struct ioctl_trans *t;
3518         int fput_needed;
3519
3520         filp = fget_light(fd, &fput_needed);
3521         if (!filp)
3522                 goto out;
3523
3524         /* RED-PEN how should LSM module know it's handling 32bit? */
3525         error = security_file_ioctl(filp, cmd, arg);
3526         if (error)
3527                 goto out_fput;
3528
3529         /*
3530          * To allow the compat_ioctl handlers to be self contained
3531          * we need to check the common ioctls here first.
3532          * Just handle them with the standard handlers below.
3533          */
3534         switch (cmd) {
3535         case FIOCLEX:
3536         case FIONCLEX:
3537         case FIONBIO:
3538         case FIOASYNC:
3539         case FIOQSIZE:
3540                 break;
3541
3542         case FIBMAP:
3543         case FIGETBSZ:
3544         case FIONREAD:
3545                 if (S_ISREG(filp->f_path.dentry->d_inode->i_mode))
3546                         break;
3547                 /*FALL THROUGH*/
3548
3549         default:
3550                 if (filp->f_op && filp->f_op->compat_ioctl) {
3551                         error = filp->f_op->compat_ioctl(filp, cmd, arg);
3552                         if (error != -ENOIOCTLCMD)
3553                                 goto out_fput;
3554                 }
3555
3556                 if (!filp->f_op ||
3557                     (!filp->f_op->ioctl && !filp->f_op->unlocked_ioctl))
3558                         goto do_ioctl;
3559                 break;
3560         }
3561
3562         for (t = ioctl32_hash_table[ioctl32_hash(cmd)]; t; t = t->next) {
3563                 if (t->cmd == cmd)
3564                         goto found_handler;
3565         }
3566
3567         if (S_ISSOCK(filp->f_path.dentry->d_inode->i_mode) &&
3568             cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) {
3569                 error = siocdevprivate_ioctl(fd, cmd, arg);
3570         } else {
3571                 static int count;
3572
3573                 if (++count <= 50)
3574                         compat_ioctl_error(filp, fd, cmd, arg);
3575                 error = -EINVAL;
3576         }
3577
3578         goto out_fput;
3579
3580  found_handler:
3581         if (t->handler) {
3582                 lock_kernel();
3583                 error = t->handler(fd, cmd, arg, filp);
3584                 unlock_kernel();
3585                 goto out_fput;
3586         }
3587
3588  do_ioctl:
3589         error = vfs_ioctl(filp, fd, cmd, arg);
3590  out_fput:
3591         fput_light(filp, fput_needed);
3592  out:
3593         return error;
3594 }
3595
3596 static void ioctl32_insert_translation(struct ioctl_trans *trans)
3597 {
3598         unsigned long hash;
3599         struct ioctl_trans *t;
3600
3601         hash = ioctl32_hash (trans->cmd);
3602         if (!ioctl32_hash_table[hash])
3603                 ioctl32_hash_table[hash] = trans;
3604         else {
3605                 t = ioctl32_hash_table[hash];
3606                 while (t->next)
3607                         t = t->next;
3608                 trans->next = NULL;
3609                 t->next = trans;
3610         }
3611 }
3612
3613 static int __init init_sys32_ioctl(void)
3614 {
3615         int i;
3616
3617         for (i = 0; i < ARRAY_SIZE(ioctl_start); i++) {
3618                 if (ioctl_start[i].next != 0) {
3619                         printk("ioctl translation %d bad\n",i);
3620                         return -1;
3621                 }
3622
3623                 ioctl32_insert_translation(&ioctl_start[i]);
3624         }
3625         return 0;
3626 }
3627 __initcall(init_sys32_ioctl);