]> bbs.cooldavid.org Git - net-next-2.6.git/blame - fs/compat_ioctl.c
compat_ioctl: inline all conversion handlers
[net-next-2.6.git] / fs / compat_ioctl.c
CommitLineData
1da177e4
LT
1/*
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
3fee37c1
AM
13#include <linux/joystick.h>
14
1da177e4
LT
15#include <linux/types.h>
16#include <linux/compat.h>
17#include <linux/kernel.h>
16f7e0fe 18#include <linux/capability.h>
1da177e4
LT
19#include <linux/compiler.h>
20#include <linux/sched.h>
21#include <linux/smp.h>
405f5571 22#include <linux/smp_lock.h>
1da177e4
LT
23#include <linux/ioctl.h>
24#include <linux/if.h>
25#include <linux/if_bridge.h>
26#include <linux/slab.h>
bff61975 27#include <linux/raid/md_u.h>
1da177e4 28#include <linux/kd.h>
1da177e4
LT
29#include <linux/route.h>
30#include <linux/in6.h>
31#include <linux/ipv6_route.h>
32#include <linux/skbuff.h>
33#include <linux/netlink.h>
34#include <linux/vt.h>
3e63cbb1 35#include <linux/falloc.h>
1da177e4
LT
36#include <linux/fs.h>
37#include <linux/file.h>
1da177e4
LT
38#include <linux/ppp_defs.h>
39#include <linux/if_ppp.h>
40#include <linux/if_pppox.h>
41#include <linux/mtio.h>
1da177e4
LT
42#include <linux/auto_fs.h>
43#include <linux/auto_fs4.h>
1da177e4
LT
44#include <linux/tty.h>
45#include <linux/vt_kern.h>
46#include <linux/fb.h>
1da177e4
LT
47#include <linux/videodev.h>
48#include <linux/netdevice.h>
49#include <linux/raw.h>
50#include <linux/smb_fs.h>
1da177e4
LT
51#include <linux/blkdev.h>
52#include <linux/elevator.h>
53#include <linux/rtc.h>
54#include <linux/pci.h>
55#include <linux/module.h>
56#include <linux/serial.h>
1da177e4
LT
57#include <linux/if_tun.h>
58#include <linux/ctype.h>
1da177e4 59#include <linux/syscalls.h>
1da177e4
LT
60#include <linux/i2c.h>
61#include <linux/i2c-dev.h>
1da177e4
LT
62#include <linux/atalk.h>
63
1da177e4
LT
64#include <net/bluetooth/bluetooth.h>
65#include <net/bluetooth/hci.h>
66#include <net/bluetooth/rfcomm.h>
67
68#include <linux/capi.h>
5024ad4a 69#include <linux/gigaset_dev.h>
1da177e4 70
3c3622dc 71#ifdef CONFIG_BLOCK
1ba0c7db 72#include <linux/loop.h>
1da177e4 73#include <scsi/scsi.h>
1da177e4 74#include <scsi/scsi_ioctl.h>
1da177e4 75#include <scsi/sg.h>
3c3622dc 76#endif
1da177e4 77
1da177e4
LT
78#include <asm/uaccess.h>
79#include <linux/ethtool.h>
80#include <linux/mii.h>
81#include <linux/if_bonding.h>
82#include <linux/watchdog.h>
1da177e4 83
1da177e4
LT
84#include <linux/soundcard.h>
85#include <linux/lp.h>
86#include <linux/ppdev.h>
87
88#include <linux/atm.h>
89#include <linux/atmarp.h>
90#include <linux/atmclip.h>
91#include <linux/atmdev.h>
92#include <linux/atmioc.h>
93#include <linux/atmlec.h>
94#include <linux/atmmpc.h>
95#include <linux/atmsvc.h>
96#include <linux/atm_tcp.h>
97#include <linux/sonet.h>
98#include <linux/atm_suni.h>
1da177e4
LT
99
100#include <linux/usb.h>
101#include <linux/usbdevice_fs.h>
102#include <linux/nbd.h>
103#include <linux/random.h>
104#include <linux/filter.h>
1da177e4
LT
105#include <linux/pktcdvd.h>
106
107#include <linux/hiddev.h>
108
6e87abd0
DM
109#include <linux/dvb/audio.h>
110#include <linux/dvb/dmx.h>
111#include <linux/dvb/frontend.h>
112#include <linux/dvb/video.h>
113
8163904e
DM
114#ifdef CONFIG_SPARC
115#include <asm/fbio.h>
116#endif
117
e6a6d2ef
CH
118static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
119 unsigned long arg, struct file *f)
120{
121 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
122}
123
1da177e4
LT
124static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
125{
126 mm_segment_t old_fs = get_fs();
127 int err;
128 unsigned long val;
129
130 set_fs (KERNEL_DS);
131 err = sys_ioctl(fd, cmd, (unsigned long)&val);
132 set_fs (old_fs);
133 if (!err && put_user(val, (u32 __user *)compat_ptr(arg)))
134 return -EFAULT;
135 return err;
136}
137
138static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg)
139{
140 mm_segment_t old_fs = get_fs();
141 u32 __user *argptr = compat_ptr(arg);
142 int err;
143 unsigned long val;
144
145 if(get_user(val, argptr))
146 return -EFAULT;
147 set_fs (KERNEL_DS);
148 err = sys_ioctl(fd, cmd, (unsigned long)&val);
149 set_fs (old_fs);
150 if (!err && put_user(val, argptr))
151 return -EFAULT;
152 return err;
153}
154
6e87abd0
DM
155struct compat_video_event {
156 int32_t type;
157 compat_time_t timestamp;
158 union {
159 video_size_t size;
160 unsigned int frame_rate;
161 } u;
162};
163
164static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long arg)
165{
166 struct video_event kevent;
167 mm_segment_t old_fs = get_fs();
168 int err;
169
170 set_fs(KERNEL_DS);
171 err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
172 set_fs(old_fs);
173
174 if (!err) {
175 struct compat_video_event __user *up = compat_ptr(arg);
176
177 err = put_user(kevent.type, &up->type);
178 err |= put_user(kevent.timestamp, &up->timestamp);
179 err |= put_user(kevent.u.size.w, &up->u.size.w);
180 err |= put_user(kevent.u.size.h, &up->u.size.h);
181 err |= put_user(kevent.u.size.aspect_ratio,
182 &up->u.size.aspect_ratio);
183 if (err)
184 err = -EFAULT;
185 }
186
187 return err;
188}
189
190struct compat_video_still_picture {
191 compat_uptr_t iFrame;
192 int32_t size;
193};
194
195static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned long arg)
196{
197 struct compat_video_still_picture __user *up;
198 struct video_still_picture __user *up_native;
199 compat_uptr_t fp;
200 int32_t size;
201 int err;
202
203 up = (struct compat_video_still_picture __user *) arg;
204 err = get_user(fp, &up->iFrame);
205 err |= get_user(size, &up->size);
206 if (err)
207 return -EFAULT;
208
209 up_native =
210 compat_alloc_user_space(sizeof(struct video_still_picture));
211
7116e994
HC
212 err = put_user(compat_ptr(fp), &up_native->iFrame);
213 err |= put_user(size, &up_native->size);
214 if (err)
215 return -EFAULT;
6e87abd0
DM
216
217 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
218
219 return err;
220}
221
222struct compat_video_spu_palette {
223 int length;
224 compat_uptr_t palette;
225};
226
227static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned long arg)
228{
229 struct compat_video_spu_palette __user *up;
230 struct video_spu_palette __user *up_native;
231 compat_uptr_t palp;
232 int length, err;
233
234 up = (struct compat_video_spu_palette __user *) arg;
235 err = get_user(palp, &up->palette);
236 err |= get_user(length, &up->length);
237
238 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
7116e994
HC
239 err = put_user(compat_ptr(palp), &up_native->palette);
240 err |= put_user(length, &up_native->length);
241 if (err)
242 return -EFAULT;
6e87abd0
DM
243
244 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
245
246 return err;
247}
248
9361401e 249#ifdef CONFIG_BLOCK
1da177e4
LT
250typedef struct sg_io_hdr32 {
251 compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */
252 compat_int_t dxfer_direction; /* [i] data transfer direction */
253 unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
254 unsigned char mx_sb_len; /* [i] max length to write to sbp */
255 unsigned short iovec_count; /* [i] 0 implies no scatter gather */
256 compat_uint_t dxfer_len; /* [i] byte count of data transfer */
257 compat_uint_t dxferp; /* [i], [*io] points to data transfer memory
258 or scatter gather list */
259 compat_uptr_t cmdp; /* [i], [*i] points to command to perform */
260 compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */
261 compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
262 compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */
263 compat_int_t pack_id; /* [i->o] unused internally (normally) */
264 compat_uptr_t usr_ptr; /* [i->o] unused internally */
265 unsigned char status; /* [o] scsi status */
266 unsigned char masked_status; /* [o] shifted, masked scsi status */
267 unsigned char msg_status; /* [o] messaging level data (optional) */
268 unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
269 unsigned short host_status; /* [o] errors from host adapter */
270 unsigned short driver_status; /* [o] errors from software driver */
271 compat_int_t resid; /* [o] dxfer_len - actual_transferred */
272 compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */
273 compat_uint_t info; /* [o] auxiliary information */
274} sg_io_hdr32_t; /* 64 bytes long (on sparc32) */
275
276typedef struct sg_iovec32 {
277 compat_uint_t iov_base;
278 compat_uint_t iov_len;
279} sg_iovec32_t;
280
281static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count)
282{
283 sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1);
284 sg_iovec32_t __user *iov32 = dxferp;
285 int i;
286
287 for (i = 0; i < iovec_count; i++) {
288 u32 base, len;
289
290 if (get_user(base, &iov32[i].iov_base) ||
291 get_user(len, &iov32[i].iov_len) ||
292 put_user(compat_ptr(base), &iov[i].iov_base) ||
293 put_user(len, &iov[i].iov_len))
294 return -EFAULT;
295 }
296
297 if (put_user(iov, &sgio->dxferp))
298 return -EFAULT;
299 return 0;
300}
301
302static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
303{
304 sg_io_hdr_t __user *sgio;
305 sg_io_hdr32_t __user *sgio32;
306 u16 iovec_count;
307 u32 data;
308 void __user *dxferp;
309 int err;
310
311 sgio32 = compat_ptr(arg);
312 if (get_user(iovec_count, &sgio32->iovec_count))
313 return -EFAULT;
314
315 {
316 void __user *top = compat_alloc_user_space(0);
317 void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) +
318 (iovec_count * sizeof(sg_iovec_t)));
319 if (new > top)
320 return -EINVAL;
321
322 sgio = new;
323 }
324
325 /* Ok, now construct. */
326 if (copy_in_user(&sgio->interface_id, &sgio32->interface_id,
327 (2 * sizeof(int)) +
328 (2 * sizeof(unsigned char)) +
329 (1 * sizeof(unsigned short)) +
330 (1 * sizeof(unsigned int))))
331 return -EFAULT;
332
333 if (get_user(data, &sgio32->dxferp))
334 return -EFAULT;
335 dxferp = compat_ptr(data);
336 if (iovec_count) {
337 if (sg_build_iovec(sgio, dxferp, iovec_count))
338 return -EFAULT;
339 } else {
340 if (put_user(dxferp, &sgio->dxferp))
341 return -EFAULT;
342 }
343
344 {
345 unsigned char __user *cmdp;
346 unsigned char __user *sbp;
347
348 if (get_user(data, &sgio32->cmdp))
349 return -EFAULT;
350 cmdp = compat_ptr(data);
351
352 if (get_user(data, &sgio32->sbp))
353 return -EFAULT;
354 sbp = compat_ptr(data);
355
356 if (put_user(cmdp, &sgio->cmdp) ||
357 put_user(sbp, &sgio->sbp))
358 return -EFAULT;
359 }
360
361 if (copy_in_user(&sgio->timeout, &sgio32->timeout,
362 3 * sizeof(int)))
363 return -EFAULT;
364
365 if (get_user(data, &sgio32->usr_ptr))
366 return -EFAULT;
367 if (put_user(compat_ptr(data), &sgio->usr_ptr))
368 return -EFAULT;
369
1da177e4
LT
370 err = sys_ioctl(fd, cmd, (unsigned long) sgio);
371
372 if (err >= 0) {
373 void __user *datap;
374
375 if (copy_in_user(&sgio32->pack_id, &sgio->pack_id,
376 sizeof(int)) ||
377 get_user(datap, &sgio->usr_ptr) ||
378 put_user((u32)(unsigned long)datap,
379 &sgio32->usr_ptr) ||
380 copy_in_user(&sgio32->status, &sgio->status,
381 (4 * sizeof(unsigned char)) +
382 (2 * sizeof(unsigned short)) +
383 (3 * sizeof(int))))
384 err = -EFAULT;
385 }
386
387 return err;
388}
389
2966387b
AK
390struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
391 char req_state;
392 char orphan;
393 char sg_io_owned;
394 char problem;
395 int pack_id;
396 compat_uptr_t usr_ptr;
397 unsigned int duration;
398 int unused;
399};
400
401static int sg_grt_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
402{
403 int err, i;
6b2b4e5a
AV
404 sg_req_info_t __user *r;
405 struct compat_sg_req_info __user *o = (void __user *)arg;
2966387b
AK
406 r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE);
407 err = sys_ioctl(fd,cmd,(unsigned long)r);
408 if (err < 0)
409 return err;
410 for (i = 0; i < SG_MAX_QUEUE; i++) {
411 void __user *ptr;
412 int d;
413
414 if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) ||
415 get_user(ptr, &r[i].usr_ptr) ||
416 get_user(d, &r[i].duration) ||
417 put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) ||
418 put_user(d, &o[i].duration))
419 return -EFAULT;
420 }
421 return err;
422}
9361401e 423#endif /* CONFIG_BLOCK */
2966387b 424
1da177e4
LT
425struct sock_fprog32 {
426 unsigned short len;
427 compat_caddr_t filter;
428};
429
430#define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
431#define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
432
433static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
434{
435 struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg);
436 struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
437 void __user *fptr64;
438 u32 fptr32;
439 u16 flen;
440
441 if (get_user(flen, &u_fprog32->len) ||
442 get_user(fptr32, &u_fprog32->filter))
443 return -EFAULT;
444
445 fptr64 = compat_ptr(fptr32);
446
447 if (put_user(flen, &u_fprog64->len) ||
448 put_user(fptr64, &u_fprog64->filter))
449 return -EFAULT;
450
451 if (cmd == PPPIOCSPASS32)
452 cmd = PPPIOCSPASS;
453 else
454 cmd = PPPIOCSACTIVE;
455
456 return sys_ioctl(fd, cmd, (unsigned long) u_fprog64);
457}
458
459struct ppp_option_data32 {
460 compat_caddr_t ptr;
461 u32 length;
462 compat_int_t transmit;
463};
464#define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
465
466struct ppp_idle32 {
467 compat_time_t xmit_idle;
468 compat_time_t recv_idle;
469};
470#define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
471
472static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg)
473{
474 struct ppp_idle __user *idle;
475 struct ppp_idle32 __user *idle32;
476 __kernel_time_t xmit, recv;
477 int err;
478
479 idle = compat_alloc_user_space(sizeof(*idle));
480 idle32 = compat_ptr(arg);
481
482 err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle);
483
484 if (!err) {
485 if (get_user(xmit, &idle->xmit_idle) ||
486 get_user(recv, &idle->recv_idle) ||
487 put_user(xmit, &idle32->xmit_idle) ||
488 put_user(recv, &idle32->recv_idle))
489 err = -EFAULT;
490 }
491 return err;
492}
493
494static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg)
495{
496 struct ppp_option_data __user *odata;
497 struct ppp_option_data32 __user *odata32;
498 __u32 data;
499 void __user *datap;
500
501 odata = compat_alloc_user_space(sizeof(*odata));
502 odata32 = compat_ptr(arg);
503
504 if (get_user(data, &odata32->ptr))
505 return -EFAULT;
506
507 datap = compat_ptr(data);
508 if (put_user(datap, &odata->ptr))
509 return -EFAULT;
510
511 if (copy_in_user(&odata->length, &odata32->length,
512 sizeof(__u32) + sizeof(int)))
513 return -EFAULT;
514
515 return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata);
516}
517
518static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
519{
520 int err;
521
522 switch (cmd) {
523 case PPPIOCGIDLE32:
524 err = ppp_gidle(fd, cmd, arg);
525 break;
526
527 case PPPIOCSCOMPRESS32:
528 err = ppp_scompress(fd, cmd, arg);
529 break;
530
531 default:
532 do {
533 static int count;
534 if (++count <= 20)
535 printk("ppp_ioctl: Unknown cmd fd(%d) "
536 "cmd(%08x) arg(%08x)\n",
537 (int)fd, (unsigned int)cmd, (unsigned int)arg);
538 } while(0);
539 err = -EINVAL;
540 break;
541 };
542
543 return err;
544}
545
546
9361401e 547#ifdef CONFIG_BLOCK
1da177e4
LT
548struct mtget32 {
549 compat_long_t mt_type;
550 compat_long_t mt_resid;
551 compat_long_t mt_dsreg;
552 compat_long_t mt_gstat;
553 compat_long_t mt_erreg;
554 compat_daddr_t mt_fileno;
555 compat_daddr_t mt_blkno;
556};
557#define MTIOCGET32 _IOR('m', 2, struct mtget32)
558
559struct mtpos32 {
560 compat_long_t mt_blkno;
561};
562#define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
563
564static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
565{
566 mm_segment_t old_fs = get_fs();
567 struct mtget get;
568 struct mtget32 __user *umget32;
569 struct mtpos pos;
570 struct mtpos32 __user *upos32;
571 unsigned long kcmd;
572 void *karg;
573 int err = 0;
574
575 switch(cmd) {
576 case MTIOCPOS32:
577 kcmd = MTIOCPOS;
578 karg = &pos;
579 break;
580 case MTIOCGET32:
581 kcmd = MTIOCGET;
582 karg = &get;
583 break;
584 default:
585 do {
586 static int count;
587 if (++count <= 20)
588 printk("mt_ioctl: Unknown cmd fd(%d) "
589 "cmd(%08x) arg(%08x)\n",
590 (int)fd, (unsigned int)cmd, (unsigned int)arg);
591 } while(0);
592 return -EINVAL;
593 }
594 set_fs (KERNEL_DS);
595 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
596 set_fs (old_fs);
597 if (err)
598 return err;
599 switch (cmd) {
600 case MTIOCPOS32:
601 upos32 = compat_ptr(arg);
602 err = __put_user(pos.mt_blkno, &upos32->mt_blkno);
603 break;
604 case MTIOCGET32:
605 umget32 = compat_ptr(arg);
606 err = __put_user(get.mt_type, &umget32->mt_type);
607 err |= __put_user(get.mt_resid, &umget32->mt_resid);
608 err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg);
609 err |= __put_user(get.mt_gstat, &umget32->mt_gstat);
610 err |= __put_user(get.mt_erreg, &umget32->mt_erreg);
611 err |= __put_user(get.mt_fileno, &umget32->mt_fileno);
612 err |= __put_user(get.mt_blkno, &umget32->mt_blkno);
613 break;
614 }
615 return err ? -EFAULT: 0;
616}
617
9361401e 618#endif /* CONFIG_BLOCK */
1da177e4 619
1da177e4
LT
620static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg)
621{
622 mm_segment_t old_fs = get_fs();
623 __kernel_uid_t kuid;
624 int err;
625
626 cmd = SMB_IOC_GETMOUNTUID;
627
628 set_fs(KERNEL_DS);
629 err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
630 set_fs(old_fs);
631
632 if (err >= 0)
633 err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg));
634
635 return err;
636}
637
1da177e4
LT
638static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
639{
640 return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
641}
642
1da177e4
LT
643/* Bluetooth ioctls */
644#define HCIUARTSETPROTO _IOW('U', 200, int)
645#define HCIUARTGETPROTO _IOR('U', 201, int)
646
647#define BNEPCONNADD _IOW('B', 200, int)
648#define BNEPCONNDEL _IOW('B', 201, int)
649#define BNEPGETCONNLIST _IOR('B', 210, int)
650#define BNEPGETCONNINFO _IOR('B', 211, int)
651
652#define CMTPCONNADD _IOW('C', 200, int)
653#define CMTPCONNDEL _IOW('C', 201, int)
654#define CMTPGETCONNLIST _IOR('C', 210, int)
655#define CMTPGETCONNINFO _IOR('C', 211, int)
656
657#define HIDPCONNADD _IOW('H', 200, int)
658#define HIDPCONNDEL _IOW('H', 201, int)
659#define HIDPGETCONNLIST _IOR('H', 210, int)
660#define HIDPGETCONNINFO _IOR('H', 211, int)
661
9361401e 662#ifdef CONFIG_BLOCK
1da177e4
LT
663struct raw32_config_request
664{
665 compat_int_t raw_minor;
666 __u64 block_major;
667 __u64 block_minor;
668} __attribute__((packed));
669
670static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
671{
672 int ret;
673
674 if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request)))
675 return -EFAULT;
676
677 ret = __get_user(req->raw_minor, &user_req->raw_minor);
678 ret |= __get_user(req->block_major, &user_req->block_major);
679 ret |= __get_user(req->block_minor, &user_req->block_minor);
680
681 return ret ? -EFAULT : 0;
682}
683
684static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
685{
686 int ret;
687
688 if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request)))
689 return -EFAULT;
690
691 ret = __put_user(req->raw_minor, &user_req->raw_minor);
692 ret |= __put_user(req->block_major, &user_req->block_major);
693 ret |= __put_user(req->block_minor, &user_req->block_minor);
694
695 return ret ? -EFAULT : 0;
696}
697
698static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
699{
700 int ret;
701
702 switch (cmd) {
703 case RAW_SETBIND:
704 case RAW_GETBIND: {
705 struct raw_config_request req;
706 struct raw32_config_request __user *user_req = compat_ptr(arg);
707 mm_segment_t oldfs = get_fs();
708
709 if ((ret = get_raw32_request(&req, user_req)))
710 return ret;
711
712 set_fs(KERNEL_DS);
713 ret = sys_ioctl(fd,cmd,(unsigned long)&req);
714 set_fs(oldfs);
715
716 if ((!ret) && (cmd == RAW_GETBIND)) {
717 ret = set_raw32_request(&req, user_req);
718 }
719 break;
720 }
721 default:
722 ret = sys_ioctl(fd, cmd, arg);
723 break;
724 }
725 return ret;
726}
9361401e 727#endif /* CONFIG_BLOCK */
1da177e4
LT
728
729struct serial_struct32 {
730 compat_int_t type;
731 compat_int_t line;
732 compat_uint_t port;
733 compat_int_t irq;
734 compat_int_t flags;
735 compat_int_t xmit_fifo_size;
736 compat_int_t custom_divisor;
737 compat_int_t baud_base;
738 unsigned short close_delay;
739 char io_type;
740 char reserved_char[1];
741 compat_int_t hub6;
742 unsigned short closing_wait; /* time to wait before closing */
743 unsigned short closing_wait2; /* no longer used... */
744 compat_uint_t iomem_base;
745 unsigned short iomem_reg_shift;
746 unsigned int port_high;
747 /* compat_ulong_t iomap_base FIXME */
748 compat_int_t reserved[1];
749};
750
751static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
752{
753 typedef struct serial_struct SS;
754 typedef struct serial_struct32 SS32;
755 struct serial_struct32 __user *ss32 = compat_ptr(arg);
756 int err;
757 struct serial_struct ss;
758 mm_segment_t oldseg = get_fs();
759 __u32 udata;
7116e994 760 unsigned int base;
1da177e4
LT
761
762 if (cmd == TIOCSSERIAL) {
763 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
764 return -EFAULT;
765 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
766 return -EFAULT;
7116e994
HC
767 if (__get_user(udata, &ss32->iomem_base))
768 return -EFAULT;
1da177e4 769 ss.iomem_base = compat_ptr(udata);
7116e994
HC
770 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
771 __get_user(ss.port_high, &ss32->port_high))
772 return -EFAULT;
1da177e4
LT
773 ss.iomap_base = 0UL;
774 }
775 set_fs(KERNEL_DS);
776 err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
777 set_fs(oldseg);
778 if (cmd == TIOCGSERIAL && err >= 0) {
779 if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32)))
780 return -EFAULT;
781 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
782 return -EFAULT;
7116e994
HC
783 base = (unsigned long)ss.iomem_base >> 32 ?
784 0xffffffff : (unsigned)(unsigned long)ss.iomem_base;
785 if (__put_user(base, &ss32->iomem_base) ||
786 __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
787 __put_user(ss.port_high, &ss32->port_high))
788 return -EFAULT;
1da177e4
LT
789 }
790 return err;
791}
792
793struct usbdevfs_ctrltransfer32 {
794 u8 bRequestType;
795 u8 bRequest;
796 u16 wValue;
797 u16 wIndex;
798 u16 wLength;
799 u32 timeout; /* in milliseconds */
800 compat_caddr_t data;
801};
802
803#define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
804
805static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
806{
807 struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg);
808 struct usbdevfs_ctrltransfer __user *p;
809 __u32 udata;
810 p = compat_alloc_user_space(sizeof(*p));
811 if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
812 get_user(udata, &p32->data) ||
813 put_user(compat_ptr(udata), &p->data))
814 return -EFAULT;
815 return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p);
816}
817
818
819struct usbdevfs_bulktransfer32 {
820 compat_uint_t ep;
821 compat_uint_t len;
822 compat_uint_t timeout; /* in milliseconds */
823 compat_caddr_t data;
824};
825
826#define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
827
828static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
829{
830 struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg);
831 struct usbdevfs_bulktransfer __user *p;
832 compat_uint_t n;
833 compat_caddr_t addr;
834
835 p = compat_alloc_user_space(sizeof(*p));
836
837 if (get_user(n, &p32->ep) || put_user(n, &p->ep) ||
838 get_user(n, &p32->len) || put_user(n, &p->len) ||
839 get_user(n, &p32->timeout) || put_user(n, &p->timeout) ||
840 get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data))
841 return -EFAULT;
842
843 return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p);
844}
845
846
847/*
848 * USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY
849 * are handled in usbdevfs core. -Christopher Li
850 */
851
852struct usbdevfs_disconnectsignal32 {
853 compat_int_t signr;
854 compat_caddr_t context;
855};
856
857#define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
858
859static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
860{
861 struct usbdevfs_disconnectsignal kdis;
862 struct usbdevfs_disconnectsignal32 __user *udis;
863 mm_segment_t old_fs;
864 u32 uctx;
865 int err;
866
867 udis = compat_ptr(arg);
868
869 if (get_user(kdis.signr, &udis->signr) ||
870 __get_user(uctx, &udis->context))
871 return -EFAULT;
872
873 kdis.context = compat_ptr(uctx);
874
875 old_fs = get_fs();
876 set_fs(KERNEL_DS);
877 err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
878 set_fs(old_fs);
879
880 return err;
881}
882
883/*
884 * I2C layer ioctls
885 */
886
887struct i2c_msg32 {
888 u16 addr;
889 u16 flags;
890 u16 len;
891 compat_caddr_t buf;
892};
893
894struct i2c_rdwr_ioctl_data32 {
895 compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
896 u32 nmsgs;
897};
898
899struct i2c_smbus_ioctl_data32 {
900 u8 read_write;
901 u8 command;
902 u32 size;
903 compat_caddr_t data; /* union i2c_smbus_data *data */
904};
905
906struct i2c_rdwr_aligned {
907 struct i2c_rdwr_ioctl_data cmd;
908 struct i2c_msg msgs[0];
909};
910
911static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
912{
913 struct i2c_rdwr_ioctl_data32 __user *udata = compat_ptr(arg);
914 struct i2c_rdwr_aligned __user *tdata;
915 struct i2c_msg __user *tmsgs;
916 struct i2c_msg32 __user *umsgs;
917 compat_caddr_t datap;
918 int nmsgs, i;
919
920 if (get_user(nmsgs, &udata->nmsgs))
921 return -EFAULT;
922 if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
923 return -EINVAL;
924
925 if (get_user(datap, &udata->msgs))
926 return -EFAULT;
927 umsgs = compat_ptr(datap);
928
929 tdata = compat_alloc_user_space(sizeof(*tdata) +
930 nmsgs * sizeof(struct i2c_msg));
931 tmsgs = &tdata->msgs[0];
932
933 if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
934 put_user(tmsgs, &tdata->cmd.msgs))
935 return -EFAULT;
936
937 for (i = 0; i < nmsgs; i++) {
938 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
939 return -EFAULT;
940 if (get_user(datap, &umsgs[i].buf) ||
941 put_user(compat_ptr(datap), &tmsgs[i].buf))
942 return -EFAULT;
943 }
944 return sys_ioctl(fd, cmd, (unsigned long)tdata);
945}
946
947static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
948{
949 struct i2c_smbus_ioctl_data __user *tdata;
950 struct i2c_smbus_ioctl_data32 __user *udata;
951 compat_caddr_t datap;
952
953 tdata = compat_alloc_user_space(sizeof(*tdata));
954 if (tdata == NULL)
955 return -ENOMEM;
956 if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
957 return -EFAULT;
958
959 udata = compat_ptr(arg);
960 if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
961 return -EFAULT;
962
963 if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
964 return -EFAULT;
965 if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
966 return -EFAULT;
967 if (__get_user(datap, &udata->data) ||
968 __put_user(compat_ptr(datap), &tdata->data))
969 return -EFAULT;
970
971 return sys_ioctl(fd, cmd, (unsigned long)tdata);
972}
973
ec3cad96
CH
974#define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
975#define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t)
976#define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
977#define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t)
978
979static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
980{
981 mm_segment_t oldfs = get_fs();
982 compat_ulong_t val32;
983 unsigned long kval;
984 int ret;
985
986 switch (cmd) {
987 case RTC_IRQP_READ32:
988 case RTC_EPOCH_READ32:
989 set_fs(KERNEL_DS);
990 ret = sys_ioctl(fd, (cmd == RTC_IRQP_READ32) ?
991 RTC_IRQP_READ : RTC_EPOCH_READ,
992 (unsigned long)&kval);
993 set_fs(oldfs);
994 if (ret)
995 return ret;
996 val32 = kval;
997 return put_user(val32, (unsigned int __user *)arg);
998 case RTC_IRQP_SET32:
fc5870f6 999 return sys_ioctl(fd, RTC_IRQP_SET, arg);
ec3cad96 1000 case RTC_EPOCH_SET32:
fc5870f6 1001 return sys_ioctl(fd, RTC_EPOCH_SET, arg);
ec3cad96
CH
1002 default:
1003 /* unreached */
1004 return -ENOIOCTLCMD;
1005 }
1006}
1007
c6b44d10
AK
1008static int
1009lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1010{
6b2b4e5a
AV
1011 struct compat_timeval __user *tc = (struct compat_timeval __user *)arg;
1012 struct timeval __user *tn = compat_alloc_user_space(sizeof(struct timeval));
c6b44d10
AK
1013 struct timeval ts;
1014 if (get_user(ts.tv_sec, &tc->tv_sec) ||
1015 get_user(ts.tv_usec, &tc->tv_usec) ||
1016 put_user(ts.tv_sec, &tn->tv_sec) ||
1017 put_user(ts.tv_usec, &tn->tv_usec))
1018 return -EFAULT;
1019 return sys_ioctl(fd, cmd, (unsigned long)tn);
1020}
1021
3e63cbb1
AJ
1022/* on ia32 l_start is on a 32-bit boundary */
1023#if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
1024struct space_resv_32 {
1025 __s16 l_type;
1026 __s16 l_whence;
1027 __s64 l_start __attribute__((packed));
1028 /* len == 0 means until end of file */
1029 __s64 l_len __attribute__((packed));
1030 __s32 l_sysid;
1031 __u32 l_pid;
1032 __s32 l_pad[4]; /* reserve area */
1033};
1034
1035#define FS_IOC_RESVSP_32 _IOW ('X', 40, struct space_resv_32)
1036#define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32)
1037
1038/* just account for different alignment */
1039static int compat_ioctl_preallocate(struct file *file, unsigned long arg)
1040{
7779d7be 1041 struct space_resv_32 __user *p32 = compat_ptr(arg);
3e63cbb1
AJ
1042 struct space_resv __user *p = compat_alloc_user_space(sizeof(*p));
1043
1044 if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) ||
1045 copy_in_user(&p->l_whence, &p32->l_whence, sizeof(s16)) ||
1046 copy_in_user(&p->l_start, &p32->l_start, sizeof(s64)) ||
1047 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
1048 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
1049 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
1050 copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
1051 return -EFAULT;
1052
1053 return ioctl_preallocate(file, p);
1054}
1055#endif
1056
6272e266
CH
1057
1058typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int,
1059 unsigned long, struct file *);
1060
1061struct ioctl_trans {
1062 unsigned long cmd;
1063 ioctl_trans_handler_t handler;
1064 struct ioctl_trans *next;
1065};
1066
e6a6d2ef
CH
1067#define HANDLE_IOCTL(cmd,handler) \
1068 { (cmd), (ioctl_trans_handler_t)(handler) },
1069
1070/* pointer to compatible structure or no argument */
1071#define COMPATIBLE_IOCTL(cmd) \
1072 { (cmd), do_ioctl32_pointer },
1073
1074/* argument is an unsigned long integer, not a pointer */
1075#define ULONG_IOCTL(cmd) \
1076 { (cmd), (ioctl_trans_handler_t)sys_ioctl },
1da177e4 1077
421f0281
AK
1078/* ioctl should not be warned about even if it's not implemented.
1079 Valid reasons to use this:
1080 - It is implemented with ->compat_ioctl on some device, but programs
1081 call it on others too.
1082 - The ioctl is not implemented in the native kernel, but programs
1083 call it commonly anyways.
1084 Most other reasons are not valid. */
1085#define IGNORE_IOCTL(cmd) COMPATIBLE_IOCTL(cmd)
e6a6d2ef 1086
6272e266 1087static struct ioctl_trans ioctl_start[] = {
644fd4f5
CH
1088/* compatible ioctls first */
1089COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */
1090COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */
1091
1092/* Big T */
1093COMPATIBLE_IOCTL(TCGETA)
1094COMPATIBLE_IOCTL(TCSETA)
1095COMPATIBLE_IOCTL(TCSETAW)
1096COMPATIBLE_IOCTL(TCSETAF)
1097COMPATIBLE_IOCTL(TCSBRK)
1098ULONG_IOCTL(TCSBRKP)
1099COMPATIBLE_IOCTL(TCXONC)
1100COMPATIBLE_IOCTL(TCFLSH)
1101COMPATIBLE_IOCTL(TCGETS)
1102COMPATIBLE_IOCTL(TCSETS)
1103COMPATIBLE_IOCTL(TCSETSW)
1104COMPATIBLE_IOCTL(TCSETSF)
1105COMPATIBLE_IOCTL(TIOCLINUX)
1106COMPATIBLE_IOCTL(TIOCSBRK)
1107COMPATIBLE_IOCTL(TIOCCBRK)
1108ULONG_IOCTL(TIOCMIWAIT)
1109COMPATIBLE_IOCTL(TIOCGICOUNT)
1110/* Little t */
1111COMPATIBLE_IOCTL(TIOCGETD)
1112COMPATIBLE_IOCTL(TIOCSETD)
1113COMPATIBLE_IOCTL(TIOCEXCL)
1114COMPATIBLE_IOCTL(TIOCNXCL)
1115COMPATIBLE_IOCTL(TIOCCONS)
1116COMPATIBLE_IOCTL(TIOCGSOFTCAR)
1117COMPATIBLE_IOCTL(TIOCSSOFTCAR)
1118COMPATIBLE_IOCTL(TIOCSWINSZ)
1119COMPATIBLE_IOCTL(TIOCGWINSZ)
1120COMPATIBLE_IOCTL(TIOCMGET)
1121COMPATIBLE_IOCTL(TIOCMBIC)
1122COMPATIBLE_IOCTL(TIOCMBIS)
1123COMPATIBLE_IOCTL(TIOCMSET)
1124COMPATIBLE_IOCTL(TIOCPKT)
1125COMPATIBLE_IOCTL(TIOCNOTTY)
1126COMPATIBLE_IOCTL(TIOCSTI)
1127COMPATIBLE_IOCTL(TIOCOUTQ)
1128COMPATIBLE_IOCTL(TIOCSPGRP)
1129COMPATIBLE_IOCTL(TIOCGPGRP)
1130ULONG_IOCTL(TIOCSCTTY)
1131COMPATIBLE_IOCTL(TIOCGPTN)
1132COMPATIBLE_IOCTL(TIOCSPTLCK)
1133COMPATIBLE_IOCTL(TIOCSERGETLSR)
81257def
HC
1134#ifdef TCGETS2
1135COMPATIBLE_IOCTL(TCGETS2)
1136COMPATIBLE_IOCTL(TCSETS2)
1137COMPATIBLE_IOCTL(TCSETSW2)
1138COMPATIBLE_IOCTL(TCSETSF2)
1139#endif
644fd4f5
CH
1140/* Little f */
1141COMPATIBLE_IOCTL(FIOCLEX)
1142COMPATIBLE_IOCTL(FIONCLEX)
1143COMPATIBLE_IOCTL(FIOASYNC)
1144COMPATIBLE_IOCTL(FIONBIO)
1145COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */
69130c7c 1146COMPATIBLE_IOCTL(FS_IOC_FIEMAP)
644fd4f5
CH
1147/* 0x00 */
1148COMPATIBLE_IOCTL(FIBMAP)
1149COMPATIBLE_IOCTL(FIGETBSZ)
5cf8cf41
CH
1150/* 'X' - originally XFS but some now in the VFS */
1151COMPATIBLE_IOCTL(FIFREEZE)
1152COMPATIBLE_IOCTL(FITHAW)
644fd4f5
CH
1153/* RAID */
1154COMPATIBLE_IOCTL(RAID_VERSION)
1155COMPATIBLE_IOCTL(GET_ARRAY_INFO)
1156COMPATIBLE_IOCTL(GET_DISK_INFO)
1157COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
1158COMPATIBLE_IOCTL(RAID_AUTORUN)
1159COMPATIBLE_IOCTL(CLEAR_ARRAY)
1160COMPATIBLE_IOCTL(ADD_NEW_DISK)
1161ULONG_IOCTL(HOT_REMOVE_DISK)
1162COMPATIBLE_IOCTL(SET_ARRAY_INFO)
1163COMPATIBLE_IOCTL(SET_DISK_INFO)
1164COMPATIBLE_IOCTL(WRITE_RAID_INFO)
1165COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
1166COMPATIBLE_IOCTL(PROTECT_ARRAY)
1167ULONG_IOCTL(HOT_ADD_DISK)
1168ULONG_IOCTL(SET_DISK_FAULTY)
1169COMPATIBLE_IOCTL(RUN_ARRAY)
1170COMPATIBLE_IOCTL(STOP_ARRAY)
1171COMPATIBLE_IOCTL(STOP_ARRAY_RO)
1172COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
1173COMPATIBLE_IOCTL(GET_BITMAP_FILE)
1174ULONG_IOCTL(SET_BITMAP_FILE)
fb07a5f8 1175/* Keyboard -- can be removed once tty3270 uses ops->compat_ioctl */
644fd4f5
CH
1176ULONG_IOCTL(KDSIGACCEPT)
1177COMPATIBLE_IOCTL(KDGETKEYCODE)
1178COMPATIBLE_IOCTL(KDSETKEYCODE)
1179ULONG_IOCTL(KIOCSOUND)
1180ULONG_IOCTL(KDMKTONE)
1181COMPATIBLE_IOCTL(KDGKBTYPE)
1182ULONG_IOCTL(KDSETMODE)
1183COMPATIBLE_IOCTL(KDGETMODE)
1184ULONG_IOCTL(KDSKBMODE)
1185COMPATIBLE_IOCTL(KDGKBMODE)
1186ULONG_IOCTL(KDSKBMETA)
1187COMPATIBLE_IOCTL(KDGKBMETA)
1188COMPATIBLE_IOCTL(KDGKBENT)
1189COMPATIBLE_IOCTL(KDSKBENT)
1190COMPATIBLE_IOCTL(KDGKBSENT)
1191COMPATIBLE_IOCTL(KDSKBSENT)
1192COMPATIBLE_IOCTL(KDGKBDIACR)
1193COMPATIBLE_IOCTL(KDSKBDIACR)
1194COMPATIBLE_IOCTL(KDKBDREP)
1195COMPATIBLE_IOCTL(KDGKBLED)
1196ULONG_IOCTL(KDSKBLED)
1197COMPATIBLE_IOCTL(KDGETLED)
1198ULONG_IOCTL(KDSETLED)
3c3622dc 1199#ifdef CONFIG_BLOCK
644fd4f5
CH
1200/* Big S */
1201COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
1202COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
1203COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
1204COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
1205COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
1206COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
1207COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
1208COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
3c3622dc 1209#endif
644fd4f5
CH
1210/* Little p (/dev/rtc, /dev/envctrl, etc.) */
1211COMPATIBLE_IOCTL(RTC_AIE_ON)
1212COMPATIBLE_IOCTL(RTC_AIE_OFF)
1213COMPATIBLE_IOCTL(RTC_UIE_ON)
1214COMPATIBLE_IOCTL(RTC_UIE_OFF)
1215COMPATIBLE_IOCTL(RTC_PIE_ON)
1216COMPATIBLE_IOCTL(RTC_PIE_OFF)
1217COMPATIBLE_IOCTL(RTC_WIE_ON)
1218COMPATIBLE_IOCTL(RTC_WIE_OFF)
1219COMPATIBLE_IOCTL(RTC_ALM_SET)
1220COMPATIBLE_IOCTL(RTC_ALM_READ)
1221COMPATIBLE_IOCTL(RTC_RD_TIME)
1222COMPATIBLE_IOCTL(RTC_SET_TIME)
1223COMPATIBLE_IOCTL(RTC_WKALM_SET)
1224COMPATIBLE_IOCTL(RTC_WKALM_RD)
1225/*
1226 * These two are only for the sbus rtc driver, but
1227 * hwclock tries them on every rtc device first when
1228 * running on sparc. On other architectures the entries
1229 * are useless but harmless.
1230 */
1231COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
1232COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
1233/* Little m */
1234COMPATIBLE_IOCTL(MTIOCTOP)
1235/* Socket level stuff */
1236COMPATIBLE_IOCTL(FIOQSIZE)
3c3622dc 1237#ifdef CONFIG_BLOCK
5a07ea0b
AB
1238/* loop */
1239IGNORE_IOCTL(LOOP_CLR_FD)
644fd4f5
CH
1240/* SG stuff */
1241COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
1242COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
1243COMPATIBLE_IOCTL(SG_EMULATED_HOST)
1244ULONG_IOCTL(SG_SET_TRANSFORM)
1245COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
1246COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
1247COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
1248COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
1249COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
1250COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
1251COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
1252COMPATIBLE_IOCTL(SG_GET_PACK_ID)
1253COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
1254COMPATIBLE_IOCTL(SG_SET_DEBUG)
1255COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
1256COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
1257COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
1258COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
1259COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
1260COMPATIBLE_IOCTL(SG_SCSI_RESET)
1261COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
1262COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
1263COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
3c3622dc 1264#endif
644fd4f5
CH
1265/* PPP stuff */
1266COMPATIBLE_IOCTL(PPPIOCGFLAGS)
1267COMPATIBLE_IOCTL(PPPIOCSFLAGS)
1268COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
1269COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
1270COMPATIBLE_IOCTL(PPPIOCGUNIT)
1271COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
1272COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
1273COMPATIBLE_IOCTL(PPPIOCGMRU)
1274COMPATIBLE_IOCTL(PPPIOCSMRU)
1275COMPATIBLE_IOCTL(PPPIOCSMAXCID)
1276COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
1277COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
1278COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
1279/* PPPIOCSCOMPRESS is translated */
1280COMPATIBLE_IOCTL(PPPIOCGNPMODE)
1281COMPATIBLE_IOCTL(PPPIOCSNPMODE)
1282COMPATIBLE_IOCTL(PPPIOCGDEBUG)
1283COMPATIBLE_IOCTL(PPPIOCSDEBUG)
1284/* PPPIOCSPASS is translated */
1285/* PPPIOCSACTIVE is translated */
1286/* PPPIOCGIDLE is translated */
1287COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
1288COMPATIBLE_IOCTL(PPPIOCATTACH)
1289COMPATIBLE_IOCTL(PPPIOCDETACH)
1290COMPATIBLE_IOCTL(PPPIOCSMRRU)
1291COMPATIBLE_IOCTL(PPPIOCCONNECT)
1292COMPATIBLE_IOCTL(PPPIOCDISCONN)
1293COMPATIBLE_IOCTL(PPPIOCATTCHAN)
1294COMPATIBLE_IOCTL(PPPIOCGCHAN)
1295/* PPPOX */
1296COMPATIBLE_IOCTL(PPPOEIOCSFWD)
1297COMPATIBLE_IOCTL(PPPOEIOCDFWD)
1298/* LP */
1299COMPATIBLE_IOCTL(LPGETSTATUS)
1300/* ppdev */
1301COMPATIBLE_IOCTL(PPSETMODE)
1302COMPATIBLE_IOCTL(PPRSTATUS)
1303COMPATIBLE_IOCTL(PPRCONTROL)
1304COMPATIBLE_IOCTL(PPWCONTROL)
1305COMPATIBLE_IOCTL(PPFCONTROL)
1306COMPATIBLE_IOCTL(PPRDATA)
1307COMPATIBLE_IOCTL(PPWDATA)
1308COMPATIBLE_IOCTL(PPCLAIM)
1309COMPATIBLE_IOCTL(PPRELEASE)
1310COMPATIBLE_IOCTL(PPYIELD)
1311COMPATIBLE_IOCTL(PPEXCL)
1312COMPATIBLE_IOCTL(PPDATADIR)
1313COMPATIBLE_IOCTL(PPNEGOT)
1314COMPATIBLE_IOCTL(PPWCTLONIRQ)
1315COMPATIBLE_IOCTL(PPCLRIRQ)
1316COMPATIBLE_IOCTL(PPSETPHASE)
1317COMPATIBLE_IOCTL(PPGETMODES)
1318COMPATIBLE_IOCTL(PPGETMODE)
1319COMPATIBLE_IOCTL(PPGETPHASE)
1320COMPATIBLE_IOCTL(PPGETFLAGS)
1321COMPATIBLE_IOCTL(PPSETFLAGS)
644fd4f5
CH
1322/* pktcdvd */
1323COMPATIBLE_IOCTL(PACKET_CTRL_CMD)
1324/* Big A */
1325/* sparc only */
1326/* Big Q for sound/OSS */
1327COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
1328COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
1329COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
1330COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
1331COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
1332COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
1333COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
1334COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
1335COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
1336COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
1337COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
1338COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
1339COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
1340COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
1341COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
1342COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
1343COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
1344COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
1345COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
1346COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
1347COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
1348COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
1349/* Big T for sound/OSS */
1350COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
1351COMPATIBLE_IOCTL(SNDCTL_TMR_START)
1352COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
1353COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
1354COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
1355COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
1356COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
1357COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
1358/* Little m for sound/OSS */
1359COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
1360COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
1361COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
1362/* Big P for sound/OSS */
1363COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
1364COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
1365COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
1366COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
1367COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
1368COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
1369COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
1370COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
1371COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
1372COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
1373COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
1374COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
1375COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
1376COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
1377COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
1378COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
1379COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
1380COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
1381COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
1382COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
1383/* SNDCTL_DSP_MAPINBUF, XXX needs translation */
1384/* SNDCTL_DSP_MAPOUTBUF, XXX needs translation */
1385COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
1386COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
1387COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
1388COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
1389COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
1390COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
1391COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
1392COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
1393/* Big C for sound/OSS */
1394COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
1395COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
1396COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
1397COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
1398COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
1399COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
1400COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
1401COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
1402COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
1403COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
1404/* Big M for sound/OSS */
1405COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
1406COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
1407COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
1408COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
1409COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
1410COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
1411COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
1412COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
1413COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
1414COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
1415COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
1416COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
1417COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
1418COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
1419COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
1420COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
1421COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
1422COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
1423COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
1424COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
1425COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
1426COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
1427COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
1428COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
1429COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
1430COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
1431/* SOUND_MIXER_READ_ENHANCE, same value as READ_MUTE */
1432/* SOUND_MIXER_READ_LOUD, same value as READ_MUTE */
1433COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
1434COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
1435COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
1436COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
1437COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
1438COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
1439COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
1440COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
1441COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
1442COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
1443COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
1444COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
1445COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
1446COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
1447COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
1448COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
1449COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
1450COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
1451COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
1452COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
1453COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
1454COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
1455COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
1456COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
1457COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
1458COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
1459COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
1460COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
1461COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
1462COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
1463COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
1464/* SOUND_MIXER_WRITE_ENHANCE, same value as WRITE_MUTE */
1465/* SOUND_MIXER_WRITE_LOUD, same value as WRITE_MUTE */
1466COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
1467COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
1468COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
1469COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
1470COMPATIBLE_IOCTL(SOUND_MIXER_AGC)
1471COMPATIBLE_IOCTL(SOUND_MIXER_3DSE)
1472COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
1473COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
1474COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
1475COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
1476COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
1477COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
1478COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
1479COMPATIBLE_IOCTL(OSS_GETVERSION)
1480/* AUTOFS */
1481ULONG_IOCTL(AUTOFS_IOC_READY)
1482ULONG_IOCTL(AUTOFS_IOC_FAIL)
1483COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
1484COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
1485COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
1486COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI)
1487COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOSUBVER)
644fd4f5
CH
1488COMPATIBLE_IOCTL(AUTOFS_IOC_ASKUMOUNT)
1489/* Raw devices */
1490COMPATIBLE_IOCTL(RAW_SETBIND)
1491COMPATIBLE_IOCTL(RAW_GETBIND)
1492/* SMB ioctls which do not need any translations */
1493COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
644fd4f5
CH
1494/* Watchdog */
1495COMPATIBLE_IOCTL(WDIOC_GETSUPPORT)
1496COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
1497COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS)
1498COMPATIBLE_IOCTL(WDIOC_GETTEMP)
1499COMPATIBLE_IOCTL(WDIOC_SETOPTIONS)
1500COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
1501COMPATIBLE_IOCTL(WDIOC_SETTIMEOUT)
1502COMPATIBLE_IOCTL(WDIOC_GETTIMEOUT)
1503/* Big R */
1504COMPATIBLE_IOCTL(RNDGETENTCNT)
1505COMPATIBLE_IOCTL(RNDADDTOENTCNT)
1506COMPATIBLE_IOCTL(RNDGETPOOL)
1507COMPATIBLE_IOCTL(RNDADDENTROPY)
1508COMPATIBLE_IOCTL(RNDZAPENTCNT)
1509COMPATIBLE_IOCTL(RNDCLEARPOOL)
1510/* Bluetooth */
1511COMPATIBLE_IOCTL(HCIDEVUP)
1512COMPATIBLE_IOCTL(HCIDEVDOWN)
1513COMPATIBLE_IOCTL(HCIDEVRESET)
1514COMPATIBLE_IOCTL(HCIDEVRESTAT)
1515COMPATIBLE_IOCTL(HCIGETDEVLIST)
1516COMPATIBLE_IOCTL(HCIGETDEVINFO)
1517COMPATIBLE_IOCTL(HCIGETCONNLIST)
1518COMPATIBLE_IOCTL(HCIGETCONNINFO)
40be492f 1519COMPATIBLE_IOCTL(HCIGETAUTHINFO)
644fd4f5
CH
1520COMPATIBLE_IOCTL(HCISETRAW)
1521COMPATIBLE_IOCTL(HCISETSCAN)
1522COMPATIBLE_IOCTL(HCISETAUTH)
1523COMPATIBLE_IOCTL(HCISETENCRYPT)
1524COMPATIBLE_IOCTL(HCISETPTYPE)
1525COMPATIBLE_IOCTL(HCISETLINKPOL)
1526COMPATIBLE_IOCTL(HCISETLINKMODE)
1527COMPATIBLE_IOCTL(HCISETACLMTU)
1528COMPATIBLE_IOCTL(HCISETSCOMTU)
1529COMPATIBLE_IOCTL(HCIINQUIRY)
1530COMPATIBLE_IOCTL(HCIUARTSETPROTO)
1531COMPATIBLE_IOCTL(HCIUARTGETPROTO)
1532COMPATIBLE_IOCTL(RFCOMMCREATEDEV)
1533COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
1534COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
1535COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
1536COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
1537COMPATIBLE_IOCTL(BNEPCONNADD)
1538COMPATIBLE_IOCTL(BNEPCONNDEL)
1539COMPATIBLE_IOCTL(BNEPGETCONNLIST)
1540COMPATIBLE_IOCTL(BNEPGETCONNINFO)
1541COMPATIBLE_IOCTL(CMTPCONNADD)
1542COMPATIBLE_IOCTL(CMTPCONNDEL)
1543COMPATIBLE_IOCTL(CMTPGETCONNLIST)
1544COMPATIBLE_IOCTL(CMTPGETCONNINFO)
1545COMPATIBLE_IOCTL(HIDPCONNADD)
1546COMPATIBLE_IOCTL(HIDPCONNDEL)
1547COMPATIBLE_IOCTL(HIDPGETCONNLIST)
1548COMPATIBLE_IOCTL(HIDPGETCONNINFO)
1549/* CAPI */
1550COMPATIBLE_IOCTL(CAPI_REGISTER)
1551COMPATIBLE_IOCTL(CAPI_GET_MANUFACTURER)
1552COMPATIBLE_IOCTL(CAPI_GET_VERSION)
1553COMPATIBLE_IOCTL(CAPI_GET_SERIAL)
1554COMPATIBLE_IOCTL(CAPI_GET_PROFILE)
1555COMPATIBLE_IOCTL(CAPI_MANUFACTURER_CMD)
1556COMPATIBLE_IOCTL(CAPI_GET_ERRCODE)
1557COMPATIBLE_IOCTL(CAPI_INSTALLED)
1558COMPATIBLE_IOCTL(CAPI_GET_FLAGS)
1559COMPATIBLE_IOCTL(CAPI_SET_FLAGS)
1560COMPATIBLE_IOCTL(CAPI_CLR_FLAGS)
1561COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT)
1562COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT)
1563/* Siemens Gigaset */
1564COMPATIBLE_IOCTL(GIGASET_REDIR)
1565COMPATIBLE_IOCTL(GIGASET_CONFIG)
1566COMPATIBLE_IOCTL(GIGASET_BRKCHARS)
1567COMPATIBLE_IOCTL(GIGASET_VERSION)
1568/* Misc. */
1569COMPATIBLE_IOCTL(0x41545900) /* ATYIO_CLKR */
1570COMPATIBLE_IOCTL(0x41545901) /* ATYIO_CLKW */
1571COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
1572COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
1573COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
1574COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
1575/* USB */
1576COMPATIBLE_IOCTL(USBDEVFS_RESETEP)
1577COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE)
1578COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION)
1579COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER)
1580COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB)
1581COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE)
1582COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE)
1583COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO)
1584COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO)
1585COMPATIBLE_IOCTL(USBDEVFS_RESET)
1586COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32)
1587COMPATIBLE_IOCTL(USBDEVFS_REAPURB32)
1588COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32)
1589COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
644fd4f5
CH
1590/* NBD */
1591ULONG_IOCTL(NBD_SET_SOCK)
1592ULONG_IOCTL(NBD_SET_BLKSIZE)
1593ULONG_IOCTL(NBD_SET_SIZE)
1594COMPATIBLE_IOCTL(NBD_DO_IT)
1595COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
1596COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
1597COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
1598ULONG_IOCTL(NBD_SET_SIZE_BLOCKS)
1599COMPATIBLE_IOCTL(NBD_DISCONNECT)
1600/* i2c */
1601COMPATIBLE_IOCTL(I2C_SLAVE)
1602COMPATIBLE_IOCTL(I2C_SLAVE_FORCE)
1603COMPATIBLE_IOCTL(I2C_TENBIT)
1604COMPATIBLE_IOCTL(I2C_PEC)
1605COMPATIBLE_IOCTL(I2C_RETRIES)
1606COMPATIBLE_IOCTL(I2C_TIMEOUT)
644fd4f5
CH
1607/* hiddev */
1608COMPATIBLE_IOCTL(HIDIOCGVERSION)
1609COMPATIBLE_IOCTL(HIDIOCAPPLICATION)
1610COMPATIBLE_IOCTL(HIDIOCGDEVINFO)
1611COMPATIBLE_IOCTL(HIDIOCGSTRING)
1612COMPATIBLE_IOCTL(HIDIOCINITREPORT)
1613COMPATIBLE_IOCTL(HIDIOCGREPORT)
1614COMPATIBLE_IOCTL(HIDIOCSREPORT)
1615COMPATIBLE_IOCTL(HIDIOCGREPORTINFO)
1616COMPATIBLE_IOCTL(HIDIOCGFIELDINFO)
1617COMPATIBLE_IOCTL(HIDIOCGUSAGE)
1618COMPATIBLE_IOCTL(HIDIOCSUSAGE)
1619COMPATIBLE_IOCTL(HIDIOCGUCODE)
1620COMPATIBLE_IOCTL(HIDIOCGFLAG)
1621COMPATIBLE_IOCTL(HIDIOCSFLAG)
1622COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINDEX)
1623COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINFO)
1624/* dvb */
1625COMPATIBLE_IOCTL(AUDIO_STOP)
1626COMPATIBLE_IOCTL(AUDIO_PLAY)
1627COMPATIBLE_IOCTL(AUDIO_PAUSE)
1628COMPATIBLE_IOCTL(AUDIO_CONTINUE)
1629COMPATIBLE_IOCTL(AUDIO_SELECT_SOURCE)
1630COMPATIBLE_IOCTL(AUDIO_SET_MUTE)
1631COMPATIBLE_IOCTL(AUDIO_SET_AV_SYNC)
1632COMPATIBLE_IOCTL(AUDIO_SET_BYPASS_MODE)
1633COMPATIBLE_IOCTL(AUDIO_CHANNEL_SELECT)
1634COMPATIBLE_IOCTL(AUDIO_GET_STATUS)
1635COMPATIBLE_IOCTL(AUDIO_GET_CAPABILITIES)
1636COMPATIBLE_IOCTL(AUDIO_CLEAR_BUFFER)
1637COMPATIBLE_IOCTL(AUDIO_SET_ID)
1638COMPATIBLE_IOCTL(AUDIO_SET_MIXER)
1639COMPATIBLE_IOCTL(AUDIO_SET_STREAMTYPE)
1640COMPATIBLE_IOCTL(AUDIO_SET_EXT_ID)
1641COMPATIBLE_IOCTL(AUDIO_SET_ATTRIBUTES)
1642COMPATIBLE_IOCTL(AUDIO_SET_KARAOKE)
1643COMPATIBLE_IOCTL(DMX_START)
1644COMPATIBLE_IOCTL(DMX_STOP)
1645COMPATIBLE_IOCTL(DMX_SET_FILTER)
1646COMPATIBLE_IOCTL(DMX_SET_PES_FILTER)
1647COMPATIBLE_IOCTL(DMX_SET_BUFFER_SIZE)
1648COMPATIBLE_IOCTL(DMX_GET_PES_PIDS)
1649COMPATIBLE_IOCTL(DMX_GET_CAPS)
1650COMPATIBLE_IOCTL(DMX_SET_SOURCE)
1651COMPATIBLE_IOCTL(DMX_GET_STC)
1652COMPATIBLE_IOCTL(FE_GET_INFO)
1653COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD)
1654COMPATIBLE_IOCTL(FE_DISEQC_SEND_MASTER_CMD)
1655COMPATIBLE_IOCTL(FE_DISEQC_RECV_SLAVE_REPLY)
1656COMPATIBLE_IOCTL(FE_DISEQC_SEND_BURST)
1657COMPATIBLE_IOCTL(FE_SET_TONE)
1658COMPATIBLE_IOCTL(FE_SET_VOLTAGE)
1659COMPATIBLE_IOCTL(FE_ENABLE_HIGH_LNB_VOLTAGE)
1660COMPATIBLE_IOCTL(FE_READ_STATUS)
1661COMPATIBLE_IOCTL(FE_READ_BER)
1662COMPATIBLE_IOCTL(FE_READ_SIGNAL_STRENGTH)
1663COMPATIBLE_IOCTL(FE_READ_SNR)
1664COMPATIBLE_IOCTL(FE_READ_UNCORRECTED_BLOCKS)
1665COMPATIBLE_IOCTL(FE_SET_FRONTEND)
1666COMPATIBLE_IOCTL(FE_GET_FRONTEND)
1667COMPATIBLE_IOCTL(FE_GET_EVENT)
1668COMPATIBLE_IOCTL(FE_DISHNETWORK_SEND_LEGACY_CMD)
1669COMPATIBLE_IOCTL(VIDEO_STOP)
1670COMPATIBLE_IOCTL(VIDEO_PLAY)
1671COMPATIBLE_IOCTL(VIDEO_FREEZE)
1672COMPATIBLE_IOCTL(VIDEO_CONTINUE)
1673COMPATIBLE_IOCTL(VIDEO_SELECT_SOURCE)
1674COMPATIBLE_IOCTL(VIDEO_SET_BLANK)
1675COMPATIBLE_IOCTL(VIDEO_GET_STATUS)
1676COMPATIBLE_IOCTL(VIDEO_SET_DISPLAY_FORMAT)
1677COMPATIBLE_IOCTL(VIDEO_FAST_FORWARD)
1678COMPATIBLE_IOCTL(VIDEO_SLOWMOTION)
1679COMPATIBLE_IOCTL(VIDEO_GET_CAPABILITIES)
1680COMPATIBLE_IOCTL(VIDEO_CLEAR_BUFFER)
1681COMPATIBLE_IOCTL(VIDEO_SET_ID)
1682COMPATIBLE_IOCTL(VIDEO_SET_STREAMTYPE)
1683COMPATIBLE_IOCTL(VIDEO_SET_FORMAT)
1684COMPATIBLE_IOCTL(VIDEO_SET_SYSTEM)
1685COMPATIBLE_IOCTL(VIDEO_SET_HIGHLIGHT)
1686COMPATIBLE_IOCTL(VIDEO_SET_SPU)
1687COMPATIBLE_IOCTL(VIDEO_GET_NAVI)
1688COMPATIBLE_IOCTL(VIDEO_SET_ATTRIBUTES)
1689COMPATIBLE_IOCTL(VIDEO_GET_SIZE)
1690COMPATIBLE_IOCTL(VIDEO_GET_FRAME_RATE)
1691
3fee37c1
AM
1692/* joystick */
1693COMPATIBLE_IOCTL(JSIOCGVERSION)
1694COMPATIBLE_IOCTL(JSIOCGAXES)
1695COMPATIBLE_IOCTL(JSIOCGBUTTONS)
1696COMPATIBLE_IOCTL(JSIOCGNAME(0))
1697
9c0cbd54
CH
1698#ifdef TIOCGLTC
1699COMPATIBLE_IOCTL(TIOCGLTC)
1700COMPATIBLE_IOCTL(TIOCSLTC)
1701#endif
7a81e316
CH
1702#ifdef TIOCSTART
1703/*
6070d81e 1704 * For these two we have definitions in ioctls.h and/or termios.h on
7a81e316
CH
1705 * some architectures but no actual implemention. Some applications
1706 * like bash call them if they are defined in the headers, so we provide
1707 * entries here to avoid syslog message spew.
1708 */
1709COMPATIBLE_IOCTL(TIOCSTART)
1710COMPATIBLE_IOCTL(TIOCSTOP)
1711#endif
1da177e4 1712/* Usbdevfs */
c36fc889 1713COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
c6b44d10
AK
1714
1715/* parport */
1716COMPATIBLE_IOCTL(LPTIME)
1717COMPATIBLE_IOCTL(LPCHAR)
1718COMPATIBLE_IOCTL(LPABORTOPEN)
1719COMPATIBLE_IOCTL(LPCAREFUL)
1720COMPATIBLE_IOCTL(LPWAIT)
1721COMPATIBLE_IOCTL(LPSETIRQ)
1722COMPATIBLE_IOCTL(LPGETSTATUS)
1723COMPATIBLE_IOCTL(LPGETSTATUS)
1724COMPATIBLE_IOCTL(LPRESET)
1725/*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/
1726COMPATIBLE_IOCTL(LPGETFLAGS)
2724b6db
AK
1727
1728/* fat 'r' ioctls. These are handled by fat with ->compat_ioctl,
1729 but we don't want warnings on other file systems. So declare
1730 them as compatible here. */
1731#define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
1732#define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
1733
1734IGNORE_IOCTL(VFAT_IOCTL_READDIR_BOTH32)
1735IGNORE_IOCTL(VFAT_IOCTL_READDIR_SHORT32)
98701dc1 1736
8163904e
DM
1737#ifdef CONFIG_SPARC
1738/* Sparc framebuffers, handled in sbusfb_compat_ioctl() */
1739IGNORE_IOCTL(FBIOGTYPE)
1740IGNORE_IOCTL(FBIOSATTR)
1741IGNORE_IOCTL(FBIOGATTR)
1742IGNORE_IOCTL(FBIOSVIDEO)
1743IGNORE_IOCTL(FBIOGVIDEO)
1744IGNORE_IOCTL(FBIOSCURPOS)
1745IGNORE_IOCTL(FBIOGCURPOS)
1746IGNORE_IOCTL(FBIOGCURMAX)
1747IGNORE_IOCTL(FBIOPUTCMAP32)
1748IGNORE_IOCTL(FBIOGETCMAP32)
1749IGNORE_IOCTL(FBIOSCURSOR32)
1750IGNORE_IOCTL(FBIOGCURSOR32)
1751#endif
e6a6d2ef 1752};
6e87abd0 1753
6272e266
CH
1754#define IOCTL_HASHSIZE 256
1755static struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE];
1756
1757static inline unsigned long ioctl32_hash(unsigned long cmd)
1758{
1759 return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE;
1760}
1761
5a07ea0b
AB
1762/*
1763 * Convert common ioctl arguments based on their command number
1764 *
1765 * Please do not add any code in here. Instead, implement
1766 * a compat_ioctl operation in the place that handleѕ the
1767 * ioctl for the native case.
1768 */
1769static long do_ioctl_trans(int fd, unsigned int cmd,
1770 unsigned long arg, struct file *file)
1771{
1772 switch (cmd) {
1773 case PPPIOCGIDLE32:
1774 case PPPIOCSCOMPRESS32:
1775 return ppp_ioctl_trans(fd, cmd, arg);
1776 case PPPIOCSPASS32:
1777 case PPPIOCSACTIVE32:
1778 return ppp_sock_fprog_ioctl_trans(fd, cmd, arg);
1779#ifdef CONFIG_BLOCK
1780 case SG_IO:
1781 return sg_ioctl_trans(fd, cmd, arg);
1782 case SG_GET_REQUEST_TABLE:
1783 return sg_grt_trans(fd, cmd, arg);
1784 case MTIOCGET32:
1785 case MTIOCPOS32:
1786 return mt_ioctl_trans(fd, cmd, arg);
1787 /* Raw devices */
1788 case RAW_SETBIND:
1789 case RAW_GETBIND:
1790 return raw_ioctl(fd, cmd, arg);
1791#endif
1792#define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
1793 case AUTOFS_IOC_SETTIMEOUT32:
1794 return ioc_settimeout(fd, cmd, arg);
1795 /* One SMB ioctl needs translations. */
1796#define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
1797 case SMB_IOC_GETMOUNTUID_32:
1798 return do_smb_getmountuid(fd, cmd, arg);
1799 /* Serial */
1800 case TIOCGSERIAL:
1801 case TIOCSSERIAL:
1802 return serial_struct_ioctl(fd, cmd, arg);
1803 /* Usbdevfs */
1804 case USBDEVFS_CONTROL32:
1805 return do_usbdevfs_control(fd, cmd, arg);
1806 case USBDEVFS_BULK32:
1807 return do_usbdevfs_bulk(fd, cmd, arg);
1808 case USBDEVFS_DISCSIGNAL32:
1809 return do_usbdevfs_discsignal(fd, cmd, arg);
1810 /* i2c */
1811 case I2C_FUNCS:
1812 return w_long(fd, cmd, arg);
1813 case I2C_RDWR:
1814 return do_i2c_rdwr_ioctl(fd, cmd, arg);
1815 case I2C_SMBUS:
1816 return do_i2c_smbus_ioctl(fd, cmd, arg);
1817 /* Not implemented in the native kernel */
1818 case RTC_IRQP_READ32:
1819 case RTC_IRQP_SET32:
1820 case RTC_EPOCH_READ32:
1821 case RTC_EPOCH_SET32:
1822 return rtc_ioctl(fd, cmd, arg);
1823
1824 /* dvb */
1825 case VIDEO_GET_EVENT:
1826 return do_video_get_event(fd, cmd, arg);
1827 case VIDEO_STILLPICTURE:
1828 return do_video_stillpicture(fd, cmd, arg);
1829 case VIDEO_SET_SPU_PALETTE:
1830 return do_video_set_spu_palette(fd, cmd, arg);
1831
1832 /* lp */
1833 case LPSETTIMEOUT:
1834 return lp_timeout_trans(fd, cmd, arg);
1835 }
1836 return -ENOIOCTLCMD;
1837}
1838
6272e266
CH
1839static void compat_ioctl_error(struct file *filp, unsigned int fd,
1840 unsigned int cmd, unsigned long arg)
1841{
1842 char buf[10];
1843 char *fn = "?";
1844 char *path;
1845
1846 /* find the name of the device. */
1847 path = (char *)__get_free_page(GFP_KERNEL);
1848 if (path) {
cf28b486 1849 fn = d_path(&filp->f_path, path, PAGE_SIZE);
6272e266
CH
1850 if (IS_ERR(fn))
1851 fn = "?";
1852 }
1853
1854 sprintf(buf,"'%c'", (cmd>>_IOC_TYPESHIFT) & _IOC_TYPEMASK);
1855 if (!isprint(buf[1]))
1856 sprintf(buf, "%02x", buf[1]);
1857 compat_printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
1858 "cmd(%08x){t:%s;sz:%u} arg(%08x) on %s\n",
1859 current->comm, current->pid,
1860 (int)fd, (unsigned int)cmd, buf,
1861 (cmd >> _IOC_SIZESHIFT) & _IOC_SIZEMASK,
1862 (unsigned int)arg, fn);
1863
1864 if (path)
1865 free_page((unsigned long)path);
1866}
1867
1868asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
1869 unsigned long arg)
1870{
1871 struct file *filp;
1872 int error = -EBADF;
1873 struct ioctl_trans *t;
1874 int fput_needed;
1875
1876 filp = fget_light(fd, &fput_needed);
1877 if (!filp)
1878 goto out;
1879
1880 /* RED-PEN how should LSM module know it's handling 32bit? */
1881 error = security_file_ioctl(filp, cmd, arg);
1882 if (error)
1883 goto out_fput;
1884
1885 /*
1886 * To allow the compat_ioctl handlers to be self contained
1887 * we need to check the common ioctls here first.
1888 * Just handle them with the standard handlers below.
1889 */
1890 switch (cmd) {
1891 case FIOCLEX:
1892 case FIONCLEX:
1893 case FIONBIO:
1894 case FIOASYNC:
1895 case FIOQSIZE:
1896 break;
1897
3e63cbb1
AJ
1898#if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
1899 case FS_IOC_RESVSP_32:
1900 case FS_IOC_RESVSP64_32:
1901 error = compat_ioctl_preallocate(filp, arg);
1902 goto out_fput;
1903#else
1904 case FS_IOC_RESVSP:
1905 case FS_IOC_RESVSP64:
7779d7be 1906 error = ioctl_preallocate(filp, compat_ptr(arg));
3e63cbb1
AJ
1907 goto out_fput;
1908#endif
1909
6272e266
CH
1910 case FIBMAP:
1911 case FIGETBSZ:
1912 case FIONREAD:
1913 if (S_ISREG(filp->f_path.dentry->d_inode->i_mode))
1914 break;
1915 /*FALL THROUGH*/
1916
1917 default:
1918 if (filp->f_op && filp->f_op->compat_ioctl) {
1919 error = filp->f_op->compat_ioctl(filp, cmd, arg);
1920 if (error != -ENOIOCTLCMD)
1921 goto out_fput;
1922 }
1923
1924 if (!filp->f_op ||
1925 (!filp->f_op->ioctl && !filp->f_op->unlocked_ioctl))
1926 goto do_ioctl;
1927 break;
1928 }
1929
1930 for (t = ioctl32_hash_table[ioctl32_hash(cmd)]; t; t = t->next) {
1931 if (t->cmd == cmd)
1932 goto found_handler;
1933 }
1934
5a07ea0b
AB
1935 error = do_ioctl_trans(fd, cmd, arg, filp);
1936 if (error == -ENOIOCTLCMD) {
6272e266
CH
1937 static int count;
1938
1939 if (++count <= 50)
1940 compat_ioctl_error(filp, fd, cmd, arg);
1941 error = -EINVAL;
1942 }
1943
1944 goto out_fput;
1945
1946 found_handler:
1947 if (t->handler) {
6272e266 1948 error = t->handler(fd, cmd, arg, filp);
6272e266
CH
1949 goto out_fput;
1950 }
1951
1952 do_ioctl:
deb21db7 1953 error = do_vfs_ioctl(filp, fd, cmd, arg);
6272e266
CH
1954 out_fput:
1955 fput_light(filp, fput_needed);
1956 out:
1957 return error;
1958}
1959
1960static void ioctl32_insert_translation(struct ioctl_trans *trans)
1961{
1962 unsigned long hash;
1963 struct ioctl_trans *t;
1964
1965 hash = ioctl32_hash (trans->cmd);
1966 if (!ioctl32_hash_table[hash])
1967 ioctl32_hash_table[hash] = trans;
1968 else {
1969 t = ioctl32_hash_table[hash];
1970 while (t->next)
1971 t = t->next;
1972 trans->next = NULL;
1973 t->next = trans;
1974 }
1975}
1976
1977static int __init init_sys32_ioctl(void)
1978{
1979 int i;
1980
1981 for (i = 0; i < ARRAY_SIZE(ioctl_start); i++) {
c80544dc 1982 if (ioctl_start[i].next) {
6272e266
CH
1983 printk("ioctl translation %d bad\n",i);
1984 return -1;
1985 }
1986
1987 ioctl32_insert_translation(&ioctl_start[i]);
1988 }
1989 return 0;
1990}
1991__initcall(init_sys32_ioctl);