compat_ioctl: Remove BKL
[deliverable/linux.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
3ff6eecc 638static __used int
1da177e4
LT
639ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
640{
641 return -EINVAL;
642}
643
1da177e4
LT
644static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
645{
646 return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
647}
648
1da177e4
LT
649/* Bluetooth ioctls */
650#define HCIUARTSETPROTO _IOW('U', 200, int)
651#define HCIUARTGETPROTO _IOR('U', 201, int)
652
653#define BNEPCONNADD _IOW('B', 200, int)
654#define BNEPCONNDEL _IOW('B', 201, int)
655#define BNEPGETCONNLIST _IOR('B', 210, int)
656#define BNEPGETCONNINFO _IOR('B', 211, int)
657
658#define CMTPCONNADD _IOW('C', 200, int)
659#define CMTPCONNDEL _IOW('C', 201, int)
660#define CMTPGETCONNLIST _IOR('C', 210, int)
661#define CMTPGETCONNINFO _IOR('C', 211, int)
662
663#define HIDPCONNADD _IOW('H', 200, int)
664#define HIDPCONNDEL _IOW('H', 201, int)
665#define HIDPGETCONNLIST _IOR('H', 210, int)
666#define HIDPGETCONNINFO _IOR('H', 211, int)
667
9361401e 668#ifdef CONFIG_BLOCK
1da177e4
LT
669struct raw32_config_request
670{
671 compat_int_t raw_minor;
672 __u64 block_major;
673 __u64 block_minor;
674} __attribute__((packed));
675
676static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
677{
678 int ret;
679
680 if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request)))
681 return -EFAULT;
682
683 ret = __get_user(req->raw_minor, &user_req->raw_minor);
684 ret |= __get_user(req->block_major, &user_req->block_major);
685 ret |= __get_user(req->block_minor, &user_req->block_minor);
686
687 return ret ? -EFAULT : 0;
688}
689
690static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
691{
692 int ret;
693
694 if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request)))
695 return -EFAULT;
696
697 ret = __put_user(req->raw_minor, &user_req->raw_minor);
698 ret |= __put_user(req->block_major, &user_req->block_major);
699 ret |= __put_user(req->block_minor, &user_req->block_minor);
700
701 return ret ? -EFAULT : 0;
702}
703
704static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
705{
706 int ret;
707
708 switch (cmd) {
709 case RAW_SETBIND:
710 case RAW_GETBIND: {
711 struct raw_config_request req;
712 struct raw32_config_request __user *user_req = compat_ptr(arg);
713 mm_segment_t oldfs = get_fs();
714
715 if ((ret = get_raw32_request(&req, user_req)))
716 return ret;
717
718 set_fs(KERNEL_DS);
719 ret = sys_ioctl(fd,cmd,(unsigned long)&req);
720 set_fs(oldfs);
721
722 if ((!ret) && (cmd == RAW_GETBIND)) {
723 ret = set_raw32_request(&req, user_req);
724 }
725 break;
726 }
727 default:
728 ret = sys_ioctl(fd, cmd, arg);
729 break;
730 }
731 return ret;
732}
9361401e 733#endif /* CONFIG_BLOCK */
1da177e4
LT
734
735struct serial_struct32 {
736 compat_int_t type;
737 compat_int_t line;
738 compat_uint_t port;
739 compat_int_t irq;
740 compat_int_t flags;
741 compat_int_t xmit_fifo_size;
742 compat_int_t custom_divisor;
743 compat_int_t baud_base;
744 unsigned short close_delay;
745 char io_type;
746 char reserved_char[1];
747 compat_int_t hub6;
748 unsigned short closing_wait; /* time to wait before closing */
749 unsigned short closing_wait2; /* no longer used... */
750 compat_uint_t iomem_base;
751 unsigned short iomem_reg_shift;
752 unsigned int port_high;
753 /* compat_ulong_t iomap_base FIXME */
754 compat_int_t reserved[1];
755};
756
757static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
758{
759 typedef struct serial_struct SS;
760 typedef struct serial_struct32 SS32;
761 struct serial_struct32 __user *ss32 = compat_ptr(arg);
762 int err;
763 struct serial_struct ss;
764 mm_segment_t oldseg = get_fs();
765 __u32 udata;
7116e994 766 unsigned int base;
1da177e4
LT
767
768 if (cmd == TIOCSSERIAL) {
769 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
770 return -EFAULT;
771 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
772 return -EFAULT;
7116e994
HC
773 if (__get_user(udata, &ss32->iomem_base))
774 return -EFAULT;
1da177e4 775 ss.iomem_base = compat_ptr(udata);
7116e994
HC
776 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
777 __get_user(ss.port_high, &ss32->port_high))
778 return -EFAULT;
1da177e4
LT
779 ss.iomap_base = 0UL;
780 }
781 set_fs(KERNEL_DS);
782 err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
783 set_fs(oldseg);
784 if (cmd == TIOCGSERIAL && err >= 0) {
785 if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32)))
786 return -EFAULT;
787 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
788 return -EFAULT;
7116e994
HC
789 base = (unsigned long)ss.iomem_base >> 32 ?
790 0xffffffff : (unsigned)(unsigned long)ss.iomem_base;
791 if (__put_user(base, &ss32->iomem_base) ||
792 __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
793 __put_user(ss.port_high, &ss32->port_high))
794 return -EFAULT;
1da177e4
LT
795 }
796 return err;
797}
798
799struct usbdevfs_ctrltransfer32 {
800 u8 bRequestType;
801 u8 bRequest;
802 u16 wValue;
803 u16 wIndex;
804 u16 wLength;
805 u32 timeout; /* in milliseconds */
806 compat_caddr_t data;
807};
808
809#define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
810
811static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
812{
813 struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg);
814 struct usbdevfs_ctrltransfer __user *p;
815 __u32 udata;
816 p = compat_alloc_user_space(sizeof(*p));
817 if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
818 get_user(udata, &p32->data) ||
819 put_user(compat_ptr(udata), &p->data))
820 return -EFAULT;
821 return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p);
822}
823
824
825struct usbdevfs_bulktransfer32 {
826 compat_uint_t ep;
827 compat_uint_t len;
828 compat_uint_t timeout; /* in milliseconds */
829 compat_caddr_t data;
830};
831
832#define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
833
834static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
835{
836 struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg);
837 struct usbdevfs_bulktransfer __user *p;
838 compat_uint_t n;
839 compat_caddr_t addr;
840
841 p = compat_alloc_user_space(sizeof(*p));
842
843 if (get_user(n, &p32->ep) || put_user(n, &p->ep) ||
844 get_user(n, &p32->len) || put_user(n, &p->len) ||
845 get_user(n, &p32->timeout) || put_user(n, &p->timeout) ||
846 get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data))
847 return -EFAULT;
848
849 return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p);
850}
851
852
853/*
854 * USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY
855 * are handled in usbdevfs core. -Christopher Li
856 */
857
858struct usbdevfs_disconnectsignal32 {
859 compat_int_t signr;
860 compat_caddr_t context;
861};
862
863#define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
864
865static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
866{
867 struct usbdevfs_disconnectsignal kdis;
868 struct usbdevfs_disconnectsignal32 __user *udis;
869 mm_segment_t old_fs;
870 u32 uctx;
871 int err;
872
873 udis = compat_ptr(arg);
874
875 if (get_user(kdis.signr, &udis->signr) ||
876 __get_user(uctx, &udis->context))
877 return -EFAULT;
878
879 kdis.context = compat_ptr(uctx);
880
881 old_fs = get_fs();
882 set_fs(KERNEL_DS);
883 err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
884 set_fs(old_fs);
885
886 return err;
887}
888
889/*
890 * I2C layer ioctls
891 */
892
893struct i2c_msg32 {
894 u16 addr;
895 u16 flags;
896 u16 len;
897 compat_caddr_t buf;
898};
899
900struct i2c_rdwr_ioctl_data32 {
901 compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
902 u32 nmsgs;
903};
904
905struct i2c_smbus_ioctl_data32 {
906 u8 read_write;
907 u8 command;
908 u32 size;
909 compat_caddr_t data; /* union i2c_smbus_data *data */
910};
911
912struct i2c_rdwr_aligned {
913 struct i2c_rdwr_ioctl_data cmd;
914 struct i2c_msg msgs[0];
915};
916
917static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
918{
919 struct i2c_rdwr_ioctl_data32 __user *udata = compat_ptr(arg);
920 struct i2c_rdwr_aligned __user *tdata;
921 struct i2c_msg __user *tmsgs;
922 struct i2c_msg32 __user *umsgs;
923 compat_caddr_t datap;
924 int nmsgs, i;
925
926 if (get_user(nmsgs, &udata->nmsgs))
927 return -EFAULT;
928 if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
929 return -EINVAL;
930
931 if (get_user(datap, &udata->msgs))
932 return -EFAULT;
933 umsgs = compat_ptr(datap);
934
935 tdata = compat_alloc_user_space(sizeof(*tdata) +
936 nmsgs * sizeof(struct i2c_msg));
937 tmsgs = &tdata->msgs[0];
938
939 if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
940 put_user(tmsgs, &tdata->cmd.msgs))
941 return -EFAULT;
942
943 for (i = 0; i < nmsgs; i++) {
944 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
945 return -EFAULT;
946 if (get_user(datap, &umsgs[i].buf) ||
947 put_user(compat_ptr(datap), &tmsgs[i].buf))
948 return -EFAULT;
949 }
950 return sys_ioctl(fd, cmd, (unsigned long)tdata);
951}
952
953static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
954{
955 struct i2c_smbus_ioctl_data __user *tdata;
956 struct i2c_smbus_ioctl_data32 __user *udata;
957 compat_caddr_t datap;
958
959 tdata = compat_alloc_user_space(sizeof(*tdata));
960 if (tdata == NULL)
961 return -ENOMEM;
962 if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
963 return -EFAULT;
964
965 udata = compat_ptr(arg);
966 if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
967 return -EFAULT;
968
969 if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
970 return -EFAULT;
971 if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
972 return -EFAULT;
973 if (__get_user(datap, &udata->data) ||
974 __put_user(compat_ptr(datap), &tdata->data))
975 return -EFAULT;
976
977 return sys_ioctl(fd, cmd, (unsigned long)tdata);
978}
979
ec3cad96
CH
980#define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
981#define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t)
982#define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
983#define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t)
984
985static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
986{
987 mm_segment_t oldfs = get_fs();
988 compat_ulong_t val32;
989 unsigned long kval;
990 int ret;
991
992 switch (cmd) {
993 case RTC_IRQP_READ32:
994 case RTC_EPOCH_READ32:
995 set_fs(KERNEL_DS);
996 ret = sys_ioctl(fd, (cmd == RTC_IRQP_READ32) ?
997 RTC_IRQP_READ : RTC_EPOCH_READ,
998 (unsigned long)&kval);
999 set_fs(oldfs);
1000 if (ret)
1001 return ret;
1002 val32 = kval;
1003 return put_user(val32, (unsigned int __user *)arg);
1004 case RTC_IRQP_SET32:
fc5870f6 1005 return sys_ioctl(fd, RTC_IRQP_SET, arg);
ec3cad96 1006 case RTC_EPOCH_SET32:
fc5870f6 1007 return sys_ioctl(fd, RTC_EPOCH_SET, arg);
ec3cad96
CH
1008 default:
1009 /* unreached */
1010 return -ENOIOCTLCMD;
1011 }
1012}
1013
c6b44d10
AK
1014static int
1015lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1016{
6b2b4e5a
AV
1017 struct compat_timeval __user *tc = (struct compat_timeval __user *)arg;
1018 struct timeval __user *tn = compat_alloc_user_space(sizeof(struct timeval));
c6b44d10
AK
1019 struct timeval ts;
1020 if (get_user(ts.tv_sec, &tc->tv_sec) ||
1021 get_user(ts.tv_usec, &tc->tv_usec) ||
1022 put_user(ts.tv_sec, &tn->tv_sec) ||
1023 put_user(ts.tv_usec, &tn->tv_usec))
1024 return -EFAULT;
1025 return sys_ioctl(fd, cmd, (unsigned long)tn);
1026}
1027
3e63cbb1
AJ
1028/* on ia32 l_start is on a 32-bit boundary */
1029#if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
1030struct space_resv_32 {
1031 __s16 l_type;
1032 __s16 l_whence;
1033 __s64 l_start __attribute__((packed));
1034 /* len == 0 means until end of file */
1035 __s64 l_len __attribute__((packed));
1036 __s32 l_sysid;
1037 __u32 l_pid;
1038 __s32 l_pad[4]; /* reserve area */
1039};
1040
1041#define FS_IOC_RESVSP_32 _IOW ('X', 40, struct space_resv_32)
1042#define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32)
1043
1044/* just account for different alignment */
1045static int compat_ioctl_preallocate(struct file *file, unsigned long arg)
1046{
7779d7be 1047 struct space_resv_32 __user *p32 = compat_ptr(arg);
3e63cbb1
AJ
1048 struct space_resv __user *p = compat_alloc_user_space(sizeof(*p));
1049
1050 if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) ||
1051 copy_in_user(&p->l_whence, &p32->l_whence, sizeof(s16)) ||
1052 copy_in_user(&p->l_start, &p32->l_start, sizeof(s64)) ||
1053 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
1054 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
1055 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
1056 copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
1057 return -EFAULT;
1058
1059 return ioctl_preallocate(file, p);
1060}
1061#endif
1062
6272e266
CH
1063
1064typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int,
1065 unsigned long, struct file *);
1066
1067struct ioctl_trans {
1068 unsigned long cmd;
1069 ioctl_trans_handler_t handler;
1070 struct ioctl_trans *next;
1071};
1072
e6a6d2ef
CH
1073#define HANDLE_IOCTL(cmd,handler) \
1074 { (cmd), (ioctl_trans_handler_t)(handler) },
1075
1076/* pointer to compatible structure or no argument */
1077#define COMPATIBLE_IOCTL(cmd) \
1078 { (cmd), do_ioctl32_pointer },
1079
1080/* argument is an unsigned long integer, not a pointer */
1081#define ULONG_IOCTL(cmd) \
1082 { (cmd), (ioctl_trans_handler_t)sys_ioctl },
1da177e4 1083
421f0281
AK
1084/* ioctl should not be warned about even if it's not implemented.
1085 Valid reasons to use this:
1086 - It is implemented with ->compat_ioctl on some device, but programs
1087 call it on others too.
1088 - The ioctl is not implemented in the native kernel, but programs
1089 call it commonly anyways.
1090 Most other reasons are not valid. */
1091#define IGNORE_IOCTL(cmd) COMPATIBLE_IOCTL(cmd)
e6a6d2ef 1092
6272e266 1093static struct ioctl_trans ioctl_start[] = {
644fd4f5
CH
1094/* compatible ioctls first */
1095COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */
1096COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */
1097
1098/* Big T */
1099COMPATIBLE_IOCTL(TCGETA)
1100COMPATIBLE_IOCTL(TCSETA)
1101COMPATIBLE_IOCTL(TCSETAW)
1102COMPATIBLE_IOCTL(TCSETAF)
1103COMPATIBLE_IOCTL(TCSBRK)
1104ULONG_IOCTL(TCSBRKP)
1105COMPATIBLE_IOCTL(TCXONC)
1106COMPATIBLE_IOCTL(TCFLSH)
1107COMPATIBLE_IOCTL(TCGETS)
1108COMPATIBLE_IOCTL(TCSETS)
1109COMPATIBLE_IOCTL(TCSETSW)
1110COMPATIBLE_IOCTL(TCSETSF)
1111COMPATIBLE_IOCTL(TIOCLINUX)
1112COMPATIBLE_IOCTL(TIOCSBRK)
1113COMPATIBLE_IOCTL(TIOCCBRK)
1114ULONG_IOCTL(TIOCMIWAIT)
1115COMPATIBLE_IOCTL(TIOCGICOUNT)
1116/* Little t */
1117COMPATIBLE_IOCTL(TIOCGETD)
1118COMPATIBLE_IOCTL(TIOCSETD)
1119COMPATIBLE_IOCTL(TIOCEXCL)
1120COMPATIBLE_IOCTL(TIOCNXCL)
1121COMPATIBLE_IOCTL(TIOCCONS)
1122COMPATIBLE_IOCTL(TIOCGSOFTCAR)
1123COMPATIBLE_IOCTL(TIOCSSOFTCAR)
1124COMPATIBLE_IOCTL(TIOCSWINSZ)
1125COMPATIBLE_IOCTL(TIOCGWINSZ)
1126COMPATIBLE_IOCTL(TIOCMGET)
1127COMPATIBLE_IOCTL(TIOCMBIC)
1128COMPATIBLE_IOCTL(TIOCMBIS)
1129COMPATIBLE_IOCTL(TIOCMSET)
1130COMPATIBLE_IOCTL(TIOCPKT)
1131COMPATIBLE_IOCTL(TIOCNOTTY)
1132COMPATIBLE_IOCTL(TIOCSTI)
1133COMPATIBLE_IOCTL(TIOCOUTQ)
1134COMPATIBLE_IOCTL(TIOCSPGRP)
1135COMPATIBLE_IOCTL(TIOCGPGRP)
1136ULONG_IOCTL(TIOCSCTTY)
1137COMPATIBLE_IOCTL(TIOCGPTN)
1138COMPATIBLE_IOCTL(TIOCSPTLCK)
1139COMPATIBLE_IOCTL(TIOCSERGETLSR)
81257def
HC
1140#ifdef TCGETS2
1141COMPATIBLE_IOCTL(TCGETS2)
1142COMPATIBLE_IOCTL(TCSETS2)
1143COMPATIBLE_IOCTL(TCSETSW2)
1144COMPATIBLE_IOCTL(TCSETSF2)
1145#endif
644fd4f5
CH
1146/* Little f */
1147COMPATIBLE_IOCTL(FIOCLEX)
1148COMPATIBLE_IOCTL(FIONCLEX)
1149COMPATIBLE_IOCTL(FIOASYNC)
1150COMPATIBLE_IOCTL(FIONBIO)
1151COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */
69130c7c 1152COMPATIBLE_IOCTL(FS_IOC_FIEMAP)
644fd4f5
CH
1153/* 0x00 */
1154COMPATIBLE_IOCTL(FIBMAP)
1155COMPATIBLE_IOCTL(FIGETBSZ)
5cf8cf41
CH
1156/* 'X' - originally XFS but some now in the VFS */
1157COMPATIBLE_IOCTL(FIFREEZE)
1158COMPATIBLE_IOCTL(FITHAW)
644fd4f5
CH
1159/* RAID */
1160COMPATIBLE_IOCTL(RAID_VERSION)
1161COMPATIBLE_IOCTL(GET_ARRAY_INFO)
1162COMPATIBLE_IOCTL(GET_DISK_INFO)
1163COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
1164COMPATIBLE_IOCTL(RAID_AUTORUN)
1165COMPATIBLE_IOCTL(CLEAR_ARRAY)
1166COMPATIBLE_IOCTL(ADD_NEW_DISK)
1167ULONG_IOCTL(HOT_REMOVE_DISK)
1168COMPATIBLE_IOCTL(SET_ARRAY_INFO)
1169COMPATIBLE_IOCTL(SET_DISK_INFO)
1170COMPATIBLE_IOCTL(WRITE_RAID_INFO)
1171COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
1172COMPATIBLE_IOCTL(PROTECT_ARRAY)
1173ULONG_IOCTL(HOT_ADD_DISK)
1174ULONG_IOCTL(SET_DISK_FAULTY)
1175COMPATIBLE_IOCTL(RUN_ARRAY)
1176COMPATIBLE_IOCTL(STOP_ARRAY)
1177COMPATIBLE_IOCTL(STOP_ARRAY_RO)
1178COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
1179COMPATIBLE_IOCTL(GET_BITMAP_FILE)
1180ULONG_IOCTL(SET_BITMAP_FILE)
fb07a5f8 1181/* Keyboard -- can be removed once tty3270 uses ops->compat_ioctl */
644fd4f5
CH
1182ULONG_IOCTL(KDSIGACCEPT)
1183COMPATIBLE_IOCTL(KDGETKEYCODE)
1184COMPATIBLE_IOCTL(KDSETKEYCODE)
1185ULONG_IOCTL(KIOCSOUND)
1186ULONG_IOCTL(KDMKTONE)
1187COMPATIBLE_IOCTL(KDGKBTYPE)
1188ULONG_IOCTL(KDSETMODE)
1189COMPATIBLE_IOCTL(KDGETMODE)
1190ULONG_IOCTL(KDSKBMODE)
1191COMPATIBLE_IOCTL(KDGKBMODE)
1192ULONG_IOCTL(KDSKBMETA)
1193COMPATIBLE_IOCTL(KDGKBMETA)
1194COMPATIBLE_IOCTL(KDGKBENT)
1195COMPATIBLE_IOCTL(KDSKBENT)
1196COMPATIBLE_IOCTL(KDGKBSENT)
1197COMPATIBLE_IOCTL(KDSKBSENT)
1198COMPATIBLE_IOCTL(KDGKBDIACR)
1199COMPATIBLE_IOCTL(KDSKBDIACR)
1200COMPATIBLE_IOCTL(KDKBDREP)
1201COMPATIBLE_IOCTL(KDGKBLED)
1202ULONG_IOCTL(KDSKBLED)
1203COMPATIBLE_IOCTL(KDGETLED)
1204ULONG_IOCTL(KDSETLED)
3c3622dc 1205#ifdef CONFIG_BLOCK
644fd4f5
CH
1206/* Big S */
1207COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
1208COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
1209COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
1210COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
1211COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
1212COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
1213COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
1214COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
3c3622dc 1215#endif
644fd4f5
CH
1216/* Little p (/dev/rtc, /dev/envctrl, etc.) */
1217COMPATIBLE_IOCTL(RTC_AIE_ON)
1218COMPATIBLE_IOCTL(RTC_AIE_OFF)
1219COMPATIBLE_IOCTL(RTC_UIE_ON)
1220COMPATIBLE_IOCTL(RTC_UIE_OFF)
1221COMPATIBLE_IOCTL(RTC_PIE_ON)
1222COMPATIBLE_IOCTL(RTC_PIE_OFF)
1223COMPATIBLE_IOCTL(RTC_WIE_ON)
1224COMPATIBLE_IOCTL(RTC_WIE_OFF)
1225COMPATIBLE_IOCTL(RTC_ALM_SET)
1226COMPATIBLE_IOCTL(RTC_ALM_READ)
1227COMPATIBLE_IOCTL(RTC_RD_TIME)
1228COMPATIBLE_IOCTL(RTC_SET_TIME)
1229COMPATIBLE_IOCTL(RTC_WKALM_SET)
1230COMPATIBLE_IOCTL(RTC_WKALM_RD)
1231/*
1232 * These two are only for the sbus rtc driver, but
1233 * hwclock tries them on every rtc device first when
1234 * running on sparc. On other architectures the entries
1235 * are useless but harmless.
1236 */
1237COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
1238COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
1239/* Little m */
1240COMPATIBLE_IOCTL(MTIOCTOP)
1241/* Socket level stuff */
1242COMPATIBLE_IOCTL(FIOQSIZE)
3c3622dc 1243#ifdef CONFIG_BLOCK
644fd4f5
CH
1244/* SG stuff */
1245COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
1246COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
1247COMPATIBLE_IOCTL(SG_EMULATED_HOST)
1248ULONG_IOCTL(SG_SET_TRANSFORM)
1249COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
1250COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
1251COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
1252COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
1253COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
1254COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
1255COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
1256COMPATIBLE_IOCTL(SG_GET_PACK_ID)
1257COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
1258COMPATIBLE_IOCTL(SG_SET_DEBUG)
1259COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
1260COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
1261COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
1262COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
1263COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
1264COMPATIBLE_IOCTL(SG_SCSI_RESET)
1265COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
1266COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
1267COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
3c3622dc 1268#endif
644fd4f5
CH
1269/* PPP stuff */
1270COMPATIBLE_IOCTL(PPPIOCGFLAGS)
1271COMPATIBLE_IOCTL(PPPIOCSFLAGS)
1272COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
1273COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
1274COMPATIBLE_IOCTL(PPPIOCGUNIT)
1275COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
1276COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
1277COMPATIBLE_IOCTL(PPPIOCGMRU)
1278COMPATIBLE_IOCTL(PPPIOCSMRU)
1279COMPATIBLE_IOCTL(PPPIOCSMAXCID)
1280COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
1281COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
1282COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
1283/* PPPIOCSCOMPRESS is translated */
1284COMPATIBLE_IOCTL(PPPIOCGNPMODE)
1285COMPATIBLE_IOCTL(PPPIOCSNPMODE)
1286COMPATIBLE_IOCTL(PPPIOCGDEBUG)
1287COMPATIBLE_IOCTL(PPPIOCSDEBUG)
1288/* PPPIOCSPASS is translated */
1289/* PPPIOCSACTIVE is translated */
1290/* PPPIOCGIDLE is translated */
1291COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
1292COMPATIBLE_IOCTL(PPPIOCATTACH)
1293COMPATIBLE_IOCTL(PPPIOCDETACH)
1294COMPATIBLE_IOCTL(PPPIOCSMRRU)
1295COMPATIBLE_IOCTL(PPPIOCCONNECT)
1296COMPATIBLE_IOCTL(PPPIOCDISCONN)
1297COMPATIBLE_IOCTL(PPPIOCATTCHAN)
1298COMPATIBLE_IOCTL(PPPIOCGCHAN)
1299/* PPPOX */
1300COMPATIBLE_IOCTL(PPPOEIOCSFWD)
1301COMPATIBLE_IOCTL(PPPOEIOCDFWD)
1302/* LP */
1303COMPATIBLE_IOCTL(LPGETSTATUS)
1304/* ppdev */
1305COMPATIBLE_IOCTL(PPSETMODE)
1306COMPATIBLE_IOCTL(PPRSTATUS)
1307COMPATIBLE_IOCTL(PPRCONTROL)
1308COMPATIBLE_IOCTL(PPWCONTROL)
1309COMPATIBLE_IOCTL(PPFCONTROL)
1310COMPATIBLE_IOCTL(PPRDATA)
1311COMPATIBLE_IOCTL(PPWDATA)
1312COMPATIBLE_IOCTL(PPCLAIM)
1313COMPATIBLE_IOCTL(PPRELEASE)
1314COMPATIBLE_IOCTL(PPYIELD)
1315COMPATIBLE_IOCTL(PPEXCL)
1316COMPATIBLE_IOCTL(PPDATADIR)
1317COMPATIBLE_IOCTL(PPNEGOT)
1318COMPATIBLE_IOCTL(PPWCTLONIRQ)
1319COMPATIBLE_IOCTL(PPCLRIRQ)
1320COMPATIBLE_IOCTL(PPSETPHASE)
1321COMPATIBLE_IOCTL(PPGETMODES)
1322COMPATIBLE_IOCTL(PPGETMODE)
1323COMPATIBLE_IOCTL(PPGETPHASE)
1324COMPATIBLE_IOCTL(PPGETFLAGS)
1325COMPATIBLE_IOCTL(PPSETFLAGS)
644fd4f5
CH
1326/* pktcdvd */
1327COMPATIBLE_IOCTL(PACKET_CTRL_CMD)
1328/* Big A */
1329/* sparc only */
1330/* Big Q for sound/OSS */
1331COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
1332COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
1333COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
1334COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
1335COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
1336COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
1337COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
1338COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
1339COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
1340COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
1341COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
1342COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
1343COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
1344COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
1345COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
1346COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
1347COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
1348COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
1349COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
1350COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
1351COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
1352COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
1353/* Big T for sound/OSS */
1354COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
1355COMPATIBLE_IOCTL(SNDCTL_TMR_START)
1356COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
1357COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
1358COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
1359COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
1360COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
1361COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
1362/* Little m for sound/OSS */
1363COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
1364COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
1365COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
1366/* Big P for sound/OSS */
1367COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
1368COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
1369COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
1370COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
1371COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
1372COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
1373COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
1374COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
1375COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
1376COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
1377COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
1378COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
1379COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
1380COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
1381COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
1382COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
1383COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
1384COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
1385COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
1386COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
1387/* SNDCTL_DSP_MAPINBUF, XXX needs translation */
1388/* SNDCTL_DSP_MAPOUTBUF, XXX needs translation */
1389COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
1390COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
1391COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
1392COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
1393COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
1394COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
1395COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
1396COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
1397/* Big C for sound/OSS */
1398COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
1399COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
1400COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
1401COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
1402COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
1403COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
1404COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
1405COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
1406COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
1407COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
1408/* Big M for sound/OSS */
1409COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
1410COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
1411COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
1412COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
1413COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
1414COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
1415COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
1416COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
1417COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
1418COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
1419COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
1420COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
1421COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
1422COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
1423COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
1424COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
1425COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
1426COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
1427COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
1428COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
1429COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
1430COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
1431COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
1432COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
1433COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
1434COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
1435/* SOUND_MIXER_READ_ENHANCE, same value as READ_MUTE */
1436/* SOUND_MIXER_READ_LOUD, same value as READ_MUTE */
1437COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
1438COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
1439COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
1440COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
1441COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
1442COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
1443COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
1444COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
1445COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
1446COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
1447COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
1448COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
1449COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
1450COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
1451COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
1452COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
1453COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
1454COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
1455COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
1456COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
1457COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
1458COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
1459COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
1460COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
1461COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
1462COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
1463COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
1464COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
1465COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
1466COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
1467COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
1468/* SOUND_MIXER_WRITE_ENHANCE, same value as WRITE_MUTE */
1469/* SOUND_MIXER_WRITE_LOUD, same value as WRITE_MUTE */
1470COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
1471COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
1472COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
1473COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
1474COMPATIBLE_IOCTL(SOUND_MIXER_AGC)
1475COMPATIBLE_IOCTL(SOUND_MIXER_3DSE)
1476COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
1477COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
1478COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
1479COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
1480COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
1481COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
1482COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
1483COMPATIBLE_IOCTL(OSS_GETVERSION)
1484/* AUTOFS */
1485ULONG_IOCTL(AUTOFS_IOC_READY)
1486ULONG_IOCTL(AUTOFS_IOC_FAIL)
1487COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
1488COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
1489COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
1490COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI)
1491COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOSUBVER)
644fd4f5
CH
1492COMPATIBLE_IOCTL(AUTOFS_IOC_ASKUMOUNT)
1493/* Raw devices */
1494COMPATIBLE_IOCTL(RAW_SETBIND)
1495COMPATIBLE_IOCTL(RAW_GETBIND)
1496/* SMB ioctls which do not need any translations */
1497COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
644fd4f5
CH
1498/* Watchdog */
1499COMPATIBLE_IOCTL(WDIOC_GETSUPPORT)
1500COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
1501COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS)
1502COMPATIBLE_IOCTL(WDIOC_GETTEMP)
1503COMPATIBLE_IOCTL(WDIOC_SETOPTIONS)
1504COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
1505COMPATIBLE_IOCTL(WDIOC_SETTIMEOUT)
1506COMPATIBLE_IOCTL(WDIOC_GETTIMEOUT)
1507/* Big R */
1508COMPATIBLE_IOCTL(RNDGETENTCNT)
1509COMPATIBLE_IOCTL(RNDADDTOENTCNT)
1510COMPATIBLE_IOCTL(RNDGETPOOL)
1511COMPATIBLE_IOCTL(RNDADDENTROPY)
1512COMPATIBLE_IOCTL(RNDZAPENTCNT)
1513COMPATIBLE_IOCTL(RNDCLEARPOOL)
1514/* Bluetooth */
1515COMPATIBLE_IOCTL(HCIDEVUP)
1516COMPATIBLE_IOCTL(HCIDEVDOWN)
1517COMPATIBLE_IOCTL(HCIDEVRESET)
1518COMPATIBLE_IOCTL(HCIDEVRESTAT)
1519COMPATIBLE_IOCTL(HCIGETDEVLIST)
1520COMPATIBLE_IOCTL(HCIGETDEVINFO)
1521COMPATIBLE_IOCTL(HCIGETCONNLIST)
1522COMPATIBLE_IOCTL(HCIGETCONNINFO)
40be492f 1523COMPATIBLE_IOCTL(HCIGETAUTHINFO)
644fd4f5
CH
1524COMPATIBLE_IOCTL(HCISETRAW)
1525COMPATIBLE_IOCTL(HCISETSCAN)
1526COMPATIBLE_IOCTL(HCISETAUTH)
1527COMPATIBLE_IOCTL(HCISETENCRYPT)
1528COMPATIBLE_IOCTL(HCISETPTYPE)
1529COMPATIBLE_IOCTL(HCISETLINKPOL)
1530COMPATIBLE_IOCTL(HCISETLINKMODE)
1531COMPATIBLE_IOCTL(HCISETACLMTU)
1532COMPATIBLE_IOCTL(HCISETSCOMTU)
1533COMPATIBLE_IOCTL(HCIINQUIRY)
1534COMPATIBLE_IOCTL(HCIUARTSETPROTO)
1535COMPATIBLE_IOCTL(HCIUARTGETPROTO)
1536COMPATIBLE_IOCTL(RFCOMMCREATEDEV)
1537COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
1538COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
1539COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
1540COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
1541COMPATIBLE_IOCTL(BNEPCONNADD)
1542COMPATIBLE_IOCTL(BNEPCONNDEL)
1543COMPATIBLE_IOCTL(BNEPGETCONNLIST)
1544COMPATIBLE_IOCTL(BNEPGETCONNINFO)
1545COMPATIBLE_IOCTL(CMTPCONNADD)
1546COMPATIBLE_IOCTL(CMTPCONNDEL)
1547COMPATIBLE_IOCTL(CMTPGETCONNLIST)
1548COMPATIBLE_IOCTL(CMTPGETCONNINFO)
1549COMPATIBLE_IOCTL(HIDPCONNADD)
1550COMPATIBLE_IOCTL(HIDPCONNDEL)
1551COMPATIBLE_IOCTL(HIDPGETCONNLIST)
1552COMPATIBLE_IOCTL(HIDPGETCONNINFO)
1553/* CAPI */
1554COMPATIBLE_IOCTL(CAPI_REGISTER)
1555COMPATIBLE_IOCTL(CAPI_GET_MANUFACTURER)
1556COMPATIBLE_IOCTL(CAPI_GET_VERSION)
1557COMPATIBLE_IOCTL(CAPI_GET_SERIAL)
1558COMPATIBLE_IOCTL(CAPI_GET_PROFILE)
1559COMPATIBLE_IOCTL(CAPI_MANUFACTURER_CMD)
1560COMPATIBLE_IOCTL(CAPI_GET_ERRCODE)
1561COMPATIBLE_IOCTL(CAPI_INSTALLED)
1562COMPATIBLE_IOCTL(CAPI_GET_FLAGS)
1563COMPATIBLE_IOCTL(CAPI_SET_FLAGS)
1564COMPATIBLE_IOCTL(CAPI_CLR_FLAGS)
1565COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT)
1566COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT)
1567/* Siemens Gigaset */
1568COMPATIBLE_IOCTL(GIGASET_REDIR)
1569COMPATIBLE_IOCTL(GIGASET_CONFIG)
1570COMPATIBLE_IOCTL(GIGASET_BRKCHARS)
1571COMPATIBLE_IOCTL(GIGASET_VERSION)
1572/* Misc. */
1573COMPATIBLE_IOCTL(0x41545900) /* ATYIO_CLKR */
1574COMPATIBLE_IOCTL(0x41545901) /* ATYIO_CLKW */
1575COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
1576COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
1577COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
1578COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
1579/* USB */
1580COMPATIBLE_IOCTL(USBDEVFS_RESETEP)
1581COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE)
1582COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION)
1583COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER)
1584COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB)
1585COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE)
1586COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE)
1587COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO)
1588COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO)
1589COMPATIBLE_IOCTL(USBDEVFS_RESET)
1590COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32)
1591COMPATIBLE_IOCTL(USBDEVFS_REAPURB32)
1592COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32)
1593COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
644fd4f5
CH
1594/* NBD */
1595ULONG_IOCTL(NBD_SET_SOCK)
1596ULONG_IOCTL(NBD_SET_BLKSIZE)
1597ULONG_IOCTL(NBD_SET_SIZE)
1598COMPATIBLE_IOCTL(NBD_DO_IT)
1599COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
1600COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
1601COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
1602ULONG_IOCTL(NBD_SET_SIZE_BLOCKS)
1603COMPATIBLE_IOCTL(NBD_DISCONNECT)
1604/* i2c */
1605COMPATIBLE_IOCTL(I2C_SLAVE)
1606COMPATIBLE_IOCTL(I2C_SLAVE_FORCE)
1607COMPATIBLE_IOCTL(I2C_TENBIT)
1608COMPATIBLE_IOCTL(I2C_PEC)
1609COMPATIBLE_IOCTL(I2C_RETRIES)
1610COMPATIBLE_IOCTL(I2C_TIMEOUT)
644fd4f5
CH
1611/* hiddev */
1612COMPATIBLE_IOCTL(HIDIOCGVERSION)
1613COMPATIBLE_IOCTL(HIDIOCAPPLICATION)
1614COMPATIBLE_IOCTL(HIDIOCGDEVINFO)
1615COMPATIBLE_IOCTL(HIDIOCGSTRING)
1616COMPATIBLE_IOCTL(HIDIOCINITREPORT)
1617COMPATIBLE_IOCTL(HIDIOCGREPORT)
1618COMPATIBLE_IOCTL(HIDIOCSREPORT)
1619COMPATIBLE_IOCTL(HIDIOCGREPORTINFO)
1620COMPATIBLE_IOCTL(HIDIOCGFIELDINFO)
1621COMPATIBLE_IOCTL(HIDIOCGUSAGE)
1622COMPATIBLE_IOCTL(HIDIOCSUSAGE)
1623COMPATIBLE_IOCTL(HIDIOCGUCODE)
1624COMPATIBLE_IOCTL(HIDIOCGFLAG)
1625COMPATIBLE_IOCTL(HIDIOCSFLAG)
1626COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINDEX)
1627COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINFO)
1628/* dvb */
1629COMPATIBLE_IOCTL(AUDIO_STOP)
1630COMPATIBLE_IOCTL(AUDIO_PLAY)
1631COMPATIBLE_IOCTL(AUDIO_PAUSE)
1632COMPATIBLE_IOCTL(AUDIO_CONTINUE)
1633COMPATIBLE_IOCTL(AUDIO_SELECT_SOURCE)
1634COMPATIBLE_IOCTL(AUDIO_SET_MUTE)
1635COMPATIBLE_IOCTL(AUDIO_SET_AV_SYNC)
1636COMPATIBLE_IOCTL(AUDIO_SET_BYPASS_MODE)
1637COMPATIBLE_IOCTL(AUDIO_CHANNEL_SELECT)
1638COMPATIBLE_IOCTL(AUDIO_GET_STATUS)
1639COMPATIBLE_IOCTL(AUDIO_GET_CAPABILITIES)
1640COMPATIBLE_IOCTL(AUDIO_CLEAR_BUFFER)
1641COMPATIBLE_IOCTL(AUDIO_SET_ID)
1642COMPATIBLE_IOCTL(AUDIO_SET_MIXER)
1643COMPATIBLE_IOCTL(AUDIO_SET_STREAMTYPE)
1644COMPATIBLE_IOCTL(AUDIO_SET_EXT_ID)
1645COMPATIBLE_IOCTL(AUDIO_SET_ATTRIBUTES)
1646COMPATIBLE_IOCTL(AUDIO_SET_KARAOKE)
1647COMPATIBLE_IOCTL(DMX_START)
1648COMPATIBLE_IOCTL(DMX_STOP)
1649COMPATIBLE_IOCTL(DMX_SET_FILTER)
1650COMPATIBLE_IOCTL(DMX_SET_PES_FILTER)
1651COMPATIBLE_IOCTL(DMX_SET_BUFFER_SIZE)
1652COMPATIBLE_IOCTL(DMX_GET_PES_PIDS)
1653COMPATIBLE_IOCTL(DMX_GET_CAPS)
1654COMPATIBLE_IOCTL(DMX_SET_SOURCE)
1655COMPATIBLE_IOCTL(DMX_GET_STC)
1656COMPATIBLE_IOCTL(FE_GET_INFO)
1657COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD)
1658COMPATIBLE_IOCTL(FE_DISEQC_SEND_MASTER_CMD)
1659COMPATIBLE_IOCTL(FE_DISEQC_RECV_SLAVE_REPLY)
1660COMPATIBLE_IOCTL(FE_DISEQC_SEND_BURST)
1661COMPATIBLE_IOCTL(FE_SET_TONE)
1662COMPATIBLE_IOCTL(FE_SET_VOLTAGE)
1663COMPATIBLE_IOCTL(FE_ENABLE_HIGH_LNB_VOLTAGE)
1664COMPATIBLE_IOCTL(FE_READ_STATUS)
1665COMPATIBLE_IOCTL(FE_READ_BER)
1666COMPATIBLE_IOCTL(FE_READ_SIGNAL_STRENGTH)
1667COMPATIBLE_IOCTL(FE_READ_SNR)
1668COMPATIBLE_IOCTL(FE_READ_UNCORRECTED_BLOCKS)
1669COMPATIBLE_IOCTL(FE_SET_FRONTEND)
1670COMPATIBLE_IOCTL(FE_GET_FRONTEND)
1671COMPATIBLE_IOCTL(FE_GET_EVENT)
1672COMPATIBLE_IOCTL(FE_DISHNETWORK_SEND_LEGACY_CMD)
1673COMPATIBLE_IOCTL(VIDEO_STOP)
1674COMPATIBLE_IOCTL(VIDEO_PLAY)
1675COMPATIBLE_IOCTL(VIDEO_FREEZE)
1676COMPATIBLE_IOCTL(VIDEO_CONTINUE)
1677COMPATIBLE_IOCTL(VIDEO_SELECT_SOURCE)
1678COMPATIBLE_IOCTL(VIDEO_SET_BLANK)
1679COMPATIBLE_IOCTL(VIDEO_GET_STATUS)
1680COMPATIBLE_IOCTL(VIDEO_SET_DISPLAY_FORMAT)
1681COMPATIBLE_IOCTL(VIDEO_FAST_FORWARD)
1682COMPATIBLE_IOCTL(VIDEO_SLOWMOTION)
1683COMPATIBLE_IOCTL(VIDEO_GET_CAPABILITIES)
1684COMPATIBLE_IOCTL(VIDEO_CLEAR_BUFFER)
1685COMPATIBLE_IOCTL(VIDEO_SET_ID)
1686COMPATIBLE_IOCTL(VIDEO_SET_STREAMTYPE)
1687COMPATIBLE_IOCTL(VIDEO_SET_FORMAT)
1688COMPATIBLE_IOCTL(VIDEO_SET_SYSTEM)
1689COMPATIBLE_IOCTL(VIDEO_SET_HIGHLIGHT)
1690COMPATIBLE_IOCTL(VIDEO_SET_SPU)
1691COMPATIBLE_IOCTL(VIDEO_GET_NAVI)
1692COMPATIBLE_IOCTL(VIDEO_SET_ATTRIBUTES)
1693COMPATIBLE_IOCTL(VIDEO_GET_SIZE)
1694COMPATIBLE_IOCTL(VIDEO_GET_FRAME_RATE)
1695
3fee37c1
AM
1696/* joystick */
1697COMPATIBLE_IOCTL(JSIOCGVERSION)
1698COMPATIBLE_IOCTL(JSIOCGAXES)
1699COMPATIBLE_IOCTL(JSIOCGBUTTONS)
1700COMPATIBLE_IOCTL(JSIOCGNAME(0))
1701
644fd4f5 1702/* now things that need handlers */
9361401e 1703#ifdef CONFIG_BLOCK
1da177e4 1704HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
2966387b 1705HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans)
9361401e 1706#endif
1da177e4
LT
1707HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans)
1708HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans)
1709HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans)
1710HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans)
9361401e 1711#ifdef CONFIG_BLOCK
1da177e4
LT
1712HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans)
1713HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans)
9361401e 1714#endif
1da177e4
LT
1715#define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
1716HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout)
1da177e4
LT
1717/* One SMB ioctl needs translations. */
1718#define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
1719HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
1da177e4 1720/* block stuff */
9361401e 1721#ifdef CONFIG_BLOCK
1ba0c7db
AB
1722/* loop */
1723IGNORE_IOCTL(LOOP_CLR_FD)
1da177e4
LT
1724/* Raw devices */
1725HANDLE_IOCTL(RAW_SETBIND, raw_ioctl)
1726HANDLE_IOCTL(RAW_GETBIND, raw_ioctl)
9361401e 1727#endif
1da177e4
LT
1728/* Serial */
1729HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl)
1730HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl)
9c0cbd54
CH
1731#ifdef TIOCGLTC
1732COMPATIBLE_IOCTL(TIOCGLTC)
1733COMPATIBLE_IOCTL(TIOCSLTC)
1734#endif
7a81e316
CH
1735#ifdef TIOCSTART
1736/*
6070d81e 1737 * For these two we have definitions in ioctls.h and/or termios.h on
7a81e316
CH
1738 * some architectures but no actual implemention. Some applications
1739 * like bash call them if they are defined in the headers, so we provide
1740 * entries here to avoid syslog message spew.
1741 */
1742COMPATIBLE_IOCTL(TIOCSTART)
1743COMPATIBLE_IOCTL(TIOCSTOP)
1744#endif
1da177e4
LT
1745/* Usbdevfs */
1746HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
1747HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
1748HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
c36fc889 1749COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
1da177e4
LT
1750/* i2c */
1751HANDLE_IOCTL(I2C_FUNCS, w_long)
1752HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
1753HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
9d016dd4 1754/* Not implemented in the native kernel */
ec3cad96
CH
1755HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl)
1756HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl)
1757HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl)
1758HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl)
1da177e4 1759
6e87abd0 1760/* dvb */
6e87abd0
DM
1761HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event)
1762HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture)
1763HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette)
c6b44d10
AK
1764
1765/* parport */
1766COMPATIBLE_IOCTL(LPTIME)
1767COMPATIBLE_IOCTL(LPCHAR)
1768COMPATIBLE_IOCTL(LPABORTOPEN)
1769COMPATIBLE_IOCTL(LPCAREFUL)
1770COMPATIBLE_IOCTL(LPWAIT)
1771COMPATIBLE_IOCTL(LPSETIRQ)
1772COMPATIBLE_IOCTL(LPGETSTATUS)
1773COMPATIBLE_IOCTL(LPGETSTATUS)
1774COMPATIBLE_IOCTL(LPRESET)
1775/*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/
1776COMPATIBLE_IOCTL(LPGETFLAGS)
1777HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans)
2724b6db
AK
1778
1779/* fat 'r' ioctls. These are handled by fat with ->compat_ioctl,
1780 but we don't want warnings on other file systems. So declare
1781 them as compatible here. */
1782#define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
1783#define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
1784
1785IGNORE_IOCTL(VFAT_IOCTL_READDIR_BOTH32)
1786IGNORE_IOCTL(VFAT_IOCTL_READDIR_SHORT32)
98701dc1 1787
8163904e
DM
1788#ifdef CONFIG_SPARC
1789/* Sparc framebuffers, handled in sbusfb_compat_ioctl() */
1790IGNORE_IOCTL(FBIOGTYPE)
1791IGNORE_IOCTL(FBIOSATTR)
1792IGNORE_IOCTL(FBIOGATTR)
1793IGNORE_IOCTL(FBIOSVIDEO)
1794IGNORE_IOCTL(FBIOGVIDEO)
1795IGNORE_IOCTL(FBIOSCURPOS)
1796IGNORE_IOCTL(FBIOGCURPOS)
1797IGNORE_IOCTL(FBIOGCURMAX)
1798IGNORE_IOCTL(FBIOPUTCMAP32)
1799IGNORE_IOCTL(FBIOGETCMAP32)
1800IGNORE_IOCTL(FBIOSCURSOR32)
1801IGNORE_IOCTL(FBIOGCURSOR32)
1802#endif
e6a6d2ef 1803};
6e87abd0 1804
6272e266
CH
1805#define IOCTL_HASHSIZE 256
1806static struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE];
1807
1808static inline unsigned long ioctl32_hash(unsigned long cmd)
1809{
1810 return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE;
1811}
1812
1813static void compat_ioctl_error(struct file *filp, unsigned int fd,
1814 unsigned int cmd, unsigned long arg)
1815{
1816 char buf[10];
1817 char *fn = "?";
1818 char *path;
1819
1820 /* find the name of the device. */
1821 path = (char *)__get_free_page(GFP_KERNEL);
1822 if (path) {
cf28b486 1823 fn = d_path(&filp->f_path, path, PAGE_SIZE);
6272e266
CH
1824 if (IS_ERR(fn))
1825 fn = "?";
1826 }
1827
1828 sprintf(buf,"'%c'", (cmd>>_IOC_TYPESHIFT) & _IOC_TYPEMASK);
1829 if (!isprint(buf[1]))
1830 sprintf(buf, "%02x", buf[1]);
1831 compat_printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
1832 "cmd(%08x){t:%s;sz:%u} arg(%08x) on %s\n",
1833 current->comm, current->pid,
1834 (int)fd, (unsigned int)cmd, buf,
1835 (cmd >> _IOC_SIZESHIFT) & _IOC_SIZEMASK,
1836 (unsigned int)arg, fn);
1837
1838 if (path)
1839 free_page((unsigned long)path);
1840}
1841
1842asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
1843 unsigned long arg)
1844{
1845 struct file *filp;
1846 int error = -EBADF;
1847 struct ioctl_trans *t;
1848 int fput_needed;
1849
1850 filp = fget_light(fd, &fput_needed);
1851 if (!filp)
1852 goto out;
1853
1854 /* RED-PEN how should LSM module know it's handling 32bit? */
1855 error = security_file_ioctl(filp, cmd, arg);
1856 if (error)
1857 goto out_fput;
1858
1859 /*
1860 * To allow the compat_ioctl handlers to be self contained
1861 * we need to check the common ioctls here first.
1862 * Just handle them with the standard handlers below.
1863 */
1864 switch (cmd) {
1865 case FIOCLEX:
1866 case FIONCLEX:
1867 case FIONBIO:
1868 case FIOASYNC:
1869 case FIOQSIZE:
1870 break;
1871
3e63cbb1
AJ
1872#if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
1873 case FS_IOC_RESVSP_32:
1874 case FS_IOC_RESVSP64_32:
1875 error = compat_ioctl_preallocate(filp, arg);
1876 goto out_fput;
1877#else
1878 case FS_IOC_RESVSP:
1879 case FS_IOC_RESVSP64:
7779d7be 1880 error = ioctl_preallocate(filp, compat_ptr(arg));
3e63cbb1
AJ
1881 goto out_fput;
1882#endif
1883
6272e266
CH
1884 case FIBMAP:
1885 case FIGETBSZ:
1886 case FIONREAD:
1887 if (S_ISREG(filp->f_path.dentry->d_inode->i_mode))
1888 break;
1889 /*FALL THROUGH*/
1890
1891 default:
1892 if (filp->f_op && filp->f_op->compat_ioctl) {
1893 error = filp->f_op->compat_ioctl(filp, cmd, arg);
1894 if (error != -ENOIOCTLCMD)
1895 goto out_fput;
1896 }
1897
1898 if (!filp->f_op ||
1899 (!filp->f_op->ioctl && !filp->f_op->unlocked_ioctl))
1900 goto do_ioctl;
1901 break;
1902 }
1903
1904 for (t = ioctl32_hash_table[ioctl32_hash(cmd)]; t; t = t->next) {
1905 if (t->cmd == cmd)
1906 goto found_handler;
1907 }
1908
d9de2622 1909 {
6272e266
CH
1910 static int count;
1911
1912 if (++count <= 50)
1913 compat_ioctl_error(filp, fd, cmd, arg);
1914 error = -EINVAL;
1915 }
1916
1917 goto out_fput;
1918
1919 found_handler:
1920 if (t->handler) {
6272e266 1921 error = t->handler(fd, cmd, arg, filp);
6272e266
CH
1922 goto out_fput;
1923 }
1924
1925 do_ioctl:
deb21db7 1926 error = do_vfs_ioctl(filp, fd, cmd, arg);
6272e266
CH
1927 out_fput:
1928 fput_light(filp, fput_needed);
1929 out:
1930 return error;
1931}
1932
1933static void ioctl32_insert_translation(struct ioctl_trans *trans)
1934{
1935 unsigned long hash;
1936 struct ioctl_trans *t;
1937
1938 hash = ioctl32_hash (trans->cmd);
1939 if (!ioctl32_hash_table[hash])
1940 ioctl32_hash_table[hash] = trans;
1941 else {
1942 t = ioctl32_hash_table[hash];
1943 while (t->next)
1944 t = t->next;
1945 trans->next = NULL;
1946 t->next = trans;
1947 }
1948}
1949
1950static int __init init_sys32_ioctl(void)
1951{
1952 int i;
1953
1954 for (i = 0; i < ARRAY_SIZE(ioctl_start); i++) {
c80544dc 1955 if (ioctl_start[i].next) {
6272e266
CH
1956 printk("ioctl translation %d bad\n",i);
1957 return -1;
1958 }
1959
1960 ioctl32_insert_translation(&ioctl_start[i]);
1961 }
1962 return 0;
1963}
1964__initcall(init_sys32_ioctl);
This page took 0.548726 seconds and 5 git commands to generate.