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