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
14 #include <linux/config.h>
15 #include <linux/types.h>
16 #include <linux/compat.h>
17 #include <linux/kernel.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/slab.h>
24 #include <linux/hdreg.h>
25 #include <linux/raid/md.h>
27 #include <linux/dirent.h>
28 #include <linux/route.h>
29 #include <linux/in6.h>
30 #include <linux/ipv6_route.h>
31 #include <linux/skbuff.h>
32 #include <linux/netlink.h>
35 #include <linux/file.h>
37 #include <linux/ppp_defs.h>
38 #include <linux/if_ppp.h>
39 #include <linux/if_pppox.h>
40 #include <linux/mtio.h>
41 #include <linux/cdrom.h>
42 #include <linux/loop.h>
43 #include <linux/auto_fs.h>
44 #include <linux/auto_fs4.h>
45 #include <linux/devfs_fs.h>
46 #include <linux/tty.h>
47 #include <linux/vt_kern.h>
49 #include <linux/ext2_fs.h>
50 #include <linux/videodev.h>
51 #include <linux/netdevice.h>
52 #include <linux/raw.h>
53 #include <linux/smb_fs.h>
54 #include <linux/blkpg.h>
55 #include <linux/blkdev.h>
56 #include <linux/elevator.h>
57 #include <linux/rtc.h>
58 #include <linux/pci.h>
59 #include <linux/module.h>
60 #include <linux/serial.h>
61 #include <linux/reiserfs_fs.h>
62 #include <linux/if_tun.h>
63 #include <linux/ctype.h>
64 #include <linux/ioctl32.h>
65 #include <linux/ncp_fs.h>
67 #include <net/sock.h> /* siocdevprivate_ioctl */
68 #include <net/bluetooth/bluetooth.h>
69 #include <net/bluetooth/rfcomm.h>
70 #include <net/bluetooth/hci.h>
72 #include <scsi/scsi.h>
75 #include <scsi/scsi_ioctl.h>
79 #include <asm/types.h>
80 #include <asm/uaccess.h>
81 #include <linux/ethtool.h>
82 #include <linux/mii.h>
83 #include <linux/if_bonding.h>
84 #include <linux/watchdog.h>
85 #include <linux/dm-ioctl.h>
87 #include <asm/module.h>
88 #include <linux/soundcard.h>
91 #include <linux/atm.h>
92 #include <linux/atmarp.h>
93 #include <linux/atmclip.h>
94 #include <linux/atmdev.h>
95 #include <linux/atmioc.h>
96 #include <linux/atmlec.h>
97 #include <linux/atmmpc.h>
98 #include <linux/atmsvc.h>
99 #include <linux/atm_tcp.h>
100 #include <linux/sonet.h>
101 #include <linux/atm_suni.h>
102 #include <linux/mtd/mtd.h>
104 #include <linux/usb.h>
105 #include <linux/usbdevice_fs.h>
106 #include <linux/nbd.h>
107 #include <linux/random.h>
108 #include <linux/filter.h>
109 #include <linux/msdos_fs.h>
116 /* Aiee. Someone does not find a difference between int and long */
117 #define EXT2_IOC32_GETFLAGS _IOR('f', 1, int)
118 #define EXT2_IOC32_SETFLAGS _IOW('f', 2, int)
119 #define EXT2_IOC32_GETVERSION _IOR('v', 1, int)
120 #define EXT2_IOC32_SETVERSION _IOW('v', 2, int)
122 static int w_long(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
124 mm_segment_t old_fs
= get_fs();
129 err
= sys_ioctl(fd
, cmd
, (unsigned long)&val
);
131 if (!err
&& put_user(val
, (u32
*)arg
))
136 static int rw_long(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
138 mm_segment_t old_fs
= get_fs();
142 if(get_user(val
, (u32
*)arg
))
145 err
= sys_ioctl(fd
, cmd
, (unsigned long)&val
);
147 if (!err
&& put_user(val
, (u32
*)arg
))
152 static int do_ext2_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
154 /* These are just misnamed, they actually get/put from/to user an int */
156 case EXT2_IOC32_GETFLAGS
: cmd
= EXT2_IOC_GETFLAGS
; break;
157 case EXT2_IOC32_SETFLAGS
: cmd
= EXT2_IOC_SETFLAGS
; break;
158 case EXT2_IOC32_GETVERSION
: cmd
= EXT2_IOC_GETVERSION
; break;
159 case EXT2_IOC32_SETVERSION
: cmd
= EXT2_IOC_SETVERSION
; break;
161 return sys_ioctl(fd
, cmd
, arg
);
164 struct video_tuner32
{
167 compat_ulong_t rangelow
, rangehigh
;
168 u32 flags
; /* It is really u32 in videodev.h */
172 static int get_video_tuner32(struct video_tuner
*kp
, struct video_tuner32
*up
)
176 if(get_user(kp
->tuner
, &up
->tuner
))
178 for(i
= 0; i
< 32; i
++)
179 __get_user(kp
->name
[i
], &up
->name
[i
]);
180 __get_user(kp
->rangelow
, &up
->rangelow
);
181 __get_user(kp
->rangehigh
, &up
->rangehigh
);
182 __get_user(kp
->flags
, &up
->flags
);
183 __get_user(kp
->mode
, &up
->mode
);
184 __get_user(kp
->signal
, &up
->signal
);
188 static int put_video_tuner32(struct video_tuner
*kp
, struct video_tuner32
*up
)
192 if(put_user(kp
->tuner
, &up
->tuner
))
194 for(i
= 0; i
< 32; i
++)
195 __put_user(kp
->name
[i
], &up
->name
[i
]);
196 __put_user(kp
->rangelow
, &up
->rangelow
);
197 __put_user(kp
->rangehigh
, &up
->rangehigh
);
198 __put_user(kp
->flags
, &up
->flags
);
199 __put_user(kp
->mode
, &up
->mode
);
200 __put_user(kp
->signal
, &up
->signal
);
204 struct video_buffer32
{
206 compat_int_t height
, width
, depth
, bytesperline
;
209 static int get_video_buffer32(struct video_buffer
*kp
, struct video_buffer32
*up
)
213 if(get_user(tmp
, &up
->base
))
215 kp
->base
= (void *) ((unsigned long)tmp
);
216 __get_user(kp
->height
, &up
->height
);
217 __get_user(kp
->width
, &up
->width
);
218 __get_user(kp
->depth
, &up
->depth
);
219 __get_user(kp
->bytesperline
, &up
->bytesperline
);
223 static int put_video_buffer32(struct video_buffer
*kp
, struct video_buffer32
*up
)
225 u32 tmp
= (u32
)((unsigned long)kp
->base
);
227 if(put_user(tmp
, &up
->base
))
229 __put_user(kp
->height
, &up
->height
);
230 __put_user(kp
->width
, &up
->width
);
231 __put_user(kp
->depth
, &up
->depth
);
232 __put_user(kp
->bytesperline
, &up
->bytesperline
);
236 struct video_clip32
{
237 s32 x
, y
, width
, height
; /* Its really s32 in videodev.h */
241 struct video_window32
{
242 u32 x
, y
, width
, height
, chromakey
, flags
;
243 compat_caddr_t clips
;
244 compat_int_t clipcount
;
247 static void free_kvideo_clips(struct video_window
*kp
)
249 struct video_clip
*cp
;
256 static int get_video_window32(struct video_window
*kp
, struct video_window32
*up
)
258 struct video_clip32
*ucp
;
259 struct video_clip
*kcp
;
263 if(get_user(kp
->x
, &up
->x
))
265 __get_user(kp
->y
, &up
->y
);
266 __get_user(kp
->width
, &up
->width
);
267 __get_user(kp
->height
, &up
->height
);
268 __get_user(kp
->chromakey
, &up
->chromakey
);
269 __get_user(kp
->flags
, &up
->flags
);
270 __get_user(kp
->clipcount
, &up
->clipcount
);
271 __get_user(tmp
, &up
->clips
);
272 ucp
= compat_ptr(tmp
);
275 nclips
= kp
->clipcount
;
282 /* Peculiar interface... */
284 nclips
= VIDEO_CLIPMAP_SIZE
;
286 kcp
= kmalloc(nclips
* sizeof(struct video_clip
), GFP_KERNEL
);
289 goto cleanup_and_err
;
292 for(i
= 0; i
< nclips
; i
++) {
293 __get_user(kcp
[i
].x
, &ucp
[i
].x
);
294 __get_user(kcp
[i
].y
, &ucp
[i
].y
);
295 __get_user(kcp
[i
].width
, &ucp
[i
].width
);
296 __get_user(kcp
[i
].height
, &ucp
[i
].height
);
297 kcp
[nclips
].next
= NULL
;
303 free_kvideo_clips(kp
);
307 /* You get back everything except the clips... */
308 static int put_video_window32(struct video_window
*kp
, struct video_window32
*up
)
310 if(put_user(kp
->x
, &up
->x
))
312 __put_user(kp
->y
, &up
->y
);
313 __put_user(kp
->width
, &up
->width
);
314 __put_user(kp
->height
, &up
->height
);
315 __put_user(kp
->chromakey
, &up
->chromakey
);
316 __put_user(kp
->flags
, &up
->flags
);
317 __put_user(kp
->clipcount
, &up
->clipcount
);
321 #define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32)
322 #define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32)
323 #define VIDIOCGWIN32 _IOR('v',9, struct video_window32)
324 #define VIDIOCSWIN32 _IOW('v',10, struct video_window32)
325 #define VIDIOCGFBUF32 _IOR('v',11, struct video_buffer32)
326 #define VIDIOCSFBUF32 _IOW('v',12, struct video_buffer32)
327 #define VIDIOCGFREQ32 _IOR('v',14, u32)
328 #define VIDIOCSFREQ32 _IOW('v',15, u32)
330 static int do_video_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
333 struct video_tuner vt
;
334 struct video_buffer vb
;
335 struct video_window vw
;
338 mm_segment_t old_fs
= get_fs();
339 void *up
= (void *)arg
;
342 /* First, convert the command. */
344 case VIDIOCGTUNER32
: cmd
= VIDIOCGTUNER
; break;
345 case VIDIOCSTUNER32
: cmd
= VIDIOCSTUNER
; break;
346 case VIDIOCGWIN32
: cmd
= VIDIOCGWIN
; break;
347 case VIDIOCSWIN32
: cmd
= VIDIOCSWIN
; break;
348 case VIDIOCGFBUF32
: cmd
= VIDIOCGFBUF
; break;
349 case VIDIOCSFBUF32
: cmd
= VIDIOCSFBUF
; break;
350 case VIDIOCGFREQ32
: cmd
= VIDIOCGFREQ
; break;
351 case VIDIOCSFREQ32
: cmd
= VIDIOCSFREQ
; break;
357 err
= get_video_tuner32(&karg
.vt
, up
);
361 err
= get_video_window32(&karg
.vw
, up
);
365 err
= get_video_buffer32(&karg
.vb
, up
);
369 err
= get_user(karg
.vx
, (u32
*)up
);
376 err
= sys_ioctl(fd
, cmd
, (unsigned long)&karg
);
379 if(cmd
== VIDIOCSWIN
)
380 free_kvideo_clips(&karg
.vw
);
385 err
= put_video_tuner32(&karg
.vt
, up
);
389 err
= put_video_window32(&karg
.vw
, up
);
393 err
= put_video_buffer32(&karg
.vb
, up
);
397 err
= put_user(((u32
)karg
.vx
), (u32
*)up
);
405 static int do_siocgstamp(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
407 struct compat_timeval
*up
= (struct compat_timeval
*)arg
;
409 mm_segment_t old_fs
= get_fs();
413 err
= sys_ioctl(fd
, cmd
, (unsigned long)&ktv
);
416 err
= put_user(ktv
.tv_sec
, &up
->tv_sec
);
417 err
|= __put_user(ktv
.tv_usec
, &up
->tv_usec
);
423 compat_ulong_t mem_start
;
424 compat_ulong_t mem_end
;
425 unsigned short base_addr
;
432 #define IFHWADDRLEN 6
435 char ifrn_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
438 struct sockaddr ifru_addr
;
439 struct sockaddr ifru_dstaddr
;
440 struct sockaddr ifru_broadaddr
;
441 struct sockaddr ifru_netmask
;
442 struct sockaddr ifru_hwaddr
;
444 compat_int_t ifru_ivalue
;
445 compat_int_t ifru_mtu
;
446 struct ifmap32 ifru_map
;
447 char ifru_slave
[IFNAMSIZ
]; /* Just fits the size */
448 char ifru_newname
[IFNAMSIZ
];
449 compat_caddr_t ifru_data
;
450 /* XXXX? ifru_settings should be here */
455 compat_int_t ifc_len
; /* size of buffer */
456 compat_caddr_t ifcbuf
;
460 static int dev_ifname32(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
462 struct net_device
*dev
;
463 struct ifreq32 ifr32
;
466 if (copy_from_user(&ifr32
, (struct ifreq32
*)arg
, sizeof(struct ifreq32
)))
469 dev
= dev_get_by_index(ifr32
.ifr_ifindex
);
473 strlcpy(ifr32
.ifr_name
, dev
->name
, sizeof(ifr32
.ifr_name
));
476 err
= copy_to_user((struct ifreq32
*)arg
, &ifr32
, sizeof(struct ifreq32
));
477 return (err
? -EFAULT
: 0);
481 static int dev_ifconf(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
483 struct ifconf32 ifc32
;
485 struct ifreq32
*ifr32
;
491 if (copy_from_user(&ifc32
, (struct ifconf32
*)arg
, sizeof(struct ifconf32
)))
494 if(ifc32
.ifcbuf
== 0) {
499 ifc
.ifc_len
= ((ifc32
.ifc_len
/ sizeof (struct ifreq32
)) + 1) *
500 sizeof (struct ifreq
);
501 ifc
.ifc_buf
= kmalloc (ifc
.ifc_len
, GFP_KERNEL
);
506 ifr32
= compat_ptr(ifc32
.ifcbuf
);
507 for (i
= 0; i
< ifc32
.ifc_len
; i
+= sizeof (struct ifreq32
)) {
508 if (copy_from_user(ifr
, ifr32
, sizeof (struct ifreq32
))) {
515 old_fs
= get_fs(); set_fs (KERNEL_DS
);
516 err
= sys_ioctl (fd
, SIOCGIFCONF
, (unsigned long)&ifc
);
520 ifr32
= compat_ptr(ifc32
.ifcbuf
);
521 for (i
= 0, j
= 0; i
< ifc32
.ifc_len
&& j
< ifc
.ifc_len
;
522 i
+= sizeof (struct ifreq32
), j
+= sizeof (struct ifreq
)) {
523 int k
= copy_to_user(ifr32
, ifr
, sizeof (struct ifreq32
));
533 if (ifc32
.ifcbuf
== 0) {
534 /* Translate from 64-bit structure multiple to
538 i
= ((i
/ sizeof(struct ifreq
)) * sizeof(struct ifreq32
));
541 if (i
<= ifc32
.ifc_len
)
544 ifc32
.ifc_len
= i
- sizeof (struct ifreq32
);
546 if (copy_to_user((struct ifconf32
*)arg
, &ifc32
, sizeof(struct ifconf32
)))
550 if(ifc
.ifc_buf
!= NULL
)
555 static int ethtool_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
558 struct ifreq32
*ifr32
;
562 ifr
= compat_alloc_user_space(sizeof(*ifr
));
563 ifr32
= (struct ifreq32
*) arg
;
565 if (copy_in_user(&ifr
->ifr_name
, &ifr32
->ifr_name
, IFNAMSIZ
))
568 if (get_user(data
, &ifr32
->ifr_ifru
.ifru_data
))
571 datap
= (void *) (unsigned long) data
;
572 if (put_user(datap
, &ifr
->ifr_ifru
.ifru_data
))
575 return sys_ioctl(fd
, cmd
, (unsigned long) ifr
);
578 static int bond_ioctl(unsigned long fd
, unsigned int cmd
, unsigned long arg
)
582 struct ifreq32
*ifr32
= (struct ifreq32
*) arg
;
589 case SIOCBONDENSLAVE
:
590 case SIOCBONDRELEASE
:
591 case SIOCBONDSETHWADDR
:
592 case SIOCBONDCHANGEACTIVE
:
593 if (copy_from_user(&kifr
, ifr32
, sizeof(struct ifreq32
)))
598 err
= sys_ioctl (fd
, cmd
, (unsigned long)&kifr
);
602 case SIOCBONDSLAVEINFOQUERY
:
603 case SIOCBONDINFOQUERY
:
604 uifr
= compat_alloc_user_space(sizeof(*uifr
));
605 if (copy_in_user(&uifr
->ifr_name
, &ifr32
->ifr_name
, IFNAMSIZ
))
608 if (get_user(data
, &ifr32
->ifr_ifru
.ifru_data
))
611 datap
= compat_ptr(data
);
612 if (put_user(datap
, &uifr
->ifr_ifru
.ifru_data
))
615 return sys_ioctl (fd
, cmd
, (unsigned long)uifr
);
621 int siocdevprivate_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
623 struct ifreq
*u_ifreq64
;
624 struct ifreq32
*u_ifreq32
= (struct ifreq32
*) arg
;
625 char tmp_buf
[IFNAMSIZ
];
629 if (copy_from_user(&tmp_buf
[0], &(u_ifreq32
->ifr_ifrn
.ifrn_name
[0]),
632 if (__get_user(data32
, &u_ifreq32
->ifr_ifru
.ifru_data
))
634 data64
= compat_ptr(data32
);
636 u_ifreq64
= compat_alloc_user_space(sizeof(*u_ifreq64
));
638 /* Don't check these user accesses, just let that get trapped
639 * in the ioctl handler instead.
641 copy_to_user(&u_ifreq64
->ifr_ifrn
.ifrn_name
[0], &tmp_buf
[0], IFNAMSIZ
);
642 __put_user(data64
, &u_ifreq64
->ifr_ifru
.ifru_data
);
644 return sys_ioctl(fd
, cmd
, (unsigned long) u_ifreq64
);
647 static int dev_ifsioc(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
655 err
= copy_from_user(&ifr
, (struct ifreq32
*)arg
, sizeof(ifr
.ifr_name
));
656 err
|= __get_user(ifr
.ifr_map
.mem_start
, &(((struct ifreq32
*)arg
)->ifr_ifru
.ifru_map
.mem_start
));
657 err
|= __get_user(ifr
.ifr_map
.mem_end
, &(((struct ifreq32
*)arg
)->ifr_ifru
.ifru_map
.mem_end
));
658 err
|= __get_user(ifr
.ifr_map
.base_addr
, &(((struct ifreq32
*)arg
)->ifr_ifru
.ifru_map
.base_addr
));
659 err
|= __get_user(ifr
.ifr_map
.irq
, &(((struct ifreq32
*)arg
)->ifr_ifru
.ifru_map
.irq
));
660 err
|= __get_user(ifr
.ifr_map
.dma
, &(((struct ifreq32
*)arg
)->ifr_ifru
.ifru_map
.dma
));
661 err
|= __get_user(ifr
.ifr_map
.port
, &(((struct ifreq32
*)arg
)->ifr_ifru
.ifru_map
.port
));
666 if (copy_from_user(&ifr
, (struct ifreq32
*)arg
, sizeof(struct ifreq32
)))
672 err
= sys_ioctl (fd
, cmd
, (unsigned long)&ifr
);
687 if (copy_to_user((struct ifreq32
*)arg
, &ifr
, sizeof(struct ifreq32
)))
691 err
= copy_to_user((struct ifreq32
*)arg
, &ifr
, sizeof(ifr
.ifr_name
));
692 err
|= __put_user(ifr
.ifr_map
.mem_start
, &(((struct ifreq32
*)arg
)->ifr_ifru
.ifru_map
.mem_start
));
693 err
|= __put_user(ifr
.ifr_map
.mem_end
, &(((struct ifreq32
*)arg
)->ifr_ifru
.ifru_map
.mem_end
));
694 err
|= __put_user(ifr
.ifr_map
.base_addr
, &(((struct ifreq32
*)arg
)->ifr_ifru
.ifru_map
.base_addr
));
695 err
|= __put_user(ifr
.ifr_map
.irq
, &(((struct ifreq32
*)arg
)->ifr_ifru
.ifru_map
.irq
));
696 err
|= __put_user(ifr
.ifr_map
.dma
, &(((struct ifreq32
*)arg
)->ifr_ifru
.ifru_map
.dma
));
697 err
|= __put_user(ifr
.ifr_map
.port
, &(((struct ifreq32
*)arg
)->ifr_ifru
.ifru_map
.port
));
708 struct sockaddr rt_dst
; /* target address */
709 struct sockaddr rt_gateway
; /* gateway addr (RTF_GATEWAY) */
710 struct sockaddr rt_genmask
; /* target network mask (IP) */
711 unsigned short rt_flags
;
714 unsigned char rt_tos
;
715 unsigned char rt_class
;
717 short rt_metric
; /* +1 for binary compatibility! */
718 /* char * */ u32 rt_dev
; /* forcing the device at add */
719 u32 rt_mtu
; /* per route MTU/Window */
720 u32 rt_window
; /* Window clamping */
721 unsigned short rt_irtt
; /* Initial RTT */
726 struct in6_addr rtmsg_dst
;
727 struct in6_addr rtmsg_src
;
728 struct in6_addr rtmsg_gateway
;
738 static int routing_ioctl(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
746 mm_segment_t old_fs
= get_fs();
748 struct socket
*mysock
= sockfd_lookup(fd
, &ret
);
750 if (mysock
&& mysock
->sk
&& mysock
->sk
->sk_family
== AF_INET6
) { /* ipv6 */
751 ret
= copy_from_user (&r6
.rtmsg_dst
, &(((struct in6_rtmsg32
*)arg
)->rtmsg_dst
),
752 3 * sizeof(struct in6_addr
));
753 ret
|= __get_user (r6
.rtmsg_type
, &(((struct in6_rtmsg32
*)arg
)->rtmsg_type
));
754 ret
|= __get_user (r6
.rtmsg_dst_len
, &(((struct in6_rtmsg32
*)arg
)->rtmsg_dst_len
));
755 ret
|= __get_user (r6
.rtmsg_src_len
, &(((struct in6_rtmsg32
*)arg
)->rtmsg_src_len
));
756 ret
|= __get_user (r6
.rtmsg_metric
, &(((struct in6_rtmsg32
*)arg
)->rtmsg_metric
));
757 ret
|= __get_user (r6
.rtmsg_info
, &(((struct in6_rtmsg32
*)arg
)->rtmsg_info
));
758 ret
|= __get_user (r6
.rtmsg_flags
, &(((struct in6_rtmsg32
*)arg
)->rtmsg_flags
));
759 ret
|= __get_user (r6
.rtmsg_ifindex
, &(((struct in6_rtmsg32
*)arg
)->rtmsg_ifindex
));
763 ret
= copy_from_user (&r4
.rt_dst
, &(((struct rtentry32
*)arg
)->rt_dst
), 3 * sizeof(struct sockaddr
));
764 ret
|= __get_user (r4
.rt_flags
, &(((struct rtentry32
*)arg
)->rt_flags
));
765 ret
|= __get_user (r4
.rt_metric
, &(((struct rtentry32
*)arg
)->rt_metric
));
766 ret
|= __get_user (r4
.rt_mtu
, &(((struct rtentry32
*)arg
)->rt_mtu
));
767 ret
|= __get_user (r4
.rt_window
, &(((struct rtentry32
*)arg
)->rt_window
));
768 ret
|= __get_user (r4
.rt_irtt
, &(((struct rtentry32
*)arg
)->rt_irtt
));
769 ret
|= __get_user (rtdev
, &(((struct rtentry32
*)arg
)->rt_dev
));
771 ret
|= copy_from_user (devname
, compat_ptr(rtdev
), 15);
772 r4
.rt_dev
= devname
; devname
[15] = 0;
783 ret
= sys_ioctl (fd
, cmd
, (long) r
);
792 struct hd_geometry32
{
794 unsigned char sectors
;
795 unsigned short cylinders
;
799 static int hdio_getgeo(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
801 mm_segment_t old_fs
= get_fs();
802 struct hd_geometry geo
;
806 err
= sys_ioctl(fd
, HDIO_GETGEO
, (unsigned long)&geo
);
809 err
= copy_to_user ((struct hd_geometry32
*)arg
, &geo
, 4);
810 err
|= __put_user (geo
.start
, &(((struct hd_geometry32
*)arg
)->start
));
812 return err
? -EFAULT
: 0;
815 struct fb_fix_screeninfo32
{
817 compat_caddr_t smem_start
;
826 compat_caddr_t mmio_start
;
836 compat_caddr_t green
;
838 compat_caddr_t transp
;
841 static int do_cmap_ptr(__u16
**ptr64
, __u32
*ptr32
)
846 if (get_user(data
, ptr32
))
848 datap
= (void *) (unsigned long) data
;
849 if (put_user(datap
, ptr64
))
854 static int fb_getput_cmap(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
856 struct fb_cmap
*cmap
;
857 struct fb_cmap32
*cmap32
;
860 cmap
= compat_alloc_user_space(sizeof(*cmap
));
861 cmap32
= (struct fb_cmap32
*) arg
;
863 if (copy_in_user(&cmap
->start
, &cmap32
->start
, 2 * sizeof(__u32
)))
866 if (do_cmap_ptr(&cmap
->red
, &cmap32
->red
) ||
867 do_cmap_ptr(&cmap
->green
, &cmap32
->green
) ||
868 do_cmap_ptr(&cmap
->blue
, &cmap32
->blue
) ||
869 do_cmap_ptr(&cmap
->transp
, &cmap32
->transp
))
872 err
= sys_ioctl(fd
, cmd
, (unsigned long) cmap
);
875 if (copy_in_user(&cmap32
->start
,
883 static int do_fscreeninfo_to_user(struct fb_fix_screeninfo
*fix
,
884 struct fb_fix_screeninfo32
*fix32
)
889 err
= copy_to_user(&fix32
->id
, &fix
->id
, sizeof(fix32
->id
));
891 data
= (__u32
) (unsigned long) fix
->smem_start
;
892 err
|= put_user(data
, &fix32
->smem_start
);
894 err
|= put_user(fix
->smem_len
, &fix32
->smem_len
);
895 err
|= put_user(fix
->type
, &fix32
->type
);
896 err
|= put_user(fix
->type_aux
, &fix32
->type_aux
);
897 err
|= put_user(fix
->visual
, &fix32
->visual
);
898 err
|= put_user(fix
->xpanstep
, &fix32
->xpanstep
);
899 err
|= put_user(fix
->ypanstep
, &fix32
->ypanstep
);
900 err
|= put_user(fix
->ywrapstep
, &fix32
->ywrapstep
);
901 err
|= put_user(fix
->line_length
, &fix32
->line_length
);
903 data
= (__u32
) (unsigned long) fix
->mmio_start
;
904 err
|= put_user(data
, &fix32
->mmio_start
);
906 err
|= put_user(fix
->mmio_len
, &fix32
->mmio_len
);
907 err
|= put_user(fix
->accel
, &fix32
->accel
);
908 err
|= copy_to_user(fix32
->reserved
, fix
->reserved
,
909 sizeof(fix
->reserved
));
914 static int fb_get_fscreeninfo(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
917 struct fb_fix_screeninfo fix
;
918 struct fb_fix_screeninfo32
*fix32
;
921 fix32
= (struct fb_fix_screeninfo32
*) arg
;
925 err
= sys_ioctl(fd
, cmd
, (unsigned long) &fix
);
929 err
= do_fscreeninfo_to_user(&fix
, fix32
);
934 static int fb_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
939 case FBIOGET_FSCREENINFO
:
940 err
= fb_get_fscreeninfo(fd
,cmd
, arg
);
945 err
= fb_getput_cmap(fd
, cmd
, arg
);
952 printk("%s: Unknown fb ioctl cmd fd(%d) "
953 "cmd(%08x) arg(%08lx)\n",
954 __FUNCTION__
, fd
, cmd
, arg
);
963 static int hdio_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
965 mm_segment_t old_fs
= get_fs();
971 error
= sys_ioctl(fd
, cmd
, (long)&kval
);
975 uvp
= (unsigned int *)arg
;
976 if(put_user(kval
, uvp
))
983 typedef struct sg_io_hdr32
{
984 compat_int_t interface_id
; /* [i] 'S' for SCSI generic (required) */
985 compat_int_t dxfer_direction
; /* [i] data transfer direction */
986 unsigned char cmd_len
; /* [i] SCSI command length ( <= 16 bytes) */
987 unsigned char mx_sb_len
; /* [i] max length to write to sbp */
988 unsigned short iovec_count
; /* [i] 0 implies no scatter gather */
989 compat_uint_t dxfer_len
; /* [i] byte count of data transfer */
990 compat_uint_t dxferp
; /* [i], [*io] points to data transfer memory
991 or scatter gather list */
992 compat_uptr_t cmdp
; /* [i], [*i] points to command to perform */
993 compat_uptr_t sbp
; /* [i], [*o] points to sense_buffer memory */
994 compat_uint_t timeout
; /* [i] MAX_UINT->no timeout (unit: millisec) */
995 compat_uint_t flags
; /* [i] 0 -> default, see SG_FLAG... */
996 compat_int_t pack_id
; /* [i->o] unused internally (normally) */
997 compat_uptr_t usr_ptr
; /* [i->o] unused internally */
998 unsigned char status
; /* [o] scsi status */
999 unsigned char masked_status
; /* [o] shifted, masked scsi status */
1000 unsigned char msg_status
; /* [o] messaging level data (optional) */
1001 unsigned char sb_len_wr
; /* [o] byte count actually written to sbp */
1002 unsigned short host_status
; /* [o] errors from host adapter */
1003 unsigned short driver_status
; /* [o] errors from software driver */
1004 compat_int_t resid
; /* [o] dxfer_len - actual_transferred */
1005 compat_uint_t duration
; /* [o] time taken by cmd (unit: millisec) */
1006 compat_uint_t info
; /* [o] auxiliary information */
1007 } sg_io_hdr32_t
; /* 64 bytes long (on sparc32) */
1009 typedef struct sg_iovec32
{
1010 compat_uint_t iov_base
;
1011 compat_uint_t iov_len
;
1014 static int sg_build_iovec(sg_io_hdr_t
*sgio
, void *dxferp
, u16 iovec_count
)
1016 sg_iovec_t
*iov
= (sg_iovec_t
*) (sgio
+ 1);
1017 sg_iovec32_t
*iov32
= dxferp
;
1020 for (i
= 0; i
< iovec_count
; i
++) {
1023 if (get_user(base
, &iov32
[i
].iov_base
) ||
1024 get_user(len
, &iov32
[i
].iov_len
) ||
1025 put_user((void *)(unsigned long)base
, &iov
[i
].iov_base
) ||
1026 put_user(len
, &iov
[i
].iov_len
))
1034 static int sg_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1037 sg_io_hdr32_t
*sgio32
;
1043 sgio32
= (sg_io_hdr32_t
*) arg
;
1044 if (get_user(iovec_count
, &sgio32
->iovec_count
))
1050 top
= compat_alloc_user_space(0);
1051 new = compat_alloc_user_space(sizeof(sg_io_hdr_t
) +
1053 sizeof(sg_iovec_t
)));
1060 /* Ok, now construct. */
1061 if (copy_in_user(&sgio
->interface_id
, &sgio32
->interface_id
,
1063 (2 * sizeof(unsigned char)) +
1064 (1 * sizeof(unsigned short)) +
1065 (1 * sizeof(unsigned int))))
1068 if (get_user(data
, &sgio32
->dxferp
))
1070 dxferp
= (void *) (unsigned long) data
;
1072 if (sg_build_iovec(sgio
, dxferp
, iovec_count
))
1075 if (put_user(dxferp
, &sgio
->dxferp
))
1080 unsigned char *cmdp
, *sbp
;
1082 if (get_user(data
, &sgio32
->cmdp
))
1084 cmdp
= (unsigned char *) (unsigned long) data
;
1086 if (get_user(data
, &sgio32
->sbp
))
1088 sbp
= (unsigned char *) (unsigned long) data
;
1090 if (put_user(cmdp
, &sgio
->cmdp
) ||
1091 put_user(sbp
, &sgio
->sbp
))
1095 if (copy_in_user(&sgio
->timeout
, &sgio32
->timeout
,
1099 if (get_user(data
, &sgio32
->usr_ptr
))
1101 if (put_user((void *)(unsigned long)data
, &sgio
->usr_ptr
))
1104 if (copy_in_user(&sgio
->status
, &sgio32
->status
,
1105 (4 * sizeof(unsigned char)) +
1106 (2 * sizeof(unsigned (short))) +
1110 err
= sys_ioctl(fd
, cmd
, (unsigned long) sgio
);
1115 if (copy_in_user(&sgio32
->pack_id
, &sgio
->pack_id
,
1117 get_user(datap
, &sgio
->usr_ptr
) ||
1118 put_user((u32
)(unsigned long)datap
,
1119 &sgio32
->usr_ptr
) ||
1120 copy_in_user(&sgio32
->status
, &sgio
->status
,
1121 (4 * sizeof(unsigned char)) +
1122 (2 * sizeof(unsigned short)) +
1130 struct sock_fprog32
{
1132 compat_caddr_t filter
;
1135 #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
1136 #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
1138 static int ppp_sock_fprog_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1140 struct sock_fprog32
*u_fprog32
= (struct sock_fprog32
*) arg
;
1141 struct sock_fprog
*u_fprog64
= compat_alloc_user_space(sizeof(struct sock_fprog
));
1146 if (get_user(flen
, &u_fprog32
->len
) ||
1147 get_user(fptr32
, &u_fprog32
->filter
))
1150 fptr64
= compat_ptr(fptr32
);
1152 if (put_user(flen
, &u_fprog64
->len
) ||
1153 put_user(fptr64
, &u_fprog64
->filter
))
1156 if (cmd
== PPPIOCSPASS32
)
1159 cmd
= PPPIOCSACTIVE
;
1161 return sys_ioctl(fd
, cmd
, (unsigned long) u_fprog64
);
1164 struct ppp_option_data32
{
1167 compat_int_t transmit
;
1169 #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
1172 compat_time_t xmit_idle
;
1173 compat_time_t recv_idle
;
1175 #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
1177 static int ppp_gidle(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1179 struct ppp_idle
*idle
;
1180 struct ppp_idle32
*idle32
;
1181 __kernel_time_t xmit
, recv
;
1184 idle
= compat_alloc_user_space(sizeof(*idle
));
1185 idle32
= (struct ppp_idle32
*) arg
;
1187 err
= sys_ioctl(fd
, PPPIOCGIDLE
, (unsigned long) idle
);
1190 if (get_user(xmit
, &idle
->xmit_idle
) ||
1191 get_user(recv
, &idle
->recv_idle
) ||
1192 put_user(xmit
, &idle32
->xmit_idle
) ||
1193 put_user(recv
, &idle32
->recv_idle
))
1199 static int ppp_scompress(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1201 struct ppp_option_data
*odata
;
1202 struct ppp_option_data32
*odata32
;
1206 odata
= compat_alloc_user_space(sizeof(*odata
));
1207 odata32
= (struct ppp_option_data32
*) arg
;
1209 if (get_user(data
, &odata32
->ptr
))
1212 datap
= (void *) (unsigned long) data
;
1213 if (put_user(datap
, &odata
->ptr
))
1216 if (copy_in_user(&odata
->length
, &odata32
->length
,
1217 sizeof(__u32
) + sizeof(int)))
1220 return sys_ioctl(fd
, PPPIOCSCOMPRESS
, (unsigned long) odata
);
1223 static int ppp_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1229 err
= ppp_gidle(fd
, cmd
, arg
);
1232 case PPPIOCSCOMPRESS32
:
1233 err
= ppp_scompress(fd
, cmd
, arg
);
1240 printk("ppp_ioctl: Unknown cmd fd(%d) "
1241 "cmd(%08x) arg(%08x)\n",
1242 (int)fd
, (unsigned int)cmd
, (unsigned int)arg
);
1253 compat_long_t mt_type
;
1254 compat_long_t mt_resid
;
1255 compat_long_t mt_dsreg
;
1256 compat_long_t mt_gstat
;
1257 compat_long_t mt_erreg
;
1258 compat_daddr_t mt_fileno
;
1259 compat_daddr_t mt_blkno
;
1261 #define MTIOCGET32 _IOR('m', 2, struct mtget32)
1264 compat_long_t mt_blkno
;
1266 #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
1268 struct mtconfiginfo32
{
1269 compat_long_t mt_type
;
1270 compat_long_t ifc_type
;
1271 unsigned short irqnr
;
1272 unsigned short dmanr
;
1273 unsigned short port
;
1274 compat_ulong_t debug
;
1275 compat_uint_t have_dens
:1;
1276 compat_uint_t have_bsf
:1;
1277 compat_uint_t have_fsr
:1;
1278 compat_uint_t have_bsr
:1;
1279 compat_uint_t have_eod
:1;
1280 compat_uint_t have_seek
:1;
1281 compat_uint_t have_tell
:1;
1282 compat_uint_t have_ras1
:1;
1283 compat_uint_t have_ras2
:1;
1284 compat_uint_t have_ras3
:1;
1285 compat_uint_t have_qfa
:1;
1286 compat_uint_t pad1
:5;
1289 #define MTIOCGETCONFIG32 _IOR('m', 4, struct mtconfiginfo32)
1290 #define MTIOCSETCONFIG32 _IOW('m', 5, struct mtconfiginfo32)
1292 static int mt_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1294 mm_segment_t old_fs
= get_fs();
1295 struct mtconfiginfo info
;
1311 case MTIOCGETCONFIG32
:
1312 kcmd
= MTIOCGETCONFIG
;
1315 case MTIOCSETCONFIG32
:
1316 kcmd
= MTIOCSETCONFIG
;
1318 err
= __get_user(info
.mt_type
, &((struct mtconfiginfo32
*)arg
)->mt_type
);
1319 err
|= __get_user(info
.ifc_type
, &((struct mtconfiginfo32
*)arg
)->ifc_type
);
1320 err
|= __get_user(info
.irqnr
, &((struct mtconfiginfo32
*)arg
)->irqnr
);
1321 err
|= __get_user(info
.dmanr
, &((struct mtconfiginfo32
*)arg
)->dmanr
);
1322 err
|= __get_user(info
.port
, &((struct mtconfiginfo32
*)arg
)->port
);
1323 err
|= __get_user(info
.debug
, &((struct mtconfiginfo32
*)arg
)->debug
);
1324 err
|= __copy_from_user((char *)&info
.debug
+ sizeof(info
.debug
),
1325 (char *)&((struct mtconfiginfo32
*)arg
)->debug
1326 + sizeof(((struct mtconfiginfo32
*)arg
)->debug
), sizeof(__u32
));
1334 printk("mt_ioctl: Unknown cmd fd(%d) "
1335 "cmd(%08x) arg(%08x)\n",
1336 (int)fd
, (unsigned int)cmd
, (unsigned int)arg
);
1341 err
= sys_ioctl (fd
, kcmd
, (unsigned long)karg
);
1347 err
= __put_user(pos
.mt_blkno
, &((struct mtpos32
*)arg
)->mt_blkno
);
1350 err
= __put_user(get
.mt_type
, &((struct mtget32
*)arg
)->mt_type
);
1351 err
|= __put_user(get
.mt_resid
, &((struct mtget32
*)arg
)->mt_resid
);
1352 err
|= __put_user(get
.mt_dsreg
, &((struct mtget32
*)arg
)->mt_dsreg
);
1353 err
|= __put_user(get
.mt_gstat
, &((struct mtget32
*)arg
)->mt_gstat
);
1354 err
|= __put_user(get
.mt_erreg
, &((struct mtget32
*)arg
)->mt_erreg
);
1355 err
|= __put_user(get
.mt_fileno
, &((struct mtget32
*)arg
)->mt_fileno
);
1356 err
|= __put_user(get
.mt_blkno
, &((struct mtget32
*)arg
)->mt_blkno
);
1358 case MTIOCGETCONFIG32
:
1359 err
= __put_user(info
.mt_type
, &((struct mtconfiginfo32
*)arg
)->mt_type
);
1360 err
|= __put_user(info
.ifc_type
, &((struct mtconfiginfo32
*)arg
)->ifc_type
);
1361 err
|= __put_user(info
.irqnr
, &((struct mtconfiginfo32
*)arg
)->irqnr
);
1362 err
|= __put_user(info
.dmanr
, &((struct mtconfiginfo32
*)arg
)->dmanr
);
1363 err
|= __put_user(info
.port
, &((struct mtconfiginfo32
*)arg
)->port
);
1364 err
|= __put_user(info
.debug
, &((struct mtconfiginfo32
*)arg
)->debug
);
1365 err
|= __copy_to_user((char *)&((struct mtconfiginfo32
*)arg
)->debug
1366 + sizeof(((struct mtconfiginfo32
*)arg
)->debug
),
1367 (char *)&info
.debug
+ sizeof(info
.debug
), sizeof(__u32
));
1369 case MTIOCSETCONFIG32
:
1372 return err
? -EFAULT
: 0;
1375 struct cdrom_read_audio32
{
1376 union cdrom_addr addr
;
1378 compat_int_t nframes
;
1382 struct cdrom_generic_command32
{
1383 unsigned char cmd
[CDROM_PACKET_SIZE
];
1384 compat_caddr_t buffer
;
1385 compat_uint_t buflen
;
1387 compat_caddr_t sense
;
1388 unsigned char data_direction
;
1390 compat_int_t timeout
;
1391 compat_caddr_t reserved
[1];
1394 static int cdrom_do_read_audio(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1396 struct cdrom_read_audio
*cdread_audio
;
1397 struct cdrom_read_audio32
*cdread_audio32
;
1401 cdread_audio
= compat_alloc_user_space(sizeof(*cdread_audio
));
1402 cdread_audio32
= (struct cdrom_read_audio32
*) arg
;
1404 if (copy_in_user(&cdread_audio
->addr
,
1405 &cdread_audio32
->addr
,
1406 (sizeof(*cdread_audio32
) -
1407 sizeof(compat_caddr_t
))))
1410 if (get_user(data
, &cdread_audio32
->buf
))
1412 datap
= (void *) (unsigned long) data
;
1413 if (put_user(datap
, &cdread_audio
->buf
))
1416 return sys_ioctl(fd
, cmd
, (unsigned long) cdread_audio
);
1419 static int __cgc_do_ptr(void **ptr64
, __u32
*ptr32
)
1424 if (get_user(data
, ptr32
))
1426 datap
= (void *) (unsigned long) data
;
1427 if (put_user(datap
, ptr64
))
1433 static int cdrom_do_generic_command(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1435 struct cdrom_generic_command
*cgc
;
1436 struct cdrom_generic_command32
*cgc32
;
1439 cgc
= compat_alloc_user_space(sizeof(*cgc
));
1440 cgc32
= (struct cdrom_generic_command32
*) arg
;
1442 if (copy_in_user(&cgc
->cmd
, &cgc32
->cmd
, sizeof(cgc
->cmd
)) ||
1443 __cgc_do_ptr((void **) &cgc
->buffer
, &cgc32
->buffer
) ||
1444 copy_in_user(&cgc
->buflen
, &cgc32
->buflen
,
1445 (sizeof(unsigned int) + sizeof(int))) ||
1446 __cgc_do_ptr((void **) &cgc
->sense
, &cgc32
->sense
))
1449 if (get_user(dir
, &cgc
->data_direction
) ||
1450 put_user(dir
, &cgc32
->data_direction
))
1453 if (copy_in_user(&cgc
->quiet
, &cgc32
->quiet
,
1457 if (__cgc_do_ptr(&cgc
->reserved
[0], &cgc32
->reserved
[0]))
1460 return sys_ioctl(fd
, cmd
, (unsigned long) cgc
);
1463 static int cdrom_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1468 case CDROMREADAUDIO
:
1469 err
= cdrom_do_read_audio(fd
, cmd
, arg
);
1472 case CDROM_SEND_PACKET
:
1473 err
= cdrom_do_generic_command(fd
, cmd
, arg
);
1480 printk("cdrom_ioctl: Unknown cmd fd(%d) "
1481 "cmd(%08x) arg(%08x)\n",
1482 (int)fd
, (unsigned int)cmd
, (unsigned int)arg
);
1491 struct loop_info32
{
1492 compat_int_t lo_number
; /* ioctl r/o */
1493 compat_dev_t lo_device
; /* ioctl r/o */
1494 compat_ulong_t lo_inode
; /* ioctl r/o */
1495 compat_dev_t lo_rdevice
; /* ioctl r/o */
1496 compat_int_t lo_offset
;
1497 compat_int_t lo_encrypt_type
;
1498 compat_int_t lo_encrypt_key_size
; /* ioctl w/o */
1499 compat_int_t lo_flags
; /* ioctl r/o */
1500 char lo_name
[LO_NAME_SIZE
];
1501 unsigned char lo_encrypt_key
[LO_KEY_SIZE
]; /* ioctl w/o */
1502 compat_ulong_t lo_init
[2];
1506 static int loop_status(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1508 mm_segment_t old_fs
= get_fs();
1513 case LOOP_SET_STATUS
:
1514 err
= get_user(l
.lo_number
, &((struct loop_info32
*)arg
)->lo_number
);
1515 err
|= __get_user(l
.lo_device
, &((struct loop_info32
*)arg
)->lo_device
);
1516 err
|= __get_user(l
.lo_inode
, &((struct loop_info32
*)arg
)->lo_inode
);
1517 err
|= __get_user(l
.lo_rdevice
, &((struct loop_info32
*)arg
)->lo_rdevice
);
1518 err
|= __copy_from_user((char *)&l
.lo_offset
, (char *)&((struct loop_info32
*)arg
)->lo_offset
,
1519 8 + (unsigned long)l
.lo_init
- (unsigned long)&l
.lo_offset
);
1524 err
= sys_ioctl (fd
, cmd
, (unsigned long)&l
);
1528 case LOOP_GET_STATUS
:
1530 err
= sys_ioctl (fd
, cmd
, (unsigned long)&l
);
1533 err
= put_user(l
.lo_number
, &((struct loop_info32
*)arg
)->lo_number
);
1534 err
|= __put_user(l
.lo_device
, &((struct loop_info32
*)arg
)->lo_device
);
1535 err
|= __put_user(l
.lo_inode
, &((struct loop_info32
*)arg
)->lo_inode
);
1536 err
|= __put_user(l
.lo_rdevice
, &((struct loop_info32
*)arg
)->lo_rdevice
);
1537 err
|= __copy_to_user((char *)&((struct loop_info32
*)arg
)->lo_offset
,
1538 (char *)&l
.lo_offset
, (unsigned long)l
.lo_init
- (unsigned long)&l
.lo_offset
);
1546 printk("%s: Unknown loop ioctl cmd, fd(%d) "
1547 "cmd(%08x) arg(%08lx)\n",
1548 __FUNCTION__
, fd
, cmd
, arg
);
1554 extern int tty_ioctl(struct inode
* inode
, struct file
* file
, unsigned int cmd
, unsigned long arg
);
1558 static int vt_check(struct file
*file
)
1560 struct tty_struct
*tty
;
1561 struct inode
*inode
= file
->f_dentry
->d_inode
;
1563 if (file
->f_op
->ioctl
!= tty_ioctl
)
1566 tty
= (struct tty_struct
*)file
->private_data
;
1567 if (tty_paranoia_check(tty
, inode
, "tty_ioctl"))
1570 if (tty
->driver
->ioctl
!= vt_ioctl
)
1574 * To have permissions to do most of the vt ioctls, we either have
1575 * to be the owner of the tty, or super-user.
1577 if (process_tty(current
) == tty
|| capable(CAP_SYS_ADMIN
))
1582 struct consolefontdesc32
{
1583 unsigned short charcount
; /* characters in font (256 or 512) */
1584 unsigned short charheight
; /* scan lines per character (1-32) */
1585 compat_caddr_t chardata
; /* font data in expanded form */
1588 static int do_fontx_ioctl(unsigned int fd
, int cmd
, struct consolefontdesc32
*user_cfd
, struct file
*file
)
1590 struct consolefontdesc cfdarg
;
1591 struct console_font_op op
;
1594 perm
= vt_check(file
);
1595 if (perm
< 0) return perm
;
1597 if (copy_from_user(&cfdarg
, user_cfd
, sizeof(struct consolefontdesc32
)))
1600 cfdarg
.chardata
= compat_ptr(((struct consolefontdesc32
*)&cfdarg
)->chardata
);
1606 op
.op
= KD_FONT_OP_SET
;
1609 op
.height
= cfdarg
.charheight
;
1610 op
.charcount
= cfdarg
.charcount
;
1611 op
.data
= cfdarg
.chardata
;
1612 return con_font_op(fg_console
, &op
);
1614 if (!cfdarg
.chardata
)
1616 op
.op
= KD_FONT_OP_GET
;
1619 op
.height
= cfdarg
.charheight
;
1620 op
.charcount
= cfdarg
.charcount
;
1621 op
.data
= cfdarg
.chardata
;
1622 i
= con_font_op(fg_console
, &op
);
1625 cfdarg
.charheight
= op
.height
;
1626 cfdarg
.charcount
= op
.charcount
;
1627 ((struct consolefontdesc32
*)&cfdarg
)->chardata
= (unsigned long)cfdarg
.chardata
;
1628 if (copy_to_user(user_cfd
, &cfdarg
, sizeof(struct consolefontdesc32
)))
1635 struct console_font_op32
{
1636 compat_uint_t op
; /* operation code KD_FONT_OP_* */
1637 compat_uint_t flags
; /* KD_FONT_FLAG_* */
1638 compat_uint_t width
, height
; /* font size */
1639 compat_uint_t charcount
;
1640 compat_caddr_t data
; /* font data with height fixed to 32 */
1643 static int do_kdfontop_ioctl(unsigned int fd
, unsigned int cmd
, struct console_font_op32
*fontop
, struct file
*file
)
1645 struct console_font_op op
;
1646 int perm
= vt_check(file
), i
;
1647 struct vt_struct
*vt
;
1649 if (perm
< 0) return perm
;
1651 if (copy_from_user(&op
, (void *) fontop
, sizeof(struct console_font_op32
)))
1653 if (!perm
&& op
.op
!= KD_FONT_OP_GET
)
1655 op
.data
= compat_ptr(((struct console_font_op32
*)&op
)->data
);
1656 op
.flags
|= KD_FONT_FLAG_OLD
;
1657 vt
= (struct vt_struct
*)((struct tty_struct
*)file
->private_data
)->driver_data
;
1658 i
= con_font_op(vt
->vc_num
, &op
);
1660 ((struct console_font_op32
*)&op
)->data
= (unsigned long)op
.data
;
1661 if (copy_to_user((void *) fontop
, &op
, sizeof(struct console_font_op32
)))
1666 struct unimapdesc32
{
1667 unsigned short entry_ct
;
1668 compat_caddr_t entries
;
1671 static int do_unimap_ioctl(unsigned int fd
, unsigned int cmd
, struct unimapdesc32
*user_ud
, struct file
*file
)
1673 struct unimapdesc32 tmp
;
1674 int perm
= vt_check(file
);
1676 if (perm
< 0) return perm
;
1677 if (copy_from_user(&tmp
, user_ud
, sizeof tmp
))
1681 if (!perm
) return -EPERM
;
1682 return con_set_unimap(fg_console
, tmp
.entry_ct
, compat_ptr(tmp
.entries
));
1684 return con_get_unimap(fg_console
, tmp
.entry_ct
, &(user_ud
->entry_ct
), compat_ptr(tmp
.entries
));
1689 #endif /* CONFIG_VT */
1691 static int do_smb_getmountuid(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1693 mm_segment_t old_fs
= get_fs();
1694 __kernel_uid_t kuid
;
1697 cmd
= SMB_IOC_GETMOUNTUID
;
1700 err
= sys_ioctl(fd
, cmd
, (unsigned long)&kuid
);
1704 err
= put_user(kuid
, (compat_pid_t
*)arg
);
1709 struct atmif_sioc32
{
1710 compat_int_t number
;
1711 compat_int_t length
;
1715 struct atm_iobuf32
{
1716 compat_int_t length
;
1717 compat_caddr_t buffer
;
1720 #define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32)
1721 #define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32)
1722 #define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32)
1723 #define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32)
1724 #define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32)
1725 #define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32)
1726 #define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32)
1727 #define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32)
1728 #define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32)
1729 #define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32)
1730 #define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32)
1731 #define ATM_SETESIF32 _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32)
1732 #define ATM_GETSTAT32 _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32)
1733 #define ATM_GETSTATZ32 _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32)
1734 #define ATM_GETLOOP32 _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32)
1735 #define ATM_SETLOOP32 _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32)
1736 #define ATM_QUERYLOOP32 _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32)
1741 } atm_ioctl_map
[] = {
1742 { ATM_GETLINKRATE32
, ATM_GETLINKRATE
},
1743 { ATM_GETNAMES32
, ATM_GETNAMES
},
1744 { ATM_GETTYPE32
, ATM_GETTYPE
},
1745 { ATM_GETESI32
, ATM_GETESI
},
1746 { ATM_GETADDR32
, ATM_GETADDR
},
1747 { ATM_RSTADDR32
, ATM_RSTADDR
},
1748 { ATM_ADDADDR32
, ATM_ADDADDR
},
1749 { ATM_DELADDR32
, ATM_DELADDR
},
1750 { ATM_GETCIRANGE32
, ATM_GETCIRANGE
},
1751 { ATM_SETCIRANGE32
, ATM_SETCIRANGE
},
1752 { ATM_SETESI32
, ATM_SETESI
},
1753 { ATM_SETESIF32
, ATM_SETESIF
},
1754 { ATM_GETSTAT32
, ATM_GETSTAT
},
1755 { ATM_GETSTATZ32
, ATM_GETSTATZ
},
1756 { ATM_GETLOOP32
, ATM_GETLOOP
},
1757 { ATM_SETLOOP32
, ATM_SETLOOP
},
1758 { ATM_QUERYLOOP32
, ATM_QUERYLOOP
}
1761 #define NR_ATM_IOCTL (sizeof(atm_ioctl_map)/sizeof(atm_ioctl_map[0]))
1764 static int do_atm_iobuf(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1766 struct atm_iobuf
*iobuf
;
1767 struct atm_iobuf32
*iobuf32
;
1772 iobuf
= compat_alloc_user_space(sizeof(*iobuf
));
1773 iobuf32
= (struct atm_iobuf32
*) arg
;
1775 if (get_user(len
, &iobuf32
->length
) ||
1776 get_user(data
, &iobuf32
->buffer
))
1778 datap
= (void *) (unsigned long) data
;
1779 if (put_user(len
, &iobuf
->length
) ||
1780 put_user(datap
, &iobuf
->buffer
))
1783 err
= sys_ioctl(fd
, cmd
, (unsigned long)iobuf
);
1786 if (copy_in_user(&iobuf32
->length
, &iobuf
->length
,
1794 static int do_atmif_sioc(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1796 struct atmif_sioc
*sioc
;
1797 struct atmif_sioc32
*sioc32
;
1802 sioc
= compat_alloc_user_space(sizeof(*sioc
));
1803 sioc32
= (struct atmif_sioc32
*) arg
;
1805 if (copy_in_user(&sioc
->number
, &sioc32
->number
, 2 * sizeof(int)) ||
1806 get_user(data
, &sioc32
->arg
))
1808 datap
= (void *) (unsigned long) data
;
1809 if (put_user(datap
, &sioc
->arg
))
1812 err
= sys_ioctl(fd
, cmd
, (unsigned long) sioc
);
1815 if (copy_in_user(&sioc32
->length
, &sioc
->length
,
1822 static int do_atm_ioctl(unsigned int fd
, unsigned int cmd32
, unsigned long arg
)
1825 unsigned int cmd
= 0;
1829 case SONET_GETSTATZ
:
1833 case SONET_SETFRAMING
:
1834 case SONET_GETFRAMING
:
1835 case SONET_GETFRSENSE
:
1836 return do_atmif_sioc(fd
, cmd32
, arg
);
1839 for (i
= 0; i
< NR_ATM_IOCTL
; i
++) {
1840 if (cmd32
== atm_ioctl_map
[i
].cmd32
) {
1841 cmd
= atm_ioctl_map
[i
].cmd
;
1845 if (i
== NR_ATM_IOCTL
)
1850 return do_atm_iobuf(fd
, cmd
, arg
);
1852 case ATM_GETLINKRATE
:
1859 case ATM_GETCIRANGE
:
1860 case ATM_SETCIRANGE
:
1868 return do_atmif_sioc(fd
, cmd
, arg
);
1874 static int ret_einval(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1879 static int broken_blkgetsize(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1881 /* The mkswap binary hard codes it to Intel value :-((( */
1882 return w_long(fd
, BLKGETSIZE
, arg
);
1885 struct blkpg_ioctl_arg32
{
1888 compat_int_t datalen
;
1889 compat_caddr_t data
;
1892 static int blkpg_ioctl_trans(unsigned int fd
, unsigned int cmd
, struct blkpg_ioctl_arg32
*arg
)
1894 struct blkpg_ioctl_arg a
;
1895 struct blkpg_partition p
;
1897 mm_segment_t old_fs
= get_fs();
1899 err
= get_user(a
.op
, &arg
->op
);
1900 err
|= __get_user(a
.flags
, &arg
->flags
);
1901 err
|= __get_user(a
.datalen
, &arg
->datalen
);
1902 err
|= __get_user((long)a
.data
, &arg
->data
);
1903 if (err
) return err
;
1905 case BLKPG_ADD_PARTITION
:
1906 case BLKPG_DEL_PARTITION
:
1907 if (a
.datalen
< sizeof(struct blkpg_partition
))
1909 if (copy_from_user(&p
, a
.data
, sizeof(struct blkpg_partition
)))
1913 err
= sys_ioctl(fd
, cmd
, (unsigned long)&a
);
1921 static int ioc_settimeout(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1923 return rw_long(fd
, AUTOFS_IOC_SETTIMEOUT
, arg
);
1926 /* Fix sizeof(sizeof()) breakage */
1927 #define BLKBSZGET_32 _IOR(0x12,112,int)
1928 #define BLKBSZSET_32 _IOW(0x12,113,int)
1929 #define BLKGETSIZE64_32 _IOR(0x12,114,int)
1931 static int do_blkbszget(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1933 return sys_ioctl(fd
, BLKBSZGET
, arg
);
1936 static int do_blkbszset(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
1938 return sys_ioctl(fd
, BLKBSZSET
, arg
);
1941 static int do_blkgetsize64(unsigned int fd
, unsigned int cmd
,
1944 return sys_ioctl(fd
, BLKGETSIZE64
, arg
);
1947 /* Bluetooth ioctls */
1948 #define HCIUARTSETPROTO _IOW('U', 200, int)
1949 #define HCIUARTGETPROTO _IOR('U', 201, int)
1951 #define BNEPCONNADD _IOW('B', 200, int)
1952 #define BNEPCONNDEL _IOW('B', 201, int)
1953 #define BNEPGETCONNLIST _IOR('B', 210, int)
1954 #define BNEPGETCONNINFO _IOR('B', 211, int)
1956 struct floppy_struct32
{
1960 compat_uint_t track
;
1961 compat_uint_t stretch
;
1964 unsigned char spec1
;
1965 unsigned char fmt_gap
;
1966 const compat_caddr_t name
;
1969 struct floppy_drive_params32
{
1971 compat_ulong_t max_dtr
;
1975 compat_ulong_t spinup
;
1976 compat_ulong_t spindown
;
1977 unsigned char spindown_offset
;
1978 unsigned char select_delay
;
1980 unsigned char tracks
;
1981 compat_ulong_t timeout
;
1982 unsigned char interleave_sect
;
1983 struct floppy_max_errors max_errors
;
1986 short autodetect
[8];
1987 compat_int_t checkfreq
;
1988 compat_int_t native_format
;
1991 struct floppy_drive_struct32
{
1993 compat_ulong_t spinup_date
;
1994 compat_ulong_t select_date
;
1995 compat_ulong_t first_read_date
;
1996 short probed_format
;
2000 compat_int_t generation
;
2001 compat_int_t keep_data
;
2002 compat_int_t fd_ref
;
2003 compat_int_t fd_device
;
2004 compat_int_t last_checked
;
2005 compat_caddr_t dmabuf
;
2006 compat_int_t bufblocks
;
2009 struct floppy_fdc_state32
{
2013 unsigned char version
;
2015 compat_ulong_t address
;
2016 unsigned int rawcmd
:2;
2017 unsigned int reset
:1;
2018 unsigned int need_configure
:1;
2019 unsigned int perp_mode
:2;
2020 unsigned int has_fifo
:1;
2021 unsigned int driver_version
;
2022 unsigned char track
[4];
2025 struct floppy_write_errors32
{
2026 unsigned int write_errors
;
2027 compat_ulong_t first_error_sector
;
2028 compat_int_t first_error_generation
;
2029 compat_ulong_t last_error_sector
;
2030 compat_int_t last_error_generation
;
2031 compat_uint_t badness
;
2034 #define FDSETPRM32 _IOW(2, 0x42, struct floppy_struct32)
2035 #define FDDEFPRM32 _IOW(2, 0x43, struct floppy_struct32)
2036 #define FDGETPRM32 _IOR(2, 0x04, struct floppy_struct32)
2037 #define FDSETDRVPRM32 _IOW(2, 0x90, struct floppy_drive_params32)
2038 #define FDGETDRVPRM32 _IOR(2, 0x11, struct floppy_drive_params32)
2039 #define FDGETDRVSTAT32 _IOR(2, 0x12, struct floppy_drive_struct32)
2040 #define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct floppy_drive_struct32)
2041 #define FDGETFDCSTAT32 _IOR(2, 0x15, struct floppy_fdc_state32)
2042 #define FDWERRORGET32 _IOR(2, 0x17, struct floppy_write_errors32)
2047 } fd_ioctl_trans_table
[] = {
2048 { FDSETPRM32
, FDSETPRM
},
2049 { FDDEFPRM32
, FDDEFPRM
},
2050 { FDGETPRM32
, FDGETPRM
},
2051 { FDSETDRVPRM32
, FDSETDRVPRM
},
2052 { FDGETDRVPRM32
, FDGETDRVPRM
},
2053 { FDGETDRVSTAT32
, FDGETDRVSTAT
},
2054 { FDPOLLDRVSTAT32
, FDPOLLDRVSTAT
},
2055 { FDGETFDCSTAT32
, FDGETFDCSTAT
},
2056 { FDWERRORGET32
, FDWERRORGET
}
2059 #define NR_FD_IOCTL_TRANS (sizeof(fd_ioctl_trans_table)/sizeof(fd_ioctl_trans_table[0]))
2061 static int fd_ioctl_trans(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2063 mm_segment_t old_fs
= get_fs();
2065 unsigned int kcmd
= 0;
2068 for (i
= 0; i
< NR_FD_IOCTL_TRANS
; i
++)
2069 if (cmd
== fd_ioctl_trans_table
[i
].cmd32
) {
2070 kcmd
= fd_ioctl_trans_table
[i
].cmd
;
2081 struct floppy_struct
*f
;
2083 f
= karg
= kmalloc(sizeof(struct floppy_struct
), GFP_KERNEL
);
2086 if (cmd
== FDGETPRM32
)
2088 err
= __get_user(f
->size
, &((struct floppy_struct32
*)arg
)->size
);
2089 err
|= __get_user(f
->sect
, &((struct floppy_struct32
*)arg
)->sect
);
2090 err
|= __get_user(f
->head
, &((struct floppy_struct32
*)arg
)->head
);
2091 err
|= __get_user(f
->track
, &((struct floppy_struct32
*)arg
)->track
);
2092 err
|= __get_user(f
->stretch
, &((struct floppy_struct32
*)arg
)->stretch
);
2093 err
|= __get_user(f
->gap
, &((struct floppy_struct32
*)arg
)->gap
);
2094 err
|= __get_user(f
->rate
, &((struct floppy_struct32
*)arg
)->rate
);
2095 err
|= __get_user(f
->spec1
, &((struct floppy_struct32
*)arg
)->spec1
);
2096 err
|= __get_user(f
->fmt_gap
, &((struct floppy_struct32
*)arg
)->fmt_gap
);
2097 err
|= __get_user((u64
)f
->name
, &((struct floppy_struct32
*)arg
)->name
);
2107 struct floppy_drive_params
*f
;
2109 f
= karg
= kmalloc(sizeof(struct floppy_drive_params
), GFP_KERNEL
);
2112 if (cmd
== FDGETDRVPRM32
)
2114 err
= __get_user(f
->cmos
, &((struct floppy_drive_params32
*)arg
)->cmos
);
2115 err
|= __get_user(f
->max_dtr
, &((struct floppy_drive_params32
*)arg
)->max_dtr
);
2116 err
|= __get_user(f
->hlt
, &((struct floppy_drive_params32
*)arg
)->hlt
);
2117 err
|= __get_user(f
->hut
, &((struct floppy_drive_params32
*)arg
)->hut
);
2118 err
|= __get_user(f
->srt
, &((struct floppy_drive_params32
*)arg
)->srt
);
2119 err
|= __get_user(f
->spinup
, &((struct floppy_drive_params32
*)arg
)->spinup
);
2120 err
|= __get_user(f
->spindown
, &((struct floppy_drive_params32
*)arg
)->spindown
);
2121 err
|= __get_user(f
->spindown_offset
, &((struct floppy_drive_params32
*)arg
)->spindown_offset
);
2122 err
|= __get_user(f
->select_delay
, &((struct floppy_drive_params32
*)arg
)->select_delay
);
2123 err
|= __get_user(f
->rps
, &((struct floppy_drive_params32
*)arg
)->rps
);
2124 err
|= __get_user(f
->tracks
, &((struct floppy_drive_params32
*)arg
)->tracks
);
2125 err
|= __get_user(f
->timeout
, &((struct floppy_drive_params32
*)arg
)->timeout
);
2126 err
|= __get_user(f
->interleave_sect
, &((struct floppy_drive_params32
*)arg
)->interleave_sect
);
2127 err
|= __copy_from_user(&f
->max_errors
, &((struct floppy_drive_params32
*)arg
)->max_errors
, sizeof(f
->max_errors
));
2128 err
|= __get_user(f
->flags
, &((struct floppy_drive_params32
*)arg
)->flags
);
2129 err
|= __get_user(f
->read_track
, &((struct floppy_drive_params32
*)arg
)->read_track
);
2130 err
|= __copy_from_user(f
->autodetect
, ((struct floppy_drive_params32
*)arg
)->autodetect
, sizeof(f
->autodetect
));
2131 err
|= __get_user(f
->checkfreq
, &((struct floppy_drive_params32
*)arg
)->checkfreq
);
2132 err
|= __get_user(f
->native_format
, &((struct floppy_drive_params32
*)arg
)->native_format
);
2139 case FDGETDRVSTAT32
:
2140 case FDPOLLDRVSTAT32
:
2141 karg
= kmalloc(sizeof(struct floppy_drive_struct
), GFP_KERNEL
);
2145 case FDGETFDCSTAT32
:
2146 karg
= kmalloc(sizeof(struct floppy_fdc_state
), GFP_KERNEL
);
2151 karg
= kmalloc(sizeof(struct floppy_write_errors
), GFP_KERNEL
);
2159 err
= sys_ioctl (fd
, kcmd
, (unsigned long)karg
);
2166 struct floppy_struct
*f
= karg
;
2168 err
= __put_user(f
->size
, &((struct floppy_struct32
*)arg
)->size
);
2169 err
|= __put_user(f
->sect
, &((struct floppy_struct32
*)arg
)->sect
);
2170 err
|= __put_user(f
->head
, &((struct floppy_struct32
*)arg
)->head
);
2171 err
|= __put_user(f
->track
, &((struct floppy_struct32
*)arg
)->track
);
2172 err
|= __put_user(f
->stretch
, &((struct floppy_struct32
*)arg
)->stretch
);
2173 err
|= __put_user(f
->gap
, &((struct floppy_struct32
*)arg
)->gap
);
2174 err
|= __put_user(f
->rate
, &((struct floppy_struct32
*)arg
)->rate
);
2175 err
|= __put_user(f
->spec1
, &((struct floppy_struct32
*)arg
)->spec1
);
2176 err
|= __put_user(f
->fmt_gap
, &((struct floppy_struct32
*)arg
)->fmt_gap
);
2177 err
|= __put_user((u64
)f
->name
, &((struct floppy_struct32
*)arg
)->name
);
2182 struct floppy_drive_params
*f
= karg
;
2184 err
= __put_user(f
->cmos
, &((struct floppy_drive_params32
*)arg
)->cmos
);
2185 err
|= __put_user(f
->max_dtr
, &((struct floppy_drive_params32
*)arg
)->max_dtr
);
2186 err
|= __put_user(f
->hlt
, &((struct floppy_drive_params32
*)arg
)->hlt
);
2187 err
|= __put_user(f
->hut
, &((struct floppy_drive_params32
*)arg
)->hut
);
2188 err
|= __put_user(f
->srt
, &((struct floppy_drive_params32
*)arg
)->srt
);
2189 err
|= __put_user(f
->spinup
, &((struct floppy_drive_params32
*)arg
)->spinup
);
2190 err
|= __put_user(f
->spindown
, &((struct floppy_drive_params32
*)arg
)->spindown
);
2191 err
|= __put_user(f
->spindown_offset
, &((struct floppy_drive_params32
*)arg
)->spindown_offset
);
2192 err
|= __put_user(f
->select_delay
, &((struct floppy_drive_params32
*)arg
)->select_delay
);
2193 err
|= __put_user(f
->rps
, &((struct floppy_drive_params32
*)arg
)->rps
);
2194 err
|= __put_user(f
->tracks
, &((struct floppy_drive_params32
*)arg
)->tracks
);
2195 err
|= __put_user(f
->timeout
, &((struct floppy_drive_params32
*)arg
)->timeout
);
2196 err
|= __put_user(f
->interleave_sect
, &((struct floppy_drive_params32
*)arg
)->interleave_sect
);
2197 err
|= __copy_to_user(&((struct floppy_drive_params32
*)arg
)->max_errors
, &f
->max_errors
, sizeof(f
->max_errors
));
2198 err
|= __put_user(f
->flags
, &((struct floppy_drive_params32
*)arg
)->flags
);
2199 err
|= __put_user(f
->read_track
, &((struct floppy_drive_params32
*)arg
)->read_track
);
2200 err
|= __copy_to_user(((struct floppy_drive_params32
*)arg
)->autodetect
, f
->autodetect
, sizeof(f
->autodetect
));
2201 err
|= __put_user(f
->checkfreq
, &((struct floppy_drive_params32
*)arg
)->checkfreq
);
2202 err
|= __put_user(f
->native_format
, &((struct floppy_drive_params32
*)arg
)->native_format
);
2205 case FDGETDRVSTAT32
:
2206 case FDPOLLDRVSTAT32
:
2208 struct floppy_drive_struct
*f
= karg
;
2210 err
= __put_user(f
->flags
, &((struct floppy_drive_struct32
*)arg
)->flags
);
2211 err
|= __put_user(f
->spinup_date
, &((struct floppy_drive_struct32
*)arg
)->spinup_date
);
2212 err
|= __put_user(f
->select_date
, &((struct floppy_drive_struct32
*)arg
)->select_date
);
2213 err
|= __put_user(f
->first_read_date
, &((struct floppy_drive_struct32
*)arg
)->first_read_date
);
2214 err
|= __put_user(f
->probed_format
, &((struct floppy_drive_struct32
*)arg
)->probed_format
);
2215 err
|= __put_user(f
->track
, &((struct floppy_drive_struct32
*)arg
)->track
);
2216 err
|= __put_user(f
->maxblock
, &((struct floppy_drive_struct32
*)arg
)->maxblock
);
2217 err
|= __put_user(f
->maxtrack
, &((struct floppy_drive_struct32
*)arg
)->maxtrack
);
2218 err
|= __put_user(f
->generation
, &((struct floppy_drive_struct32
*)arg
)->generation
);
2219 err
|= __put_user(f
->keep_data
, &((struct floppy_drive_struct32
*)arg
)->keep_data
);
2220 err
|= __put_user(f
->fd_ref
, &((struct floppy_drive_struct32
*)arg
)->fd_ref
);
2221 err
|= __put_user(f
->fd_device
, &((struct floppy_drive_struct32
*)arg
)->fd_device
);
2222 err
|= __put_user(f
->last_checked
, &((struct floppy_drive_struct32
*)arg
)->last_checked
);
2223 err
|= __put_user((u64
)f
->dmabuf
, &((struct floppy_drive_struct32
*)arg
)->dmabuf
);
2224 err
|= __put_user((u64
)f
->bufblocks
, &((struct floppy_drive_struct32
*)arg
)->bufblocks
);
2227 case FDGETFDCSTAT32
:
2229 struct floppy_fdc_state
*f
= karg
;
2231 err
= __put_user(f
->spec1
, &((struct floppy_fdc_state32
*)arg
)->spec1
);
2232 err
|= __put_user(f
->spec2
, &((struct floppy_fdc_state32
*)arg
)->spec2
);
2233 err
|= __put_user(f
->dtr
, &((struct floppy_fdc_state32
*)arg
)->dtr
);
2234 err
|= __put_user(f
->version
, &((struct floppy_fdc_state32
*)arg
)->version
);
2235 err
|= __put_user(f
->dor
, &((struct floppy_fdc_state32
*)arg
)->dor
);
2236 err
|= __put_user(f
->address
, &((struct floppy_fdc_state32
*)arg
)->address
);
2237 err
|= __copy_to_user((char *)&((struct floppy_fdc_state32
*)arg
)->address
2238 + sizeof(((struct floppy_fdc_state32
*)arg
)->address
),
2239 (char *)&f
->address
+ sizeof(f
->address
), sizeof(int));
2240 err
|= __put_user(f
->driver_version
, &((struct floppy_fdc_state32
*)arg
)->driver_version
);
2241 err
|= __copy_to_user(((struct floppy_fdc_state32
*)arg
)->track
, f
->track
, sizeof(f
->track
));
2246 struct floppy_write_errors
*f
= karg
;
2248 err
= __put_user(f
->write_errors
, &((struct floppy_write_errors32
*)arg
)->write_errors
);
2249 err
|= __put_user(f
->first_error_sector
, &((struct floppy_write_errors32
*)arg
)->first_error_sector
);
2250 err
|= __put_user(f
->first_error_generation
, &((struct floppy_write_errors32
*)arg
)->first_error_generation
);
2251 err
|= __put_user(f
->last_error_sector
, &((struct floppy_write_errors32
*)arg
)->last_error_sector
);
2252 err
|= __put_user(f
->last_error_generation
, &((struct floppy_write_errors32
*)arg
)->last_error_generation
);
2253 err
|= __put_user(f
->badness
, &((struct floppy_write_errors32
*)arg
)->badness
);
2262 out
: if (karg
) kfree(karg
);
2266 struct mtd_oob_buf32
{
2269 compat_caddr_t ptr
; /* unsigned char* */
2272 #define MEMWRITEOOB32 _IOWR('M',3,struct mtd_oob_buf32)
2273 #define MEMREADOOB32 _IOWR('M',4,struct mtd_oob_buf32)
2275 static int mtd_rw_oob(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2277 struct mtd_oob_buf
*buf
= compat_alloc_user_space(sizeof(*buf
));
2278 struct mtd_oob_buf32
*buf32
= (struct mtd_oob_buf32
*) arg
;
2281 unsigned int real_cmd
;
2284 real_cmd
= (cmd
== MEMREADOOB32
) ?
2285 MEMREADOOB
: MEMWRITEOOB
;
2287 if (copy_in_user(&buf
->start
, &buf32
->start
,
2289 get_user(data
, &buf32
->ptr
))
2291 datap
= (void *) (unsigned long) data
;
2292 if (put_user(datap
, &buf
->ptr
))
2295 err
= sys_ioctl(fd
, real_cmd
, (unsigned long) buf
);
2298 if (copy_in_user(&buf32
->start
, &buf
->start
,
2306 #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
2307 #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
2310 put_dirent32 (struct dirent
*d
, struct compat_dirent
*d32
)
2314 if ((ret
= verify_area(VERIFY_WRITE
, d32
,
2315 sizeof(struct compat_dirent
))))
2318 __put_user(d
->d_ino
, &d32
->d_ino
);
2319 __put_user(d
->d_off
, &d32
->d_off
);
2320 __put_user(d
->d_reclen
, &d32
->d_reclen
);
2321 __copy_to_user(d32
->d_name
, d
->d_name
, d
->d_reclen
);
2325 static int vfat_ioctl32(unsigned fd
, unsigned cmd
, void *ptr
)
2328 mm_segment_t oldfs
= get_fs();
2333 case VFAT_IOCTL_READDIR_BOTH32
:
2334 cmd
= VFAT_IOCTL_READDIR_BOTH
;
2336 case VFAT_IOCTL_READDIR_SHORT32
:
2337 cmd
= VFAT_IOCTL_READDIR_SHORT
;
2342 ret
= sys_ioctl(fd
,cmd
,(unsigned long)&d
);
2345 ret
|= put_dirent32(&d
[0], (struct compat_dirent
*)ptr
);
2346 ret
|= put_dirent32(&d
[1], ((struct compat_dirent
*)ptr
) + 1);
2351 #define REISERFS_IOC_UNPACK32 _IOW(0xCD,1,int)
2353 static int reiserfs_ioctl32(unsigned fd
, unsigned cmd
, unsigned long ptr
)
2355 if (cmd
== REISERFS_IOC_UNPACK32
)
2356 cmd
= REISERFS_IOC_UNPACK
;
2358 return sys_ioctl(fd
,cmd
,ptr
);
2361 struct raw32_config_request
2363 compat_int_t raw_minor
;
2366 } __attribute__((packed
));
2368 static int get_raw32_request(struct raw_config_request
*req
, struct raw32_config_request
*user_req
)
2370 __u32 lo_maj
, hi_maj
, lo_min
, hi_min
;
2373 if ((ret
= verify_area(VERIFY_READ
, user_req
,
2374 sizeof(struct raw32_config_request
))))
2377 __get_user(req
->raw_minor
, &user_req
->raw_minor
);
2378 __get_user(lo_maj
, (__u32
*)&user_req
->block_major
);
2379 __get_user(hi_maj
, ((__u32
*)(&user_req
->block_major
) + 1));
2380 __get_user(lo_min
, (__u32
*)&user_req
->block_minor
);
2381 __get_user(hi_min
, ((__u32
*)(&user_req
->block_minor
) + 1));
2383 req
->block_major
= lo_maj
| (((__u64
)hi_maj
) << 32);
2384 req
->block_minor
= lo_min
| (((__u64
)lo_min
) << 32);
2389 static int set_raw32_request(struct raw_config_request
*req
, struct raw32_config_request
*user_req
)
2393 if ((ret
= verify_area(VERIFY_WRITE
, user_req
,
2394 sizeof(struct raw32_config_request
))))
2397 __put_user(req
->raw_minor
, &user_req
->raw_minor
);
2398 __put_user((__u32
)(req
->block_major
), (__u32
*)&user_req
->block_major
);
2399 __put_user((__u32
)(req
->block_major
>> 32), ((__u32
*)(&user_req
->block_major
) + 1));
2400 __put_user((__u32
)(req
->block_minor
), (__u32
*)&user_req
->block_minor
);
2401 __put_user((__u32
)(req
->block_minor
>> 32), ((__u32
*)(&user_req
->block_minor
) + 1));
2406 static int raw_ioctl(unsigned fd
, unsigned cmd
, void *ptr
)
2413 struct raw_config_request req
;
2414 struct raw32_config_request
*user_req
= ptr
;
2415 mm_segment_t oldfs
= get_fs();
2417 if ((ret
= get_raw32_request(&req
, user_req
)))
2421 ret
= sys_ioctl(fd
,cmd
,(unsigned long)&req
);
2424 if ((!ret
) && (cmd
== RAW_GETBIND
)) {
2425 ret
= set_raw32_request(&req
, user_req
);
2430 ret
= sys_ioctl(fd
,cmd
,(unsigned long)ptr
);
2436 struct serial_struct32
{
2442 compat_int_t xmit_fifo_size
;
2443 compat_int_t custom_divisor
;
2444 compat_int_t baud_base
;
2445 unsigned short close_delay
;
2447 char reserved_char
[1];
2449 unsigned short closing_wait
; /* time to wait before closing */
2450 unsigned short closing_wait2
; /* no longer used... */
2451 compat_uint_t iomem_base
;
2452 unsigned short iomem_reg_shift
;
2453 unsigned int port_high
;
2454 compat_int_t reserved
[1];
2457 static int serial_struct_ioctl(unsigned fd
, unsigned cmd
, void *ptr
)
2459 typedef struct serial_struct SS
;
2460 typedef struct serial_struct32 SS32
;
2461 struct serial_struct32
*ss32
= ptr
;
2463 struct serial_struct ss
;
2464 mm_segment_t oldseg
= get_fs();
2467 if (cmd
== TIOCSSERIAL
) {
2468 if (verify_area(VERIFY_READ
, ss32
, sizeof(SS32
)))
2470 __copy_from_user(&ss
, ss32
, offsetof(SS32
, iomem_base
));
2471 __get_user(udata
, &ss32
->iomem_base
);
2472 ss
.iomem_base
= compat_ptr(udata
);
2473 __get_user(ss
.iomem_reg_shift
, &ss32
->iomem_reg_shift
);
2474 __get_user(ss
.port_high
, &ss32
->port_high
);
2475 ss
.iomap_base
= 0UL;
2478 err
= sys_ioctl(fd
,cmd
,(unsigned long)(&ss
));
2480 if (cmd
== TIOCGSERIAL
&& err
>= 0) {
2481 if (verify_area(VERIFY_WRITE
, ss32
, sizeof(SS32
)))
2483 __copy_to_user(ss32
,&ss
,offsetof(SS32
,iomem_base
));
2484 __put_user((unsigned long)ss
.iomem_base
>> 32 ?
2485 0xffffffff : (unsigned)(unsigned long)ss
.iomem_base
,
2487 __put_user(ss
.iomem_reg_shift
, &ss32
->iomem_reg_shift
);
2488 __put_user(ss
.port_high
, &ss32
->port_high
);
2494 struct usbdevfs_ctrltransfer32
{
2500 u32 timeout
; /* in milliseconds */
2501 compat_caddr_t data
;
2504 #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
2506 static int do_usbdevfs_control(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2508 struct usbdevfs_ctrltransfer kctrl
;
2509 struct usbdevfs_ctrltransfer32
*uctrl
;
2510 mm_segment_t old_fs
;
2515 uctrl
= (struct usbdevfs_ctrltransfer32
*) arg
;
2517 if (copy_from_user(&kctrl
, uctrl
,
2518 (sizeof(struct usbdevfs_ctrltransfer32
) -
2519 sizeof(compat_caddr_t
))))
2522 if (get_user(udata
, &uctrl
->data
))
2524 uptr
= compat_ptr(udata
);
2525 /* In usbdevice_fs, it limits the control buffer to a page,
2526 * for simplicity so do we.
2528 if (!uptr
|| kctrl
.wLength
> PAGE_SIZE
)
2531 kptr
= (void *)__get_free_page(GFP_KERNEL
);
2533 if ((kctrl
.bRequestType
& USB_DIR_IN
) == 0) {
2535 if (copy_from_user(kptr
, uptr
, kctrl
.wLength
))
2543 err
= sys_ioctl(fd
, USBDEVFS_CONTROL
, (unsigned long)&kctrl
);
2547 ((kctrl
.bRequestType
& USB_DIR_IN
) != 0)) {
2548 if (copy_to_user(uptr
, kptr
, kctrl
.wLength
))
2553 free_page((unsigned long) kptr
);
2558 struct usbdevfs_bulktransfer32
{
2561 compat_uint_t timeout
; /* in milliseconds */
2562 compat_caddr_t data
;
2565 #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
2567 static int do_usbdevfs_bulk(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2569 struct usbdevfs_bulktransfer kbulk
;
2570 struct usbdevfs_bulktransfer32
*ubulk
;
2571 mm_segment_t old_fs
;
2576 ubulk
= (struct usbdevfs_bulktransfer32
*) arg
;
2578 if (get_user(kbulk
.ep
, &ubulk
->ep
) ||
2579 get_user(kbulk
.len
, &ubulk
->len
) ||
2580 get_user(kbulk
.timeout
, &ubulk
->timeout
) ||
2581 get_user(udata
, &ubulk
->data
))
2584 uptr
= compat_ptr(udata
);
2586 /* In usbdevice_fs, it limits the control buffer to a page,
2587 * for simplicity so do we.
2589 if (!uptr
|| kbulk
.len
> PAGE_SIZE
)
2592 kptr
= (void *) __get_free_page(GFP_KERNEL
);
2594 if ((kbulk
.ep
& 0x80) == 0) {
2596 if (copy_from_user(kptr
, uptr
, kbulk
.len
))
2604 err
= sys_ioctl(fd
, USBDEVFS_BULK
, (unsigned long) &kbulk
);
2608 ((kbulk
.ep
& 0x80) != 0)) {
2609 if (copy_to_user(uptr
, kptr
, kbulk
.len
))
2614 free_page((unsigned long) kptr
);
2618 /* This needs more work before we can enable it. Unfortunately
2619 * because of the fancy asynchronous way URB status/error is written
2620 * back to userspace, we'll need to fiddle with USB devio internals
2621 * and/or reimplement entirely the frontend of it ourselves. -DaveM
2625 * When an URB is submitted via usbdevicefs it is put onto an
2626 * asynchronous queue. When the URB completes, it may be reaped
2627 * via another ioctl. During this reaping the status is written
2628 * back to userspace along with the length of the transfer.
2630 * We must translate into 64-bit kernel types so we pass in a kernel
2631 * space copy of the usbdevfs_urb structure. This would mean that we
2632 * must do something to deal with the async entry reaping. First we
2633 * have to deal somehow with this transitory memory we've allocated.
2634 * This is problematic since there are many call sites from which the
2635 * async entries can be destroyed (and thus when we'd need to free up
2636 * this kernel memory). One of which is the close() op of usbdevicefs.
2637 * To handle that we'd need to make our own file_operations struct which
2638 * overrides usbdevicefs's release op with our own which runs usbdevicefs's
2639 * real release op then frees up the kernel memory.
2641 * But how to keep track of these kernel buffers? We'd need to either
2642 * keep track of them in some table _or_ know about usbdevicefs internals
2643 * (ie. the exact layout of its file private, which is actually defined
2644 * in linux/usbdevice_fs.h, the layout of the async queues are private to
2647 * There is one possible other solution I considered, also involving knowledge
2648 * of usbdevicefs internals:
2650 * After an URB is submitted, we "fix up" the address back to the user
2651 * space one. This would work if the status/length fields written back
2652 * by the async URB completion lines up perfectly in the 32-bit type with
2653 * the 64-bit kernel type. Unfortunately, it does not because the iso
2654 * frame descriptors, at the end of the struct, can be written back.
2656 * I think we'll just need to simply duplicate the devio URB engine here.
2659 struct usbdevfs_urb32
{
2661 unsigned char endpoint
;
2662 compat_int_t status
;
2663 compat_uint_t flags
;
2664 compat_caddr_t buffer
;
2665 compat_int_t buffer_length
;
2666 compat_int_t actual_length
;
2667 compat_int_t start_frame
;
2668 compat_int_t number_of_packets
;
2669 compat_int_t error_count
;
2670 compat_uint_t signr
;
2671 compat_caddr_t usercontext
; /* unused */
2672 struct usbdevfs_iso_packet_desc iso_frame_desc
[0];
2675 #define USBDEVFS_SUBMITURB32 _IOR('U', 10, struct usbdevfs_urb32)
2677 static int get_urb32(struct usbdevfs_urb
*kurb
,
2678 struct usbdevfs_urb32
*uurb
)
2680 if (get_user(kurb
->type
, &uurb
->type
) ||
2681 __get_user(kurb
->endpoint
, &uurb
->endpoint
) ||
2682 __get_user(kurb
->status
, &uurb
->status
) ||
2683 __get_user(kurb
->flags
, &uurb
->flags
) ||
2684 __get_user(kurb
->buffer_length
, &uurb
->buffer_length
) ||
2685 __get_user(kurb
->actual_length
, &uurb
->actual_length
) ||
2686 __get_user(kurb
->start_frame
, &uurb
->start_frame
) ||
2687 __get_user(kurb
->number_of_packets
, &uurb
->number_of_packets
) ||
2688 __get_user(kurb
->error_count
, &uurb
->error_count
) ||
2689 __get_user(kurb
->signr
, &uurb
->signr
))
2692 kurb
->usercontext
= 0; /* unused currently */
2697 /* Just put back the values which usbdevfs actually changes. */
2698 static int put_urb32(struct usbdevfs_urb
*kurb
,
2699 struct usbdevfs_urb32
*uurb
)
2701 if (put_user(kurb
->status
, &uurb
->status
) ||
2702 __put_user(kurb
->actual_length
, &uurb
->actual_length
) ||
2703 __put_user(kurb
->error_count
, &uurb
->error_count
))
2706 if (kurb
->number_of_packets
!= 0) {
2709 for (i
= 0; i
< kurb
->number_of_packets
; i
++) {
2710 if (__put_user(kurb
->iso_frame_desc
[i
].actual_length
,
2711 &uurb
->iso_frame_desc
[i
].actual_length
) ||
2712 __put_user(kurb
->iso_frame_desc
[i
].status
,
2713 &uurb
->iso_frame_desc
[i
].status
))
2721 static int get_urb32_isoframes(struct usbdevfs_urb
*kurb
,
2722 struct usbdevfs_urb32
*uurb
)
2724 unsigned int totlen
;
2727 if (kurb
->type
!= USBDEVFS_URB_TYPE_ISO
) {
2728 kurb
->number_of_packets
= 0;
2732 if (kurb
->number_of_packets
< 1 ||
2733 kurb
->number_of_packets
> 128)
2736 if (copy_from_user(&kurb
->iso_frame_desc
[0],
2737 &uurb
->iso_frame_desc
[0],
2738 sizeof(struct usbdevfs_iso_packet_desc
) *
2739 kurb
->number_of_packets
))
2743 for (i
= 0; i
< kurb
->number_of_packets
; i
++) {
2744 unsigned int this_len
;
2746 this_len
= kurb
->iso_frame_desc
[i
].length
;
2747 if (this_len
> 1023)
2756 kurb
->buffer_length
= totlen
;
2761 static int do_usbdevfs_urb(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2763 struct usbdevfs_urb
*kurb
;
2764 struct usbdevfs_urb32
*uurb
;
2765 mm_segment_t old_fs
;
2768 unsigned int buflen
;
2771 uurb
= (struct usbdevfs_urb32
*) arg
;
2774 kurb
= kmalloc(sizeof(struct usbdevfs_urb
) +
2775 (sizeof(struct usbdevfs_iso_packet_desc
) * 128),
2781 if (get_urb32(kurb
, uurb
))
2784 err
= get_urb32_isoframes(kurb
, uurb
);
2789 if (__get_user(udata
, &uurb
->buffer
))
2791 uptr
= compat_ptr(udata
);
2793 buflen
= kurb
->buffer_length
;
2794 err
= verify_area(VERIFY_WRITE
, uptr
, buflen
);
2801 err
= sys_ioctl(fd
, USBDEVFS_SUBMITURB
, (unsigned long) kurb
);
2805 /* RED-PEN Shit, this doesn't work for async URBs :-( XXX */
2806 if (put_urb32(kurb
, uurb
)) {
2817 #define USBDEVFS_REAPURB32 _IOW('U', 12, u32)
2818 #define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, u32)
2820 static int do_usbdevfs_reapurb(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2822 mm_segment_t old_fs
;
2829 (cmd
== USBDEVFS_REAPURB32
?
2831 USBDEVFS_REAPURBNDELAY
),
2832 (unsigned long) &kptr
);
2836 put_user((u32
)(u64
)kptr
, (u32
*)arg
))
2842 struct usbdevfs_disconnectsignal32
{
2844 compat_caddr_t context
;
2847 #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
2849 static int do_usbdevfs_discsignal(unsigned int fd
, unsigned int cmd
, unsigned long arg
)
2851 struct usbdevfs_disconnectsignal kdis
;
2852 struct usbdevfs_disconnectsignal32
*udis
;
2853 mm_segment_t old_fs
;
2857 udis
= (struct usbdevfs_disconnectsignal32
*) arg
;
2859 if (get_user(kdis
.signr
, &udis
->signr
) ||
2860 __get_user(uctx
, &udis
->context
))
2863 kdis
.context
= (void *) (long)uctx
;
2867 err
= sys_ioctl(fd
, USBDEVFS_DISCSIGNAL
, (unsigned long) &kdis
);
2876 HANDLE_IOCTL(MEMREADOOB32
, mtd_rw_oob
)
2877 HANDLE_IOCTL(MEMWRITEOOB32
, mtd_rw_oob
)
2879 HANDLE_IOCTL(SIOCGIFNAME
, dev_ifname32
)
2881 HANDLE_IOCTL(SIOCGIFCONF
, dev_ifconf
)
2882 HANDLE_IOCTL(SIOCGIFFLAGS
, dev_ifsioc
)
2883 HANDLE_IOCTL(SIOCSIFFLAGS
, dev_ifsioc
)
2884 HANDLE_IOCTL(SIOCGIFMETRIC
, dev_ifsioc
)
2885 HANDLE_IOCTL(SIOCSIFMETRIC
, dev_ifsioc
)
2886 HANDLE_IOCTL(SIOCGIFMTU
, dev_ifsioc
)
2887 HANDLE_IOCTL(SIOCSIFMTU
, dev_ifsioc
)
2888 HANDLE_IOCTL(SIOCGIFMEM
, dev_ifsioc
)
2889 HANDLE_IOCTL(SIOCSIFMEM
, dev_ifsioc
)
2890 HANDLE_IOCTL(SIOCGIFHWADDR
, dev_ifsioc
)
2891 HANDLE_IOCTL(SIOCSIFHWADDR
, dev_ifsioc
)
2892 HANDLE_IOCTL(SIOCADDMULTI
, dev_ifsioc
)
2893 HANDLE_IOCTL(SIOCDELMULTI
, dev_ifsioc
)
2894 HANDLE_IOCTL(SIOCGIFINDEX
, dev_ifsioc
)
2895 HANDLE_IOCTL(SIOCGIFMAP
, dev_ifsioc
)
2896 HANDLE_IOCTL(SIOCSIFMAP
, dev_ifsioc
)
2897 HANDLE_IOCTL(SIOCGIFADDR
, dev_ifsioc
)
2898 HANDLE_IOCTL(SIOCSIFADDR
, dev_ifsioc
)
2899 HANDLE_IOCTL(SIOCGIFBRDADDR
, dev_ifsioc
)
2900 HANDLE_IOCTL(SIOCSIFBRDADDR
, dev_ifsioc
)
2901 HANDLE_IOCTL(SIOCGIFDSTADDR
, dev_ifsioc
)
2902 HANDLE_IOCTL(SIOCSIFDSTADDR
, dev_ifsioc
)
2903 HANDLE_IOCTL(SIOCGIFNETMASK
, dev_ifsioc
)
2904 HANDLE_IOCTL(SIOCSIFNETMASK
, dev_ifsioc
)
2905 HANDLE_IOCTL(SIOCSIFPFLAGS
, dev_ifsioc
)
2906 HANDLE_IOCTL(SIOCGIFPFLAGS
, dev_ifsioc
)
2907 HANDLE_IOCTL(SIOCGIFTXQLEN
, dev_ifsioc
)
2908 HANDLE_IOCTL(SIOCSIFTXQLEN
, dev_ifsioc
)
2909 HANDLE_IOCTL(SIOCETHTOOL
, ethtool_ioctl
)
2910 HANDLE_IOCTL(SIOCBONDENSLAVE
, bond_ioctl
)
2911 HANDLE_IOCTL(SIOCBONDRELEASE
, bond_ioctl
)
2912 HANDLE_IOCTL(SIOCBONDSETHWADDR
, bond_ioctl
)
2913 HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY
, bond_ioctl
)
2914 HANDLE_IOCTL(SIOCBONDINFOQUERY
, bond_ioctl
)
2915 HANDLE_IOCTL(SIOCBONDCHANGEACTIVE
, bond_ioctl
)
2916 HANDLE_IOCTL(SIOCADDRT
, routing_ioctl
)
2917 HANDLE_IOCTL(SIOCDELRT
, routing_ioctl
)
2918 /* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
2919 HANDLE_IOCTL(SIOCRTMSG
, ret_einval
)
2920 HANDLE_IOCTL(SIOCGSTAMP
, do_siocgstamp
)
2921 HANDLE_IOCTL(HDIO_GETGEO
, hdio_getgeo
)
2922 HANDLE_IOCTL(BLKRAGET
, w_long
)
2923 HANDLE_IOCTL(BLKGETSIZE
, w_long
)
2924 HANDLE_IOCTL(0x1260, broken_blkgetsize
)
2925 HANDLE_IOCTL(BLKFRAGET
, w_long
)
2926 HANDLE_IOCTL(BLKSECTGET
, w_long
)
2927 HANDLE_IOCTL(FBIOGET_FSCREENINFO
, fb_ioctl_trans
)
2928 HANDLE_IOCTL(BLKPG
, blkpg_ioctl_trans
)
2929 HANDLE_IOCTL(FBIOGETCMAP
, fb_ioctl_trans
)
2930 HANDLE_IOCTL(FBIOPUTCMAP
, fb_ioctl_trans
)
2931 HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS
, hdio_ioctl_trans
)
2932 HANDLE_IOCTL(HDIO_GET_UNMASKINTR
, hdio_ioctl_trans
)
2933 HANDLE_IOCTL(HDIO_GET_DMA
, hdio_ioctl_trans
)
2934 HANDLE_IOCTL(HDIO_GET_32BIT
, hdio_ioctl_trans
)
2935 HANDLE_IOCTL(HDIO_GET_MULTCOUNT
, hdio_ioctl_trans
)
2936 HANDLE_IOCTL(HDIO_GET_NOWERR
, hdio_ioctl_trans
)
2937 HANDLE_IOCTL(HDIO_GET_NICE
, hdio_ioctl_trans
)
2938 HANDLE_IOCTL(FDSETPRM32
, fd_ioctl_trans
)
2939 HANDLE_IOCTL(FDDEFPRM32
, fd_ioctl_trans
)
2940 HANDLE_IOCTL(FDGETPRM32
, fd_ioctl_trans
)
2941 HANDLE_IOCTL(FDSETDRVPRM32
, fd_ioctl_trans
)
2942 HANDLE_IOCTL(FDGETDRVPRM32
, fd_ioctl_trans
)
2943 HANDLE_IOCTL(FDGETDRVSTAT32
, fd_ioctl_trans
)
2944 HANDLE_IOCTL(FDPOLLDRVSTAT32
, fd_ioctl_trans
)
2945 HANDLE_IOCTL(FDGETFDCSTAT32
, fd_ioctl_trans
)
2946 HANDLE_IOCTL(FDWERRORGET32
, fd_ioctl_trans
)
2947 HANDLE_IOCTL(SG_IO
,sg_ioctl_trans
)
2948 HANDLE_IOCTL(PPPIOCGIDLE32
, ppp_ioctl_trans
)
2949 HANDLE_IOCTL(PPPIOCSCOMPRESS32
, ppp_ioctl_trans
)
2950 HANDLE_IOCTL(PPPIOCSPASS32
, ppp_sock_fprog_ioctl_trans
)
2951 HANDLE_IOCTL(PPPIOCSACTIVE32
, ppp_sock_fprog_ioctl_trans
)
2952 HANDLE_IOCTL(MTIOCGET32
, mt_ioctl_trans
)
2953 HANDLE_IOCTL(MTIOCPOS32
, mt_ioctl_trans
)
2954 HANDLE_IOCTL(MTIOCGETCONFIG32
, mt_ioctl_trans
)
2955 HANDLE_IOCTL(MTIOCSETCONFIG32
, mt_ioctl_trans
)
2956 HANDLE_IOCTL(CDROMREADAUDIO
, cdrom_ioctl_trans
)
2957 HANDLE_IOCTL(CDROM_SEND_PACKET
, cdrom_ioctl_trans
)
2958 HANDLE_IOCTL(LOOP_SET_STATUS
, loop_status
)
2959 HANDLE_IOCTL(LOOP_GET_STATUS
, loop_status
)
2960 #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
2961 HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32
, ioc_settimeout
)
2963 HANDLE_IOCTL(PIO_FONTX
, do_fontx_ioctl
)
2964 HANDLE_IOCTL(GIO_FONTX
, do_fontx_ioctl
)
2965 HANDLE_IOCTL(PIO_UNIMAP
, do_unimap_ioctl
)
2966 HANDLE_IOCTL(GIO_UNIMAP
, do_unimap_ioctl
)
2967 HANDLE_IOCTL(KDFONTOP
, do_kdfontop_ioctl
)
2969 HANDLE_IOCTL(EXT2_IOC32_GETFLAGS
, do_ext2_ioctl
)
2970 HANDLE_IOCTL(EXT2_IOC32_SETFLAGS
, do_ext2_ioctl
)
2971 HANDLE_IOCTL(EXT2_IOC32_GETVERSION
, do_ext2_ioctl
)
2972 HANDLE_IOCTL(EXT2_IOC32_SETVERSION
, do_ext2_ioctl
)
2973 HANDLE_IOCTL(VIDIOCGTUNER32
, do_video_ioctl
)
2974 HANDLE_IOCTL(VIDIOCSTUNER32
, do_video_ioctl
)
2975 HANDLE_IOCTL(VIDIOCGWIN32
, do_video_ioctl
)
2976 HANDLE_IOCTL(VIDIOCSWIN32
, do_video_ioctl
)
2977 HANDLE_IOCTL(VIDIOCGFBUF32
, do_video_ioctl
)
2978 HANDLE_IOCTL(VIDIOCSFBUF32
, do_video_ioctl
)
2979 HANDLE_IOCTL(VIDIOCGFREQ32
, do_video_ioctl
)
2980 HANDLE_IOCTL(VIDIOCSFREQ32
, do_video_ioctl
)
2981 /* One SMB ioctl needs translations. */
2982 #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_pid_t)
2983 HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32
, do_smb_getmountuid
)
2984 HANDLE_IOCTL(ATM_GETLINKRATE32
, do_atm_ioctl
)
2985 HANDLE_IOCTL(ATM_GETNAMES32
, do_atm_ioctl
)
2986 HANDLE_IOCTL(ATM_GETTYPE32
, do_atm_ioctl
)
2987 HANDLE_IOCTL(ATM_GETESI32
, do_atm_ioctl
)
2988 HANDLE_IOCTL(ATM_GETADDR32
, do_atm_ioctl
)
2989 HANDLE_IOCTL(ATM_RSTADDR32
, do_atm_ioctl
)
2990 HANDLE_IOCTL(ATM_ADDADDR32
, do_atm_ioctl
)
2991 HANDLE_IOCTL(ATM_DELADDR32
, do_atm_ioctl
)
2992 HANDLE_IOCTL(ATM_GETCIRANGE32
, do_atm_ioctl
)
2993 HANDLE_IOCTL(ATM_SETCIRANGE32
, do_atm_ioctl
)
2994 HANDLE_IOCTL(ATM_SETESI32
, do_atm_ioctl
)
2995 HANDLE_IOCTL(ATM_SETESIF32
, do_atm_ioctl
)
2996 HANDLE_IOCTL(ATM_GETSTAT32
, do_atm_ioctl
)
2997 HANDLE_IOCTL(ATM_GETSTATZ32
, do_atm_ioctl
)
2998 HANDLE_IOCTL(ATM_GETLOOP32
, do_atm_ioctl
)
2999 HANDLE_IOCTL(ATM_SETLOOP32
, do_atm_ioctl
)
3000 HANDLE_IOCTL(ATM_QUERYLOOP32
, do_atm_ioctl
)
3001 HANDLE_IOCTL(SONET_GETSTAT
, do_atm_ioctl
)
3002 HANDLE_IOCTL(SONET_GETSTATZ
, do_atm_ioctl
)
3003 HANDLE_IOCTL(SONET_GETDIAG
, do_atm_ioctl
)
3004 HANDLE_IOCTL(SONET_SETDIAG
, do_atm_ioctl
)
3005 HANDLE_IOCTL(SONET_CLRDIAG
, do_atm_ioctl
)
3006 HANDLE_IOCTL(SONET_SETFRAMING
, do_atm_ioctl
)
3007 HANDLE_IOCTL(SONET_GETFRAMING
, do_atm_ioctl
)
3008 HANDLE_IOCTL(SONET_GETFRSENSE
, do_atm_ioctl
)
3010 HANDLE_IOCTL(BLKBSZGET_32
, do_blkbszget
)
3011 HANDLE_IOCTL(BLKBSZSET_32
, do_blkbszset
)
3012 HANDLE_IOCTL(BLKGETSIZE64_32
, do_blkgetsize64
)
3014 HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32
, vfat_ioctl32
)
3015 HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32
, vfat_ioctl32
)
3016 HANDLE_IOCTL(REISERFS_IOC_UNPACK32
, reiserfs_ioctl32
)
3018 HANDLE_IOCTL(RAW_SETBIND
, raw_ioctl
)
3019 HANDLE_IOCTL(RAW_GETBIND
, raw_ioctl
)
3021 HANDLE_IOCTL(TIOCGSERIAL
, serial_struct_ioctl
)
3022 HANDLE_IOCTL(TIOCSSERIAL
, serial_struct_ioctl
)
3024 HANDLE_IOCTL(USBDEVFS_CONTROL32
, do_usbdevfs_control
)
3025 HANDLE_IOCTL(USBDEVFS_BULK32
, do_usbdevfs_bulk
)
3026 /*HANDLE_IOCTL(USBDEVFS_SUBMITURB32, do_usbdevfs_urb)*/
3027 HANDLE_IOCTL(USBDEVFS_REAPURB32
, do_usbdevfs_reapurb
)
3028 HANDLE_IOCTL(USBDEVFS_REAPURBNDELAY32
, do_usbdevfs_reapurb
)
3029 HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32
, do_usbdevfs_discsignal
)