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