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