ia64/linux-2.6.18-xen.hg

view fs/compat_ioctl.c @ 452:c7ed6fe5dca0

kexec: dont initialise regions in reserve_memory()

There is no need to initialise efi_memmap_res and boot_param_res in
reserve_memory() for the initial xen domain as it is done in
machine_kexec_setup_resources() using values from the kexec hypercall.

Signed-off-by: Simon Horman <horms@verge.net.au>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 28 10:55:18 2008 +0000 (2008-02-28)
parents e5f633c33025
children 70acfc9814c9
line source
1 /*
2 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
3 *
4 * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
5 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
6 * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs
7 * Copyright (C) 2003 Pavel Machek (pavel@suse.cz)
8 *
9 * These routines maintain argument size conversion between 32bit and 64bit
10 * ioctls.
11 */
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>
22 #include <linux/if.h>
23 #include <linux/if_bridge.h>
24 #include <linux/slab.h>
25 #include <linux/hdreg.h>
26 #include <linux/raid/md.h>
27 #include <linux/kd.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>
34 #include <linux/vt.h>
35 #include <linux/fs.h>
36 #include <linux/file.h>
37 #include <linux/fd.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/loop.h>
44 #include <linux/auto_fs.h>
45 #include <linux/auto_fs4.h>
46 #include <linux/tty.h>
47 #include <linux/vt_kern.h>
48 #include <linux/fb.h>
49 #include <linux/ext2_fs.h>
50 #include <linux/ext3_jbd.h>
51 #include <linux/ext3_fs.h>
52 #include <linux/videodev.h>
53 #include <linux/netdevice.h>
54 #include <linux/raw.h>
55 #include <linux/smb_fs.h>
56 #include <linux/blkpg.h>
57 #include <linux/blkdev.h>
58 #include <linux/elevator.h>
59 #include <linux/rtc.h>
60 #include <linux/pci.h>
61 #include <linux/module.h>
62 #include <linux/serial.h>
63 #include <linux/reiserfs_fs.h>
64 #include <linux/if_tun.h>
65 #include <linux/ctype.h>
66 #include <linux/ioctl32.h>
67 #include <linux/syscalls.h>
68 #include <linux/ncp_fs.h>
69 #include <linux/i2c.h>
70 #include <linux/i2c-dev.h>
71 #include <linux/wireless.h>
72 #include <linux/atalk.h>
73 #include <linux/blktrace_api.h>
75 #include <net/sock.h> /* siocdevprivate_ioctl */
76 #include <net/bluetooth/bluetooth.h>
77 #include <net/bluetooth/hci.h>
78 #include <net/bluetooth/rfcomm.h>
80 #include <linux/capi.h>
81 #include <linux/gigaset_dev.h>
83 #include <scsi/scsi.h>
84 #include <scsi/scsi_ioctl.h>
85 #include <scsi/sg.h>
87 #include <asm/uaccess.h>
88 #include <linux/ethtool.h>
89 #include <linux/mii.h>
90 #include <linux/if_bonding.h>
91 #include <linux/watchdog.h>
92 #include <linux/dm-ioctl.h>
94 #include <linux/soundcard.h>
95 #include <linux/lp.h>
96 #include <linux/ppdev.h>
98 #include <linux/atm.h>
99 #include <linux/atmarp.h>
100 #include <linux/atmclip.h>
101 #include <linux/atmdev.h>
102 #include <linux/atmioc.h>
103 #include <linux/atmlec.h>
104 #include <linux/atmmpc.h>
105 #include <linux/atmsvc.h>
106 #include <linux/atm_tcp.h>
107 #include <linux/sonet.h>
108 #include <linux/atm_suni.h>
109 #include <linux/mtd/mtd.h>
111 #include <linux/usb.h>
112 #include <linux/usbdevice_fs.h>
113 #include <linux/nbd.h>
114 #include <linux/random.h>
115 #include <linux/filter.h>
116 #include <linux/msdos_fs.h>
117 #include <linux/pktcdvd.h>
119 #include <linux/hiddev.h>
121 #include <linux/dvb/audio.h>
122 #include <linux/dvb/dmx.h>
123 #include <linux/dvb/frontend.h>
124 #include <linux/dvb/video.h>
125 #include <linux/lp.h>
127 #include <xen/interface/xen.h>
128 #include <xen/public/evtchn.h>
129 #include <xen/public/privcmd.h>
130 #include <xen/compat_ioctl.h>
132 /* Aiee. Someone does not find a difference between int and long */
133 #define EXT2_IOC32_GETFLAGS _IOR('f', 1, int)
134 #define EXT2_IOC32_SETFLAGS _IOW('f', 2, int)
135 #define EXT3_IOC32_GETVERSION _IOR('f', 3, int)
136 #define EXT3_IOC32_SETVERSION _IOW('f', 4, int)
137 #define EXT3_IOC32_GETRSVSZ _IOR('f', 5, int)
138 #define EXT3_IOC32_SETRSVSZ _IOW('f', 6, int)
139 #define EXT3_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int)
140 #ifdef CONFIG_JBD_DEBUG
141 #define EXT3_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int)
142 #endif
144 #define EXT2_IOC32_GETVERSION _IOR('v', 1, int)
145 #define EXT2_IOC32_SETVERSION _IOW('v', 2, int)
147 static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
148 unsigned long arg, struct file *f)
149 {
150 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
151 }
153 static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
154 {
155 mm_segment_t old_fs = get_fs();
156 int err;
157 unsigned long val;
159 set_fs (KERNEL_DS);
160 err = sys_ioctl(fd, cmd, (unsigned long)&val);
161 set_fs (old_fs);
162 if (!err && put_user(val, (u32 __user *)compat_ptr(arg)))
163 return -EFAULT;
164 return err;
165 }
167 static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg)
168 {
169 mm_segment_t old_fs = get_fs();
170 u32 __user *argptr = compat_ptr(arg);
171 int err;
172 unsigned long val;
174 if(get_user(val, argptr))
175 return -EFAULT;
176 set_fs (KERNEL_DS);
177 err = sys_ioctl(fd, cmd, (unsigned long)&val);
178 set_fs (old_fs);
179 if (!err && put_user(val, argptr))
180 return -EFAULT;
181 return err;
182 }
184 static int do_ext2_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
185 {
186 /* These are just misnamed, they actually get/put from/to user an int */
187 switch (cmd) {
188 case EXT2_IOC32_GETFLAGS: cmd = EXT2_IOC_GETFLAGS; break;
189 case EXT2_IOC32_SETFLAGS: cmd = EXT2_IOC_SETFLAGS; break;
190 case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; break;
191 case EXT2_IOC32_SETVERSION: cmd = EXT2_IOC_SETVERSION; break;
192 }
193 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
194 }
196 static int do_ext3_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
197 {
198 /* These are just misnamed, they actually get/put from/to user an int */
199 switch (cmd) {
200 case EXT3_IOC32_GETVERSION: cmd = EXT3_IOC_GETVERSION; break;
201 case EXT3_IOC32_SETVERSION: cmd = EXT3_IOC_SETVERSION; break;
202 case EXT3_IOC32_GETRSVSZ: cmd = EXT3_IOC_GETRSVSZ; break;
203 case EXT3_IOC32_SETRSVSZ: cmd = EXT3_IOC_SETRSVSZ; break;
204 case EXT3_IOC32_GROUP_EXTEND: cmd = EXT3_IOC_GROUP_EXTEND; break;
205 #ifdef CONFIG_JBD_DEBUG
206 case EXT3_IOC32_WAIT_FOR_READONLY: cmd = EXT3_IOC_WAIT_FOR_READONLY; break;
207 #endif
208 }
209 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
210 }
212 struct compat_video_event {
213 int32_t type;
214 compat_time_t timestamp;
215 union {
216 video_size_t size;
217 unsigned int frame_rate;
218 } u;
219 };
221 static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long arg)
222 {
223 struct video_event kevent;
224 mm_segment_t old_fs = get_fs();
225 int err;
227 set_fs(KERNEL_DS);
228 err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
229 set_fs(old_fs);
231 if (!err) {
232 struct compat_video_event __user *up = compat_ptr(arg);
234 err = put_user(kevent.type, &up->type);
235 err |= put_user(kevent.timestamp, &up->timestamp);
236 err |= put_user(kevent.u.size.w, &up->u.size.w);
237 err |= put_user(kevent.u.size.h, &up->u.size.h);
238 err |= put_user(kevent.u.size.aspect_ratio,
239 &up->u.size.aspect_ratio);
240 if (err)
241 err = -EFAULT;
242 }
244 return err;
245 }
247 struct compat_video_still_picture {
248 compat_uptr_t iFrame;
249 int32_t size;
250 };
252 static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned long arg)
253 {
254 struct compat_video_still_picture __user *up;
255 struct video_still_picture __user *up_native;
256 compat_uptr_t fp;
257 int32_t size;
258 int err;
260 up = (struct compat_video_still_picture __user *) arg;
261 err = get_user(fp, &up->iFrame);
262 err |= get_user(size, &up->size);
263 if (err)
264 return -EFAULT;
266 up_native =
267 compat_alloc_user_space(sizeof(struct video_still_picture));
269 put_user(compat_ptr(fp), &up_native->iFrame);
270 put_user(size, &up_native->size);
272 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
274 return err;
275 }
277 struct compat_video_spu_palette {
278 int length;
279 compat_uptr_t palette;
280 };
282 static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned long arg)
283 {
284 struct compat_video_spu_palette __user *up;
285 struct video_spu_palette __user *up_native;
286 compat_uptr_t palp;
287 int length, err;
289 up = (struct compat_video_spu_palette __user *) arg;
290 err = get_user(palp, &up->palette);
291 err |= get_user(length, &up->length);
293 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
294 put_user(compat_ptr(palp), &up_native->palette);
295 put_user(length, &up_native->length);
297 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
299 return err;
300 }
302 #ifdef CONFIG_NET
303 static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
304 {
305 struct compat_timeval __user *up = compat_ptr(arg);
306 struct timeval ktv;
307 mm_segment_t old_fs = get_fs();
308 int err;
310 set_fs(KERNEL_DS);
311 err = sys_ioctl(fd, cmd, (unsigned long)&ktv);
312 set_fs(old_fs);
313 if(!err) {
314 err = put_user(ktv.tv_sec, &up->tv_sec);
315 err |= __put_user(ktv.tv_usec, &up->tv_usec);
316 }
317 return err;
318 }
320 struct ifmap32 {
321 compat_ulong_t mem_start;
322 compat_ulong_t mem_end;
323 unsigned short base_addr;
324 unsigned char irq;
325 unsigned char dma;
326 unsigned char port;
327 };
329 struct ifreq32 {
330 #define IFHWADDRLEN 6
331 #define IFNAMSIZ 16
332 union {
333 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
334 } ifr_ifrn;
335 union {
336 struct sockaddr ifru_addr;
337 struct sockaddr ifru_dstaddr;
338 struct sockaddr ifru_broadaddr;
339 struct sockaddr ifru_netmask;
340 struct sockaddr ifru_hwaddr;
341 short ifru_flags;
342 compat_int_t ifru_ivalue;
343 compat_int_t ifru_mtu;
344 struct ifmap32 ifru_map;
345 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
346 char ifru_newname[IFNAMSIZ];
347 compat_caddr_t ifru_data;
348 /* XXXX? ifru_settings should be here */
349 } ifr_ifru;
350 };
352 struct ifconf32 {
353 compat_int_t ifc_len; /* size of buffer */
354 compat_caddr_t ifcbuf;
355 };
357 static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
358 {
359 struct net_device *dev;
360 struct ifreq32 ifr32;
361 int err;
363 if (copy_from_user(&ifr32, compat_ptr(arg), sizeof(ifr32)))
364 return -EFAULT;
366 dev = dev_get_by_index(ifr32.ifr_ifindex);
367 if (!dev)
368 return -ENODEV;
370 strlcpy(ifr32.ifr_name, dev->name, sizeof(ifr32.ifr_name));
371 dev_put(dev);
373 err = copy_to_user(compat_ptr(arg), &ifr32, sizeof(ifr32));
374 return (err ? -EFAULT : 0);
375 }
377 static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)
378 {
379 struct ifconf32 ifc32;
380 struct ifconf ifc;
381 struct ifconf __user *uifc;
382 struct ifreq32 __user *ifr32;
383 struct ifreq __user *ifr;
384 unsigned int i, j;
385 int err;
387 if (copy_from_user(&ifc32, compat_ptr(arg), sizeof(struct ifconf32)))
388 return -EFAULT;
390 if (ifc32.ifcbuf == 0) {
391 ifc32.ifc_len = 0;
392 ifc.ifc_len = 0;
393 ifc.ifc_req = NULL;
394 uifc = compat_alloc_user_space(sizeof(struct ifconf));
395 } else {
396 size_t len =((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) *
397 sizeof (struct ifreq);
398 uifc = compat_alloc_user_space(sizeof(struct ifconf) + len);
399 ifc.ifc_len = len;
400 ifr = ifc.ifc_req = (void __user *)(uifc + 1);
401 ifr32 = compat_ptr(ifc32.ifcbuf);
402 for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) {
403 if (copy_in_user(ifr, ifr32, sizeof(struct ifreq32)))
404 return -EFAULT;
405 ifr++;
406 ifr32++;
407 }
408 }
409 if (copy_to_user(uifc, &ifc, sizeof(struct ifconf)))
410 return -EFAULT;
412 err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)uifc);
413 if (err)
414 return err;
416 if (copy_from_user(&ifc, uifc, sizeof(struct ifconf)))
417 return -EFAULT;
419 ifr = ifc.ifc_req;
420 ifr32 = compat_ptr(ifc32.ifcbuf);
421 for (i = 0, j = 0;
422 i + sizeof (struct ifreq32) <= ifc32.ifc_len && j < ifc.ifc_len;
423 i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
424 if (copy_in_user(ifr32, ifr, sizeof (struct ifreq32)))
425 return -EFAULT;
426 ifr32++;
427 ifr++;
428 }
430 if (ifc32.ifcbuf == 0) {
431 /* Translate from 64-bit structure multiple to
432 * a 32-bit one.
433 */
434 i = ifc.ifc_len;
435 i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32));
436 ifc32.ifc_len = i;
437 } else {
438 ifc32.ifc_len = i;
439 }
440 if (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32)))
441 return -EFAULT;
443 return 0;
444 }
446 static int ethtool_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
447 {
448 struct ifreq __user *ifr;
449 struct ifreq32 __user *ifr32;
450 u32 data;
451 void __user *datap;
453 ifr = compat_alloc_user_space(sizeof(*ifr));
454 ifr32 = compat_ptr(arg);
456 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
457 return -EFAULT;
459 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
460 return -EFAULT;
462 datap = compat_ptr(data);
463 if (put_user(datap, &ifr->ifr_ifru.ifru_data))
464 return -EFAULT;
466 return sys_ioctl(fd, cmd, (unsigned long) ifr);
467 }
469 static int bond_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
470 {
471 struct ifreq kifr;
472 struct ifreq __user *uifr;
473 struct ifreq32 __user *ifr32 = compat_ptr(arg);
474 mm_segment_t old_fs;
475 int err;
476 u32 data;
477 void __user *datap;
479 switch (cmd) {
480 case SIOCBONDENSLAVE:
481 case SIOCBONDRELEASE:
482 case SIOCBONDSETHWADDR:
483 case SIOCBONDCHANGEACTIVE:
484 if (copy_from_user(&kifr, ifr32, sizeof(struct ifreq32)))
485 return -EFAULT;
487 old_fs = get_fs();
488 set_fs (KERNEL_DS);
489 err = sys_ioctl (fd, cmd, (unsigned long)&kifr);
490 set_fs (old_fs);
492 return err;
493 case SIOCBONDSLAVEINFOQUERY:
494 case SIOCBONDINFOQUERY:
495 uifr = compat_alloc_user_space(sizeof(*uifr));
496 if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
497 return -EFAULT;
499 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
500 return -EFAULT;
502 datap = compat_ptr(data);
503 if (put_user(datap, &uifr->ifr_ifru.ifru_data))
504 return -EFAULT;
506 return sys_ioctl (fd, cmd, (unsigned long)uifr);
507 default:
508 return -EINVAL;
509 };
510 }
512 int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
513 {
514 struct ifreq __user *u_ifreq64;
515 struct ifreq32 __user *u_ifreq32 = compat_ptr(arg);
516 char tmp_buf[IFNAMSIZ];
517 void __user *data64;
518 u32 data32;
520 if (copy_from_user(&tmp_buf[0], &(u_ifreq32->ifr_ifrn.ifrn_name[0]),
521 IFNAMSIZ))
522 return -EFAULT;
523 if (__get_user(data32, &u_ifreq32->ifr_ifru.ifru_data))
524 return -EFAULT;
525 data64 = compat_ptr(data32);
527 u_ifreq64 = compat_alloc_user_space(sizeof(*u_ifreq64));
529 /* Don't check these user accesses, just let that get trapped
530 * in the ioctl handler instead.
531 */
532 if (copy_to_user(&u_ifreq64->ifr_ifrn.ifrn_name[0], &tmp_buf[0],
533 IFNAMSIZ))
534 return -EFAULT;
535 if (__put_user(data64, &u_ifreq64->ifr_ifru.ifru_data))
536 return -EFAULT;
538 return sys_ioctl(fd, cmd, (unsigned long) u_ifreq64);
539 }
541 static int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg)
542 {
543 struct ifreq ifr;
544 struct ifreq32 __user *uifr32;
545 struct ifmap32 __user *uifmap32;
546 mm_segment_t old_fs;
547 int err;
549 uifr32 = compat_ptr(arg);
550 uifmap32 = &uifr32->ifr_ifru.ifru_map;
551 switch (cmd) {
552 case SIOCSIFMAP:
553 err = copy_from_user(&ifr, uifr32, sizeof(ifr.ifr_name));
554 err |= __get_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
555 err |= __get_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
556 err |= __get_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
557 err |= __get_user(ifr.ifr_map.irq, &uifmap32->irq);
558 err |= __get_user(ifr.ifr_map.dma, &uifmap32->dma);
559 err |= __get_user(ifr.ifr_map.port, &uifmap32->port);
560 if (err)
561 return -EFAULT;
562 break;
563 default:
564 if (copy_from_user(&ifr, uifr32, sizeof(*uifr32)))
565 return -EFAULT;
566 break;
567 }
568 old_fs = get_fs();
569 set_fs (KERNEL_DS);
570 err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
571 set_fs (old_fs);
572 if (!err) {
573 switch (cmd) {
574 /* TUNSETIFF is defined as _IOW, it should be _IORW
575 * as the data is copied back to user space, but that
576 * cannot be fixed without breaking all existing apps.
577 */
578 case TUNSETIFF:
579 case SIOCGIFFLAGS:
580 case SIOCGIFMETRIC:
581 case SIOCGIFMTU:
582 case SIOCGIFMEM:
583 case SIOCGIFHWADDR:
584 case SIOCGIFINDEX:
585 case SIOCGIFADDR:
586 case SIOCGIFBRDADDR:
587 case SIOCGIFDSTADDR:
588 case SIOCGIFNETMASK:
589 case SIOCGIFTXQLEN:
590 if (copy_to_user(uifr32, &ifr, sizeof(*uifr32)))
591 return -EFAULT;
592 break;
593 case SIOCGIFMAP:
594 err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name));
595 err |= __put_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
596 err |= __put_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
597 err |= __put_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
598 err |= __put_user(ifr.ifr_map.irq, &uifmap32->irq);
599 err |= __put_user(ifr.ifr_map.dma, &uifmap32->dma);
600 err |= __put_user(ifr.ifr_map.port, &uifmap32->port);
601 if (err)
602 err = -EFAULT;
603 break;
604 }
605 }
606 return err;
607 }
609 struct rtentry32 {
610 u32 rt_pad1;
611 struct sockaddr rt_dst; /* target address */
612 struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
613 struct sockaddr rt_genmask; /* target network mask (IP) */
614 unsigned short rt_flags;
615 short rt_pad2;
616 u32 rt_pad3;
617 unsigned char rt_tos;
618 unsigned char rt_class;
619 short rt_pad4;
620 short rt_metric; /* +1 for binary compatibility! */
621 /* char * */ u32 rt_dev; /* forcing the device at add */
622 u32 rt_mtu; /* per route MTU/Window */
623 u32 rt_window; /* Window clamping */
624 unsigned short rt_irtt; /* Initial RTT */
626 };
628 struct in6_rtmsg32 {
629 struct in6_addr rtmsg_dst;
630 struct in6_addr rtmsg_src;
631 struct in6_addr rtmsg_gateway;
632 u32 rtmsg_type;
633 u16 rtmsg_dst_len;
634 u16 rtmsg_src_len;
635 u32 rtmsg_metric;
636 u32 rtmsg_info;
637 u32 rtmsg_flags;
638 s32 rtmsg_ifindex;
639 };
641 static int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
642 {
643 int ret;
644 void *r = NULL;
645 struct in6_rtmsg r6;
646 struct rtentry r4;
647 char devname[16];
648 u32 rtdev;
649 mm_segment_t old_fs = get_fs();
651 struct socket *mysock = sockfd_lookup(fd, &ret);
653 if (mysock && mysock->sk && mysock->sk->sk_family == AF_INET6) { /* ipv6 */
654 struct in6_rtmsg32 __user *ur6 = compat_ptr(arg);
655 ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst),
656 3 * sizeof(struct in6_addr));
657 ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type));
658 ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len));
659 ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len));
660 ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric));
661 ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info));
662 ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags));
663 ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex));
665 r = (void *) &r6;
666 } else { /* ipv4 */
667 struct rtentry32 __user *ur4 = compat_ptr(arg);
668 ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst),
669 3 * sizeof(struct sockaddr));
670 ret |= __get_user (r4.rt_flags, &(ur4->rt_flags));
671 ret |= __get_user (r4.rt_metric, &(ur4->rt_metric));
672 ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu));
673 ret |= __get_user (r4.rt_window, &(ur4->rt_window));
674 ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt));
675 ret |= __get_user (rtdev, &(ur4->rt_dev));
676 if (rtdev) {
677 ret |= copy_from_user (devname, compat_ptr(rtdev), 15);
678 r4.rt_dev = devname; devname[15] = 0;
679 } else
680 r4.rt_dev = NULL;
682 r = (void *) &r4;
683 }
685 if (ret) {
686 ret = -EFAULT;
687 goto out;
688 }
690 set_fs (KERNEL_DS);
691 ret = sys_ioctl (fd, cmd, (unsigned long) r);
692 set_fs (old_fs);
694 out:
695 if (mysock)
696 sockfd_put(mysock);
698 return ret;
699 }
700 #endif
702 struct hd_geometry32 {
703 unsigned char heads;
704 unsigned char sectors;
705 unsigned short cylinders;
706 u32 start;
707 };
709 static int hdio_getgeo(unsigned int fd, unsigned int cmd, unsigned long arg)
710 {
711 mm_segment_t old_fs = get_fs();
712 struct hd_geometry geo;
713 struct hd_geometry32 __user *ugeo;
714 int err;
716 set_fs (KERNEL_DS);
717 err = sys_ioctl(fd, HDIO_GETGEO, (unsigned long)&geo);
718 set_fs (old_fs);
719 ugeo = compat_ptr(arg);
720 if (!err) {
721 err = copy_to_user (ugeo, &geo, 4);
722 err |= __put_user (geo.start, &ugeo->start);
723 }
724 return err ? -EFAULT : 0;
725 }
727 static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
728 {
729 mm_segment_t old_fs = get_fs();
730 unsigned long kval;
731 unsigned int __user *uvp;
732 int error;
734 set_fs(KERNEL_DS);
735 error = sys_ioctl(fd, cmd, (long)&kval);
736 set_fs(old_fs);
738 if(error == 0) {
739 uvp = compat_ptr(arg);
740 if(put_user(kval, uvp))
741 error = -EFAULT;
742 }
743 return error;
744 }
747 typedef struct sg_io_hdr32 {
748 compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */
749 compat_int_t dxfer_direction; /* [i] data transfer direction */
750 unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
751 unsigned char mx_sb_len; /* [i] max length to write to sbp */
752 unsigned short iovec_count; /* [i] 0 implies no scatter gather */
753 compat_uint_t dxfer_len; /* [i] byte count of data transfer */
754 compat_uint_t dxferp; /* [i], [*io] points to data transfer memory
755 or scatter gather list */
756 compat_uptr_t cmdp; /* [i], [*i] points to command to perform */
757 compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */
758 compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
759 compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */
760 compat_int_t pack_id; /* [i->o] unused internally (normally) */
761 compat_uptr_t usr_ptr; /* [i->o] unused internally */
762 unsigned char status; /* [o] scsi status */
763 unsigned char masked_status; /* [o] shifted, masked scsi status */
764 unsigned char msg_status; /* [o] messaging level data (optional) */
765 unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
766 unsigned short host_status; /* [o] errors from host adapter */
767 unsigned short driver_status; /* [o] errors from software driver */
768 compat_int_t resid; /* [o] dxfer_len - actual_transferred */
769 compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */
770 compat_uint_t info; /* [o] auxiliary information */
771 } sg_io_hdr32_t; /* 64 bytes long (on sparc32) */
773 typedef struct sg_iovec32 {
774 compat_uint_t iov_base;
775 compat_uint_t iov_len;
776 } sg_iovec32_t;
778 static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count)
779 {
780 sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1);
781 sg_iovec32_t __user *iov32 = dxferp;
782 int i;
784 for (i = 0; i < iovec_count; i++) {
785 u32 base, len;
787 if (get_user(base, &iov32[i].iov_base) ||
788 get_user(len, &iov32[i].iov_len) ||
789 put_user(compat_ptr(base), &iov[i].iov_base) ||
790 put_user(len, &iov[i].iov_len))
791 return -EFAULT;
792 }
794 if (put_user(iov, &sgio->dxferp))
795 return -EFAULT;
796 return 0;
797 }
799 static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
800 {
801 sg_io_hdr_t __user *sgio;
802 sg_io_hdr32_t __user *sgio32;
803 u16 iovec_count;
804 u32 data;
805 void __user *dxferp;
806 int err;
808 sgio32 = compat_ptr(arg);
809 if (get_user(iovec_count, &sgio32->iovec_count))
810 return -EFAULT;
812 {
813 void __user *top = compat_alloc_user_space(0);
814 void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) +
815 (iovec_count * sizeof(sg_iovec_t)));
816 if (new > top)
817 return -EINVAL;
819 sgio = new;
820 }
822 /* Ok, now construct. */
823 if (copy_in_user(&sgio->interface_id, &sgio32->interface_id,
824 (2 * sizeof(int)) +
825 (2 * sizeof(unsigned char)) +
826 (1 * sizeof(unsigned short)) +
827 (1 * sizeof(unsigned int))))
828 return -EFAULT;
830 if (get_user(data, &sgio32->dxferp))
831 return -EFAULT;
832 dxferp = compat_ptr(data);
833 if (iovec_count) {
834 if (sg_build_iovec(sgio, dxferp, iovec_count))
835 return -EFAULT;
836 } else {
837 if (put_user(dxferp, &sgio->dxferp))
838 return -EFAULT;
839 }
841 {
842 unsigned char __user *cmdp;
843 unsigned char __user *sbp;
845 if (get_user(data, &sgio32->cmdp))
846 return -EFAULT;
847 cmdp = compat_ptr(data);
849 if (get_user(data, &sgio32->sbp))
850 return -EFAULT;
851 sbp = compat_ptr(data);
853 if (put_user(cmdp, &sgio->cmdp) ||
854 put_user(sbp, &sgio->sbp))
855 return -EFAULT;
856 }
858 if (copy_in_user(&sgio->timeout, &sgio32->timeout,
859 3 * sizeof(int)))
860 return -EFAULT;
862 if (get_user(data, &sgio32->usr_ptr))
863 return -EFAULT;
864 if (put_user(compat_ptr(data), &sgio->usr_ptr))
865 return -EFAULT;
867 if (copy_in_user(&sgio->status, &sgio32->status,
868 (4 * sizeof(unsigned char)) +
869 (2 * sizeof(unsigned (short))) +
870 (3 * sizeof(int))))
871 return -EFAULT;
873 err = sys_ioctl(fd, cmd, (unsigned long) sgio);
875 if (err >= 0) {
876 void __user *datap;
878 if (copy_in_user(&sgio32->pack_id, &sgio->pack_id,
879 sizeof(int)) ||
880 get_user(datap, &sgio->usr_ptr) ||
881 put_user((u32)(unsigned long)datap,
882 &sgio32->usr_ptr) ||
883 copy_in_user(&sgio32->status, &sgio->status,
884 (4 * sizeof(unsigned char)) +
885 (2 * sizeof(unsigned short)) +
886 (3 * sizeof(int))))
887 err = -EFAULT;
888 }
890 return err;
891 }
893 struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
894 char req_state;
895 char orphan;
896 char sg_io_owned;
897 char problem;
898 int pack_id;
899 compat_uptr_t usr_ptr;
900 unsigned int duration;
901 int unused;
902 };
904 static int sg_grt_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
905 {
906 int err, i;
907 sg_req_info_t __user *r;
908 struct compat_sg_req_info __user *o = (void __user *)arg;
909 r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE);
910 err = sys_ioctl(fd,cmd,(unsigned long)r);
911 if (err < 0)
912 return err;
913 for (i = 0; i < SG_MAX_QUEUE; i++) {
914 void __user *ptr;
915 int d;
917 if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) ||
918 get_user(ptr, &r[i].usr_ptr) ||
919 get_user(d, &r[i].duration) ||
920 put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) ||
921 put_user(d, &o[i].duration))
922 return -EFAULT;
923 }
924 return err;
925 }
927 struct sock_fprog32 {
928 unsigned short len;
929 compat_caddr_t filter;
930 };
932 #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
933 #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
935 static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
936 {
937 struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg);
938 struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
939 void __user *fptr64;
940 u32 fptr32;
941 u16 flen;
943 if (get_user(flen, &u_fprog32->len) ||
944 get_user(fptr32, &u_fprog32->filter))
945 return -EFAULT;
947 fptr64 = compat_ptr(fptr32);
949 if (put_user(flen, &u_fprog64->len) ||
950 put_user(fptr64, &u_fprog64->filter))
951 return -EFAULT;
953 if (cmd == PPPIOCSPASS32)
954 cmd = PPPIOCSPASS;
955 else
956 cmd = PPPIOCSACTIVE;
958 return sys_ioctl(fd, cmd, (unsigned long) u_fprog64);
959 }
961 struct ppp_option_data32 {
962 compat_caddr_t ptr;
963 u32 length;
964 compat_int_t transmit;
965 };
966 #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
968 struct ppp_idle32 {
969 compat_time_t xmit_idle;
970 compat_time_t recv_idle;
971 };
972 #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
974 static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg)
975 {
976 struct ppp_idle __user *idle;
977 struct ppp_idle32 __user *idle32;
978 __kernel_time_t xmit, recv;
979 int err;
981 idle = compat_alloc_user_space(sizeof(*idle));
982 idle32 = compat_ptr(arg);
984 err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle);
986 if (!err) {
987 if (get_user(xmit, &idle->xmit_idle) ||
988 get_user(recv, &idle->recv_idle) ||
989 put_user(xmit, &idle32->xmit_idle) ||
990 put_user(recv, &idle32->recv_idle))
991 err = -EFAULT;
992 }
993 return err;
994 }
996 static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg)
997 {
998 struct ppp_option_data __user *odata;
999 struct ppp_option_data32 __user *odata32;
1000 __u32 data;
1001 void __user *datap;
1003 odata = compat_alloc_user_space(sizeof(*odata));
1004 odata32 = compat_ptr(arg);
1006 if (get_user(data, &odata32->ptr))
1007 return -EFAULT;
1009 datap = compat_ptr(data);
1010 if (put_user(datap, &odata->ptr))
1011 return -EFAULT;
1013 if (copy_in_user(&odata->length, &odata32->length,
1014 sizeof(__u32) + sizeof(int)))
1015 return -EFAULT;
1017 return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata);
1020 static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1022 int err;
1024 switch (cmd) {
1025 case PPPIOCGIDLE32:
1026 err = ppp_gidle(fd, cmd, arg);
1027 break;
1029 case PPPIOCSCOMPRESS32:
1030 err = ppp_scompress(fd, cmd, arg);
1031 break;
1033 default:
1034 do {
1035 static int count;
1036 if (++count <= 20)
1037 printk("ppp_ioctl: Unknown cmd fd(%d) "
1038 "cmd(%08x) arg(%08x)\n",
1039 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1040 } while(0);
1041 err = -EINVAL;
1042 break;
1043 };
1045 return err;
1049 struct mtget32 {
1050 compat_long_t mt_type;
1051 compat_long_t mt_resid;
1052 compat_long_t mt_dsreg;
1053 compat_long_t mt_gstat;
1054 compat_long_t mt_erreg;
1055 compat_daddr_t mt_fileno;
1056 compat_daddr_t mt_blkno;
1057 };
1058 #define MTIOCGET32 _IOR('m', 2, struct mtget32)
1060 struct mtpos32 {
1061 compat_long_t mt_blkno;
1062 };
1063 #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
1065 static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1067 mm_segment_t old_fs = get_fs();
1068 struct mtget get;
1069 struct mtget32 __user *umget32;
1070 struct mtpos pos;
1071 struct mtpos32 __user *upos32;
1072 unsigned long kcmd;
1073 void *karg;
1074 int err = 0;
1076 switch(cmd) {
1077 case MTIOCPOS32:
1078 kcmd = MTIOCPOS;
1079 karg = &pos;
1080 break;
1081 case MTIOCGET32:
1082 kcmd = MTIOCGET;
1083 karg = &get;
1084 break;
1085 default:
1086 do {
1087 static int count;
1088 if (++count <= 20)
1089 printk("mt_ioctl: Unknown cmd fd(%d) "
1090 "cmd(%08x) arg(%08x)\n",
1091 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1092 } while(0);
1093 return -EINVAL;
1095 set_fs (KERNEL_DS);
1096 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1097 set_fs (old_fs);
1098 if (err)
1099 return err;
1100 switch (cmd) {
1101 case MTIOCPOS32:
1102 upos32 = compat_ptr(arg);
1103 err = __put_user(pos.mt_blkno, &upos32->mt_blkno);
1104 break;
1105 case MTIOCGET32:
1106 umget32 = compat_ptr(arg);
1107 err = __put_user(get.mt_type, &umget32->mt_type);
1108 err |= __put_user(get.mt_resid, &umget32->mt_resid);
1109 err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg);
1110 err |= __put_user(get.mt_gstat, &umget32->mt_gstat);
1111 err |= __put_user(get.mt_erreg, &umget32->mt_erreg);
1112 err |= __put_user(get.mt_fileno, &umget32->mt_fileno);
1113 err |= __put_user(get.mt_blkno, &umget32->mt_blkno);
1114 break;
1116 return err ? -EFAULT: 0;
1119 struct cdrom_read_audio32 {
1120 union cdrom_addr addr;
1121 u8 addr_format;
1122 compat_int_t nframes;
1123 compat_caddr_t buf;
1124 };
1126 struct cdrom_generic_command32 {
1127 unsigned char cmd[CDROM_PACKET_SIZE];
1128 compat_caddr_t buffer;
1129 compat_uint_t buflen;
1130 compat_int_t stat;
1131 compat_caddr_t sense;
1132 unsigned char data_direction;
1133 compat_int_t quiet;
1134 compat_int_t timeout;
1135 compat_caddr_t reserved[1];
1136 };
1138 static int cdrom_do_read_audio(unsigned int fd, unsigned int cmd, unsigned long arg)
1140 struct cdrom_read_audio __user *cdread_audio;
1141 struct cdrom_read_audio32 __user *cdread_audio32;
1142 __u32 data;
1143 void __user *datap;
1145 cdread_audio = compat_alloc_user_space(sizeof(*cdread_audio));
1146 cdread_audio32 = compat_ptr(arg);
1148 if (copy_in_user(&cdread_audio->addr,
1149 &cdread_audio32->addr,
1150 (sizeof(*cdread_audio32) -
1151 sizeof(compat_caddr_t))))
1152 return -EFAULT;
1154 if (get_user(data, &cdread_audio32->buf))
1155 return -EFAULT;
1156 datap = compat_ptr(data);
1157 if (put_user(datap, &cdread_audio->buf))
1158 return -EFAULT;
1160 return sys_ioctl(fd, cmd, (unsigned long) cdread_audio);
1163 static int cdrom_do_generic_command(unsigned int fd, unsigned int cmd, unsigned long arg)
1165 struct cdrom_generic_command __user *cgc;
1166 struct cdrom_generic_command32 __user *cgc32;
1167 u32 data;
1168 unsigned char dir;
1169 int itmp;
1171 cgc = compat_alloc_user_space(sizeof(*cgc));
1172 cgc32 = compat_ptr(arg);
1174 if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) ||
1175 get_user(data, &cgc32->buffer) ||
1176 put_user(compat_ptr(data), &cgc->buffer) ||
1177 copy_in_user(&cgc->buflen, &cgc32->buflen,
1178 (sizeof(unsigned int) + sizeof(int))) ||
1179 get_user(data, &cgc32->sense) ||
1180 put_user(compat_ptr(data), &cgc->sense) ||
1181 get_user(dir, &cgc32->data_direction) ||
1182 put_user(dir, &cgc->data_direction) ||
1183 get_user(itmp, &cgc32->quiet) ||
1184 put_user(itmp, &cgc->quiet) ||
1185 get_user(itmp, &cgc32->timeout) ||
1186 put_user(itmp, &cgc->timeout) ||
1187 get_user(data, &cgc32->reserved[0]) ||
1188 put_user(compat_ptr(data), &cgc->reserved[0]))
1189 return -EFAULT;
1191 return sys_ioctl(fd, cmd, (unsigned long) cgc);
1194 static int cdrom_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1196 int err;
1198 switch(cmd) {
1199 case CDROMREADAUDIO:
1200 err = cdrom_do_read_audio(fd, cmd, arg);
1201 break;
1203 case CDROM_SEND_PACKET:
1204 err = cdrom_do_generic_command(fd, cmd, arg);
1205 break;
1207 default:
1208 do {
1209 static int count;
1210 if (++count <= 20)
1211 printk("cdrom_ioctl: Unknown cmd fd(%d) "
1212 "cmd(%08x) arg(%08x)\n",
1213 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1214 } while(0);
1215 err = -EINVAL;
1216 break;
1217 };
1219 return err;
1222 struct loop_info32 {
1223 compat_int_t lo_number; /* ioctl r/o */
1224 compat_dev_t lo_device; /* ioctl r/o */
1225 compat_ulong_t lo_inode; /* ioctl r/o */
1226 compat_dev_t lo_rdevice; /* ioctl r/o */
1227 compat_int_t lo_offset;
1228 compat_int_t lo_encrypt_type;
1229 compat_int_t lo_encrypt_key_size; /* ioctl w/o */
1230 compat_int_t lo_flags; /* ioctl r/o */
1231 char lo_name[LO_NAME_SIZE];
1232 unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
1233 compat_ulong_t lo_init[2];
1234 char reserved[4];
1235 };
1237 static int loop_status(unsigned int fd, unsigned int cmd, unsigned long arg)
1239 mm_segment_t old_fs = get_fs();
1240 struct loop_info l;
1241 struct loop_info32 __user *ul;
1242 int err = -EINVAL;
1244 ul = compat_ptr(arg);
1245 switch(cmd) {
1246 case LOOP_SET_STATUS:
1247 err = get_user(l.lo_number, &ul->lo_number);
1248 err |= __get_user(l.lo_device, &ul->lo_device);
1249 err |= __get_user(l.lo_inode, &ul->lo_inode);
1250 err |= __get_user(l.lo_rdevice, &ul->lo_rdevice);
1251 err |= __copy_from_user(&l.lo_offset, &ul->lo_offset,
1252 8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1253 if (err) {
1254 err = -EFAULT;
1255 } else {
1256 set_fs (KERNEL_DS);
1257 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1258 set_fs (old_fs);
1260 break;
1261 case LOOP_GET_STATUS:
1262 set_fs (KERNEL_DS);
1263 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1264 set_fs (old_fs);
1265 if (!err) {
1266 err = put_user(l.lo_number, &ul->lo_number);
1267 err |= __put_user(l.lo_device, &ul->lo_device);
1268 err |= __put_user(l.lo_inode, &ul->lo_inode);
1269 err |= __put_user(l.lo_rdevice, &ul->lo_rdevice);
1270 err |= __copy_to_user(&ul->lo_offset, &l.lo_offset,
1271 (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1272 if (err)
1273 err = -EFAULT;
1275 break;
1276 default: {
1277 static int count;
1278 if (++count <= 20)
1279 printk("%s: Unknown loop ioctl cmd, fd(%d) "
1280 "cmd(%08x) arg(%08lx)\n",
1281 __FUNCTION__, fd, cmd, arg);
1284 return err;
1287 extern int tty_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg);
1289 #ifdef CONFIG_VT
1291 static int vt_check(struct file *file)
1293 struct tty_struct *tty;
1294 struct inode *inode = file->f_dentry->d_inode;
1296 if (file->f_op->ioctl != tty_ioctl)
1297 return -EINVAL;
1299 tty = (struct tty_struct *)file->private_data;
1300 if (tty_paranoia_check(tty, inode, "tty_ioctl"))
1301 return -EINVAL;
1303 if (tty->driver->ioctl != vt_ioctl)
1304 return -EINVAL;
1306 /*
1307 * To have permissions to do most of the vt ioctls, we either have
1308 * to be the owner of the tty, or super-user.
1309 */
1310 if (current->signal->tty == tty || capable(CAP_SYS_ADMIN))
1311 return 1;
1312 return 0;
1315 struct consolefontdesc32 {
1316 unsigned short charcount; /* characters in font (256 or 512) */
1317 unsigned short charheight; /* scan lines per character (1-32) */
1318 compat_caddr_t chardata; /* font data in expanded form */
1319 };
1321 static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1323 struct consolefontdesc32 __user *user_cfd = compat_ptr(arg);
1324 struct console_font_op op;
1325 compat_caddr_t data;
1326 int i, perm;
1328 perm = vt_check(file);
1329 if (perm < 0) return perm;
1331 switch (cmd) {
1332 case PIO_FONTX:
1333 if (!perm)
1334 return -EPERM;
1335 op.op = KD_FONT_OP_SET;
1336 op.flags = 0;
1337 op.width = 8;
1338 if (get_user(op.height, &user_cfd->charheight) ||
1339 get_user(op.charcount, &user_cfd->charcount) ||
1340 get_user(data, &user_cfd->chardata))
1341 return -EFAULT;
1342 op.data = compat_ptr(data);
1343 return con_font_op(vc_cons[fg_console].d, &op);
1344 case GIO_FONTX:
1345 op.op = KD_FONT_OP_GET;
1346 op.flags = 0;
1347 op.width = 8;
1348 if (get_user(op.height, &user_cfd->charheight) ||
1349 get_user(op.charcount, &user_cfd->charcount) ||
1350 get_user(data, &user_cfd->chardata))
1351 return -EFAULT;
1352 if (!data)
1353 return 0;
1354 op.data = compat_ptr(data);
1355 i = con_font_op(vc_cons[fg_console].d, &op);
1356 if (i)
1357 return i;
1358 if (put_user(op.height, &user_cfd->charheight) ||
1359 put_user(op.charcount, &user_cfd->charcount) ||
1360 put_user((compat_caddr_t)(unsigned long)op.data,
1361 &user_cfd->chardata))
1362 return -EFAULT;
1363 return 0;
1365 return -EINVAL;
1368 struct console_font_op32 {
1369 compat_uint_t op; /* operation code KD_FONT_OP_* */
1370 compat_uint_t flags; /* KD_FONT_FLAG_* */
1371 compat_uint_t width, height; /* font size */
1372 compat_uint_t charcount;
1373 compat_caddr_t data; /* font data with height fixed to 32 */
1374 };
1376 static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1378 struct console_font_op op;
1379 struct console_font_op32 __user *fontop = compat_ptr(arg);
1380 int perm = vt_check(file), i;
1381 struct vc_data *vc;
1383 if (perm < 0) return perm;
1385 if (copy_from_user(&op, fontop, sizeof(struct console_font_op32)))
1386 return -EFAULT;
1387 if (!perm && op.op != KD_FONT_OP_GET)
1388 return -EPERM;
1389 op.data = compat_ptr(((struct console_font_op32 *)&op)->data);
1390 op.flags |= KD_FONT_FLAG_OLD;
1391 vc = ((struct tty_struct *)file->private_data)->driver_data;
1392 i = con_font_op(vc, &op);
1393 if (i)
1394 return i;
1395 ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
1396 if (copy_to_user(fontop, &op, sizeof(struct console_font_op32)))
1397 return -EFAULT;
1398 return 0;
1401 struct unimapdesc32 {
1402 unsigned short entry_ct;
1403 compat_caddr_t entries;
1404 };
1406 static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1408 struct unimapdesc32 tmp;
1409 struct unimapdesc32 __user *user_ud = compat_ptr(arg);
1410 int perm = vt_check(file);
1412 if (perm < 0) return perm;
1413 if (copy_from_user(&tmp, user_ud, sizeof tmp))
1414 return -EFAULT;
1415 switch (cmd) {
1416 case PIO_UNIMAP:
1417 if (!perm) return -EPERM;
1418 return con_set_unimap(vc_cons[fg_console].d, tmp.entry_ct, compat_ptr(tmp.entries));
1419 case GIO_UNIMAP:
1420 return con_get_unimap(vc_cons[fg_console].d, tmp.entry_ct, &(user_ud->entry_ct), compat_ptr(tmp.entries));
1422 return 0;
1425 #endif /* CONFIG_VT */
1427 static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg)
1429 mm_segment_t old_fs = get_fs();
1430 __kernel_uid_t kuid;
1431 int err;
1433 cmd = SMB_IOC_GETMOUNTUID;
1435 set_fs(KERNEL_DS);
1436 err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
1437 set_fs(old_fs);
1439 if (err >= 0)
1440 err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg));
1442 return err;
1445 struct atmif_sioc32 {
1446 compat_int_t number;
1447 compat_int_t length;
1448 compat_caddr_t arg;
1449 };
1451 struct atm_iobuf32 {
1452 compat_int_t length;
1453 compat_caddr_t buffer;
1454 };
1456 #define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32)
1457 #define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32)
1458 #define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32)
1459 #define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32)
1460 #define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32)
1461 #define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32)
1462 #define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32)
1463 #define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32)
1464 #define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32)
1465 #define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32)
1466 #define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32)
1467 #define ATM_SETESIF32 _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32)
1468 #define ATM_GETSTAT32 _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32)
1469 #define ATM_GETSTATZ32 _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32)
1470 #define ATM_GETLOOP32 _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32)
1471 #define ATM_SETLOOP32 _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32)
1472 #define ATM_QUERYLOOP32 _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32)
1474 static struct {
1475 unsigned int cmd32;
1476 unsigned int cmd;
1477 } atm_ioctl_map[] = {
1478 { ATM_GETLINKRATE32, ATM_GETLINKRATE },
1479 { ATM_GETNAMES32, ATM_GETNAMES },
1480 { ATM_GETTYPE32, ATM_GETTYPE },
1481 { ATM_GETESI32, ATM_GETESI },
1482 { ATM_GETADDR32, ATM_GETADDR },
1483 { ATM_RSTADDR32, ATM_RSTADDR },
1484 { ATM_ADDADDR32, ATM_ADDADDR },
1485 { ATM_DELADDR32, ATM_DELADDR },
1486 { ATM_GETCIRANGE32, ATM_GETCIRANGE },
1487 { ATM_SETCIRANGE32, ATM_SETCIRANGE },
1488 { ATM_SETESI32, ATM_SETESI },
1489 { ATM_SETESIF32, ATM_SETESIF },
1490 { ATM_GETSTAT32, ATM_GETSTAT },
1491 { ATM_GETSTATZ32, ATM_GETSTATZ },
1492 { ATM_GETLOOP32, ATM_GETLOOP },
1493 { ATM_SETLOOP32, ATM_SETLOOP },
1494 { ATM_QUERYLOOP32, ATM_QUERYLOOP }
1495 };
1497 #define NR_ATM_IOCTL ARRAY_SIZE(atm_ioctl_map)
1499 static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg)
1501 struct atm_iobuf __user *iobuf;
1502 struct atm_iobuf32 __user *iobuf32;
1503 u32 data;
1504 void __user *datap;
1505 int len, err;
1507 iobuf = compat_alloc_user_space(sizeof(*iobuf));
1508 iobuf32 = compat_ptr(arg);
1510 if (get_user(len, &iobuf32->length) ||
1511 get_user(data, &iobuf32->buffer))
1512 return -EFAULT;
1513 datap = compat_ptr(data);
1514 if (put_user(len, &iobuf->length) ||
1515 put_user(datap, &iobuf->buffer))
1516 return -EFAULT;
1518 err = sys_ioctl(fd, cmd, (unsigned long)iobuf);
1520 if (!err) {
1521 if (copy_in_user(&iobuf32->length, &iobuf->length,
1522 sizeof(int)))
1523 err = -EFAULT;
1526 return err;
1529 static int do_atmif_sioc(unsigned int fd, unsigned int cmd, unsigned long arg)
1531 struct atmif_sioc __user *sioc;
1532 struct atmif_sioc32 __user *sioc32;
1533 u32 data;
1534 void __user *datap;
1535 int err;
1537 sioc = compat_alloc_user_space(sizeof(*sioc));
1538 sioc32 = compat_ptr(arg);
1540 if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) ||
1541 get_user(data, &sioc32->arg))
1542 return -EFAULT;
1543 datap = compat_ptr(data);
1544 if (put_user(datap, &sioc->arg))
1545 return -EFAULT;
1547 err = sys_ioctl(fd, cmd, (unsigned long) sioc);
1549 if (!err) {
1550 if (copy_in_user(&sioc32->length, &sioc->length,
1551 sizeof(int)))
1552 err = -EFAULT;
1554 return err;
1557 static int do_atm_ioctl(unsigned int fd, unsigned int cmd32, unsigned long arg)
1559 int i;
1560 unsigned int cmd = 0;
1562 switch (cmd32) {
1563 case SONET_GETSTAT:
1564 case SONET_GETSTATZ:
1565 case SONET_GETDIAG:
1566 case SONET_SETDIAG:
1567 case SONET_CLRDIAG:
1568 case SONET_SETFRAMING:
1569 case SONET_GETFRAMING:
1570 case SONET_GETFRSENSE:
1571 return do_atmif_sioc(fd, cmd32, arg);
1574 for (i = 0; i < NR_ATM_IOCTL; i++) {
1575 if (cmd32 == atm_ioctl_map[i].cmd32) {
1576 cmd = atm_ioctl_map[i].cmd;
1577 break;
1580 if (i == NR_ATM_IOCTL)
1581 return -EINVAL;
1583 switch (cmd) {
1584 case ATM_GETNAMES:
1585 return do_atm_iobuf(fd, cmd, arg);
1587 case ATM_GETLINKRATE:
1588 case ATM_GETTYPE:
1589 case ATM_GETESI:
1590 case ATM_GETADDR:
1591 case ATM_RSTADDR:
1592 case ATM_ADDADDR:
1593 case ATM_DELADDR:
1594 case ATM_GETCIRANGE:
1595 case ATM_SETCIRANGE:
1596 case ATM_SETESI:
1597 case ATM_SETESIF:
1598 case ATM_GETSTAT:
1599 case ATM_GETSTATZ:
1600 case ATM_GETLOOP:
1601 case ATM_SETLOOP:
1602 case ATM_QUERYLOOP:
1603 return do_atmif_sioc(fd, cmd, arg);
1606 return -EINVAL;
1609 static __attribute_used__ int
1610 ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
1612 return -EINVAL;
1615 static int broken_blkgetsize(unsigned int fd, unsigned int cmd, unsigned long arg)
1617 /* The mkswap binary hard codes it to Intel value :-((( */
1618 return w_long(fd, BLKGETSIZE, arg);
1621 struct blkpg_ioctl_arg32 {
1622 compat_int_t op;
1623 compat_int_t flags;
1624 compat_int_t datalen;
1625 compat_caddr_t data;
1626 };
1628 static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1630 struct blkpg_ioctl_arg32 __user *ua32 = compat_ptr(arg);
1631 struct blkpg_ioctl_arg __user *a = compat_alloc_user_space(sizeof(*a));
1632 compat_caddr_t udata;
1633 compat_int_t n;
1634 int err;
1636 err = get_user(n, &ua32->op);
1637 err |= put_user(n, &a->op);
1638 err |= get_user(n, &ua32->flags);
1639 err |= put_user(n, &a->flags);
1640 err |= get_user(n, &ua32->datalen);
1641 err |= put_user(n, &a->datalen);
1642 err |= get_user(udata, &ua32->data);
1643 err |= put_user(compat_ptr(udata), &a->data);
1644 if (err)
1645 return err;
1647 return sys_ioctl(fd, cmd, (unsigned long)a);
1650 static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
1652 return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
1655 /* Fix sizeof(sizeof()) breakage */
1656 #define BLKBSZGET_32 _IOR(0x12,112,int)
1657 #define BLKBSZSET_32 _IOW(0x12,113,int)
1658 #define BLKGETSIZE64_32 _IOR(0x12,114,int)
1660 static int do_blkbszget(unsigned int fd, unsigned int cmd, unsigned long arg)
1662 return sys_ioctl(fd, BLKBSZGET, (unsigned long)compat_ptr(arg));
1665 static int do_blkbszset(unsigned int fd, unsigned int cmd, unsigned long arg)
1667 return sys_ioctl(fd, BLKBSZSET, (unsigned long)compat_ptr(arg));
1670 static int do_blkgetsize64(unsigned int fd, unsigned int cmd,
1671 unsigned long arg)
1673 return sys_ioctl(fd, BLKGETSIZE64, (unsigned long)compat_ptr(arg));
1676 /* Bluetooth ioctls */
1677 #define HCIUARTSETPROTO _IOW('U', 200, int)
1678 #define HCIUARTGETPROTO _IOR('U', 201, int)
1680 #define BNEPCONNADD _IOW('B', 200, int)
1681 #define BNEPCONNDEL _IOW('B', 201, int)
1682 #define BNEPGETCONNLIST _IOR('B', 210, int)
1683 #define BNEPGETCONNINFO _IOR('B', 211, int)
1685 #define CMTPCONNADD _IOW('C', 200, int)
1686 #define CMTPCONNDEL _IOW('C', 201, int)
1687 #define CMTPGETCONNLIST _IOR('C', 210, int)
1688 #define CMTPGETCONNINFO _IOR('C', 211, int)
1690 #define HIDPCONNADD _IOW('H', 200, int)
1691 #define HIDPCONNDEL _IOW('H', 201, int)
1692 #define HIDPGETCONNLIST _IOR('H', 210, int)
1693 #define HIDPGETCONNINFO _IOR('H', 211, int)
1695 struct floppy_struct32 {
1696 compat_uint_t size;
1697 compat_uint_t sect;
1698 compat_uint_t head;
1699 compat_uint_t track;
1700 compat_uint_t stretch;
1701 unsigned char gap;
1702 unsigned char rate;
1703 unsigned char spec1;
1704 unsigned char fmt_gap;
1705 const compat_caddr_t name;
1706 };
1708 struct floppy_drive_params32 {
1709 char cmos;
1710 compat_ulong_t max_dtr;
1711 compat_ulong_t hlt;
1712 compat_ulong_t hut;
1713 compat_ulong_t srt;
1714 compat_ulong_t spinup;
1715 compat_ulong_t spindown;
1716 unsigned char spindown_offset;
1717 unsigned char select_delay;
1718 unsigned char rps;
1719 unsigned char tracks;
1720 compat_ulong_t timeout;
1721 unsigned char interleave_sect;
1722 struct floppy_max_errors max_errors;
1723 char flags;
1724 char read_track;
1725 short autodetect[8];
1726 compat_int_t checkfreq;
1727 compat_int_t native_format;
1728 };
1730 struct floppy_drive_struct32 {
1731 signed char flags;
1732 compat_ulong_t spinup_date;
1733 compat_ulong_t select_date;
1734 compat_ulong_t first_read_date;
1735 short probed_format;
1736 short track;
1737 short maxblock;
1738 short maxtrack;
1739 compat_int_t generation;
1740 compat_int_t keep_data;
1741 compat_int_t fd_ref;
1742 compat_int_t fd_device;
1743 compat_int_t last_checked;
1744 compat_caddr_t dmabuf;
1745 compat_int_t bufblocks;
1746 };
1748 struct floppy_fdc_state32 {
1749 compat_int_t spec1;
1750 compat_int_t spec2;
1751 compat_int_t dtr;
1752 unsigned char version;
1753 unsigned char dor;
1754 compat_ulong_t address;
1755 unsigned int rawcmd:2;
1756 unsigned int reset:1;
1757 unsigned int need_configure:1;
1758 unsigned int perp_mode:2;
1759 unsigned int has_fifo:1;
1760 unsigned int driver_version;
1761 unsigned char track[4];
1762 };
1764 struct floppy_write_errors32 {
1765 unsigned int write_errors;
1766 compat_ulong_t first_error_sector;
1767 compat_int_t first_error_generation;
1768 compat_ulong_t last_error_sector;
1769 compat_int_t last_error_generation;
1770 compat_uint_t badness;
1771 };
1773 #define FDSETPRM32 _IOW(2, 0x42, struct floppy_struct32)
1774 #define FDDEFPRM32 _IOW(2, 0x43, struct floppy_struct32)
1775 #define FDGETPRM32 _IOR(2, 0x04, struct floppy_struct32)
1776 #define FDSETDRVPRM32 _IOW(2, 0x90, struct floppy_drive_params32)
1777 #define FDGETDRVPRM32 _IOR(2, 0x11, struct floppy_drive_params32)
1778 #define FDGETDRVSTAT32 _IOR(2, 0x12, struct floppy_drive_struct32)
1779 #define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct floppy_drive_struct32)
1780 #define FDGETFDCSTAT32 _IOR(2, 0x15, struct floppy_fdc_state32)
1781 #define FDWERRORGET32 _IOR(2, 0x17, struct floppy_write_errors32)
1783 static struct {
1784 unsigned int cmd32;
1785 unsigned int cmd;
1786 } fd_ioctl_trans_table[] = {
1787 { FDSETPRM32, FDSETPRM },
1788 { FDDEFPRM32, FDDEFPRM },
1789 { FDGETPRM32, FDGETPRM },
1790 { FDSETDRVPRM32, FDSETDRVPRM },
1791 { FDGETDRVPRM32, FDGETDRVPRM },
1792 { FDGETDRVSTAT32, FDGETDRVSTAT },
1793 { FDPOLLDRVSTAT32, FDPOLLDRVSTAT },
1794 { FDGETFDCSTAT32, FDGETFDCSTAT },
1795 { FDWERRORGET32, FDWERRORGET }
1796 };
1798 #define NR_FD_IOCTL_TRANS ARRAY_SIZE(fd_ioctl_trans_table)
1800 static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1802 mm_segment_t old_fs = get_fs();
1803 void *karg = NULL;
1804 unsigned int kcmd = 0;
1805 int i, err;
1807 for (i = 0; i < NR_FD_IOCTL_TRANS; i++)
1808 if (cmd == fd_ioctl_trans_table[i].cmd32) {
1809 kcmd = fd_ioctl_trans_table[i].cmd;
1810 break;
1812 if (!kcmd)
1813 return -EINVAL;
1815 switch (cmd) {
1816 case FDSETPRM32:
1817 case FDDEFPRM32:
1818 case FDGETPRM32:
1820 compat_uptr_t name;
1821 struct floppy_struct32 __user *uf;
1822 struct floppy_struct *f;
1824 uf = compat_ptr(arg);
1825 f = karg = kmalloc(sizeof(struct floppy_struct), GFP_KERNEL);
1826 if (!karg)
1827 return -ENOMEM;
1828 if (cmd == FDGETPRM32)
1829 break;
1830 err = __get_user(f->size, &uf->size);
1831 err |= __get_user(f->sect, &uf->sect);
1832 err |= __get_user(f->head, &uf->head);
1833 err |= __get_user(f->track, &uf->track);
1834 err |= __get_user(f->stretch, &uf->stretch);
1835 err |= __get_user(f->gap, &uf->gap);
1836 err |= __get_user(f->rate, &uf->rate);
1837 err |= __get_user(f->spec1, &uf->spec1);
1838 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
1839 err |= __get_user(name, &uf->name);
1840 f->name = compat_ptr(name);
1841 if (err) {
1842 err = -EFAULT;
1843 goto out;
1845 break;
1847 case FDSETDRVPRM32:
1848 case FDGETDRVPRM32:
1850 struct floppy_drive_params32 __user *uf;
1851 struct floppy_drive_params *f;
1853 uf = compat_ptr(arg);
1854 f = karg = kmalloc(sizeof(struct floppy_drive_params), GFP_KERNEL);
1855 if (!karg)
1856 return -ENOMEM;
1857 if (cmd == FDGETDRVPRM32)
1858 break;
1859 err = __get_user(f->cmos, &uf->cmos);
1860 err |= __get_user(f->max_dtr, &uf->max_dtr);
1861 err |= __get_user(f->hlt, &uf->hlt);
1862 err |= __get_user(f->hut, &uf->hut);
1863 err |= __get_user(f->srt, &uf->srt);
1864 err |= __get_user(f->spinup, &uf->spinup);
1865 err |= __get_user(f->spindown, &uf->spindown);
1866 err |= __get_user(f->spindown_offset, &uf->spindown_offset);
1867 err |= __get_user(f->select_delay, &uf->select_delay);
1868 err |= __get_user(f->rps, &uf->rps);
1869 err |= __get_user(f->tracks, &uf->tracks);
1870 err |= __get_user(f->timeout, &uf->timeout);
1871 err |= __get_user(f->interleave_sect, &uf->interleave_sect);
1872 err |= __copy_from_user(&f->max_errors, &uf->max_errors, sizeof(f->max_errors));
1873 err |= __get_user(f->flags, &uf->flags);
1874 err |= __get_user(f->read_track, &uf->read_track);
1875 err |= __copy_from_user(f->autodetect, uf->autodetect, sizeof(f->autodetect));
1876 err |= __get_user(f->checkfreq, &uf->checkfreq);
1877 err |= __get_user(f->native_format, &uf->native_format);
1878 if (err) {
1879 err = -EFAULT;
1880 goto out;
1882 break;
1884 case FDGETDRVSTAT32:
1885 case FDPOLLDRVSTAT32:
1886 karg = kmalloc(sizeof(struct floppy_drive_struct), GFP_KERNEL);
1887 if (!karg)
1888 return -ENOMEM;
1889 break;
1890 case FDGETFDCSTAT32:
1891 karg = kmalloc(sizeof(struct floppy_fdc_state), GFP_KERNEL);
1892 if (!karg)
1893 return -ENOMEM;
1894 break;
1895 case FDWERRORGET32:
1896 karg = kmalloc(sizeof(struct floppy_write_errors), GFP_KERNEL);
1897 if (!karg)
1898 return -ENOMEM;
1899 break;
1900 default:
1901 return -EINVAL;
1903 set_fs (KERNEL_DS);
1904 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1905 set_fs (old_fs);
1906 if (err)
1907 goto out;
1908 switch (cmd) {
1909 case FDGETPRM32:
1911 struct floppy_struct *f = karg;
1912 struct floppy_struct32 __user *uf = compat_ptr(arg);
1914 err = __put_user(f->size, &uf->size);
1915 err |= __put_user(f->sect, &uf->sect);
1916 err |= __put_user(f->head, &uf->head);
1917 err |= __put_user(f->track, &uf->track);
1918 err |= __put_user(f->stretch, &uf->stretch);
1919 err |= __put_user(f->gap, &uf->gap);
1920 err |= __put_user(f->rate, &uf->rate);
1921 err |= __put_user(f->spec1, &uf->spec1);
1922 err |= __put_user(f->fmt_gap, &uf->fmt_gap);
1923 err |= __put_user((u64)f->name, (compat_caddr_t __user *)&uf->name);
1924 break;
1926 case FDGETDRVPRM32:
1928 struct floppy_drive_params32 __user *uf;
1929 struct floppy_drive_params *f = karg;
1931 uf = compat_ptr(arg);
1932 err = __put_user(f->cmos, &uf->cmos);
1933 err |= __put_user(f->max_dtr, &uf->max_dtr);
1934 err |= __put_user(f->hlt, &uf->hlt);
1935 err |= __put_user(f->hut, &uf->hut);
1936 err |= __put_user(f->srt, &uf->srt);
1937 err |= __put_user(f->spinup, &uf->spinup);
1938 err |= __put_user(f->spindown, &uf->spindown);
1939 err |= __put_user(f->spindown_offset, &uf->spindown_offset);
1940 err |= __put_user(f->select_delay, &uf->select_delay);
1941 err |= __put_user(f->rps, &uf->rps);
1942 err |= __put_user(f->tracks, &uf->tracks);
1943 err |= __put_user(f->timeout, &uf->timeout);
1944 err |= __put_user(f->interleave_sect, &uf->interleave_sect);
1945 err |= __copy_to_user(&uf->max_errors, &f->max_errors, sizeof(f->max_errors));
1946 err |= __put_user(f->flags, &uf->flags);
1947 err |= __put_user(f->read_track, &uf->read_track);
1948 err |= __copy_to_user(uf->autodetect, f->autodetect, sizeof(f->autodetect));
1949 err |= __put_user(f->checkfreq, &uf->checkfreq);
1950 err |= __put_user(f->native_format, &uf->native_format);
1951 break;
1953 case FDGETDRVSTAT32:
1954 case FDPOLLDRVSTAT32:
1956 struct floppy_drive_struct32 __user *uf;
1957 struct floppy_drive_struct *f = karg;
1959 uf = compat_ptr(arg);
1960 err = __put_user(f->flags, &uf->flags);
1961 err |= __put_user(f->spinup_date, &uf->spinup_date);
1962 err |= __put_user(f->select_date, &uf->select_date);
1963 err |= __put_user(f->first_read_date, &uf->first_read_date);
1964 err |= __put_user(f->probed_format, &uf->probed_format);
1965 err |= __put_user(f->track, &uf->track);
1966 err |= __put_user(f->maxblock, &uf->maxblock);
1967 err |= __put_user(f->maxtrack, &uf->maxtrack);
1968 err |= __put_user(f->generation, &uf->generation);
1969 err |= __put_user(f->keep_data, &uf->keep_data);
1970 err |= __put_user(f->fd_ref, &uf->fd_ref);
1971 err |= __put_user(f->fd_device, &uf->fd_device);
1972 err |= __put_user(f->last_checked, &uf->last_checked);
1973 err |= __put_user((u64)f->dmabuf, &uf->dmabuf);
1974 err |= __put_user((u64)f->bufblocks, &uf->bufblocks);
1975 break;
1977 case FDGETFDCSTAT32:
1979 struct floppy_fdc_state32 __user *uf;
1980 struct floppy_fdc_state *f = karg;
1982 uf = compat_ptr(arg);
1983 err = __put_user(f->spec1, &uf->spec1);
1984 err |= __put_user(f->spec2, &uf->spec2);
1985 err |= __put_user(f->dtr, &uf->dtr);
1986 err |= __put_user(f->version, &uf->version);
1987 err |= __put_user(f->dor, &uf->dor);
1988 err |= __put_user(f->address, &uf->address);
1989 err |= __copy_to_user((char __user *)&uf->address + sizeof(uf->address),
1990 (char *)&f->address + sizeof(f->address), sizeof(int));
1991 err |= __put_user(f->driver_version, &uf->driver_version);
1992 err |= __copy_to_user(uf->track, f->track, sizeof(f->track));
1993 break;
1995 case FDWERRORGET32:
1997 struct floppy_write_errors32 __user *uf;
1998 struct floppy_write_errors *f = karg;
2000 uf = compat_ptr(arg);
2001 err = __put_user(f->write_errors, &uf->write_errors);
2002 err |= __put_user(f->first_error_sector, &uf->first_error_sector);
2003 err |= __put_user(f->first_error_generation, &uf->first_error_generation);
2004 err |= __put_user(f->last_error_sector, &uf->last_error_sector);
2005 err |= __put_user(f->last_error_generation, &uf->last_error_generation);
2006 err |= __put_user(f->badness, &uf->badness);
2007 break;
2009 default:
2010 break;
2012 if (err)
2013 err = -EFAULT;
2015 out:
2016 kfree(karg);
2017 return err;
2020 struct mtd_oob_buf32 {
2021 u_int32_t start;
2022 u_int32_t length;
2023 compat_caddr_t ptr; /* unsigned char* */
2024 };
2026 #define MEMWRITEOOB32 _IOWR('M',3,struct mtd_oob_buf32)
2027 #define MEMREADOOB32 _IOWR('M',4,struct mtd_oob_buf32)
2029 static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg)
2031 struct mtd_oob_buf __user *buf = compat_alloc_user_space(sizeof(*buf));
2032 struct mtd_oob_buf32 __user *buf32 = compat_ptr(arg);
2033 u32 data;
2034 char __user *datap;
2035 unsigned int real_cmd;
2036 int err;
2038 real_cmd = (cmd == MEMREADOOB32) ?
2039 MEMREADOOB : MEMWRITEOOB;
2041 if (copy_in_user(&buf->start, &buf32->start,
2042 2 * sizeof(u32)) ||
2043 get_user(data, &buf32->ptr))
2044 return -EFAULT;
2045 datap = compat_ptr(data);
2046 if (put_user(datap, &buf->ptr))
2047 return -EFAULT;
2049 err = sys_ioctl(fd, real_cmd, (unsigned long) buf);
2051 if (!err) {
2052 if (copy_in_user(&buf32->start, &buf->start,
2053 2 * sizeof(u32)))
2054 err = -EFAULT;
2057 return err;
2060 #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
2061 #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
2063 static long
2064 put_dirent32 (struct dirent *d, struct compat_dirent __user *d32)
2066 if (!access_ok(VERIFY_WRITE, d32, sizeof(struct compat_dirent)))
2067 return -EFAULT;
2069 __put_user(d->d_ino, &d32->d_ino);
2070 __put_user(d->d_off, &d32->d_off);
2071 __put_user(d->d_reclen, &d32->d_reclen);
2072 if (__copy_to_user(d32->d_name, d->d_name, d->d_reclen))
2073 return -EFAULT;
2075 return 0;
2078 static int vfat_ioctl32(unsigned fd, unsigned cmd, unsigned long arg)
2080 struct compat_dirent __user *p = compat_ptr(arg);
2081 int ret;
2082 mm_segment_t oldfs = get_fs();
2083 struct dirent d[2];
2085 switch(cmd)
2087 case VFAT_IOCTL_READDIR_BOTH32:
2088 cmd = VFAT_IOCTL_READDIR_BOTH;
2089 break;
2090 case VFAT_IOCTL_READDIR_SHORT32:
2091 cmd = VFAT_IOCTL_READDIR_SHORT;
2092 break;
2095 set_fs(KERNEL_DS);
2096 ret = sys_ioctl(fd,cmd,(unsigned long)&d);
2097 set_fs(oldfs);
2098 if (ret >= 0) {
2099 ret |= put_dirent32(&d[0], p);
2100 ret |= put_dirent32(&d[1], p + 1);
2102 return ret;
2105 #define REISERFS_IOC_UNPACK32 _IOW(0xCD,1,int)
2107 static int reiserfs_ioctl32(unsigned fd, unsigned cmd, unsigned long ptr)
2109 if (cmd == REISERFS_IOC_UNPACK32)
2110 cmd = REISERFS_IOC_UNPACK;
2112 return sys_ioctl(fd,cmd,ptr);
2115 struct raw32_config_request
2117 compat_int_t raw_minor;
2118 __u64 block_major;
2119 __u64 block_minor;
2120 } __attribute__((packed));
2122 static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
2124 int ret;
2126 if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request)))
2127 return -EFAULT;
2129 ret = __get_user(req->raw_minor, &user_req->raw_minor);
2130 ret |= __get_user(req->block_major, &user_req->block_major);
2131 ret |= __get_user(req->block_minor, &user_req->block_minor);
2133 return ret ? -EFAULT : 0;
2136 static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
2138 int ret;
2140 if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request)))
2141 return -EFAULT;
2143 ret = __put_user(req->raw_minor, &user_req->raw_minor);
2144 ret |= __put_user(req->block_major, &user_req->block_major);
2145 ret |= __put_user(req->block_minor, &user_req->block_minor);
2147 return ret ? -EFAULT : 0;
2150 static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2152 int ret;
2154 switch (cmd) {
2155 case RAW_SETBIND:
2156 case RAW_GETBIND: {
2157 struct raw_config_request req;
2158 struct raw32_config_request __user *user_req = compat_ptr(arg);
2159 mm_segment_t oldfs = get_fs();
2161 if ((ret = get_raw32_request(&req, user_req)))
2162 return ret;
2164 set_fs(KERNEL_DS);
2165 ret = sys_ioctl(fd,cmd,(unsigned long)&req);
2166 set_fs(oldfs);
2168 if ((!ret) && (cmd == RAW_GETBIND)) {
2169 ret = set_raw32_request(&req, user_req);
2171 break;
2173 default:
2174 ret = sys_ioctl(fd, cmd, arg);
2175 break;
2177 return ret;
2180 struct serial_struct32 {
2181 compat_int_t type;
2182 compat_int_t line;
2183 compat_uint_t port;
2184 compat_int_t irq;
2185 compat_int_t flags;
2186 compat_int_t xmit_fifo_size;
2187 compat_int_t custom_divisor;
2188 compat_int_t baud_base;
2189 unsigned short close_delay;
2190 char io_type;
2191 char reserved_char[1];
2192 compat_int_t hub6;
2193 unsigned short closing_wait; /* time to wait before closing */
2194 unsigned short closing_wait2; /* no longer used... */
2195 compat_uint_t iomem_base;
2196 unsigned short iomem_reg_shift;
2197 unsigned int port_high;
2198 /* compat_ulong_t iomap_base FIXME */
2199 compat_int_t reserved[1];
2200 };
2202 static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2204 typedef struct serial_struct SS;
2205 typedef struct serial_struct32 SS32;
2206 struct serial_struct32 __user *ss32 = compat_ptr(arg);
2207 int err;
2208 struct serial_struct ss;
2209 mm_segment_t oldseg = get_fs();
2210 __u32 udata;
2212 if (cmd == TIOCSSERIAL) {
2213 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
2214 return -EFAULT;
2215 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
2216 return -EFAULT;
2217 __get_user(udata, &ss32->iomem_base);
2218 ss.iomem_base = compat_ptr(udata);
2219 __get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift);
2220 __get_user(ss.port_high, &ss32->port_high);
2221 ss.iomap_base = 0UL;
2223 set_fs(KERNEL_DS);
2224 err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
2225 set_fs(oldseg);
2226 if (cmd == TIOCGSERIAL && err >= 0) {
2227 if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32)))
2228 return -EFAULT;
2229 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
2230 return -EFAULT;
2231 __put_user((unsigned long)ss.iomem_base >> 32 ?
2232 0xffffffff : (unsigned)(unsigned long)ss.iomem_base,
2233 &ss32->iomem_base);
2234 __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift);
2235 __put_user(ss.port_high, &ss32->port_high);
2238 return err;
2241 struct usbdevfs_ctrltransfer32 {
2242 u8 bRequestType;
2243 u8 bRequest;
2244 u16 wValue;
2245 u16 wIndex;
2246 u16 wLength;
2247 u32 timeout; /* in milliseconds */
2248 compat_caddr_t data;
2249 };
2251 #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
2253 static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
2255 struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg);
2256 struct usbdevfs_ctrltransfer __user *p;
2257 __u32 udata;
2258 p = compat_alloc_user_space(sizeof(*p));
2259 if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
2260 get_user(udata, &p32->data) ||
2261 put_user(compat_ptr(udata), &p->data))
2262 return -EFAULT;
2263 return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p);
2267 struct usbdevfs_bulktransfer32 {
2268 compat_uint_t ep;
2269 compat_uint_t len;
2270 compat_uint_t timeout; /* in milliseconds */
2271 compat_caddr_t data;
2272 };
2274 #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
2276 static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
2278 struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg);
2279 struct usbdevfs_bulktransfer __user *p;
2280 compat_uint_t n;
2281 compat_caddr_t addr;
2283 p = compat_alloc_user_space(sizeof(*p));
2285 if (get_user(n, &p32->ep) || put_user(n, &p->ep) ||
2286 get_user(n, &p32->len) || put_user(n, &p->len) ||
2287 get_user(n, &p32->timeout) || put_user(n, &p->timeout) ||
2288 get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data))
2289 return -EFAULT;
2291 return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p);
2295 /*
2296 * USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY
2297 * are handled in usbdevfs core. -Christopher Li
2298 */
2300 struct usbdevfs_disconnectsignal32 {
2301 compat_int_t signr;
2302 compat_caddr_t context;
2303 };
2305 #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
2307 static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
2309 struct usbdevfs_disconnectsignal kdis;
2310 struct usbdevfs_disconnectsignal32 __user *udis;
2311 mm_segment_t old_fs;
2312 u32 uctx;
2313 int err;
2315 udis = compat_ptr(arg);
2317 if (get_user(kdis.signr, &udis->signr) ||
2318 __get_user(uctx, &udis->context))
2319 return -EFAULT;
2321 kdis.context = compat_ptr(uctx);
2323 old_fs = get_fs();
2324 set_fs(KERNEL_DS);
2325 err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
2326 set_fs(old_fs);
2328 return err;
2331 /*
2332 * I2C layer ioctls
2333 */
2335 struct i2c_msg32 {
2336 u16 addr;
2337 u16 flags;
2338 u16 len;
2339 compat_caddr_t buf;
2340 };
2342 struct i2c_rdwr_ioctl_data32 {
2343 compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
2344 u32 nmsgs;
2345 };
2347 struct i2c_smbus_ioctl_data32 {
2348 u8 read_write;
2349 u8 command;
2350 u32 size;
2351 compat_caddr_t data; /* union i2c_smbus_data *data */
2352 };
2354 struct i2c_rdwr_aligned {
2355 struct i2c_rdwr_ioctl_data cmd;
2356 struct i2c_msg msgs[0];
2357 };
2359 static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2361 struct i2c_rdwr_ioctl_data32 __user *udata = compat_ptr(arg);
2362 struct i2c_rdwr_aligned __user *tdata;
2363 struct i2c_msg __user *tmsgs;
2364 struct i2c_msg32 __user *umsgs;
2365 compat_caddr_t datap;
2366 int nmsgs, i;
2368 if (get_user(nmsgs, &udata->nmsgs))
2369 return -EFAULT;
2370 if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
2371 return -EINVAL;
2373 if (get_user(datap, &udata->msgs))
2374 return -EFAULT;
2375 umsgs = compat_ptr(datap);
2377 tdata = compat_alloc_user_space(sizeof(*tdata) +
2378 nmsgs * sizeof(struct i2c_msg));
2379 tmsgs = &tdata->msgs[0];
2381 if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
2382 put_user(tmsgs, &tdata->cmd.msgs))
2383 return -EFAULT;
2385 for (i = 0; i < nmsgs; i++) {
2386 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
2387 return -EFAULT;
2388 if (get_user(datap, &umsgs[i].buf) ||
2389 put_user(compat_ptr(datap), &tmsgs[i].buf))
2390 return -EFAULT;
2392 return sys_ioctl(fd, cmd, (unsigned long)tdata);
2395 static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2397 struct i2c_smbus_ioctl_data __user *tdata;
2398 struct i2c_smbus_ioctl_data32 __user *udata;
2399 compat_caddr_t datap;
2401 tdata = compat_alloc_user_space(sizeof(*tdata));
2402 if (tdata == NULL)
2403 return -ENOMEM;
2404 if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
2405 return -EFAULT;
2407 udata = compat_ptr(arg);
2408 if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
2409 return -EFAULT;
2411 if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
2412 return -EFAULT;
2413 if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
2414 return -EFAULT;
2415 if (__get_user(datap, &udata->data) ||
2416 __put_user(compat_ptr(datap), &tdata->data))
2417 return -EFAULT;
2419 return sys_ioctl(fd, cmd, (unsigned long)tdata);
2422 struct compat_iw_point {
2423 compat_caddr_t pointer;
2424 __u16 length;
2425 __u16 flags;
2426 };
2428 static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2430 struct iwreq __user *iwr;
2431 struct iwreq __user *iwr_u;
2432 struct iw_point __user *iwp;
2433 struct compat_iw_point __user *iwp_u;
2434 compat_caddr_t pointer;
2435 __u16 length, flags;
2437 iwr_u = compat_ptr(arg);
2438 iwp_u = (struct compat_iw_point __user *) &iwr_u->u.data;
2439 iwr = compat_alloc_user_space(sizeof(*iwr));
2440 if (iwr == NULL)
2441 return -ENOMEM;
2443 iwp = &iwr->u.data;
2445 if (!access_ok(VERIFY_WRITE, iwr, sizeof(*iwr)))
2446 return -EFAULT;
2448 if (__copy_in_user(&iwr->ifr_ifrn.ifrn_name[0],
2449 &iwr_u->ifr_ifrn.ifrn_name[0],
2450 sizeof(iwr->ifr_ifrn.ifrn_name)))
2451 return -EFAULT;
2453 if (__get_user(pointer, &iwp_u->pointer) ||
2454 __get_user(length, &iwp_u->length) ||
2455 __get_user(flags, &iwp_u->flags))
2456 return -EFAULT;
2458 if (__put_user(compat_ptr(pointer), &iwp->pointer) ||
2459 __put_user(length, &iwp->length) ||
2460 __put_user(flags, &iwp->flags))
2461 return -EFAULT;
2463 return sys_ioctl(fd, cmd, (unsigned long) iwr);
2466 /* Since old style bridge ioctl's endup using SIOCDEVPRIVATE
2467 * for some operations; this forces use of the newer bridge-utils that
2468 * use compatiable ioctls
2469 */
2470 static int old_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2472 u32 tmp;
2474 if (get_user(tmp, (u32 __user *) arg))
2475 return -EFAULT;
2476 if (tmp == BRCTL_GET_VERSION)
2477 return BRCTL_VERSION + 1;
2478 return -EINVAL;
2481 #define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
2482 #define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t)
2483 #define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
2484 #define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t)
2486 static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2488 mm_segment_t oldfs = get_fs();
2489 compat_ulong_t val32;
2490 unsigned long kval;
2491 int ret;
2493 switch (cmd) {
2494 case RTC_IRQP_READ32:
2495 case RTC_EPOCH_READ32:
2496 set_fs(KERNEL_DS);
2497 ret = sys_ioctl(fd, (cmd == RTC_IRQP_READ32) ?
2498 RTC_IRQP_READ : RTC_EPOCH_READ,
2499 (unsigned long)&kval);
2500 set_fs(oldfs);
2501 if (ret)
2502 return ret;
2503 val32 = kval;
2504 return put_user(val32, (unsigned int __user *)arg);
2505 case RTC_IRQP_SET32:
2506 return sys_ioctl(fd, RTC_IRQP_SET, arg);
2507 case RTC_EPOCH_SET32:
2508 return sys_ioctl(fd, RTC_EPOCH_SET, arg);
2509 default:
2510 /* unreached */
2511 return -ENOIOCTLCMD;
2515 #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
2516 struct ncp_ioctl_request_32 {
2517 u32 function;
2518 u32 size;
2519 compat_caddr_t data;
2520 };
2522 struct ncp_fs_info_v2_32 {
2523 s32 version;
2524 u32 mounted_uid;
2525 u32 connection;
2526 u32 buffer_size;
2528 u32 volume_number;
2529 u32 directory_id;
2531 u32 dummy1;
2532 u32 dummy2;
2533 u32 dummy3;
2534 };
2536 struct ncp_objectname_ioctl_32
2538 s32 auth_type;
2539 u32 object_name_len;
2540 compat_caddr_t object_name; /* an userspace data, in most cases user name */
2541 };
2543 struct ncp_privatedata_ioctl_32
2545 u32 len;
2546 compat_caddr_t data; /* ~1000 for NDS */
2547 };
2549 #define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct ncp_ioctl_request_32)
2550 #define NCP_IOC_GETMOUNTUID2_32 _IOW('n', 2, u32)
2551 #define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct ncp_fs_info_v2_32)
2552 #define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct ncp_objectname_ioctl_32)
2553 #define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct ncp_objectname_ioctl_32)
2554 #define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct ncp_privatedata_ioctl_32)
2555 #define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct ncp_privatedata_ioctl_32)
2557 static int do_ncp_ncprequest(unsigned int fd, unsigned int cmd, unsigned long arg)
2559 struct ncp_ioctl_request_32 n32;
2560 struct ncp_ioctl_request __user *p = compat_alloc_user_space(sizeof(*p));
2562 if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)) ||
2563 put_user(n32.function, &p->function) ||
2564 put_user(n32.size, &p->size) ||
2565 put_user(compat_ptr(n32.data), &p->data))
2566 return -EFAULT;
2568 return sys_ioctl(fd, NCP_IOC_NCPREQUEST, (unsigned long)p);
2571 static int do_ncp_getmountuid2(unsigned int fd, unsigned int cmd, unsigned long arg)
2573 mm_segment_t old_fs = get_fs();
2574 __kernel_uid_t kuid;
2575 int err;
2577 cmd = NCP_IOC_GETMOUNTUID2;
2579 set_fs(KERNEL_DS);
2580 err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
2581 set_fs(old_fs);
2583 if (!err)
2584 err = put_user(kuid,
2585 (unsigned int __user *) compat_ptr(arg));
2587 return err;
2590 static int do_ncp_getfsinfo2(unsigned int fd, unsigned int cmd, unsigned long arg)
2592 mm_segment_t old_fs = get_fs();
2593 struct ncp_fs_info_v2_32 n32;
2594 struct ncp_fs_info_v2 n;
2595 int err;
2597 if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)))
2598 return -EFAULT;
2599 if (n32.version != NCP_GET_FS_INFO_VERSION_V2)
2600 return -EINVAL;
2601 n.version = NCP_GET_FS_INFO_VERSION_V2;
2603 set_fs(KERNEL_DS);
2604 err = sys_ioctl(fd, NCP_IOC_GET_FS_INFO_V2, (unsigned long)&n);
2605 set_fs(old_fs);
2607 if (!err) {
2608 n32.version = n.version;
2609 n32.mounted_uid = n.mounted_uid;
2610 n32.connection = n.connection;
2611 n32.buffer_size = n.buffer_size;
2612 n32.volume_number = n.volume_number;
2613 n32.directory_id = n.directory_id;
2614 n32.dummy1 = n.dummy1;
2615 n32.dummy2 = n.dummy2;
2616 n32.dummy3 = n.dummy3;
2617 err = copy_to_user(compat_ptr(arg), &n32, sizeof(n32)) ? -EFAULT : 0;
2619 return err;
2622 static int do_ncp_getobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
2624 struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2625 struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
2626 s32 auth_type;
2627 u32 name_len;
2628 int err;
2630 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2631 put_user(n32.object_name_len, &p->object_name_len) ||
2632 put_user(compat_ptr(n32.object_name), &p->object_name))
2633 return -EFAULT;
2635 err = sys_ioctl(fd, NCP_IOC_GETOBJECTNAME, (unsigned long)p);
2636 if (err)
2637 return err;
2639 if (get_user(auth_type, &p->auth_type) ||
2640 put_user(auth_type, &p32->auth_type) ||
2641 get_user(name_len, &p->object_name_len) ||
2642 put_user(name_len, &p32->object_name_len))
2643 return -EFAULT;
2645 return 0;
2648 static int do_ncp_setobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
2650 struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2651 struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
2653 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2654 put_user(n32.auth_type, &p->auth_type) ||
2655 put_user(n32.object_name_len, &p->object_name_len) ||
2656 put_user(compat_ptr(n32.object_name), &p->object_name))
2657 return -EFAULT;
2659 return sys_ioctl(fd, NCP_IOC_SETOBJECTNAME, (unsigned long)p);
2662 static int do_ncp_getprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
2664 struct ncp_privatedata_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2665 struct ncp_privatedata_ioctl __user *p =
2666 compat_alloc_user_space(sizeof(*p));
2667 u32 len;
2668 int err;
2670 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2671 put_user(n32.len, &p->len) ||
2672 put_user(compat_ptr(n32.data), &p->data))
2673 return -EFAULT;
2675 err = sys_ioctl(fd, NCP_IOC_GETPRIVATEDATA, (unsigned long)p);
2676 if (err)
2677 return err;
2679 if (get_user(len, &p->len) ||
2680 put_user(len, &p32->len))
2681 return -EFAULT;
2683 return 0;
2686 static int do_ncp_setprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
2688 struct ncp_privatedata_ioctl_32 n32;
2689 struct ncp_privatedata_ioctl_32 __user *p32 = compat_ptr(arg);
2690 struct ncp_privatedata_ioctl __user *p =
2691 compat_alloc_user_space(sizeof(*p));
2693 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2694 put_user(n32.len, &p->len) ||
2695 put_user(compat_ptr(n32.data), &p->data))
2696 return -EFAULT;
2698 return sys_ioctl(fd, NCP_IOC_SETPRIVATEDATA, (unsigned long)p);
2700 #endif
2702 static int
2703 lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
2705 struct compat_timeval __user *tc = (struct compat_timeval __user *)arg;
2706 struct timeval __user *tn = compat_alloc_user_space(sizeof(struct timeval));
2707 struct timeval ts;
2708 if (get_user(ts.tv_sec, &tc->tv_sec) ||
2709 get_user(ts.tv_usec, &tc->tv_usec) ||
2710 put_user(ts.tv_sec, &tn->tv_sec) ||
2711 put_user(ts.tv_usec, &tn->tv_usec))
2712 return -EFAULT;
2713 return sys_ioctl(fd, cmd, (unsigned long)tn);
2716 #define HANDLE_IOCTL(cmd,handler) \
2717 { (cmd), (ioctl_trans_handler_t)(handler) },
2719 /* pointer to compatible structure or no argument */
2720 #define COMPATIBLE_IOCTL(cmd) \
2721 { (cmd), do_ioctl32_pointer },
2723 /* argument is an unsigned long integer, not a pointer */
2724 #define ULONG_IOCTL(cmd) \
2725 { (cmd), (ioctl_trans_handler_t)sys_ioctl },
2728 struct ioctl_trans ioctl_start[] = {
2729 #include <linux/compat_ioctl.h>
2730 HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob)
2731 HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob)
2732 #ifdef CONFIG_NET
2733 HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
2734 HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)
2735 HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc)
2736 HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc)
2737 HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc)
2738 HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc)
2739 HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc)
2740 HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc)
2741 HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc)
2742 HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc)
2743 HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc)
2744 HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc)
2745 HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc)
2746 HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc)
2747 HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc)
2748 HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc)
2749 HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
2750 HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
2751 HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
2753 /* ioctls used by appletalk ddp.c */
2754 HANDLE_IOCTL(SIOCATALKDIFADDR, dev_ifsioc)
2755 HANDLE_IOCTL(SIOCDIFADDR, dev_ifsioc)
2756 HANDLE_IOCTL(SIOCSARP, dev_ifsioc)
2757 HANDLE_IOCTL(SIOCDARP, dev_ifsioc)
2759 HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc)
2760 HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc)
2761 HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc)
2762 HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc)
2763 HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc)
2764 HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc)
2765 HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc)
2766 HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc)
2767 HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc)
2768 HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc)
2769 HANDLE_IOCTL(TUNSETIFF, dev_ifsioc)
2770 HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl)
2771 HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl)
2772 HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl)
2773 HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl)
2774 HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl)
2775 HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl)
2776 HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl)
2777 HANDLE_IOCTL(SIOCADDRT, routing_ioctl)
2778 HANDLE_IOCTL(SIOCDELRT, routing_ioctl)
2779 HANDLE_IOCTL(SIOCBRADDIF, dev_ifsioc)
2780 HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc)
2781 /* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
2782 HANDLE_IOCTL(SIOCRTMSG, ret_einval)
2783 HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
2784 #endif
2785 HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo)
2786 HANDLE_IOCTL(BLKRAGET, w_long)
2787 HANDLE_IOCTL(BLKGETSIZE, w_long)
2788 HANDLE_IOCTL(0x1260, broken_blkgetsize)
2789 HANDLE_IOCTL(BLKFRAGET, w_long)
2790 HANDLE_IOCTL(BLKSECTGET, w_long)
2791 HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
2792 HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans)
2793 HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans)
2794 HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans)
2795 HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans)
2796 HANDLE_IOCTL(HDIO_GET_MULTCOUNT, hdio_ioctl_trans)
2797 HANDLE_IOCTL(HDIO_GET_NOWERR, hdio_ioctl_trans)
2798 HANDLE_IOCTL(HDIO_GET_NICE, hdio_ioctl_trans)
2799 HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans)
2800 HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans)
2801 HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans)
2802 HANDLE_IOCTL(FDSETDRVPRM32, fd_ioctl_trans)
2803 HANDLE_IOCTL(FDGETDRVPRM32, fd_ioctl_trans)
2804 HANDLE_IOCTL(FDGETDRVSTAT32, fd_ioctl_trans)
2805 HANDLE_IOCTL(FDPOLLDRVSTAT32, fd_ioctl_trans)
2806 HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans)
2807 HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans)
2808 HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
2809 HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans)
2810 HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans)
2811 HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans)
2812 HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans)
2813 HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans)
2814 HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans)
2815 HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans)
2816 HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans)
2817 HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans)
2818 HANDLE_IOCTL(LOOP_SET_STATUS, loop_status)
2819 HANDLE_IOCTL(LOOP_GET_STATUS, loop_status)
2820 #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
2821 HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout)
2822 #ifdef CONFIG_VT
2823 HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl)
2824 HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl)
2825 HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl)
2826 HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl)
2827 HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl)
2828 #endif
2829 HANDLE_IOCTL(EXT2_IOC32_GETFLAGS, do_ext2_ioctl)
2830 HANDLE_IOCTL(EXT2_IOC32_SETFLAGS, do_ext2_ioctl)
2831 HANDLE_IOCTL(EXT2_IOC32_GETVERSION, do_ext2_ioctl)
2832 HANDLE_IOCTL(EXT2_IOC32_SETVERSION, do_ext2_ioctl)
2833 HANDLE_IOCTL(EXT3_IOC32_GETVERSION, do_ext3_ioctl)
2834 HANDLE_IOCTL(EXT3_IOC32_SETVERSION, do_ext3_ioctl)
2835 HANDLE_IOCTL(EXT3_IOC32_GETRSVSZ, do_ext3_ioctl)
2836 HANDLE_IOCTL(EXT3_IOC32_SETRSVSZ, do_ext3_ioctl)
2837 HANDLE_IOCTL(EXT3_IOC32_GROUP_EXTEND, do_ext3_ioctl)
2838 COMPATIBLE_IOCTL(EXT3_IOC_GROUP_ADD)
2839 #ifdef CONFIG_JBD_DEBUG
2840 HANDLE_IOCTL(EXT3_IOC32_WAIT_FOR_READONLY, do_ext3_ioctl)
2841 #endif
2842 /* One SMB ioctl needs translations. */
2843 #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
2844 HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
2845 HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl)
2846 HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl)
2847 HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl)
2848 HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl)
2849 HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl)
2850 HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl)
2851 HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl)
2852 HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl)
2853 HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl)
2854 HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl)
2855 HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl)
2856 HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl)
2857 HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl)
2858 HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl)
2859 HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl)
2860 HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl)
2861 HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl)
2862 HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl)
2863 HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl)
2864 HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl)
2865 HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl)
2866 HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl)
2867 HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl)
2868 HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl)
2869 HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl)
2870 /* block stuff */
2871 HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget)
2872 HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset)
2873 HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64)
2874 /* vfat */
2875 HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32)
2876 HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32, vfat_ioctl32)
2877 HANDLE_IOCTL(REISERFS_IOC_UNPACK32, reiserfs_ioctl32)
2878 /* Raw devices */
2879 HANDLE_IOCTL(RAW_SETBIND, raw_ioctl)
2880 HANDLE_IOCTL(RAW_GETBIND, raw_ioctl)
2881 /* Serial */
2882 HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl)
2883 HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl)
2884 #ifdef TIOCGLTC
2885 COMPATIBLE_IOCTL(TIOCGLTC)
2886 COMPATIBLE_IOCTL(TIOCSLTC)
2887 #endif
2888 #ifdef TIOCSTART
2889 /*
2890 * For these two we have defintions in ioctls.h and/or termios.h on
2891 * some architectures but no actual implemention. Some applications
2892 * like bash call them if they are defined in the headers, so we provide
2893 * entries here to avoid syslog message spew.
2894 */
2895 COMPATIBLE_IOCTL(TIOCSTART)
2896 COMPATIBLE_IOCTL(TIOCSTOP)
2897 #endif
2898 /* Usbdevfs */
2899 HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
2900 HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
2901 HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
2902 COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
2903 /* i2c */
2904 HANDLE_IOCTL(I2C_FUNCS, w_long)
2905 HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
2906 HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
2907 /* wireless */
2908 HANDLE_IOCTL(SIOCGIWRANGE, do_wireless_ioctl)
2909 HANDLE_IOCTL(SIOCSIWSPY, do_wireless_ioctl)
2910 HANDLE_IOCTL(SIOCGIWSPY, do_wireless_ioctl)
2911 HANDLE_IOCTL(SIOCSIWTHRSPY, do_wireless_ioctl)
2912 HANDLE_IOCTL(SIOCGIWTHRSPY, do_wireless_ioctl)
2913 HANDLE_IOCTL(SIOCGIWAPLIST, do_wireless_ioctl)
2914 HANDLE_IOCTL(SIOCGIWSCAN, do_wireless_ioctl)
2915 HANDLE_IOCTL(SIOCSIWESSID, do_wireless_ioctl)
2916 HANDLE_IOCTL(SIOCGIWESSID, do_wireless_ioctl)
2917 HANDLE_IOCTL(SIOCSIWNICKN, do_wireless_ioctl)
2918 HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl)
2919 HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl)
2920 HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl)
2921 HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl)
2922 HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl)
2923 HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl)
2924 HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl)
2925 HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl)
2926 HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl)
2928 #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
2929 HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest)
2930 HANDLE_IOCTL(NCP_IOC_GETMOUNTUID2_32, do_ncp_getmountuid2)
2931 HANDLE_IOCTL(NCP_IOC_GET_FS_INFO_V2_32, do_ncp_getfsinfo2)
2932 HANDLE_IOCTL(NCP_IOC_GETOBJECTNAME_32, do_ncp_getobjectname)
2933 HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32, do_ncp_setobjectname)
2934 HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata)
2935 HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata)
2936 #endif
2938 /* dvb */
2939 HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event)
2940 HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture)
2941 HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette)
2943 /* parport */
2944 COMPATIBLE_IOCTL(LPTIME)
2945 COMPATIBLE_IOCTL(LPCHAR)
2946 COMPATIBLE_IOCTL(LPABORTOPEN)
2947 COMPATIBLE_IOCTL(LPCAREFUL)
2948 COMPATIBLE_IOCTL(LPWAIT)
2949 COMPATIBLE_IOCTL(LPSETIRQ)
2950 COMPATIBLE_IOCTL(LPGETSTATUS)
2951 COMPATIBLE_IOCTL(LPGETSTATUS)
2952 COMPATIBLE_IOCTL(LPRESET)
2953 /*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/
2954 COMPATIBLE_IOCTL(LPGETFLAGS)
2955 HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans)
2957 #ifdef CONFIG_XEN
2958 HANDLE_IOCTL(IOCTL_PRIVCMD_MMAP_32, privcmd_ioctl_32)
2959 HANDLE_IOCTL(IOCTL_PRIVCMD_MMAPBATCH_32, privcmd_ioctl_32)
2960 COMPATIBLE_IOCTL(IOCTL_PRIVCMD_HYPERCALL)
2961 COMPATIBLE_IOCTL(IOCTL_EVTCHN_BIND_VIRQ)
2962 COMPATIBLE_IOCTL(IOCTL_EVTCHN_BIND_INTERDOMAIN)
2963 COMPATIBLE_IOCTL(IOCTL_EVTCHN_BIND_UNBOUND_PORT)
2964 COMPATIBLE_IOCTL(IOCTL_EVTCHN_UNBIND)
2965 COMPATIBLE_IOCTL(IOCTL_EVTCHN_NOTIFY)
2966 COMPATIBLE_IOCTL(IOCTL_EVTCHN_RESET)
2967 #endif
2968 };
2970 int ioctl_table_size = ARRAY_SIZE(ioctl_start);