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