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