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