2 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
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)
9 * These routines maintain argument size conversion between 32bit and 64bit
13 #include <linux/types.h>
14 #include <linux/compat.h>
15 #include <linux/kernel.h>
16 #include <linux/capability.h>
17 #include <linux/compiler.h>
18 #include <linux/sched.h>
19 #include <linux/smp.h>
20 #include <linux/smp_lock.h>
21 #include <linux/ioctl.h>
23 #include <linux/if_bridge.h>
24 #include <linux/slab.h>
25 #include <linux/hdreg.h>
26 #include <linux/raid/md.h>
28 #include <linux/dirent.h>
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>
36 #include <linux/file.h>
38 #include <linux/ppp_defs.h>
39 #include <linux/if_ppp.h>
40 #include <linux/if_pppox.h>
41 #include <linux/mtio.h>
42 #include <linux/cdrom.h>
43 #include <linux/auto_fs.h>
44 #include <linux/auto_fs4.h>
45 #include <linux/tty.h>
46 #include <linux/vt_kern.h>
48 #include <linux/ext2_fs.h>
49 #include <linux/ext3_jbd.h>
50 #include <linux/ext3_fs.h>
51 #include <linux/videodev.h>
52 #include <linux/netdevice.h>
53 #include <linux/raw.h>
54 #include <linux/smb_fs.h>
55 #include <linux/blkpg.h>
56 #include <linux/blkdev.h>
57 #include <linux/elevator.h>
58 #include <linux/rtc.h>
59 #include <linux/pci.h>
60 #include <linux/module.h>
61 #include <linux/serial.h>
62 #include <linux/if_tun.h>
63 #include <linux/ctype.h>
64 #include <linux/ioctl32.h>
65 #include <linux/syscalls.h>
66 #include <linux/ncp_fs.h>
67 #include <linux/i2c.h>
68 #include <linux/i2c-dev.h>
69 #include <linux/wireless.h>
70 #include <linux/atalk.h>
71 #include <linux/blktrace_api.h>
73 #include <net/sock.h> /* siocdevprivate_ioctl */
74 #include <net/bluetooth/bluetooth.h>
75 #include <net/bluetooth/hci.h>
76 #include <net/bluetooth/rfcomm.h>
78 #include <linux/capi.h>
79 #include <linux/gigaset_dev.h>
81 #include <scsi/scsi.h>
82 #include <scsi/scsi_ioctl.h>
85 #include <asm/uaccess.h>
86 #include <linux/ethtool.h>
87 #include <linux/mii.h>
88 #include <linux/if_bonding.h>
89 #include <linux/watchdog.h>
90 #include <linux/dm-ioctl.h>
92 #include <linux/soundcard.h>
94 #include <linux/ppdev.h>
96 #include <linux/atm.h>
97 #include <linux/atmarp.h>
98 #include <linux/atmclip.h>
99 #include <linux/atmdev.h>
100 #include <linux/atmioc.h>
101 #include <linux/atmlec.h>
102 #include <linux/atmmpc.h>
103 #include <linux/atmsvc.h>
104 #include <linux/atm_tcp.h>
105 #include <linux/sonet.h>
106 #include <linux/atm_suni.h>
107 #include <linux/mtd/mtd.h>
109 #include <linux/usb.h>
110 #include <linux/usbdevice_fs.h>
111 #include <linux/nbd.h>
112 #include <linux/random.h>
113 #include <linux/filter.h>
114 #include <linux/msdos_fs.h>
115 #include <linux/pktcdvd.h>
117 #include <linux/hiddev.h>
119 #include <linux/dvb/audio.h>
120 #include <linux/dvb/dmx.h>
121 #include <linux/dvb/frontend.h>
122 #include <linux/dvb/video.h>
123 #include <linux/lp.h>
125 static int do_ioctl32_pointer(unsigned int fd
, unsigned int cmd
,
126 unsigned long arg
, struct file
*f
)
128 return sys_ioctl(fd
, cmd
, (unsigned long)compat_ptr(arg
));
131 static int w_long(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
133 mm_segment_t old_fs
= get_fs();
138 err
= sys_ioctl(fd
, cmd
, (unsigned long)&val
);
140 if (!err
&& put_user(val
, (u32 __user
*)compat_ptr(arg
)))
145 static int rw_long(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
147 mm_segment_t old_fs
= get_fs();
148 u32 __user
*argptr
= compat_ptr(arg
);
152 if(get_user(val
, argptr
))
155 err
= sys_ioctl(fd
, cmd
, (unsigned long)&val
);
157 if (!err
&& put_user(val
, argptr
))
162 static int do_ext2_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
164 /* These are just misnamed, they actually get/put from/to user an int */
166 case EXT2_IOC32_GETFLAGS
: cmd
= EXT2_IOC_GETFLAGS
; break;
167 case EXT2_IOC32_SETFLAGS
: cmd
= EXT2_IOC_SETFLAGS
; break;
168 case EXT2_IOC32_GETVERSION
: cmd
= EXT2_IOC_GETVERSION
; break;
169 case EXT2_IOC32_SETVERSION
: cmd
= EXT2_IOC_SETVERSION
; break;
171 return sys_ioctl(fd
, cmd
, (unsigned long)compat_ptr(arg
));
174 static int do_ext3_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
176 /* These are just misnamed, they actually get/put from/to user an int */
178 case EXT3_IOC32_GETVERSION
: cmd
= EXT3_IOC_GETVERSION
; break;
179 case EXT3_IOC32_SETVERSION
: cmd
= EXT3_IOC_SETVERSION
; break;
180 case EXT3_IOC32_GETRSVSZ
: cmd
= EXT3_IOC_GETRSVSZ
; break;
181 case EXT3_IOC32_SETRSVSZ
: cmd
= EXT3_IOC_SETRSVSZ
; break;
182 case EXT3_IOC32_GROUP_EXTEND
: cmd
= EXT3_IOC_GROUP_EXTEND
; break;
183 #ifdef CONFIG_JBD_DEBUG
184 case EXT3_IOC32_WAIT_FOR_READONLY
: cmd
= EXT3_IOC_WAIT_FOR_READONLY
; break;
187 return sys_ioctl(fd
, cmd
, (unsigned long)compat_ptr(arg
));
190 struct compat_video_event
{
192 compat_time_t timestamp
;
195 unsigned int frame_rate
;
199 static int do_video_get_event(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
201 struct video_event kevent
;
202 mm_segment_t old_fs
= get_fs();
206 err
= sys_ioctl(fd
, cmd
, (unsigned long) &kevent
);
210 struct compat_video_event __user
*up
= compat_ptr(arg
);
212 err
= put_user(kevent
.type
, &up
->type
);
213 err
|= put_user(kevent
.timestamp
, &up
->timestamp
);
214 err
|= put_user(kevent
.u
.size
.w
, &up
->u
.size
.w
);
215 err
|= put_user(kevent
.u
.size
.h
, &up
->u
.size
.h
);
216 err
|= put_user(kevent
.u
.size
.aspect_ratio
,
217 &up
->u
.size
.aspect_ratio
);
225 struct compat_video_still_picture
{
226 compat_uptr_t iFrame
;
230 static int do_video_stillpicture(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
232 struct compat_video_still_picture __user
*up
;
233 struct video_still_picture __user
*up_native
;
238 up
= (struct compat_video_still_picture __user
*) arg
;
239 err
= get_user(fp
, &up
->iFrame
);
240 err
|= get_user(size
, &up
->size
);
245 compat_alloc_user_space(sizeof(struct video_still_picture
));
247 put_user(compat_ptr(fp
), &up_native
->iFrame
);
248 put_user(size
, &up_native
->size
);
250 err
= sys_ioctl(fd
, cmd
, (unsigned long) up_native
);
255 struct compat_video_spu_palette
{
257 compat_uptr_t palette
;
260 static int do_video_set_spu_palette(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
262 struct compat_video_spu_palette __user
*up
;
263 struct video_spu_palette __user
*up_native
;
267 up
= (struct compat_video_spu_palette __user
*) arg
;
268 err
= get_user(palp
, &up
->palette
);
269 err
|= get_user(length
, &up
->length
);
271 up_native
= compat_alloc_user_space(sizeof(struct video_spu_palette
));
272 put_user(compat_ptr(palp
), &up_native
->palette
);
273 put_user(length
, &up_native
->length
);
275 err
= sys_ioctl(fd
, cmd
, (unsigned long) up_native
);
281 static int do_siocgstamp(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
283 struct compat_timeval __user
*up
= compat_ptr(arg
);
285 mm_segment_t old_fs
= get_fs();
289 err
= sys_ioctl(fd
, cmd
, (unsigned long)&ktv
);
292 err
= put_user(ktv
.tv_sec
, &up
->tv_sec
);
293 err
|= __put_user(ktv
.tv_usec
, &up
->tv_usec
);
299 compat_ulong_t mem_start
;
300 compat_ulong_t mem_end
;
301 unsigned short base_addr
;
308 #define IFHWADDRLEN 6
311 char ifrn_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
314 struct sockaddr ifru_addr
;
315 struct sockaddr ifru_dstaddr
;
316 struct sockaddr ifru_broadaddr
;
317 struct sockaddr ifru_netmask
;
318 struct sockaddr ifru_hwaddr
;
320 compat_int_t ifru_ivalue
;
321 compat_int_t ifru_mtu
;
322 struct ifmap32 ifru_map
;
323 char ifru_slave
[IFNAMSIZ
]; /* Just fits the size */
324 char ifru_newname
[IFNAMSIZ
];
325 compat_caddr_t ifru_data
;
326 /* XXXX? ifru_settings should be here */
331 compat_int_t ifc_len
; /* size of buffer */
332 compat_caddr_t ifcbuf
;
335 static int dev_ifname32(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
337 struct net_device
*dev
;
338 struct ifreq32 ifr32
;
341 if (copy_from_user(&ifr32
, compat_ptr(arg
), sizeof(ifr32
)))
344 dev
= dev_get_by_index(ifr32
.ifr_ifindex
);
348 strlcpy(ifr32
.ifr_name
, dev
->name
, sizeof(ifr32
.ifr_name
));
351 err
= copy_to_user(compat_ptr(arg
), &ifr32
, sizeof(ifr32
));
352 return (err
? -EFAULT
: 0);
355 static int dev_ifconf(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
357 struct ifconf32 ifc32
;
359 struct ifconf __user
*uifc
;
360 struct ifreq32 __user
*ifr32
;
361 struct ifreq __user
*ifr
;
365 if (copy_from_user(&ifc32
, compat_ptr(arg
), sizeof(struct ifconf32
)))
368 if (ifc32
.ifcbuf
== 0) {
372 uifc
= compat_alloc_user_space(sizeof(struct ifconf
));
374 size_t len
=((ifc32
.ifc_len
/ sizeof (struct ifreq32
)) + 1) *
375 sizeof (struct ifreq
);
376 uifc
= compat_alloc_user_space(sizeof(struct ifconf
) + len
);
378 ifr
= ifc
.ifc_req
= (void __user
*)(uifc
+ 1);
379 ifr32
= compat_ptr(ifc32
.ifcbuf
);
380 for (i
= 0; i
< ifc32
.ifc_len
; i
+= sizeof (struct ifreq32
)) {
381 if (copy_in_user(ifr
, ifr32
, sizeof(struct ifreq32
)))
387 if (copy_to_user(uifc
, &ifc
, sizeof(struct ifconf
)))
390 err
= sys_ioctl (fd
, SIOCGIFCONF
, (unsigned long)uifc
);
394 if (copy_from_user(&ifc
, uifc
, sizeof(struct ifconf
)))
398 ifr32
= compat_ptr(ifc32
.ifcbuf
);
400 i
+ sizeof (struct ifreq32
) <= ifc32
.ifc_len
&& j
< ifc
.ifc_len
;
401 i
+= sizeof (struct ifreq32
), j
+= sizeof (struct ifreq
)) {
402 if (copy_in_user(ifr32
, ifr
, sizeof (struct ifreq32
)))
408 if (ifc32
.ifcbuf
== 0) {
409 /* Translate from 64-bit structure multiple to
413 i
= ((i
/ sizeof(struct ifreq
)) * sizeof(struct ifreq32
));
418 if (copy_to_user(compat_ptr(arg
), &ifc32
, sizeof(struct ifconf32
)))
424 static int ethtool_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
426 struct ifreq __user
*ifr
;
427 struct ifreq32 __user
*ifr32
;
431 ifr
= compat_alloc_user_space(sizeof(*ifr
));
432 ifr32
= compat_ptr(arg
);
434 if (copy_in_user(&ifr
->ifr_name
, &ifr32
->ifr_name
, IFNAMSIZ
))
437 if (get_user(data
, &ifr32
->ifr_ifru
.ifru_data
))
440 datap
= compat_ptr(data
);
441 if (put_user(datap
, &ifr
->ifr_ifru
.ifru_data
))
444 return sys_ioctl(fd
, cmd
, (unsigned long) ifr
);
447 static int bond_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
450 struct ifreq __user
*uifr
;
451 struct ifreq32 __user
*ifr32
= compat_ptr(arg
);
458 case SIOCBONDENSLAVE
:
459 case SIOCBONDRELEASE
:
460 case SIOCBONDSETHWADDR
:
461 case SIOCBONDCHANGEACTIVE
:
462 if (copy_from_user(&kifr
, ifr32
, sizeof(struct ifreq32
)))
467 err
= sys_ioctl (fd
, cmd
, (unsigned long)&kifr
);
471 case SIOCBONDSLAVEINFOQUERY
:
472 case SIOCBONDINFOQUERY
:
473 uifr
= compat_alloc_user_space(sizeof(*uifr
));
474 if (copy_in_user(&uifr
->ifr_name
, &ifr32
->ifr_name
, IFNAMSIZ
))
477 if (get_user(data
, &ifr32
->ifr_ifru
.ifru_data
))
480 datap
= compat_ptr(data
);
481 if (put_user(datap
, &uifr
->ifr_ifru
.ifru_data
))
484 return sys_ioctl (fd
, cmd
, (unsigned long)uifr
);
490 int siocdevprivate_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
492 struct ifreq __user
*u_ifreq64
;
493 struct ifreq32 __user
*u_ifreq32
= compat_ptr(arg
);
494 char tmp_buf
[IFNAMSIZ
];
498 if (copy_from_user(&tmp_buf
[0], &(u_ifreq32
->ifr_ifrn
.ifrn_name
[0]),
501 if (__get_user(data32
, &u_ifreq32
->ifr_ifru
.ifru_data
))
503 data64
= compat_ptr(data32
);
505 u_ifreq64
= compat_alloc_user_space(sizeof(*u_ifreq64
));
507 /* Don't check these user accesses, just let that get trapped
508 * in the ioctl handler instead.
510 if (copy_to_user(&u_ifreq64
->ifr_ifrn
.ifrn_name
[0], &tmp_buf
[0],
513 if (__put_user(data64
, &u_ifreq64
->ifr_ifru
.ifru_data
))
516 return sys_ioctl(fd
, cmd
, (unsigned long) u_ifreq64
);
519 static int dev_ifsioc(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
522 struct ifreq32 __user
*uifr32
;
523 struct ifmap32 __user
*uifmap32
;
527 uifr32
= compat_ptr(arg
);
528 uifmap32
= &uifr32
->ifr_ifru
.ifru_map
;
531 err
= copy_from_user(&ifr
, uifr32
, sizeof(ifr
.ifr_name
));
532 err
|= __get_user(ifr
.ifr_map
.mem_start
, &uifmap32
->mem_start
);
533 err
|= __get_user(ifr
.ifr_map
.mem_end
, &uifmap32
->mem_end
);
534 err
|= __get_user(ifr
.ifr_map
.base_addr
, &uifmap32
->base_addr
);
535 err
|= __get_user(ifr
.ifr_map
.irq
, &uifmap32
->irq
);
536 err
|= __get_user(ifr
.ifr_map
.dma
, &uifmap32
->dma
);
537 err
|= __get_user(ifr
.ifr_map
.port
, &uifmap32
->port
);
542 if (copy_from_user(&ifr
, uifr32
, sizeof(*uifr32
)))
548 err
= sys_ioctl (fd
, cmd
, (unsigned long)&ifr
);
552 /* TUNSETIFF is defined as _IOW, it should be _IORW
553 * as the data is copied back to user space, but that
554 * cannot be fixed without breaking all existing apps.
568 if (copy_to_user(uifr32
, &ifr
, sizeof(*uifr32
)))
572 err
= copy_to_user(uifr32
, &ifr
, sizeof(ifr
.ifr_name
));
573 err
|= __put_user(ifr
.ifr_map
.mem_start
, &uifmap32
->mem_start
);
574 err
|= __put_user(ifr
.ifr_map
.mem_end
, &uifmap32
->mem_end
);
575 err
|= __put_user(ifr
.ifr_map
.base_addr
, &uifmap32
->base_addr
);
576 err
|= __put_user(ifr
.ifr_map
.irq
, &uifmap32
->irq
);
577 err
|= __put_user(ifr
.ifr_map
.dma
, &uifmap32
->dma
);
578 err
|= __put_user(ifr
.ifr_map
.port
, &uifmap32
->port
);
589 struct sockaddr rt_dst
; /* target address */
590 struct sockaddr rt_gateway
; /* gateway addr (RTF_GATEWAY) */
591 struct sockaddr rt_genmask
; /* target network mask (IP) */
592 unsigned short rt_flags
;
595 unsigned char rt_tos
;
596 unsigned char rt_class
;
598 short rt_metric
; /* +1 for binary compatibility! */
599 /* char * */ u32 rt_dev
; /* forcing the device at add */
600 u32 rt_mtu
; /* per route MTU/Window */
601 u32 rt_window
; /* Window clamping */
602 unsigned short rt_irtt
; /* Initial RTT */
607 struct in6_addr rtmsg_dst
;
608 struct in6_addr rtmsg_src
;
609 struct in6_addr rtmsg_gateway
;
619 static int routing_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
627 mm_segment_t old_fs
= get_fs();
629 struct socket
*mysock
= sockfd_lookup(fd
, &ret
);
631 if (mysock
&& mysock
->sk
&& mysock
->sk
->sk_family
== AF_INET6
) { /* ipv6 */
632 struct in6_rtmsg32 __user
*ur6
= compat_ptr(arg
);
633 ret
= copy_from_user (&r6
.rtmsg_dst
, &(ur6
->rtmsg_dst
),
634 3 * sizeof(struct in6_addr
));
635 ret
|= __get_user (r6
.rtmsg_type
, &(ur6
->rtmsg_type
));
636 ret
|= __get_user (r6
.rtmsg_dst_len
, &(ur6
->rtmsg_dst_len
));
637 ret
|= __get_user (r6
.rtmsg_src_len
, &(ur6
->rtmsg_src_len
));
638 ret
|= __get_user (r6
.rtmsg_metric
, &(ur6
->rtmsg_metric
));
639 ret
|= __get_user (r6
.rtmsg_info
, &(ur6
->rtmsg_info
));
640 ret
|= __get_user (r6
.rtmsg_flags
, &(ur6
->rtmsg_flags
));
641 ret
|= __get_user (r6
.rtmsg_ifindex
, &(ur6
->rtmsg_ifindex
));
645 struct rtentry32 __user
*ur4
= compat_ptr(arg
);
646 ret
= copy_from_user (&r4
.rt_dst
, &(ur4
->rt_dst
),
647 3 * sizeof(struct sockaddr
));
648 ret
|= __get_user (r4
.rt_flags
, &(ur4
->rt_flags
));
649 ret
|= __get_user (r4
.rt_metric
, &(ur4
->rt_metric
));
650 ret
|= __get_user (r4
.rt_mtu
, &(ur4
->rt_mtu
));
651 ret
|= __get_user (r4
.rt_window
, &(ur4
->rt_window
));
652 ret
|= __get_user (r4
.rt_irtt
, &(ur4
->rt_irtt
));
653 ret
|= __get_user (rtdev
, &(ur4
->rt_dev
));
655 ret
|= copy_from_user (devname
, compat_ptr(rtdev
), 15);
656 r4
.rt_dev
= devname
; devname
[15] = 0;
669 ret
= sys_ioctl (fd
, cmd
, (unsigned long) r
);
680 struct hd_geometry32
{
682 unsigned char sectors
;
683 unsigned short cylinders
;
687 static int hdio_getgeo(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
689 mm_segment_t old_fs
= get_fs();
690 struct hd_geometry geo
;
691 struct hd_geometry32 __user
*ugeo
;
695 err
= sys_ioctl(fd
, HDIO_GETGEO
, (unsigned long)&geo
);
697 ugeo
= compat_ptr(arg
);
699 err
= copy_to_user (ugeo
, &geo
, 4);
700 err
|= __put_user (geo
.start
, &ugeo
->start
);
702 return err
? -EFAULT
: 0;
705 static int hdio_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
707 mm_segment_t old_fs
= get_fs();
709 unsigned int __user
*uvp
;
713 error
= sys_ioctl(fd
, cmd
, (long)&kval
);
717 uvp
= compat_ptr(arg
);
718 if(put_user(kval
, uvp
))
725 typedef struct sg_io_hdr32
{
726 compat_int_t interface_id
; /* [i] 'S' for SCSI generic (required) */
727 compat_int_t dxfer_direction
; /* [i] data transfer direction */
728 unsigned char cmd_len
; /* [i] SCSI command length ( <= 16 bytes) */
729 unsigned char mx_sb_len
; /* [i] max length to write to sbp */
730 unsigned short iovec_count
; /* [i] 0 implies no scatter gather */
731 compat_uint_t dxfer_len
; /* [i] byte count of data transfer */
732 compat_uint_t dxferp
; /* [i], [*io] points to data transfer memory
733 or scatter gather list */
734 compat_uptr_t cmdp
; /* [i], [*i] points to command to perform */
735 compat_uptr_t sbp
; /* [i], [*o] points to sense_buffer memory */
736 compat_uint_t timeout
; /* [i] MAX_UINT->no timeout (unit: millisec) */
737 compat_uint_t flags
; /* [i] 0 -> default, see SG_FLAG... */
738 compat_int_t pack_id
; /* [i->o] unused internally (normally) */
739 compat_uptr_t usr_ptr
; /* [i->o] unused internally */
740 unsigned char status
; /* [o] scsi status */
741 unsigned char masked_status
; /* [o] shifted, masked scsi status */
742 unsigned char msg_status
; /* [o] messaging level data (optional) */
743 unsigned char sb_len_wr
; /* [o] byte count actually written to sbp */
744 unsigned short host_status
; /* [o] errors from host adapter */
745 unsigned short driver_status
; /* [o] errors from software driver */
746 compat_int_t resid
; /* [o] dxfer_len - actual_transferred */
747 compat_uint_t duration
; /* [o] time taken by cmd (unit: millisec) */
748 compat_uint_t info
; /* [o] auxiliary information */
749 } sg_io_hdr32_t
; /* 64 bytes long (on sparc32) */
751 typedef struct sg_iovec32
{
752 compat_uint_t iov_base
;
753 compat_uint_t iov_len
;
756 static int sg_build_iovec(sg_io_hdr_t __user
*sgio
, void __user
*dxferp
, u16 iovec_count
)
758 sg_iovec_t __user
*iov
= (sg_iovec_t __user
*) (sgio
+ 1);
759 sg_iovec32_t __user
*iov32
= dxferp
;
762 for (i
= 0; i
< iovec_count
; i
++) {
765 if (get_user(base
, &iov32
[i
].iov_base
) ||
766 get_user(len
, &iov32
[i
].iov_len
) ||
767 put_user(compat_ptr(base
), &iov
[i
].iov_base
) ||
768 put_user(len
, &iov
[i
].iov_len
))
772 if (put_user(iov
, &sgio
->dxferp
))
777 static int sg_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
779 sg_io_hdr_t __user
*sgio
;
780 sg_io_hdr32_t __user
*sgio32
;
786 sgio32
= compat_ptr(arg
);
787 if (get_user(iovec_count
, &sgio32
->iovec_count
))
791 void __user
*top
= compat_alloc_user_space(0);
792 void __user
*new = compat_alloc_user_space(sizeof(sg_io_hdr_t
) +
793 (iovec_count
* sizeof(sg_iovec_t
)));
800 /* Ok, now construct. */
801 if (copy_in_user(&sgio
->interface_id
, &sgio32
->interface_id
,
803 (2 * sizeof(unsigned char)) +
804 (1 * sizeof(unsigned short)) +
805 (1 * sizeof(unsigned int))))
808 if (get_user(data
, &sgio32
->dxferp
))
810 dxferp
= compat_ptr(data
);
812 if (sg_build_iovec(sgio
, dxferp
, iovec_count
))
815 if (put_user(dxferp
, &sgio
->dxferp
))
820 unsigned char __user
*cmdp
;
821 unsigned char __user
*sbp
;
823 if (get_user(data
, &sgio32
->cmdp
))
825 cmdp
= compat_ptr(data
);
827 if (get_user(data
, &sgio32
->sbp
))
829 sbp
= compat_ptr(data
);
831 if (put_user(cmdp
, &sgio
->cmdp
) ||
832 put_user(sbp
, &sgio
->sbp
))
836 if (copy_in_user(&sgio
->timeout
, &sgio32
->timeout
,
840 if (get_user(data
, &sgio32
->usr_ptr
))
842 if (put_user(compat_ptr(data
), &sgio
->usr_ptr
))
845 if (copy_in_user(&sgio
->status
, &sgio32
->status
,
846 (4 * sizeof(unsigned char)) +
847 (2 * sizeof(unsigned (short))) +
851 err
= sys_ioctl(fd
, cmd
, (unsigned long) sgio
);
856 if (copy_in_user(&sgio32
->pack_id
, &sgio
->pack_id
,
858 get_user(datap
, &sgio
->usr_ptr
) ||
859 put_user((u32
)(unsigned long)datap
,
861 copy_in_user(&sgio32
->status
, &sgio
->status
,
862 (4 * sizeof(unsigned char)) +
863 (2 * sizeof(unsigned short)) +
871 struct compat_sg_req_info
{ /* used by SG_GET_REQUEST_TABLE ioctl() */
877 compat_uptr_t usr_ptr
;
878 unsigned int duration
;
882 static int sg_grt_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
885 sg_req_info_t __user
*r
;
886 struct compat_sg_req_info __user
*o
= (void __user
*)arg
;
887 r
= compat_alloc_user_space(sizeof(sg_req_info_t
)*SG_MAX_QUEUE
);
888 err
= sys_ioctl(fd
,cmd
,(unsigned long)r
);
891 for (i
= 0; i
< SG_MAX_QUEUE
; i
++) {
895 if (copy_in_user(o
+ i
, r
+ i
, offsetof(sg_req_info_t
, usr_ptr
)) ||
896 get_user(ptr
, &r
[i
].usr_ptr
) ||
897 get_user(d
, &r
[i
].duration
) ||
898 put_user((u32
)(unsigned long)(ptr
), &o
[i
].usr_ptr
) ||
899 put_user(d
, &o
[i
].duration
))
905 struct sock_fprog32
{
907 compat_caddr_t filter
;
910 #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
911 #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
913 static int ppp_sock_fprog_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
915 struct sock_fprog32 __user
*u_fprog32
= compat_ptr(arg
);
916 struct sock_fprog __user
*u_fprog64
= compat_alloc_user_space(sizeof(struct sock_fprog
));
921 if (get_user(flen
, &u_fprog32
->len
) ||
922 get_user(fptr32
, &u_fprog32
->filter
))
925 fptr64
= compat_ptr(fptr32
);
927 if (put_user(flen
, &u_fprog64
->len
) ||
928 put_user(fptr64
, &u_fprog64
->filter
))
931 if (cmd
== PPPIOCSPASS32
)
936 return sys_ioctl(fd
, cmd
, (unsigned long) u_fprog64
);
939 struct ppp_option_data32
{
942 compat_int_t transmit
;
944 #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
947 compat_time_t xmit_idle
;
948 compat_time_t recv_idle
;
950 #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
952 static int ppp_gidle(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
954 struct ppp_idle __user
*idle
;
955 struct ppp_idle32 __user
*idle32
;
956 __kernel_time_t xmit
, recv
;
959 idle
= compat_alloc_user_space(sizeof(*idle
));
960 idle32
= compat_ptr(arg
);
962 err
= sys_ioctl(fd
, PPPIOCGIDLE
, (unsigned long) idle
);
965 if (get_user(xmit
, &idle
->xmit_idle
) ||
966 get_user(recv
, &idle
->recv_idle
) ||
967 put_user(xmit
, &idle32
->xmit_idle
) ||
968 put_user(recv
, &idle32
->recv_idle
))
974 static int ppp_scompress(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
976 struct ppp_option_data __user
*odata
;
977 struct ppp_option_data32 __user
*odata32
;
981 odata
= compat_alloc_user_space(sizeof(*odata
));
982 odata32
= compat_ptr(arg
);
984 if (get_user(data
, &odata32
->ptr
))
987 datap
= compat_ptr(data
);
988 if (put_user(datap
, &odata
->ptr
))
991 if (copy_in_user(&odata
->length
, &odata32
->length
,
992 sizeof(__u32
) + sizeof(int)))
995 return sys_ioctl(fd
, PPPIOCSCOMPRESS
, (unsigned long) odata
);
998 static int ppp_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1004 err
= ppp_gidle(fd
, cmd
, arg
);
1007 case PPPIOCSCOMPRESS32
:
1008 err
= ppp_scompress(fd
, cmd
, arg
);
1015 printk("ppp_ioctl: Unknown cmd fd(%d) "
1016 "cmd(%08x) arg(%08x)\n",
1017 (int)fd
, (unsigned int)cmd
, (unsigned int)arg
);
1028 compat_long_t mt_type
;
1029 compat_long_t mt_resid
;
1030 compat_long_t mt_dsreg
;
1031 compat_long_t mt_gstat
;
1032 compat_long_t mt_erreg
;
1033 compat_daddr_t mt_fileno
;
1034 compat_daddr_t mt_blkno
;
1036 #define MTIOCGET32 _IOR('m', 2, struct mtget32)
1039 compat_long_t mt_blkno
;
1041 #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
1043 static int mt_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1045 mm_segment_t old_fs
= get_fs();
1047 struct mtget32 __user
*umget32
;
1049 struct mtpos32 __user
*upos32
;
1067 printk("mt_ioctl: Unknown cmd fd(%d) "
1068 "cmd(%08x) arg(%08x)\n",
1069 (int)fd
, (unsigned int)cmd
, (unsigned int)arg
);
1074 err
= sys_ioctl (fd
, kcmd
, (unsigned long)karg
);
1080 upos32
= compat_ptr(arg
);
1081 err
= __put_user(pos
.mt_blkno
, &upos32
->mt_blkno
);
1084 umget32
= compat_ptr(arg
);
1085 err
= __put_user(get
.mt_type
, &umget32
->mt_type
);
1086 err
|= __put_user(get
.mt_resid
, &umget32
->mt_resid
);
1087 err
|= __put_user(get
.mt_dsreg
, &umget32
->mt_dsreg
);
1088 err
|= __put_user(get
.mt_gstat
, &umget32
->mt_gstat
);
1089 err
|= __put_user(get
.mt_erreg
, &umget32
->mt_erreg
);
1090 err
|= __put_user(get
.mt_fileno
, &umget32
->mt_fileno
);
1091 err
|= __put_user(get
.mt_blkno
, &umget32
->mt_blkno
);
1094 return err
? -EFAULT
: 0;
1097 struct cdrom_read_audio32
{
1098 union cdrom_addr addr
;
1100 compat_int_t nframes
;
1104 struct cdrom_generic_command32
{
1105 unsigned char cmd
[CDROM_PACKET_SIZE
];
1106 compat_caddr_t buffer
;
1107 compat_uint_t buflen
;
1109 compat_caddr_t sense
;
1110 unsigned char data_direction
;
1112 compat_int_t timeout
;
1113 compat_caddr_t reserved
[1];
1116 static int cdrom_do_read_audio(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1118 struct cdrom_read_audio __user
*cdread_audio
;
1119 struct cdrom_read_audio32 __user
*cdread_audio32
;
1123 cdread_audio
= compat_alloc_user_space(sizeof(*cdread_audio
));
1124 cdread_audio32
= compat_ptr(arg
);
1126 if (copy_in_user(&cdread_audio
->addr
,
1127 &cdread_audio32
->addr
,
1128 (sizeof(*cdread_audio32
) -
1129 sizeof(compat_caddr_t
))))
1132 if (get_user(data
, &cdread_audio32
->buf
))
1134 datap
= compat_ptr(data
);
1135 if (put_user(datap
, &cdread_audio
->buf
))
1138 return sys_ioctl(fd
, cmd
, (unsigned long) cdread_audio
);
1141 static int cdrom_do_generic_command(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1143 struct cdrom_generic_command __user
*cgc
;
1144 struct cdrom_generic_command32 __user
*cgc32
;
1149 cgc
= compat_alloc_user_space(sizeof(*cgc
));
1150 cgc32
= compat_ptr(arg
);
1152 if (copy_in_user(&cgc
->cmd
, &cgc32
->cmd
, sizeof(cgc
->cmd
)) ||
1153 get_user(data
, &cgc32
->buffer
) ||
1154 put_user(compat_ptr(data
), &cgc
->buffer
) ||
1155 copy_in_user(&cgc
->buflen
, &cgc32
->buflen
,
1156 (sizeof(unsigned int) + sizeof(int))) ||
1157 get_user(data
, &cgc32
->sense
) ||
1158 put_user(compat_ptr(data
), &cgc
->sense
) ||
1159 get_user(dir
, &cgc32
->data_direction
) ||
1160 put_user(dir
, &cgc
->data_direction
) ||
1161 get_user(itmp
, &cgc32
->quiet
) ||
1162 put_user(itmp
, &cgc
->quiet
) ||
1163 get_user(itmp
, &cgc32
->timeout
) ||
1164 put_user(itmp
, &cgc
->timeout
) ||
1165 get_user(data
, &cgc32
->reserved
[0]) ||
1166 put_user(compat_ptr(data
), &cgc
->reserved
[0]))
1169 return sys_ioctl(fd
, cmd
, (unsigned long) cgc
);
1172 static int cdrom_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1177 case CDROMREADAUDIO
:
1178 err
= cdrom_do_read_audio(fd
, cmd
, arg
);
1181 case CDROM_SEND_PACKET
:
1182 err
= cdrom_do_generic_command(fd
, cmd
, arg
);
1189 printk("cdrom_ioctl: Unknown cmd fd(%d) "
1190 "cmd(%08x) arg(%08x)\n",
1191 (int)fd
, (unsigned int)cmd
, (unsigned int)arg
);
1202 static int vt_check(struct file
*file
)
1204 struct tty_struct
*tty
;
1205 struct inode
*inode
= file
->f_dentry
->d_inode
;
1207 if (file
->f_op
->ioctl
!= tty_ioctl
)
1210 tty
= (struct tty_struct
*)file
->private_data
;
1211 if (tty_paranoia_check(tty
, inode
, "tty_ioctl"))
1214 if (tty
->driver
->ioctl
!= vt_ioctl
)
1218 * To have permissions to do most of the vt ioctls, we either have
1219 * to be the owner of the tty, or super-user.
1221 if (current
->signal
->tty
== tty
|| capable(CAP_SYS_ADMIN
))
1226 struct consolefontdesc32
{
1227 unsigned short charcount
; /* characters in font (256 or 512) */
1228 unsigned short charheight
; /* scan lines per character (1-32) */
1229 compat_caddr_t chardata
; /* font data in expanded form */
1232 static int do_fontx_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
, struct file
*file
)
1234 struct consolefontdesc32 __user
*user_cfd
= compat_ptr(arg
);
1235 struct console_font_op op
;
1236 compat_caddr_t data
;
1239 perm
= vt_check(file
);
1240 if (perm
< 0) return perm
;
1246 op
.op
= KD_FONT_OP_SET
;
1249 if (get_user(op
.height
, &user_cfd
->charheight
) ||
1250 get_user(op
.charcount
, &user_cfd
->charcount
) ||
1251 get_user(data
, &user_cfd
->chardata
))
1253 op
.data
= compat_ptr(data
);
1254 return con_font_op(vc_cons
[fg_console
].d
, &op
);
1256 op
.op
= KD_FONT_OP_GET
;
1259 if (get_user(op
.height
, &user_cfd
->charheight
) ||
1260 get_user(op
.charcount
, &user_cfd
->charcount
) ||
1261 get_user(data
, &user_cfd
->chardata
))
1265 op
.data
= compat_ptr(data
);
1266 i
= con_font_op(vc_cons
[fg_console
].d
, &op
);
1269 if (put_user(op
.height
, &user_cfd
->charheight
) ||
1270 put_user(op
.charcount
, &user_cfd
->charcount
) ||
1271 put_user((compat_caddr_t
)(unsigned long)op
.data
,
1272 &user_cfd
->chardata
))
1279 struct console_font_op32
{
1280 compat_uint_t op
; /* operation code KD_FONT_OP_* */
1281 compat_uint_t flags
; /* KD_FONT_FLAG_* */
1282 compat_uint_t width
, height
; /* font size */
1283 compat_uint_t charcount
;
1284 compat_caddr_t data
; /* font data with height fixed to 32 */
1287 static int do_kdfontop_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
, struct file
*file
)
1289 struct console_font_op op
;
1290 struct console_font_op32 __user
*fontop
= compat_ptr(arg
);
1291 int perm
= vt_check(file
), i
;
1294 if (perm
< 0) return perm
;
1296 if (copy_from_user(&op
, fontop
, sizeof(struct console_font_op32
)))
1298 if (!perm
&& op
.op
!= KD_FONT_OP_GET
)
1300 op
.data
= compat_ptr(((struct console_font_op32
*)&op
)->data
);
1301 op
.flags
|= KD_FONT_FLAG_OLD
;
1302 vc
= ((struct tty_struct
*)file
->private_data
)->driver_data
;
1303 i
= con_font_op(vc
, &op
);
1306 ((struct console_font_op32
*)&op
)->data
= (unsigned long)op
.data
;
1307 if (copy_to_user(fontop
, &op
, sizeof(struct console_font_op32
)))
1312 struct unimapdesc32
{
1313 unsigned short entry_ct
;
1314 compat_caddr_t entries
;
1317 static int do_unimap_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
, struct file
*file
)
1319 struct unimapdesc32 tmp
;
1320 struct unimapdesc32 __user
*user_ud
= compat_ptr(arg
);
1321 int perm
= vt_check(file
);
1323 if (perm
< 0) return perm
;
1324 if (copy_from_user(&tmp
, user_ud
, sizeof tmp
))
1328 if (!perm
) return -EPERM
;
1329 return con_set_unimap(vc_cons
[fg_console
].d
, tmp
.entry_ct
, compat_ptr(tmp
.entries
));
1331 return con_get_unimap(vc_cons
[fg_console
].d
, tmp
.entry_ct
, &(user_ud
->entry_ct
), compat_ptr(tmp
.entries
));
1336 #endif /* CONFIG_VT */
1338 static int do_smb_getmountuid(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1340 mm_segment_t old_fs
= get_fs();
1341 __kernel_uid_t kuid
;
1344 cmd
= SMB_IOC_GETMOUNTUID
;
1347 err
= sys_ioctl(fd
, cmd
, (unsigned long)&kuid
);
1351 err
= put_user(kuid
, (compat_uid_t __user
*)compat_ptr(arg
));
1356 struct atmif_sioc32
{
1357 compat_int_t number
;
1358 compat_int_t length
;
1362 struct atm_iobuf32
{
1363 compat_int_t length
;
1364 compat_caddr_t buffer
;
1367 #define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32)
1368 #define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32)
1369 #define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32)
1370 #define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32)
1371 #define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32)
1372 #define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32)
1373 #define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32)
1374 #define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32)
1375 #define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32)
1376 #define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32)
1377 #define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32)
1378 #define ATM_SETESIF32 _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32)
1379 #define ATM_GETSTAT32 _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32)
1380 #define ATM_GETSTATZ32 _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32)
1381 #define ATM_GETLOOP32 _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32)
1382 #define ATM_SETLOOP32 _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32)
1383 #define ATM_QUERYLOOP32 _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32)
1388 } atm_ioctl_map
[] = {
1389 { ATM_GETLINKRATE32
, ATM_GETLINKRATE
},
1390 { ATM_GETNAMES32
, ATM_GETNAMES
},
1391 { ATM_GETTYPE32
, ATM_GETTYPE
},
1392 { ATM_GETESI32
, ATM_GETESI
},
1393 { ATM_GETADDR32
, ATM_GETADDR
},
1394 { ATM_RSTADDR32
, ATM_RSTADDR
},
1395 { ATM_ADDADDR32
, ATM_ADDADDR
},
1396 { ATM_DELADDR32
, ATM_DELADDR
},
1397 { ATM_GETCIRANGE32
, ATM_GETCIRANGE
},
1398 { ATM_SETCIRANGE32
, ATM_SETCIRANGE
},
1399 { ATM_SETESI32
, ATM_SETESI
},
1400 { ATM_SETESIF32
, ATM_SETESIF
},
1401 { ATM_GETSTAT32
, ATM_GETSTAT
},
1402 { ATM_GETSTATZ32
, ATM_GETSTATZ
},
1403 { ATM_GETLOOP32
, ATM_GETLOOP
},
1404 { ATM_SETLOOP32
, ATM_SETLOOP
},
1405 { ATM_QUERYLOOP32
, ATM_QUERYLOOP
}
1408 #define NR_ATM_IOCTL ARRAY_SIZE(atm_ioctl_map)
1410 static int do_atm_iobuf(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1412 struct atm_iobuf __user
*iobuf
;
1413 struct atm_iobuf32 __user
*iobuf32
;
1418 iobuf
= compat_alloc_user_space(sizeof(*iobuf
));
1419 iobuf32
= compat_ptr(arg
);
1421 if (get_user(len
, &iobuf32
->length
) ||
1422 get_user(data
, &iobuf32
->buffer
))
1424 datap
= compat_ptr(data
);
1425 if (put_user(len
, &iobuf
->length
) ||
1426 put_user(datap
, &iobuf
->buffer
))
1429 err
= sys_ioctl(fd
, cmd
, (unsigned long)iobuf
);
1432 if (copy_in_user(&iobuf32
->length
, &iobuf
->length
,
1440 static int do_atmif_sioc(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1442 struct atmif_sioc __user
*sioc
;
1443 struct atmif_sioc32 __user
*sioc32
;
1448 sioc
= compat_alloc_user_space(sizeof(*sioc
));
1449 sioc32
= compat_ptr(arg
);
1451 if (copy_in_user(&sioc
->number
, &sioc32
->number
, 2 * sizeof(int)) ||
1452 get_user(data
, &sioc32
->arg
))
1454 datap
= compat_ptr(data
);
1455 if (put_user(datap
, &sioc
->arg
))
1458 err
= sys_ioctl(fd
, cmd
, (unsigned long) sioc
);
1461 if (copy_in_user(&sioc32
->length
, &sioc
->length
,
1468 static int do_atm_ioctl(unsigned int fd
, unsigned int cmd32
, unsigned long arg
)
1471 unsigned int cmd
= 0;
1475 case SONET_GETSTATZ
:
1479 case SONET_SETFRAMING
:
1480 case SONET_GETFRAMING
:
1481 case SONET_GETFRSENSE
:
1482 return do_atmif_sioc(fd
, cmd32
, arg
);
1485 for (i
= 0; i
< NR_ATM_IOCTL
; i
++) {
1486 if (cmd32
== atm_ioctl_map
[i
].cmd32
) {
1487 cmd
= atm_ioctl_map
[i
].cmd
;
1491 if (i
== NR_ATM_IOCTL
)
1496 return do_atm_iobuf(fd
, cmd
, arg
);
1498 case ATM_GETLINKRATE
:
1505 case ATM_GETCIRANGE
:
1506 case ATM_SETCIRANGE
:
1514 return do_atmif_sioc(fd
, cmd
, arg
);
1520 static __attribute_used__
int
1521 ret_einval(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1526 static int broken_blkgetsize(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1528 /* The mkswap binary hard codes it to Intel value :-((( */
1529 return w_long(fd
, BLKGETSIZE
, arg
);
1532 struct blkpg_ioctl_arg32
{
1535 compat_int_t datalen
;
1536 compat_caddr_t data
;
1539 static int blkpg_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1541 struct blkpg_ioctl_arg32 __user
*ua32
= compat_ptr(arg
);
1542 struct blkpg_ioctl_arg __user
*a
= compat_alloc_user_space(sizeof(*a
));
1543 compat_caddr_t udata
;
1547 err
= get_user(n
, &ua32
->op
);
1548 err
|= put_user(n
, &a
->op
);
1549 err
|= get_user(n
, &ua32
->flags
);
1550 err
|= put_user(n
, &a
->flags
);
1551 err
|= get_user(n
, &ua32
->datalen
);
1552 err
|= put_user(n
, &a
->datalen
);
1553 err
|= get_user(udata
, &ua32
->data
);
1554 err
|= put_user(compat_ptr(udata
), &a
->data
);
1558 return sys_ioctl(fd
, cmd
, (unsigned long)a
);
1561 static int ioc_settimeout(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1563 return rw_long(fd
, AUTOFS_IOC_SETTIMEOUT
, arg
);
1566 /* Fix sizeof(sizeof()) breakage */
1567 #define BLKBSZGET_32 _IOR(0x12,112,int)
1568 #define BLKBSZSET_32 _IOW(0x12,113,int)
1569 #define BLKGETSIZE64_32 _IOR(0x12,114,int)
1571 static int do_blkbszget(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1573 return sys_ioctl(fd
, BLKBSZGET
, (unsigned long)compat_ptr(arg
));
1576 static int do_blkbszset(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1578 return sys_ioctl(fd
, BLKBSZSET
, (unsigned long)compat_ptr(arg
));
1581 static int do_blkgetsize64(unsigned int fd
, unsigned int cmd
,
1584 return sys_ioctl(fd
, BLKGETSIZE64
, (unsigned long)compat_ptr(arg
));
1587 /* Bluetooth ioctls */
1588 #define HCIUARTSETPROTO _IOW('U', 200, int)
1589 #define HCIUARTGETPROTO _IOR('U', 201, int)
1591 #define BNEPCONNADD _IOW('B', 200, int)
1592 #define BNEPCONNDEL _IOW('B', 201, int)
1593 #define BNEPGETCONNLIST _IOR('B', 210, int)
1594 #define BNEPGETCONNINFO _IOR('B', 211, int)
1596 #define CMTPCONNADD _IOW('C', 200, int)
1597 #define CMTPCONNDEL _IOW('C', 201, int)
1598 #define CMTPGETCONNLIST _IOR('C', 210, int)
1599 #define CMTPGETCONNINFO _IOR('C', 211, int)
1601 #define HIDPCONNADD _IOW('H', 200, int)
1602 #define HIDPCONNDEL _IOW('H', 201, int)
1603 #define HIDPGETCONNLIST _IOR('H', 210, int)
1604 #define HIDPGETCONNINFO _IOR('H', 211, int)
1606 struct floppy_struct32
{
1610 compat_uint_t track
;
1611 compat_uint_t stretch
;
1614 unsigned char spec1
;
1615 unsigned char fmt_gap
;
1616 const compat_caddr_t name
;
1619 struct floppy_drive_params32
{
1621 compat_ulong_t max_dtr
;
1625 compat_ulong_t spinup
;
1626 compat_ulong_t spindown
;
1627 unsigned char spindown_offset
;
1628 unsigned char select_delay
;
1630 unsigned char tracks
;
1631 compat_ulong_t timeout
;
1632 unsigned char interleave_sect
;
1633 struct floppy_max_errors max_errors
;
1636 short autodetect
[8];
1637 compat_int_t checkfreq
;
1638 compat_int_t native_format
;
1641 struct floppy_drive_struct32
{
1643 compat_ulong_t spinup_date
;
1644 compat_ulong_t select_date
;
1645 compat_ulong_t first_read_date
;
1646 short probed_format
;
1650 compat_int_t generation
;
1651 compat_int_t keep_data
;
1652 compat_int_t fd_ref
;
1653 compat_int_t fd_device
;
1654 compat_int_t last_checked
;
1655 compat_caddr_t dmabuf
;
1656 compat_int_t bufblocks
;
1659 struct floppy_fdc_state32
{
1663 unsigned char version
;
1665 compat_ulong_t address
;
1666 unsigned int rawcmd
:2;
1667 unsigned int reset
:1;
1668 unsigned int need_configure
:1;
1669 unsigned int perp_mode
:2;
1670 unsigned int has_fifo
:1;
1671 unsigned int driver_version
;
1672 unsigned char track
[4];
1675 struct floppy_write_errors32
{
1676 unsigned int write_errors
;
1677 compat_ulong_t first_error_sector
;
1678 compat_int_t first_error_generation
;
1679 compat_ulong_t last_error_sector
;
1680 compat_int_t last_error_generation
;
1681 compat_uint_t badness
;
1684 #define FDSETPRM32 _IOW(2, 0x42, struct floppy_struct32)
1685 #define FDDEFPRM32 _IOW(2, 0x43, struct floppy_struct32)
1686 #define FDGETPRM32 _IOR(2, 0x04, struct floppy_struct32)
1687 #define FDSETDRVPRM32 _IOW(2, 0x90, struct floppy_drive_params32)
1688 #define FDGETDRVPRM32 _IOR(2, 0x11, struct floppy_drive_params32)
1689 #define FDGETDRVSTAT32 _IOR(2, 0x12, struct floppy_drive_struct32)
1690 #define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct floppy_drive_struct32)
1691 #define FDGETFDCSTAT32 _IOR(2, 0x15, struct floppy_fdc_state32)
1692 #define FDWERRORGET32 _IOR(2, 0x17, struct floppy_write_errors32)
1697 } fd_ioctl_trans_table
[] = {
1698 { FDSETPRM32
, FDSETPRM
},
1699 { FDDEFPRM32
, FDDEFPRM
},
1700 { FDGETPRM32
, FDGETPRM
},
1701 { FDSETDRVPRM32
, FDSETDRVPRM
},
1702 { FDGETDRVPRM32
, FDGETDRVPRM
},
1703 { FDGETDRVSTAT32
, FDGETDRVSTAT
},
1704 { FDPOLLDRVSTAT32
, FDPOLLDRVSTAT
},
1705 { FDGETFDCSTAT32
, FDGETFDCSTAT
},
1706 { FDWERRORGET32
, FDWERRORGET
}
1709 #define NR_FD_IOCTL_TRANS ARRAY_SIZE(fd_ioctl_trans_table)
1711 static int fd_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1713 mm_segment_t old_fs
= get_fs();
1715 unsigned int kcmd
= 0;
1718 for (i
= 0; i
< NR_FD_IOCTL_TRANS
; i
++)
1719 if (cmd
== fd_ioctl_trans_table
[i
].cmd32
) {
1720 kcmd
= fd_ioctl_trans_table
[i
].cmd
;
1732 struct floppy_struct32 __user
*uf
;
1733 struct floppy_struct
*f
;
1735 uf
= compat_ptr(arg
);
1736 f
= karg
= kmalloc(sizeof(struct floppy_struct
), GFP_KERNEL
);
1739 if (cmd
== FDGETPRM32
)
1741 err
= __get_user(f
->size
, &uf
->size
);
1742 err
|= __get_user(f
->sect
, &uf
->sect
);
1743 err
|= __get_user(f
->head
, &uf
->head
);
1744 err
|= __get_user(f
->track
, &uf
->track
);
1745 err
|= __get_user(f
->stretch
, &uf
->stretch
);
1746 err
|= __get_user(f
->gap
, &uf
->gap
);
1747 err
|= __get_user(f
->rate
, &uf
->rate
);
1748 err
|= __get_user(f
->spec1
, &uf
->spec1
);
1749 err
|= __get_user(f
->fmt_gap
, &uf
->fmt_gap
);
1750 err
|= __get_user(name
, &uf
->name
);
1751 f
->name
= compat_ptr(name
);
1761 struct floppy_drive_params32 __user
*uf
;
1762 struct floppy_drive_params
*f
;
1764 uf
= compat_ptr(arg
);
1765 f
= karg
= kmalloc(sizeof(struct floppy_drive_params
), GFP_KERNEL
);
1768 if (cmd
== FDGETDRVPRM32
)
1770 err
= __get_user(f
->cmos
, &uf
->cmos
);
1771 err
|= __get_user(f
->max_dtr
, &uf
->max_dtr
);
1772 err
|= __get_user(f
->hlt
, &uf
->hlt
);
1773 err
|= __get_user(f
->hut
, &uf
->hut
);
1774 err
|= __get_user(f
->srt
, &uf
->srt
);
1775 err
|= __get_user(f
->spinup
, &uf
->spinup
);
1776 err
|= __get_user(f
->spindown
, &uf
->spindown
);
1777 err
|= __get_user(f
->spindown_offset
, &uf
->spindown_offset
);
1778 err
|= __get_user(f
->select_delay
, &uf
->select_delay
);
1779 err
|= __get_user(f
->rps
, &uf
->rps
);
1780 err
|= __get_user(f
->tracks
, &uf
->tracks
);
1781 err
|= __get_user(f
->timeout
, &uf
->timeout
);
1782 err
|= __get_user(f
->interleave_sect
, &uf
->interleave_sect
);
1783 err
|= __copy_from_user(&f
->max_errors
, &uf
->max_errors
, sizeof(f
->max_errors
));
1784 err
|= __get_user(f
->flags
, &uf
->flags
);
1785 err
|= __get_user(f
->read_track
, &uf
->read_track
);
1786 err
|= __copy_from_user(f
->autodetect
, uf
->autodetect
, sizeof(f
->autodetect
));
1787 err
|= __get_user(f
->checkfreq
, &uf
->checkfreq
);
1788 err
|= __get_user(f
->native_format
, &uf
->native_format
);
1795 case FDGETDRVSTAT32
:
1796 case FDPOLLDRVSTAT32
:
1797 karg
= kmalloc(sizeof(struct floppy_drive_struct
), GFP_KERNEL
);
1801 case FDGETFDCSTAT32
:
1802 karg
= kmalloc(sizeof(struct floppy_fdc_state
), GFP_KERNEL
);
1807 karg
= kmalloc(sizeof(struct floppy_write_errors
), GFP_KERNEL
);
1815 err
= sys_ioctl (fd
, kcmd
, (unsigned long)karg
);
1822 struct floppy_struct
*f
= karg
;
1823 struct floppy_struct32 __user
*uf
= compat_ptr(arg
);
1825 err
= __put_user(f
->size
, &uf
->size
);
1826 err
|= __put_user(f
->sect
, &uf
->sect
);
1827 err
|= __put_user(f
->head
, &uf
->head
);
1828 err
|= __put_user(f
->track
, &uf
->track
);
1829 err
|= __put_user(f
->stretch
, &uf
->stretch
);
1830 err
|= __put_user(f
->gap
, &uf
->gap
);
1831 err
|= __put_user(f
->rate
, &uf
->rate
);
1832 err
|= __put_user(f
->spec1
, &uf
->spec1
);
1833 err
|= __put_user(f
->fmt_gap
, &uf
->fmt_gap
);
1834 err
|= __put_user((u64
)f
->name
, (compat_caddr_t __user
*)&uf
->name
);
1839 struct floppy_drive_params32 __user
*uf
;
1840 struct floppy_drive_params
*f
= karg
;
1842 uf
= compat_ptr(arg
);
1843 err
= __put_user(f
->cmos
, &uf
->cmos
);
1844 err
|= __put_user(f
->max_dtr
, &uf
->max_dtr
);
1845 err
|= __put_user(f
->hlt
, &uf
->hlt
);
1846 err
|= __put_user(f
->hut
, &uf
->hut
);
1847 err
|= __put_user(f
->srt
, &uf
->srt
);
1848 err
|= __put_user(f
->spinup
, &uf
->spinup
);
1849 err
|= __put_user(f
->spindown
, &uf
->spindown
);
1850 err
|= __put_user(f
->spindown_offset
, &uf
->spindown_offset
);
1851 err
|= __put_user(f
->select_delay
, &uf
->select_delay
);
1852 err
|= __put_user(f
->rps
, &uf
->rps
);
1853 err
|= __put_user(f
->tracks
, &uf
->tracks
);
1854 err
|= __put_user(f
->timeout
, &uf
->timeout
);
1855 err
|= __put_user(f
->interleave_sect
, &uf
->interleave_sect
);
1856 err
|= __copy_to_user(&uf
->max_errors
, &f
->max_errors
, sizeof(f
->max_errors
));
1857 err
|= __put_user(f
->flags
, &uf
->flags
);
1858 err
|= __put_user(f
->read_track
, &uf
->read_track
);
1859 err
|= __copy_to_user(uf
->autodetect
, f
->autodetect
, sizeof(f
->autodetect
));
1860 err
|= __put_user(f
->checkfreq
, &uf
->checkfreq
);
1861 err
|= __put_user(f
->native_format
, &uf
->native_format
);
1864 case FDGETDRVSTAT32
:
1865 case FDPOLLDRVSTAT32
:
1867 struct floppy_drive_struct32 __user
*uf
;
1868 struct floppy_drive_struct
*f
= karg
;
1870 uf
= compat_ptr(arg
);
1871 err
= __put_user(f
->flags
, &uf
->flags
);
1872 err
|= __put_user(f
->spinup_date
, &uf
->spinup_date
);
1873 err
|= __put_user(f
->select_date
, &uf
->select_date
);
1874 err
|= __put_user(f
->first_read_date
, &uf
->first_read_date
);
1875 err
|= __put_user(f
->probed_format
, &uf
->probed_format
);
1876 err
|= __put_user(f
->track
, &uf
->track
);
1877 err
|= __put_user(f
->maxblock
, &uf
->maxblock
);
1878 err
|= __put_user(f
->maxtrack
, &uf
->maxtrack
);
1879 err
|= __put_user(f
->generation
, &uf
->generation
);
1880 err
|= __put_user(f
->keep_data
, &uf
->keep_data
);
1881 err
|= __put_user(f
->fd_ref
, &uf
->fd_ref
);
1882 err
|= __put_user(f
->fd_device
, &uf
->fd_device
);
1883 err
|= __put_user(f
->last_checked
, &uf
->last_checked
);
1884 err
|= __put_user((u64
)f
->dmabuf
, &uf
->dmabuf
);
1885 err
|= __put_user((u64
)f
->bufblocks
, &uf
->bufblocks
);
1888 case FDGETFDCSTAT32
:
1890 struct floppy_fdc_state32 __user
*uf
;
1891 struct floppy_fdc_state
*f
= karg
;
1893 uf
= compat_ptr(arg
);
1894 err
= __put_user(f
->spec1
, &uf
->spec1
);
1895 err
|= __put_user(f
->spec2
, &uf
->spec2
);
1896 err
|= __put_user(f
->dtr
, &uf
->dtr
);
1897 err
|= __put_user(f
->version
, &uf
->version
);
1898 err
|= __put_user(f
->dor
, &uf
->dor
);
1899 err
|= __put_user(f
->address
, &uf
->address
);
1900 err
|= __copy_to_user((char __user
*)&uf
->address
+ sizeof(uf
->address
),
1901 (char *)&f
->address
+ sizeof(f
->address
), sizeof(int));
1902 err
|= __put_user(f
->driver_version
, &uf
->driver_version
);
1903 err
|= __copy_to_user(uf
->track
, f
->track
, sizeof(f
->track
));
1908 struct floppy_write_errors32 __user
*uf
;
1909 struct floppy_write_errors
*f
= karg
;
1911 uf
= compat_ptr(arg
);
1912 err
= __put_user(f
->write_errors
, &uf
->write_errors
);
1913 err
|= __put_user(f
->first_error_sector
, &uf
->first_error_sector
);
1914 err
|= __put_user(f
->first_error_generation
, &uf
->first_error_generation
);
1915 err
|= __put_user(f
->last_error_sector
, &uf
->last_error_sector
);
1916 err
|= __put_user(f
->last_error_generation
, &uf
->last_error_generation
);
1917 err
|= __put_user(f
->badness
, &uf
->badness
);
1931 struct mtd_oob_buf32
{
1934 compat_caddr_t ptr
; /* unsigned char* */
1937 #define MEMWRITEOOB32 _IOWR('M',3,struct mtd_oob_buf32)
1938 #define MEMREADOOB32 _IOWR('M',4,struct mtd_oob_buf32)
1940 static int mtd_rw_oob(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1942 struct mtd_oob_buf __user
*buf
= compat_alloc_user_space(sizeof(*buf
));
1943 struct mtd_oob_buf32 __user
*buf32
= compat_ptr(arg
);
1946 unsigned int real_cmd
;
1949 real_cmd
= (cmd
== MEMREADOOB32
) ?
1950 MEMREADOOB
: MEMWRITEOOB
;
1952 if (copy_in_user(&buf
->start
, &buf32
->start
,
1954 get_user(data
, &buf32
->ptr
))
1956 datap
= compat_ptr(data
);
1957 if (put_user(datap
, &buf
->ptr
))
1960 err
= sys_ioctl(fd
, real_cmd
, (unsigned long) buf
);
1963 if (copy_in_user(&buf32
->start
, &buf
->start
,
1971 #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
1972 #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
1975 put_dirent32 (struct dirent
*d
, struct compat_dirent __user
*d32
)
1977 if (!access_ok(VERIFY_WRITE
, d32
, sizeof(struct compat_dirent
)))
1980 __put_user(d
->d_ino
, &d32
->d_ino
);
1981 __put_user(d
->d_off
, &d32
->d_off
);
1982 __put_user(d
->d_reclen
, &d32
->d_reclen
);
1983 if (__copy_to_user(d32
->d_name
, d
->d_name
, d
->d_reclen
))
1989 static int vfat_ioctl32(unsigned fd
, unsigned cmd
, unsigned long arg
)
1991 struct compat_dirent __user
*p
= compat_ptr(arg
);
1993 mm_segment_t oldfs
= get_fs();
1998 case VFAT_IOCTL_READDIR_BOTH32
:
1999 cmd
= VFAT_IOCTL_READDIR_BOTH
;
2001 case VFAT_IOCTL_READDIR_SHORT32
:
2002 cmd
= VFAT_IOCTL_READDIR_SHORT
;
2007 ret
= sys_ioctl(fd
,cmd
,(unsigned long)&d
);
2010 ret
|= put_dirent32(&d
[0], p
);
2011 ret
|= put_dirent32(&d
[1], p
+ 1);
2016 struct raw32_config_request
2018 compat_int_t raw_minor
;
2021 } __attribute__((packed
));
2023 static int get_raw32_request(struct raw_config_request
*req
, struct raw32_config_request __user
*user_req
)
2027 if (!access_ok(VERIFY_READ
, user_req
, sizeof(struct raw32_config_request
)))
2030 ret
= __get_user(req
->raw_minor
, &user_req
->raw_minor
);
2031 ret
|= __get_user(req
->block_major
, &user_req
->block_major
);
2032 ret
|= __get_user(req
->block_minor
, &user_req
->block_minor
);
2034 return ret
? -EFAULT
: 0;
2037 static int set_raw32_request(struct raw_config_request
*req
, struct raw32_config_request __user
*user_req
)
2041 if (!access_ok(VERIFY_WRITE
, user_req
, sizeof(struct raw32_config_request
)))
2044 ret
= __put_user(req
->raw_minor
, &user_req
->raw_minor
);
2045 ret
|= __put_user(req
->block_major
, &user_req
->block_major
);
2046 ret
|= __put_user(req
->block_minor
, &user_req
->block_minor
);
2048 return ret
? -EFAULT
: 0;
2051 static int raw_ioctl(unsigned fd
, unsigned cmd
, unsigned long arg
)
2058 struct raw_config_request req
;
2059 struct raw32_config_request __user
*user_req
= compat_ptr(arg
);
2060 mm_segment_t oldfs
= get_fs();
2062 if ((ret
= get_raw32_request(&req
, user_req
)))
2066 ret
= sys_ioctl(fd
,cmd
,(unsigned long)&req
);
2069 if ((!ret
) && (cmd
== RAW_GETBIND
)) {
2070 ret
= set_raw32_request(&req
, user_req
);
2075 ret
= sys_ioctl(fd
, cmd
, arg
);
2081 struct serial_struct32
{
2087 compat_int_t xmit_fifo_size
;
2088 compat_int_t custom_divisor
;
2089 compat_int_t baud_base
;
2090 unsigned short close_delay
;
2092 char reserved_char
[1];
2094 unsigned short closing_wait
; /* time to wait before closing */
2095 unsigned short closing_wait2
; /* no longer used... */
2096 compat_uint_t iomem_base
;
2097 unsigned short iomem_reg_shift
;
2098 unsigned int port_high
;
2099 /* compat_ulong_t iomap_base FIXME */
2100 compat_int_t reserved
[1];
2103 static int serial_struct_ioctl(unsigned fd
, unsigned cmd
, unsigned long arg
)
2105 typedef struct serial_struct SS
;
2106 typedef struct serial_struct32 SS32
;
2107 struct serial_struct32 __user
*ss32
= compat_ptr(arg
);
2109 struct serial_struct ss
;
2110 mm_segment_t oldseg
= get_fs();
2113 if (cmd
== TIOCSSERIAL
) {
2114 if (!access_ok(VERIFY_READ
, ss32
, sizeof(SS32
)))
2116 if (__copy_from_user(&ss
, ss32
, offsetof(SS32
, iomem_base
)))
2118 __get_user(udata
, &ss32
->iomem_base
);
2119 ss
.iomem_base
= compat_ptr(udata
);
2120 __get_user(ss
.iomem_reg_shift
, &ss32
->iomem_reg_shift
);
2121 __get_user(ss
.port_high
, &ss32
->port_high
);
2122 ss
.iomap_base
= 0UL;
2125 err
= sys_ioctl(fd
,cmd
,(unsigned long)(&ss
));
2127 if (cmd
== TIOCGSERIAL
&& err
>= 0) {
2128 if (!access_ok(VERIFY_WRITE
, ss32
, sizeof(SS32
)))
2130 if (__copy_to_user(ss32
,&ss
,offsetof(SS32
,iomem_base
)))
2132 __put_user((unsigned long)ss
.iomem_base
>> 32 ?
2133 0xffffffff : (unsigned)(unsigned long)ss
.iomem_base
,
2135 __put_user(ss
.iomem_reg_shift
, &ss32
->iomem_reg_shift
);
2136 __put_user(ss
.port_high
, &ss32
->port_high
);
2142 struct usbdevfs_ctrltransfer32
{
2148 u32 timeout
; /* in milliseconds */
2149 compat_caddr_t data
;
2152 #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
2154 static int do_usbdevfs_control(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2156 struct usbdevfs_ctrltransfer32 __user
*p32
= compat_ptr(arg
);
2157 struct usbdevfs_ctrltransfer __user
*p
;
2159 p
= compat_alloc_user_space(sizeof(*p
));
2160 if (copy_in_user(p
, p32
, (sizeof(*p32
) - sizeof(compat_caddr_t
))) ||
2161 get_user(udata
, &p32
->data
) ||
2162 put_user(compat_ptr(udata
), &p
->data
))
2164 return sys_ioctl(fd
, USBDEVFS_CONTROL
, (unsigned long)p
);
2168 struct usbdevfs_bulktransfer32
{
2171 compat_uint_t timeout
; /* in milliseconds */
2172 compat_caddr_t data
;
2175 #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
2177 static int do_usbdevfs_bulk(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2179 struct usbdevfs_bulktransfer32 __user
*p32
= compat_ptr(arg
);
2180 struct usbdevfs_bulktransfer __user
*p
;
2182 compat_caddr_t addr
;
2184 p
= compat_alloc_user_space(sizeof(*p
));
2186 if (get_user(n
, &p32
->ep
) || put_user(n
, &p
->ep
) ||
2187 get_user(n
, &p32
->len
) || put_user(n
, &p
->len
) ||
2188 get_user(n
, &p32
->timeout
) || put_user(n
, &p
->timeout
) ||
2189 get_user(addr
, &p32
->data
) || put_user(compat_ptr(addr
), &p
->data
))
2192 return sys_ioctl(fd
, USBDEVFS_BULK
, (unsigned long)p
);
2197 * USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY
2198 * are handled in usbdevfs core. -Christopher Li
2201 struct usbdevfs_disconnectsignal32
{
2203 compat_caddr_t context
;
2206 #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
2208 static int do_usbdevfs_discsignal(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2210 struct usbdevfs_disconnectsignal kdis
;
2211 struct usbdevfs_disconnectsignal32 __user
*udis
;
2212 mm_segment_t old_fs
;
2216 udis
= compat_ptr(arg
);
2218 if (get_user(kdis
.signr
, &udis
->signr
) ||
2219 __get_user(uctx
, &udis
->context
))
2222 kdis
.context
= compat_ptr(uctx
);
2226 err
= sys_ioctl(fd
, USBDEVFS_DISCSIGNAL
, (unsigned long) &kdis
);
2243 struct i2c_rdwr_ioctl_data32
{
2244 compat_caddr_t msgs
; /* struct i2c_msg __user *msgs */
2248 struct i2c_smbus_ioctl_data32
{
2252 compat_caddr_t data
; /* union i2c_smbus_data *data */
2255 struct i2c_rdwr_aligned
{
2256 struct i2c_rdwr_ioctl_data cmd
;
2257 struct i2c_msg msgs
[0];
2260 static int do_i2c_rdwr_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2262 struct i2c_rdwr_ioctl_data32 __user
*udata
= compat_ptr(arg
);
2263 struct i2c_rdwr_aligned __user
*tdata
;
2264 struct i2c_msg __user
*tmsgs
;
2265 struct i2c_msg32 __user
*umsgs
;
2266 compat_caddr_t datap
;
2269 if (get_user(nmsgs
, &udata
->nmsgs
))
2271 if (nmsgs
> I2C_RDRW_IOCTL_MAX_MSGS
)
2274 if (get_user(datap
, &udata
->msgs
))
2276 umsgs
= compat_ptr(datap
);
2278 tdata
= compat_alloc_user_space(sizeof(*tdata
) +
2279 nmsgs
* sizeof(struct i2c_msg
));
2280 tmsgs
= &tdata
->msgs
[0];
2282 if (put_user(nmsgs
, &tdata
->cmd
.nmsgs
) ||
2283 put_user(tmsgs
, &tdata
->cmd
.msgs
))
2286 for (i
= 0; i
< nmsgs
; i
++) {
2287 if (copy_in_user(&tmsgs
[i
].addr
, &umsgs
[i
].addr
, 3*sizeof(u16
)))
2289 if (get_user(datap
, &umsgs
[i
].buf
) ||
2290 put_user(compat_ptr(datap
), &tmsgs
[i
].buf
))
2293 return sys_ioctl(fd
, cmd
, (unsigned long)tdata
);
2296 static int do_i2c_smbus_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2298 struct i2c_smbus_ioctl_data __user
*tdata
;
2299 struct i2c_smbus_ioctl_data32 __user
*udata
;
2300 compat_caddr_t datap
;
2302 tdata
= compat_alloc_user_space(sizeof(*tdata
));
2305 if (!access_ok(VERIFY_WRITE
, tdata
, sizeof(*tdata
)))
2308 udata
= compat_ptr(arg
);
2309 if (!access_ok(VERIFY_READ
, udata
, sizeof(*udata
)))
2312 if (__copy_in_user(&tdata
->read_write
, &udata
->read_write
, 2 * sizeof(u8
)))
2314 if (__copy_in_user(&tdata
->size
, &udata
->size
, 2 * sizeof(u32
)))
2316 if (__get_user(datap
, &udata
->data
) ||
2317 __put_user(compat_ptr(datap
), &tdata
->data
))
2320 return sys_ioctl(fd
, cmd
, (unsigned long)tdata
);
2323 struct compat_iw_point
{
2324 compat_caddr_t pointer
;
2329 static int do_wireless_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2331 struct iwreq __user
*iwr
;
2332 struct iwreq __user
*iwr_u
;
2333 struct iw_point __user
*iwp
;
2334 struct compat_iw_point __user
*iwp_u
;
2335 compat_caddr_t pointer
;
2336 __u16 length
, flags
;
2338 iwr_u
= compat_ptr(arg
);
2339 iwp_u
= (struct compat_iw_point __user
*) &iwr_u
->u
.data
;
2340 iwr
= compat_alloc_user_space(sizeof(*iwr
));
2346 if (!access_ok(VERIFY_WRITE
, iwr
, sizeof(*iwr
)))
2349 if (__copy_in_user(&iwr
->ifr_ifrn
.ifrn_name
[0],
2350 &iwr_u
->ifr_ifrn
.ifrn_name
[0],
2351 sizeof(iwr
->ifr_ifrn
.ifrn_name
)))
2354 if (__get_user(pointer
, &iwp_u
->pointer
) ||
2355 __get_user(length
, &iwp_u
->length
) ||
2356 __get_user(flags
, &iwp_u
->flags
))
2359 if (__put_user(compat_ptr(pointer
), &iwp
->pointer
) ||
2360 __put_user(length
, &iwp
->length
) ||
2361 __put_user(flags
, &iwp
->flags
))
2364 return sys_ioctl(fd
, cmd
, (unsigned long) iwr
);
2367 /* Since old style bridge ioctl's endup using SIOCDEVPRIVATE
2368 * for some operations; this forces use of the newer bridge-utils that
2369 * use compatiable ioctls
2371 static int old_bridge_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2375 if (get_user(tmp
, (u32 __user
*) arg
))
2377 if (tmp
== BRCTL_GET_VERSION
)
2378 return BRCTL_VERSION
+ 1;
2382 #define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
2383 #define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t)
2384 #define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
2385 #define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t)
2387 static int rtc_ioctl(unsigned fd
, unsigned cmd
, unsigned long arg
)
2389 mm_segment_t oldfs
= get_fs();
2390 compat_ulong_t val32
;
2395 case RTC_IRQP_READ32
:
2396 case RTC_EPOCH_READ32
:
2398 ret
= sys_ioctl(fd
, (cmd
== RTC_IRQP_READ32
) ?
2399 RTC_IRQP_READ
: RTC_EPOCH_READ
,
2400 (unsigned long)&kval
);
2405 return put_user(val32
, (unsigned int __user
*)arg
);
2406 case RTC_IRQP_SET32
:
2407 return sys_ioctl(fd
, RTC_IRQP_SET
, arg
);
2408 case RTC_EPOCH_SET32
:
2409 return sys_ioctl(fd
, RTC_EPOCH_SET
, arg
);
2412 return -ENOIOCTLCMD
;
2416 #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
2417 struct ncp_ioctl_request_32
{
2420 compat_caddr_t data
;
2423 struct ncp_fs_info_v2_32
{
2437 struct ncp_objectname_ioctl_32
2440 u32 object_name_len
;
2441 compat_caddr_t object_name
; /* an userspace data, in most cases user name */
2444 struct ncp_privatedata_ioctl_32
2447 compat_caddr_t data
; /* ~1000 for NDS */
2450 #define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct ncp_ioctl_request_32)
2451 #define NCP_IOC_GETMOUNTUID2_32 _IOW('n', 2, u32)
2452 #define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct ncp_fs_info_v2_32)
2453 #define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct ncp_objectname_ioctl_32)
2454 #define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct ncp_objectname_ioctl_32)
2455 #define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct ncp_privatedata_ioctl_32)
2456 #define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct ncp_privatedata_ioctl_32)
2458 static int do_ncp_ncprequest(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2460 struct ncp_ioctl_request_32 n32
;
2461 struct ncp_ioctl_request __user
*p
= compat_alloc_user_space(sizeof(*p
));
2463 if (copy_from_user(&n32
, compat_ptr(arg
), sizeof(n32
)) ||
2464 put_user(n32
.function
, &p
->function
) ||
2465 put_user(n32
.size
, &p
->size
) ||
2466 put_user(compat_ptr(n32
.data
), &p
->data
))
2469 return sys_ioctl(fd
, NCP_IOC_NCPREQUEST
, (unsigned long)p
);
2472 static int do_ncp_getmountuid2(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2474 mm_segment_t old_fs
= get_fs();
2475 __kernel_uid_t kuid
;
2478 cmd
= NCP_IOC_GETMOUNTUID2
;
2481 err
= sys_ioctl(fd
, cmd
, (unsigned long)&kuid
);
2485 err
= put_user(kuid
,
2486 (unsigned int __user
*) compat_ptr(arg
));
2491 static int do_ncp_getfsinfo2(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2493 mm_segment_t old_fs
= get_fs();
2494 struct ncp_fs_info_v2_32 n32
;
2495 struct ncp_fs_info_v2 n
;
2498 if (copy_from_user(&n32
, compat_ptr(arg
), sizeof(n32
)))
2500 if (n32
.version
!= NCP_GET_FS_INFO_VERSION_V2
)
2502 n
.version
= NCP_GET_FS_INFO_VERSION_V2
;
2505 err
= sys_ioctl(fd
, NCP_IOC_GET_FS_INFO_V2
, (unsigned long)&n
);
2509 n32
.version
= n
.version
;
2510 n32
.mounted_uid
= n
.mounted_uid
;
2511 n32
.connection
= n
.connection
;
2512 n32
.buffer_size
= n
.buffer_size
;
2513 n32
.volume_number
= n
.volume_number
;
2514 n32
.directory_id
= n
.directory_id
;
2515 n32
.dummy1
= n
.dummy1
;
2516 n32
.dummy2
= n
.dummy2
;
2517 n32
.dummy3
= n
.dummy3
;
2518 err
= copy_to_user(compat_ptr(arg
), &n32
, sizeof(n32
)) ? -EFAULT
: 0;
2523 static int do_ncp_getobjectname(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2525 struct ncp_objectname_ioctl_32 n32
, __user
*p32
= compat_ptr(arg
);
2526 struct ncp_objectname_ioctl __user
*p
= compat_alloc_user_space(sizeof(*p
));
2531 if (copy_from_user(&n32
, p32
, sizeof(n32
)) ||
2532 put_user(n32
.object_name_len
, &p
->object_name_len
) ||
2533 put_user(compat_ptr(n32
.object_name
), &p
->object_name
))
2536 err
= sys_ioctl(fd
, NCP_IOC_GETOBJECTNAME
, (unsigned long)p
);
2540 if (get_user(auth_type
, &p
->auth_type
) ||
2541 put_user(auth_type
, &p32
->auth_type
) ||
2542 get_user(name_len
, &p
->object_name_len
) ||
2543 put_user(name_len
, &p32
->object_name_len
))
2549 static int do_ncp_setobjectname(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2551 struct ncp_objectname_ioctl_32 n32
, __user
*p32
= compat_ptr(arg
);
2552 struct ncp_objectname_ioctl __user
*p
= compat_alloc_user_space(sizeof(*p
));
2554 if (copy_from_user(&n32
, p32
, sizeof(n32
)) ||
2555 put_user(n32
.auth_type
, &p
->auth_type
) ||
2556 put_user(n32
.object_name_len
, &p
->object_name_len
) ||
2557 put_user(compat_ptr(n32
.object_name
), &p
->object_name
))
2560 return sys_ioctl(fd
, NCP_IOC_SETOBJECTNAME
, (unsigned long)p
);
2563 static int do_ncp_getprivatedata(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2565 struct ncp_privatedata_ioctl_32 n32
, __user
*p32
= compat_ptr(arg
);
2566 struct ncp_privatedata_ioctl __user
*p
=
2567 compat_alloc_user_space(sizeof(*p
));
2571 if (copy_from_user(&n32
, p32
, sizeof(n32
)) ||
2572 put_user(n32
.len
, &p
->len
) ||
2573 put_user(compat_ptr(n32
.data
), &p
->data
))
2576 err
= sys_ioctl(fd
, NCP_IOC_GETPRIVATEDATA
, (unsigned long)p
);
2580 if (get_user(len
, &p
->len
) ||
2581 put_user(len
, &p32
->len
))
2587 static int do_ncp_setprivatedata(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2589 struct ncp_privatedata_ioctl_32 n32
;
2590 struct ncp_privatedata_ioctl_32 __user
*p32
= compat_ptr(arg
);
2591 struct ncp_privatedata_ioctl __user
*p
=
2592 compat_alloc_user_space(sizeof(*p
));
2594 if (copy_from_user(&n32
, p32
, sizeof(n32
)) ||
2595 put_user(n32
.len
, &p
->len
) ||
2596 put_user(compat_ptr(n32
.data
), &p
->data
))
2599 return sys_ioctl(fd
, NCP_IOC_SETPRIVATEDATA
, (unsigned long)p
);
2604 lp_timeout_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2606 struct compat_timeval __user
*tc
= (struct compat_timeval __user
*)arg
;
2607 struct timeval __user
*tn
= compat_alloc_user_space(sizeof(struct timeval
));
2609 if (get_user(ts
.tv_sec
, &tc
->tv_sec
) ||
2610 get_user(ts
.tv_usec
, &tc
->tv_usec
) ||
2611 put_user(ts
.tv_sec
, &tn
->tv_sec
) ||
2612 put_user(ts
.tv_usec
, &tn
->tv_usec
))
2614 return sys_ioctl(fd
, cmd
, (unsigned long)tn
);
2617 #define HANDLE_IOCTL(cmd,handler) \
2618 { (cmd), (ioctl_trans_handler_t)(handler) },
2620 /* pointer to compatible structure or no argument */
2621 #define COMPATIBLE_IOCTL(cmd) \
2622 { (cmd), do_ioctl32_pointer },
2624 /* argument is an unsigned long integer, not a pointer */
2625 #define ULONG_IOCTL(cmd) \
2626 { (cmd), (ioctl_trans_handler_t)sys_ioctl },
2629 struct ioctl_trans ioctl_start
[] = {
2630 #include <linux/compat_ioctl.h>
2631 HANDLE_IOCTL(MEMREADOOB32
, mtd_rw_oob
)
2632 HANDLE_IOCTL(MEMWRITEOOB32
, mtd_rw_oob
)
2634 HANDLE_IOCTL(SIOCGIFNAME
, dev_ifname32
)
2635 HANDLE_IOCTL(SIOCGIFCONF
, dev_ifconf
)
2636 HANDLE_IOCTL(SIOCGIFFLAGS
, dev_ifsioc
)
2637 HANDLE_IOCTL(SIOCSIFFLAGS
, dev_ifsioc
)
2638 HANDLE_IOCTL(SIOCGIFMETRIC
, dev_ifsioc
)
2639 HANDLE_IOCTL(SIOCSIFMETRIC
, dev_ifsioc
)
2640 HANDLE_IOCTL(SIOCGIFMTU
, dev_ifsioc
)
2641 HANDLE_IOCTL(SIOCSIFMTU
, dev_ifsioc
)
2642 HANDLE_IOCTL(SIOCGIFMEM
, dev_ifsioc
)
2643 HANDLE_IOCTL(SIOCSIFMEM
, dev_ifsioc
)
2644 HANDLE_IOCTL(SIOCGIFHWADDR
, dev_ifsioc
)
2645 HANDLE_IOCTL(SIOCSIFHWADDR
, dev_ifsioc
)
2646 HANDLE_IOCTL(SIOCADDMULTI
, dev_ifsioc
)
2647 HANDLE_IOCTL(SIOCDELMULTI
, dev_ifsioc
)
2648 HANDLE_IOCTL(SIOCGIFINDEX
, dev_ifsioc
)
2649 HANDLE_IOCTL(SIOCGIFMAP
, dev_ifsioc
)
2650 HANDLE_IOCTL(SIOCSIFMAP
, dev_ifsioc
)
2651 HANDLE_IOCTL(SIOCGIFADDR
, dev_ifsioc
)
2652 HANDLE_IOCTL(SIOCSIFADDR
, dev_ifsioc
)
2654 /* ioctls used by appletalk ddp.c */
2655 HANDLE_IOCTL(SIOCATALKDIFADDR
, dev_ifsioc
)
2656 HANDLE_IOCTL(SIOCDIFADDR
, dev_ifsioc
)
2657 HANDLE_IOCTL(SIOCSARP
, dev_ifsioc
)
2658 HANDLE_IOCTL(SIOCDARP
, dev_ifsioc
)
2660 HANDLE_IOCTL(SIOCGIFBRDADDR
, dev_ifsioc
)
2661 HANDLE_IOCTL(SIOCSIFBRDADDR
, dev_ifsioc
)
2662 HANDLE_IOCTL(SIOCGIFDSTADDR
, dev_ifsioc
)
2663 HANDLE_IOCTL(SIOCSIFDSTADDR
, dev_ifsioc
)
2664 HANDLE_IOCTL(SIOCGIFNETMASK
, dev_ifsioc
)
2665 HANDLE_IOCTL(SIOCSIFNETMASK
, dev_ifsioc
)
2666 HANDLE_IOCTL(SIOCSIFPFLAGS
, dev_ifsioc
)
2667 HANDLE_IOCTL(SIOCGIFPFLAGS
, dev_ifsioc
)
2668 HANDLE_IOCTL(SIOCGIFTXQLEN
, dev_ifsioc
)
2669 HANDLE_IOCTL(SIOCSIFTXQLEN
, dev_ifsioc
)
2670 HANDLE_IOCTL(TUNSETIFF
, dev_ifsioc
)
2671 HANDLE_IOCTL(SIOCETHTOOL
, ethtool_ioctl
)
2672 HANDLE_IOCTL(SIOCBONDENSLAVE
, bond_ioctl
)
2673 HANDLE_IOCTL(SIOCBONDRELEASE
, bond_ioctl
)
2674 HANDLE_IOCTL(SIOCBONDSETHWADDR
, bond_ioctl
)
2675 HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY
, bond_ioctl
)
2676 HANDLE_IOCTL(SIOCBONDINFOQUERY
, bond_ioctl
)
2677 HANDLE_IOCTL(SIOCBONDCHANGEACTIVE
, bond_ioctl
)
2678 HANDLE_IOCTL(SIOCADDRT
, routing_ioctl
)
2679 HANDLE_IOCTL(SIOCDELRT
, routing_ioctl
)
2680 HANDLE_IOCTL(SIOCBRADDIF
, dev_ifsioc
)
2681 HANDLE_IOCTL(SIOCBRDELIF
, dev_ifsioc
)
2682 /* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
2683 HANDLE_IOCTL(SIOCRTMSG
, ret_einval
)
2684 HANDLE_IOCTL(SIOCGSTAMP
, do_siocgstamp
)
2686 HANDLE_IOCTL(HDIO_GETGEO
, hdio_getgeo
)
2687 HANDLE_IOCTL(BLKRAGET
, w_long
)
2688 HANDLE_IOCTL(BLKGETSIZE
, w_long
)
2689 HANDLE_IOCTL(0x1260, broken_blkgetsize
)
2690 HANDLE_IOCTL(BLKFRAGET
, w_long
)
2691 HANDLE_IOCTL(BLKSECTGET
, w_long
)
2692 HANDLE_IOCTL(BLKPG
, blkpg_ioctl_trans
)
2693 HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS
, hdio_ioctl_trans
)
2694 HANDLE_IOCTL(HDIO_GET_UNMASKINTR
, hdio_ioctl_trans
)
2695 HANDLE_IOCTL(HDIO_GET_DMA
, hdio_ioctl_trans
)
2696 HANDLE_IOCTL(HDIO_GET_32BIT
, hdio_ioctl_trans
)
2697 HANDLE_IOCTL(HDIO_GET_MULTCOUNT
, hdio_ioctl_trans
)
2698 HANDLE_IOCTL(HDIO_GET_NOWERR
, hdio_ioctl_trans
)
2699 HANDLE_IOCTL(HDIO_GET_NICE
, hdio_ioctl_trans
)
2700 HANDLE_IOCTL(FDSETPRM32
, fd_ioctl_trans
)
2701 HANDLE_IOCTL(FDDEFPRM32
, fd_ioctl_trans
)
2702 HANDLE_IOCTL(FDGETPRM32
, fd_ioctl_trans
)
2703 HANDLE_IOCTL(FDSETDRVPRM32
, fd_ioctl_trans
)
2704 HANDLE_IOCTL(FDGETDRVPRM32
, fd_ioctl_trans
)
2705 HANDLE_IOCTL(FDGETDRVSTAT32
, fd_ioctl_trans
)
2706 HANDLE_IOCTL(FDPOLLDRVSTAT32
, fd_ioctl_trans
)
2707 HANDLE_IOCTL(FDGETFDCSTAT32
, fd_ioctl_trans
)
2708 HANDLE_IOCTL(FDWERRORGET32
, fd_ioctl_trans
)
2709 HANDLE_IOCTL(SG_IO
,sg_ioctl_trans
)
2710 HANDLE_IOCTL(SG_GET_REQUEST_TABLE
, sg_grt_trans
)
2711 HANDLE_IOCTL(PPPIOCGIDLE32
, ppp_ioctl_trans
)
2712 HANDLE_IOCTL(PPPIOCSCOMPRESS32
, ppp_ioctl_trans
)
2713 HANDLE_IOCTL(PPPIOCSPASS32
, ppp_sock_fprog_ioctl_trans
)
2714 HANDLE_IOCTL(PPPIOCSACTIVE32
, ppp_sock_fprog_ioctl_trans
)
2715 HANDLE_IOCTL(MTIOCGET32
, mt_ioctl_trans
)
2716 HANDLE_IOCTL(MTIOCPOS32
, mt_ioctl_trans
)
2717 HANDLE_IOCTL(CDROMREADAUDIO
, cdrom_ioctl_trans
)
2718 HANDLE_IOCTL(CDROM_SEND_PACKET
, cdrom_ioctl_trans
)
2719 #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
2720 HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32
, ioc_settimeout
)
2722 HANDLE_IOCTL(PIO_FONTX
, do_fontx_ioctl
)
2723 HANDLE_IOCTL(GIO_FONTX
, do_fontx_ioctl
)
2724 HANDLE_IOCTL(PIO_UNIMAP
, do_unimap_ioctl
)
2725 HANDLE_IOCTL(GIO_UNIMAP
, do_unimap_ioctl
)
2726 HANDLE_IOCTL(KDFONTOP
, do_kdfontop_ioctl
)
2728 HANDLE_IOCTL(EXT2_IOC32_GETFLAGS
, do_ext2_ioctl
)
2729 HANDLE_IOCTL(EXT2_IOC32_SETFLAGS
, do_ext2_ioctl
)
2730 HANDLE_IOCTL(EXT2_IOC32_GETVERSION
, do_ext2_ioctl
)
2731 HANDLE_IOCTL(EXT2_IOC32_SETVERSION
, do_ext2_ioctl
)
2732 HANDLE_IOCTL(EXT3_IOC32_GETVERSION
, do_ext3_ioctl
)
2733 HANDLE_IOCTL(EXT3_IOC32_SETVERSION
, do_ext3_ioctl
)
2734 HANDLE_IOCTL(EXT3_IOC32_GETRSVSZ
, do_ext3_ioctl
)
2735 HANDLE_IOCTL(EXT3_IOC32_SETRSVSZ
, do_ext3_ioctl
)
2736 HANDLE_IOCTL(EXT3_IOC32_GROUP_EXTEND
, do_ext3_ioctl
)
2737 COMPATIBLE_IOCTL(EXT3_IOC_GROUP_ADD
)
2738 #ifdef CONFIG_JBD_DEBUG
2739 HANDLE_IOCTL(EXT3_IOC32_WAIT_FOR_READONLY
, do_ext3_ioctl
)
2741 /* One SMB ioctl needs translations. */
2742 #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
2743 HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32
, do_smb_getmountuid
)
2744 HANDLE_IOCTL(ATM_GETLINKRATE32
, do_atm_ioctl
)
2745 HANDLE_IOCTL(ATM_GETNAMES32
, do_atm_ioctl
)
2746 HANDLE_IOCTL(ATM_GETTYPE32
, do_atm_ioctl
)
2747 HANDLE_IOCTL(ATM_GETESI32
, do_atm_ioctl
)
2748 HANDLE_IOCTL(ATM_GETADDR32
, do_atm_ioctl
)
2749 HANDLE_IOCTL(ATM_RSTADDR32
, do_atm_ioctl
)
2750 HANDLE_IOCTL(ATM_ADDADDR32
, do_atm_ioctl
)
2751 HANDLE_IOCTL(ATM_DELADDR32
, do_atm_ioctl
)
2752 HANDLE_IOCTL(ATM_GETCIRANGE32
, do_atm_ioctl
)
2753 HANDLE_IOCTL(ATM_SETCIRANGE32
, do_atm_ioctl
)
2754 HANDLE_IOCTL(ATM_SETESI32
, do_atm_ioctl
)
2755 HANDLE_IOCTL(ATM_SETESIF32
, do_atm_ioctl
)
2756 HANDLE_IOCTL(ATM_GETSTAT32
, do_atm_ioctl
)
2757 HANDLE_IOCTL(ATM_GETSTATZ32
, do_atm_ioctl
)
2758 HANDLE_IOCTL(ATM_GETLOOP32
, do_atm_ioctl
)
2759 HANDLE_IOCTL(ATM_SETLOOP32
, do_atm_ioctl
)
2760 HANDLE_IOCTL(ATM_QUERYLOOP32
, do_atm_ioctl
)
2761 HANDLE_IOCTL(SONET_GETSTAT
, do_atm_ioctl
)
2762 HANDLE_IOCTL(SONET_GETSTATZ
, do_atm_ioctl
)
2763 HANDLE_IOCTL(SONET_GETDIAG
, do_atm_ioctl
)
2764 HANDLE_IOCTL(SONET_SETDIAG
, do_atm_ioctl
)
2765 HANDLE_IOCTL(SONET_CLRDIAG
, do_atm_ioctl
)
2766 HANDLE_IOCTL(SONET_SETFRAMING
, do_atm_ioctl
)
2767 HANDLE_IOCTL(SONET_GETFRAMING
, do_atm_ioctl
)
2768 HANDLE_IOCTL(SONET_GETFRSENSE
, do_atm_ioctl
)
2770 HANDLE_IOCTL(BLKBSZGET_32
, do_blkbszget
)
2771 HANDLE_IOCTL(BLKBSZSET_32
, do_blkbszset
)
2772 HANDLE_IOCTL(BLKGETSIZE64_32
, do_blkgetsize64
)
2774 HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32
, vfat_ioctl32
)
2775 HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32
, vfat_ioctl32
)
2777 HANDLE_IOCTL(RAW_SETBIND
, raw_ioctl
)
2778 HANDLE_IOCTL(RAW_GETBIND
, raw_ioctl
)
2780 HANDLE_IOCTL(TIOCGSERIAL
, serial_struct_ioctl
)
2781 HANDLE_IOCTL(TIOCSSERIAL
, serial_struct_ioctl
)
2783 COMPATIBLE_IOCTL(TIOCGLTC
)
2784 COMPATIBLE_IOCTL(TIOCSLTC
)
2788 * For these two we have defintions in ioctls.h and/or termios.h on
2789 * some architectures but no actual implemention. Some applications
2790 * like bash call them if they are defined in the headers, so we provide
2791 * entries here to avoid syslog message spew.
2793 COMPATIBLE_IOCTL(TIOCSTART
)
2794 COMPATIBLE_IOCTL(TIOCSTOP
)
2797 HANDLE_IOCTL(USBDEVFS_CONTROL32
, do_usbdevfs_control
)
2798 HANDLE_IOCTL(USBDEVFS_BULK32
, do_usbdevfs_bulk
)
2799 HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32
, do_usbdevfs_discsignal
)
2800 COMPATIBLE_IOCTL(USBDEVFS_IOCTL32
)
2802 HANDLE_IOCTL(I2C_FUNCS
, w_long
)
2803 HANDLE_IOCTL(I2C_RDWR
, do_i2c_rdwr_ioctl
)
2804 HANDLE_IOCTL(I2C_SMBUS
, do_i2c_smbus_ioctl
)
2806 HANDLE_IOCTL(SIOCGIWRANGE
, do_wireless_ioctl
)
2807 HANDLE_IOCTL(SIOCSIWSPY
, do_wireless_ioctl
)
2808 HANDLE_IOCTL(SIOCGIWSPY
, do_wireless_ioctl
)
2809 HANDLE_IOCTL(SIOCSIWTHRSPY
, do_wireless_ioctl
)
2810 HANDLE_IOCTL(SIOCGIWTHRSPY
, do_wireless_ioctl
)
2811 HANDLE_IOCTL(SIOCGIWAPLIST
, do_wireless_ioctl
)
2812 HANDLE_IOCTL(SIOCGIWSCAN
, do_wireless_ioctl
)
2813 HANDLE_IOCTL(SIOCSIWESSID
, do_wireless_ioctl
)
2814 HANDLE_IOCTL(SIOCGIWESSID
, do_wireless_ioctl
)
2815 HANDLE_IOCTL(SIOCSIWNICKN
, do_wireless_ioctl
)
2816 HANDLE_IOCTL(SIOCGIWNICKN
, do_wireless_ioctl
)
2817 HANDLE_IOCTL(SIOCSIWENCODE
, do_wireless_ioctl
)
2818 HANDLE_IOCTL(SIOCGIWENCODE
, do_wireless_ioctl
)
2819 HANDLE_IOCTL(SIOCSIFBR
, old_bridge_ioctl
)
2820 HANDLE_IOCTL(SIOCGIFBR
, old_bridge_ioctl
)
2821 HANDLE_IOCTL(RTC_IRQP_READ32
, rtc_ioctl
)
2822 HANDLE_IOCTL(RTC_IRQP_SET32
, rtc_ioctl
)
2823 HANDLE_IOCTL(RTC_EPOCH_READ32
, rtc_ioctl
)
2824 HANDLE_IOCTL(RTC_EPOCH_SET32
, rtc_ioctl
)
2826 #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
2827 HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32
, do_ncp_ncprequest
)
2828 HANDLE_IOCTL(NCP_IOC_GETMOUNTUID2_32
, do_ncp_getmountuid2
)
2829 HANDLE_IOCTL(NCP_IOC_GET_FS_INFO_V2_32
, do_ncp_getfsinfo2
)
2830 HANDLE_IOCTL(NCP_IOC_GETOBJECTNAME_32
, do_ncp_getobjectname
)
2831 HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32
, do_ncp_setobjectname
)
2832 HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32
, do_ncp_getprivatedata
)
2833 HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32
, do_ncp_setprivatedata
)
2837 HANDLE_IOCTL(VIDEO_GET_EVENT
, do_video_get_event
)
2838 HANDLE_IOCTL(VIDEO_STILLPICTURE
, do_video_stillpicture
)
2839 HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE
, do_video_set_spu_palette
)
2842 COMPATIBLE_IOCTL(LPTIME
)
2843 COMPATIBLE_IOCTL(LPCHAR
)
2844 COMPATIBLE_IOCTL(LPABORTOPEN
)
2845 COMPATIBLE_IOCTL(LPCAREFUL
)
2846 COMPATIBLE_IOCTL(LPWAIT
)
2847 COMPATIBLE_IOCTL(LPSETIRQ
)
2848 COMPATIBLE_IOCTL(LPGETSTATUS
)
2849 COMPATIBLE_IOCTL(LPGETSTATUS
)
2850 COMPATIBLE_IOCTL(LPRESET
)
2851 /*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/
2852 COMPATIBLE_IOCTL(LPGETFLAGS
)
2853 HANDLE_IOCTL(LPSETTIMEOUT
, lp_timeout_trans
)
2856 int ioctl_table_size
= ARRAY_SIZE(ioctl_start
);