ia64/linux-2.6.18-xen.hg

view fs/compat_ioctl.c @ 524:7f8b544237bf

netfront: Allow netfront in domain 0.

This is useful if your physical network device is in a utility domain.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Apr 15 15:18:58 2008 +0100 (2008-04-15)
parents 70acfc9814c9
children
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 #ifdef CONFIG_XEN
128 #include <xen/interface/xen.h>
129 #include <xen/public/evtchn.h>
130 #include <xen/public/privcmd.h>
131 #include <xen/compat_ioctl.h>
132 #endif
134 /* Aiee. Someone does not find a difference between int and long */
135 #define EXT2_IOC32_GETFLAGS _IOR('f', 1, int)
136 #define EXT2_IOC32_SETFLAGS _IOW('f', 2, int)
137 #define EXT3_IOC32_GETVERSION _IOR('f', 3, int)
138 #define EXT3_IOC32_SETVERSION _IOW('f', 4, int)
139 #define EXT3_IOC32_GETRSVSZ _IOR('f', 5, int)
140 #define EXT3_IOC32_SETRSVSZ _IOW('f', 6, int)
141 #define EXT3_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int)
142 #ifdef CONFIG_JBD_DEBUG
143 #define EXT3_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int)
144 #endif
146 #define EXT2_IOC32_GETVERSION _IOR('v', 1, int)
147 #define EXT2_IOC32_SETVERSION _IOW('v', 2, int)
149 static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
150 unsigned long arg, struct file *f)
151 {
152 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
153 }
155 static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
156 {
157 mm_segment_t old_fs = get_fs();
158 int err;
159 unsigned long val;
161 set_fs (KERNEL_DS);
162 err = sys_ioctl(fd, cmd, (unsigned long)&val);
163 set_fs (old_fs);
164 if (!err && put_user(val, (u32 __user *)compat_ptr(arg)))
165 return -EFAULT;
166 return err;
167 }
169 static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg)
170 {
171 mm_segment_t old_fs = get_fs();
172 u32 __user *argptr = compat_ptr(arg);
173 int err;
174 unsigned long val;
176 if(get_user(val, argptr))
177 return -EFAULT;
178 set_fs (KERNEL_DS);
179 err = sys_ioctl(fd, cmd, (unsigned long)&val);
180 set_fs (old_fs);
181 if (!err && put_user(val, argptr))
182 return -EFAULT;
183 return err;
184 }
186 static int do_ext2_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
187 {
188 /* These are just misnamed, they actually get/put from/to user an int */
189 switch (cmd) {
190 case EXT2_IOC32_GETFLAGS: cmd = EXT2_IOC_GETFLAGS; break;
191 case EXT2_IOC32_SETFLAGS: cmd = EXT2_IOC_SETFLAGS; break;
192 case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; break;
193 case EXT2_IOC32_SETVERSION: cmd = EXT2_IOC_SETVERSION; break;
194 }
195 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
196 }
198 static int do_ext3_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
199 {
200 /* These are just misnamed, they actually get/put from/to user an int */
201 switch (cmd) {
202 case EXT3_IOC32_GETVERSION: cmd = EXT3_IOC_GETVERSION; break;
203 case EXT3_IOC32_SETVERSION: cmd = EXT3_IOC_SETVERSION; break;
204 case EXT3_IOC32_GETRSVSZ: cmd = EXT3_IOC_GETRSVSZ; break;
205 case EXT3_IOC32_SETRSVSZ: cmd = EXT3_IOC_SETRSVSZ; break;
206 case EXT3_IOC32_GROUP_EXTEND: cmd = EXT3_IOC_GROUP_EXTEND; break;
207 #ifdef CONFIG_JBD_DEBUG
208 case EXT3_IOC32_WAIT_FOR_READONLY: cmd = EXT3_IOC_WAIT_FOR_READONLY; break;
209 #endif
210 }
211 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
212 }
214 struct compat_video_event {
215 int32_t type;
216 compat_time_t timestamp;
217 union {
218 video_size_t size;
219 unsigned int frame_rate;
220 } u;
221 };
223 static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long arg)
224 {
225 struct video_event kevent;
226 mm_segment_t old_fs = get_fs();
227 int err;
229 set_fs(KERNEL_DS);
230 err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
231 set_fs(old_fs);
233 if (!err) {
234 struct compat_video_event __user *up = compat_ptr(arg);
236 err = put_user(kevent.type, &up->type);
237 err |= put_user(kevent.timestamp, &up->timestamp);
238 err |= put_user(kevent.u.size.w, &up->u.size.w);
239 err |= put_user(kevent.u.size.h, &up->u.size.h);
240 err |= put_user(kevent.u.size.aspect_ratio,
241 &up->u.size.aspect_ratio);
242 if (err)
243 err = -EFAULT;
244 }
246 return err;
247 }
249 struct compat_video_still_picture {
250 compat_uptr_t iFrame;
251 int32_t size;
252 };
254 static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned long arg)
255 {
256 struct compat_video_still_picture __user *up;
257 struct video_still_picture __user *up_native;
258 compat_uptr_t fp;
259 int32_t size;
260 int err;
262 up = (struct compat_video_still_picture __user *) arg;
263 err = get_user(fp, &up->iFrame);
264 err |= get_user(size, &up->size);
265 if (err)
266 return -EFAULT;
268 up_native =
269 compat_alloc_user_space(sizeof(struct video_still_picture));
271 put_user(compat_ptr(fp), &up_native->iFrame);
272 put_user(size, &up_native->size);
274 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
276 return err;
277 }
279 struct compat_video_spu_palette {
280 int length;
281 compat_uptr_t palette;
282 };
284 static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned long arg)
285 {
286 struct compat_video_spu_palette __user *up;
287 struct video_spu_palette __user *up_native;
288 compat_uptr_t palp;
289 int length, err;
291 up = (struct compat_video_spu_palette __user *) arg;
292 err = get_user(palp, &up->palette);
293 err |= get_user(length, &up->length);
295 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
296 put_user(compat_ptr(palp), &up_native->palette);
297 put_user(length, &up_native->length);
299 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
301 return err;
302 }
304 #ifdef CONFIG_NET
305 static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
306 {
307 struct compat_timeval __user *up = compat_ptr(arg);
308 struct timeval ktv;
309 mm_segment_t old_fs = get_fs();
310 int err;
312 set_fs(KERNEL_DS);
313 err = sys_ioctl(fd, cmd, (unsigned long)&ktv);
314 set_fs(old_fs);
315 if(!err) {
316 err = put_user(ktv.tv_sec, &up->tv_sec);
317 err |= __put_user(ktv.tv_usec, &up->tv_usec);
318 }
319 return err;
320 }
322 struct ifmap32 {
323 compat_ulong_t mem_start;
324 compat_ulong_t mem_end;
325 unsigned short base_addr;
326 unsigned char irq;
327 unsigned char dma;
328 unsigned char port;
329 };
331 struct ifreq32 {
332 #define IFHWADDRLEN 6
333 #define IFNAMSIZ 16
334 union {
335 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
336 } ifr_ifrn;
337 union {
338 struct sockaddr ifru_addr;
339 struct sockaddr ifru_dstaddr;
340 struct sockaddr ifru_broadaddr;
341 struct sockaddr ifru_netmask;
342 struct sockaddr ifru_hwaddr;
343 short ifru_flags;
344 compat_int_t ifru_ivalue;
345 compat_int_t ifru_mtu;
346 struct ifmap32 ifru_map;
347 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
348 char ifru_newname[IFNAMSIZ];
349 compat_caddr_t ifru_data;
350 /* XXXX? ifru_settings should be here */
351 } ifr_ifru;
352 };
354 struct ifconf32 {
355 compat_int_t ifc_len; /* size of buffer */
356 compat_caddr_t ifcbuf;
357 };
359 static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
360 {
361 struct net_device *dev;
362 struct ifreq32 ifr32;
363 int err;
365 if (copy_from_user(&ifr32, compat_ptr(arg), sizeof(ifr32)))
366 return -EFAULT;
368 dev = dev_get_by_index(ifr32.ifr_ifindex);
369 if (!dev)
370 return -ENODEV;
372 strlcpy(ifr32.ifr_name, dev->name, sizeof(ifr32.ifr_name));
373 dev_put(dev);
375 err = copy_to_user(compat_ptr(arg), &ifr32, sizeof(ifr32));
376 return (err ? -EFAULT : 0);
377 }
379 static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)
380 {
381 struct ifconf32 ifc32;
382 struct ifconf ifc;
383 struct ifconf __user *uifc;
384 struct ifreq32 __user *ifr32;
385 struct ifreq __user *ifr;
386 unsigned int i, j;
387 int err;
389 if (copy_from_user(&ifc32, compat_ptr(arg), sizeof(struct ifconf32)))
390 return -EFAULT;
392 if (ifc32.ifcbuf == 0) {
393 ifc32.ifc_len = 0;
394 ifc.ifc_len = 0;
395 ifc.ifc_req = NULL;
396 uifc = compat_alloc_user_space(sizeof(struct ifconf));
397 } else {
398 size_t len =((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) *
399 sizeof (struct ifreq);
400 uifc = compat_alloc_user_space(sizeof(struct ifconf) + len);
401 ifc.ifc_len = len;
402 ifr = ifc.ifc_req = (void __user *)(uifc + 1);
403 ifr32 = compat_ptr(ifc32.ifcbuf);
404 for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) {
405 if (copy_in_user(ifr, ifr32, sizeof(struct ifreq32)))
406 return -EFAULT;
407 ifr++;
408 ifr32++;
409 }
410 }
411 if (copy_to_user(uifc, &ifc, sizeof(struct ifconf)))
412 return -EFAULT;
414 err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)uifc);
415 if (err)
416 return err;
418 if (copy_from_user(&ifc, uifc, sizeof(struct ifconf)))
419 return -EFAULT;
421 ifr = ifc.ifc_req;
422 ifr32 = compat_ptr(ifc32.ifcbuf);
423 for (i = 0, j = 0;
424 i + sizeof (struct ifreq32) <= ifc32.ifc_len && j < ifc.ifc_len;
425 i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
426 if (copy_in_user(ifr32, ifr, sizeof (struct ifreq32)))
427 return -EFAULT;
428 ifr32++;
429 ifr++;
430 }
432 if (ifc32.ifcbuf == 0) {
433 /* Translate from 64-bit structure multiple to
434 * a 32-bit one.
435 */
436 i = ifc.ifc_len;
437 i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32));
438 ifc32.ifc_len = i;
439 } else {
440 ifc32.ifc_len = i;
441 }
442 if (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32)))
443 return -EFAULT;
445 return 0;
446 }
448 static int ethtool_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
449 {
450 struct ifreq __user *ifr;
451 struct ifreq32 __user *ifr32;
452 u32 data;
453 void __user *datap;
455 ifr = compat_alloc_user_space(sizeof(*ifr));
456 ifr32 = compat_ptr(arg);
458 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
459 return -EFAULT;
461 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
462 return -EFAULT;
464 datap = compat_ptr(data);
465 if (put_user(datap, &ifr->ifr_ifru.ifru_data))
466 return -EFAULT;
468 return sys_ioctl(fd, cmd, (unsigned long) ifr);
469 }
471 static int bond_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
472 {
473 struct ifreq kifr;
474 struct ifreq __user *uifr;
475 struct ifreq32 __user *ifr32 = compat_ptr(arg);
476 mm_segment_t old_fs;
477 int err;
478 u32 data;
479 void __user *datap;
481 switch (cmd) {
482 case SIOCBONDENSLAVE:
483 case SIOCBONDRELEASE:
484 case SIOCBONDSETHWADDR:
485 case SIOCBONDCHANGEACTIVE:
486 if (copy_from_user(&kifr, ifr32, sizeof(struct ifreq32)))
487 return -EFAULT;
489 old_fs = get_fs();
490 set_fs (KERNEL_DS);
491 err = sys_ioctl (fd, cmd, (unsigned long)&kifr);
492 set_fs (old_fs);
494 return err;
495 case SIOCBONDSLAVEINFOQUERY:
496 case SIOCBONDINFOQUERY:
497 uifr = compat_alloc_user_space(sizeof(*uifr));
498 if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
499 return -EFAULT;
501 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
502 return -EFAULT;
504 datap = compat_ptr(data);
505 if (put_user(datap, &uifr->ifr_ifru.ifru_data))
506 return -EFAULT;
508 return sys_ioctl (fd, cmd, (unsigned long)uifr);
509 default:
510 return -EINVAL;
511 };
512 }
514 int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
515 {
516 struct ifreq __user *u_ifreq64;
517 struct ifreq32 __user *u_ifreq32 = compat_ptr(arg);
518 char tmp_buf[IFNAMSIZ];
519 void __user *data64;
520 u32 data32;
522 if (copy_from_user(&tmp_buf[0], &(u_ifreq32->ifr_ifrn.ifrn_name[0]),
523 IFNAMSIZ))
524 return -EFAULT;
525 if (__get_user(data32, &u_ifreq32->ifr_ifru.ifru_data))
526 return -EFAULT;
527 data64 = compat_ptr(data32);
529 u_ifreq64 = compat_alloc_user_space(sizeof(*u_ifreq64));
531 /* Don't check these user accesses, just let that get trapped
532 * in the ioctl handler instead.
533 */
534 if (copy_to_user(&u_ifreq64->ifr_ifrn.ifrn_name[0], &tmp_buf[0],
535 IFNAMSIZ))
536 return -EFAULT;
537 if (__put_user(data64, &u_ifreq64->ifr_ifru.ifru_data))
538 return -EFAULT;
540 return sys_ioctl(fd, cmd, (unsigned long) u_ifreq64);
541 }
543 static int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg)
544 {
545 struct ifreq ifr;
546 struct ifreq32 __user *uifr32;
547 struct ifmap32 __user *uifmap32;
548 mm_segment_t old_fs;
549 int err;
551 uifr32 = compat_ptr(arg);
552 uifmap32 = &uifr32->ifr_ifru.ifru_map;
553 switch (cmd) {
554 case SIOCSIFMAP:
555 err = copy_from_user(&ifr, uifr32, sizeof(ifr.ifr_name));
556 err |= __get_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
557 err |= __get_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
558 err |= __get_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
559 err |= __get_user(ifr.ifr_map.irq, &uifmap32->irq);
560 err |= __get_user(ifr.ifr_map.dma, &uifmap32->dma);
561 err |= __get_user(ifr.ifr_map.port, &uifmap32->port);
562 if (err)
563 return -EFAULT;
564 break;
565 default:
566 if (copy_from_user(&ifr, uifr32, sizeof(*uifr32)))
567 return -EFAULT;
568 break;
569 }
570 old_fs = get_fs();
571 set_fs (KERNEL_DS);
572 err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
573 set_fs (old_fs);
574 if (!err) {
575 switch (cmd) {
576 /* TUNSETIFF is defined as _IOW, it should be _IORW
577 * as the data is copied back to user space, but that
578 * cannot be fixed without breaking all existing apps.
579 */
580 case TUNSETIFF:
581 case SIOCGIFFLAGS:
582 case SIOCGIFMETRIC:
583 case SIOCGIFMTU:
584 case SIOCGIFMEM:
585 case SIOCGIFHWADDR:
586 case SIOCGIFINDEX:
587 case SIOCGIFADDR:
588 case SIOCGIFBRDADDR:
589 case SIOCGIFDSTADDR:
590 case SIOCGIFNETMASK:
591 case SIOCGIFTXQLEN:
592 if (copy_to_user(uifr32, &ifr, sizeof(*uifr32)))
593 return -EFAULT;
594 break;
595 case SIOCGIFMAP:
596 err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name));
597 err |= __put_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
598 err |= __put_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
599 err |= __put_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
600 err |= __put_user(ifr.ifr_map.irq, &uifmap32->irq);
601 err |= __put_user(ifr.ifr_map.dma, &uifmap32->dma);
602 err |= __put_user(ifr.ifr_map.port, &uifmap32->port);
603 if (err)
604 err = -EFAULT;
605 break;
606 }
607 }
608 return err;
609 }
611 struct rtentry32 {
612 u32 rt_pad1;
613 struct sockaddr rt_dst; /* target address */
614 struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
615 struct sockaddr rt_genmask; /* target network mask (IP) */
616 unsigned short rt_flags;
617 short rt_pad2;
618 u32 rt_pad3;
619 unsigned char rt_tos;
620 unsigned char rt_class;
621 short rt_pad4;
622 short rt_metric; /* +1 for binary compatibility! */
623 /* char * */ u32 rt_dev; /* forcing the device at add */
624 u32 rt_mtu; /* per route MTU/Window */
625 u32 rt_window; /* Window clamping */
626 unsigned short rt_irtt; /* Initial RTT */
628 };
630 struct in6_rtmsg32 {
631 struct in6_addr rtmsg_dst;
632 struct in6_addr rtmsg_src;
633 struct in6_addr rtmsg_gateway;
634 u32 rtmsg_type;
635 u16 rtmsg_dst_len;
636 u16 rtmsg_src_len;
637 u32 rtmsg_metric;
638 u32 rtmsg_info;
639 u32 rtmsg_flags;
640 s32 rtmsg_ifindex;
641 };
643 static int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
644 {
645 int ret;
646 void *r = NULL;
647 struct in6_rtmsg r6;
648 struct rtentry r4;
649 char devname[16];
650 u32 rtdev;
651 mm_segment_t old_fs = get_fs();
653 struct socket *mysock = sockfd_lookup(fd, &ret);
655 if (mysock && mysock->sk && mysock->sk->sk_family == AF_INET6) { /* ipv6 */
656 struct in6_rtmsg32 __user *ur6 = compat_ptr(arg);
657 ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst),
658 3 * sizeof(struct in6_addr));
659 ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type));
660 ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len));
661 ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len));
662 ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric));
663 ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info));
664 ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags));
665 ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex));
667 r = (void *) &r6;
668 } else { /* ipv4 */
669 struct rtentry32 __user *ur4 = compat_ptr(arg);
670 ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst),
671 3 * sizeof(struct sockaddr));
672 ret |= __get_user (r4.rt_flags, &(ur4->rt_flags));
673 ret |= __get_user (r4.rt_metric, &(ur4->rt_metric));
674 ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu));
675 ret |= __get_user (r4.rt_window, &(ur4->rt_window));
676 ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt));
677 ret |= __get_user (rtdev, &(ur4->rt_dev));
678 if (rtdev) {
679 ret |= copy_from_user (devname, compat_ptr(rtdev), 15);
680 r4.rt_dev = devname; devname[15] = 0;
681 } else
682 r4.rt_dev = NULL;
684 r = (void *) &r4;
685 }
687 if (ret) {
688 ret = -EFAULT;
689 goto out;
690 }
692 set_fs (KERNEL_DS);
693 ret = sys_ioctl (fd, cmd, (unsigned long) r);
694 set_fs (old_fs);
696 out:
697 if (mysock)
698 sockfd_put(mysock);
700 return ret;
701 }
702 #endif
704 struct hd_geometry32 {
705 unsigned char heads;
706 unsigned char sectors;
707 unsigned short cylinders;
708 u32 start;
709 };
711 static int hdio_getgeo(unsigned int fd, unsigned int cmd, unsigned long arg)
712 {
713 mm_segment_t old_fs = get_fs();
714 struct hd_geometry geo;
715 struct hd_geometry32 __user *ugeo;
716 int err;
718 set_fs (KERNEL_DS);
719 err = sys_ioctl(fd, HDIO_GETGEO, (unsigned long)&geo);
720 set_fs (old_fs);
721 ugeo = compat_ptr(arg);
722 if (!err) {
723 err = copy_to_user (ugeo, &geo, 4);
724 err |= __put_user (geo.start, &ugeo->start);
725 }
726 return err ? -EFAULT : 0;
727 }
729 static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
730 {
731 mm_segment_t old_fs = get_fs();
732 unsigned long kval;
733 unsigned int __user *uvp;
734 int error;
736 set_fs(KERNEL_DS);
737 error = sys_ioctl(fd, cmd, (long)&kval);
738 set_fs(old_fs);
740 if(error == 0) {
741 uvp = compat_ptr(arg);
742 if(put_user(kval, uvp))
743 error = -EFAULT;
744 }
745 return error;
746 }
749 typedef struct sg_io_hdr32 {
750 compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */
751 compat_int_t dxfer_direction; /* [i] data transfer direction */
752 unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
753 unsigned char mx_sb_len; /* [i] max length to write to sbp */
754 unsigned short iovec_count; /* [i] 0 implies no scatter gather */
755 compat_uint_t dxfer_len; /* [i] byte count of data transfer */
756 compat_uint_t dxferp; /* [i], [*io] points to data transfer memory
757 or scatter gather list */
758 compat_uptr_t cmdp; /* [i], [*i] points to command to perform */
759 compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */
760 compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
761 compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */
762 compat_int_t pack_id; /* [i->o] unused internally (normally) */
763 compat_uptr_t usr_ptr; /* [i->o] unused internally */
764 unsigned char status; /* [o] scsi status */
765 unsigned char masked_status; /* [o] shifted, masked scsi status */
766 unsigned char msg_status; /* [o] messaging level data (optional) */
767 unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
768 unsigned short host_status; /* [o] errors from host adapter */
769 unsigned short driver_status; /* [o] errors from software driver */
770 compat_int_t resid; /* [o] dxfer_len - actual_transferred */
771 compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */
772 compat_uint_t info; /* [o] auxiliary information */
773 } sg_io_hdr32_t; /* 64 bytes long (on sparc32) */
775 typedef struct sg_iovec32 {
776 compat_uint_t iov_base;
777 compat_uint_t iov_len;
778 } sg_iovec32_t;
780 static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count)
781 {
782 sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1);
783 sg_iovec32_t __user *iov32 = dxferp;
784 int i;
786 for (i = 0; i < iovec_count; i++) {
787 u32 base, len;
789 if (get_user(base, &iov32[i].iov_base) ||
790 get_user(len, &iov32[i].iov_len) ||
791 put_user(compat_ptr(base), &iov[i].iov_base) ||
792 put_user(len, &iov[i].iov_len))
793 return -EFAULT;
794 }
796 if (put_user(iov, &sgio->dxferp))
797 return -EFAULT;
798 return 0;
799 }
801 static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
802 {
803 sg_io_hdr_t __user *sgio;
804 sg_io_hdr32_t __user *sgio32;
805 u16 iovec_count;
806 u32 data;
807 void __user *dxferp;
808 int err;
810 sgio32 = compat_ptr(arg);
811 if (get_user(iovec_count, &sgio32->iovec_count))
812 return -EFAULT;
814 {
815 void __user *top = compat_alloc_user_space(0);
816 void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) +
817 (iovec_count * sizeof(sg_iovec_t)));
818 if (new > top)
819 return -EINVAL;
821 sgio = new;
822 }
824 /* Ok, now construct. */
825 if (copy_in_user(&sgio->interface_id, &sgio32->interface_id,
826 (2 * sizeof(int)) +
827 (2 * sizeof(unsigned char)) +
828 (1 * sizeof(unsigned short)) +
829 (1 * sizeof(unsigned int))))
830 return -EFAULT;
832 if (get_user(data, &sgio32->dxferp))
833 return -EFAULT;
834 dxferp = compat_ptr(data);
835 if (iovec_count) {
836 if (sg_build_iovec(sgio, dxferp, iovec_count))
837 return -EFAULT;
838 } else {
839 if (put_user(dxferp, &sgio->dxferp))
840 return -EFAULT;
841 }
843 {
844 unsigned char __user *cmdp;
845 unsigned char __user *sbp;
847 if (get_user(data, &sgio32->cmdp))
848 return -EFAULT;
849 cmdp = compat_ptr(data);
851 if (get_user(data, &sgio32->sbp))
852 return -EFAULT;
853 sbp = compat_ptr(data);
855 if (put_user(cmdp, &sgio->cmdp) ||
856 put_user(sbp, &sgio->sbp))
857 return -EFAULT;
858 }
860 if (copy_in_user(&sgio->timeout, &sgio32->timeout,
861 3 * sizeof(int)))
862 return -EFAULT;
864 if (get_user(data, &sgio32->usr_ptr))
865 return -EFAULT;
866 if (put_user(compat_ptr(data), &sgio->usr_ptr))
867 return -EFAULT;
869 if (copy_in_user(&sgio->status, &sgio32->status,
870 (4 * sizeof(unsigned char)) +
871 (2 * sizeof(unsigned (short))) +
872 (3 * sizeof(int))))
873 return -EFAULT;
875 err = sys_ioctl(fd, cmd, (unsigned long) sgio);
877 if (err >= 0) {
878 void __user *datap;
880 if (copy_in_user(&sgio32->pack_id, &sgio->pack_id,
881 sizeof(int)) ||
882 get_user(datap, &sgio->usr_ptr) ||
883 put_user((u32)(unsigned long)datap,
884 &sgio32->usr_ptr) ||
885 copy_in_user(&sgio32->status, &sgio->status,
886 (4 * sizeof(unsigned char)) +
887 (2 * sizeof(unsigned short)) +
888 (3 * sizeof(int))))
889 err = -EFAULT;
890 }
892 return err;
893 }
895 struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
896 char req_state;
897 char orphan;
898 char sg_io_owned;
899 char problem;
900 int pack_id;
901 compat_uptr_t usr_ptr;
902 unsigned int duration;
903 int unused;
904 };
906 static int sg_grt_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
907 {
908 int err, i;
909 sg_req_info_t __user *r;
910 struct compat_sg_req_info __user *o = (void __user *)arg;
911 r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE);
912 err = sys_ioctl(fd,cmd,(unsigned long)r);
913 if (err < 0)
914 return err;
915 for (i = 0; i < SG_MAX_QUEUE; i++) {
916 void __user *ptr;
917 int d;
919 if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) ||
920 get_user(ptr, &r[i].usr_ptr) ||
921 get_user(d, &r[i].duration) ||
922 put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) ||
923 put_user(d, &o[i].duration))
924 return -EFAULT;
925 }
926 return err;
927 }
929 struct sock_fprog32 {
930 unsigned short len;
931 compat_caddr_t filter;
932 };
934 #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
935 #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
937 static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
938 {
939 struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg);
940 struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
941 void __user *fptr64;
942 u32 fptr32;
943 u16 flen;
945 if (get_user(flen, &u_fprog32->len) ||
946 get_user(fptr32, &u_fprog32->filter))
947 return -EFAULT;
949 fptr64 = compat_ptr(fptr32);
951 if (put_user(flen, &u_fprog64->len) ||
952 put_user(fptr64, &u_fprog64->filter))
953 return -EFAULT;
955 if (cmd == PPPIOCSPASS32)
956 cmd = PPPIOCSPASS;
957 else
958 cmd = PPPIOCSACTIVE;
960 return sys_ioctl(fd, cmd, (unsigned long) u_fprog64);
961 }
963 struct ppp_option_data32 {
964 compat_caddr_t ptr;
965 u32 length;
966 compat_int_t transmit;
967 };
968 #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
970 struct ppp_idle32 {
971 compat_time_t xmit_idle;
972 compat_time_t recv_idle;
973 };
974 #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
976 static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg)
977 {
978 struct ppp_idle __user *idle;
979 struct ppp_idle32 __user *idle32;
980 __kernel_time_t xmit, recv;
981 int err;
983 idle = compat_alloc_user_space(sizeof(*idle));
984 idle32 = compat_ptr(arg);
986 err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle);
988 if (!err) {
989 if (get_user(xmit, &idle->xmit_idle) ||
990 get_user(recv, &idle->recv_idle) ||
991 put_user(xmit, &idle32->xmit_idle) ||
992 put_user(recv, &idle32->recv_idle))
993 err = -EFAULT;
994 }
995 return err;
996 }
998 static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg)
999 {
1000 struct ppp_option_data __user *odata;
1001 struct ppp_option_data32 __user *odata32;
1002 __u32 data;
1003 void __user *datap;
1005 odata = compat_alloc_user_space(sizeof(*odata));
1006 odata32 = compat_ptr(arg);
1008 if (get_user(data, &odata32->ptr))
1009 return -EFAULT;
1011 datap = compat_ptr(data);
1012 if (put_user(datap, &odata->ptr))
1013 return -EFAULT;
1015 if (copy_in_user(&odata->length, &odata32->length,
1016 sizeof(__u32) + sizeof(int)))
1017 return -EFAULT;
1019 return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata);
1022 static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1024 int err;
1026 switch (cmd) {
1027 case PPPIOCGIDLE32:
1028 err = ppp_gidle(fd, cmd, arg);
1029 break;
1031 case PPPIOCSCOMPRESS32:
1032 err = ppp_scompress(fd, cmd, arg);
1033 break;
1035 default:
1036 do {
1037 static int count;
1038 if (++count <= 20)
1039 printk("ppp_ioctl: Unknown cmd fd(%d) "
1040 "cmd(%08x) arg(%08x)\n",
1041 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1042 } while(0);
1043 err = -EINVAL;
1044 break;
1045 };
1047 return err;
1051 struct mtget32 {
1052 compat_long_t mt_type;
1053 compat_long_t mt_resid;
1054 compat_long_t mt_dsreg;
1055 compat_long_t mt_gstat;
1056 compat_long_t mt_erreg;
1057 compat_daddr_t mt_fileno;
1058 compat_daddr_t mt_blkno;
1059 };
1060 #define MTIOCGET32 _IOR('m', 2, struct mtget32)
1062 struct mtpos32 {
1063 compat_long_t mt_blkno;
1064 };
1065 #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
1067 static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1069 mm_segment_t old_fs = get_fs();
1070 struct mtget get;
1071 struct mtget32 __user *umget32;
1072 struct mtpos pos;
1073 struct mtpos32 __user *upos32;
1074 unsigned long kcmd;
1075 void *karg;
1076 int err = 0;
1078 switch(cmd) {
1079 case MTIOCPOS32:
1080 kcmd = MTIOCPOS;
1081 karg = &pos;
1082 break;
1083 case MTIOCGET32:
1084 kcmd = MTIOCGET;
1085 karg = &get;
1086 break;
1087 default:
1088 do {
1089 static int count;
1090 if (++count <= 20)
1091 printk("mt_ioctl: Unknown cmd fd(%d) "
1092 "cmd(%08x) arg(%08x)\n",
1093 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1094 } while(0);
1095 return -EINVAL;
1097 set_fs (KERNEL_DS);
1098 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1099 set_fs (old_fs);
1100 if (err)
1101 return err;
1102 switch (cmd) {
1103 case MTIOCPOS32:
1104 upos32 = compat_ptr(arg);
1105 err = __put_user(pos.mt_blkno, &upos32->mt_blkno);
1106 break;
1107 case MTIOCGET32:
1108 umget32 = compat_ptr(arg);
1109 err = __put_user(get.mt_type, &umget32->mt_type);
1110 err |= __put_user(get.mt_resid, &umget32->mt_resid);
1111 err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg);
1112 err |= __put_user(get.mt_gstat, &umget32->mt_gstat);
1113 err |= __put_user(get.mt_erreg, &umget32->mt_erreg);
1114 err |= __put_user(get.mt_fileno, &umget32->mt_fileno);
1115 err |= __put_user(get.mt_blkno, &umget32->mt_blkno);
1116 break;
1118 return err ? -EFAULT: 0;
1121 struct cdrom_read_audio32 {
1122 union cdrom_addr addr;
1123 u8 addr_format;
1124 compat_int_t nframes;
1125 compat_caddr_t buf;
1126 };
1128 struct cdrom_generic_command32 {
1129 unsigned char cmd[CDROM_PACKET_SIZE];
1130 compat_caddr_t buffer;
1131 compat_uint_t buflen;
1132 compat_int_t stat;
1133 compat_caddr_t sense;
1134 unsigned char data_direction;
1135 compat_int_t quiet;
1136 compat_int_t timeout;
1137 compat_caddr_t reserved[1];
1138 };
1140 static int cdrom_do_read_audio(unsigned int fd, unsigned int cmd, unsigned long arg)
1142 struct cdrom_read_audio __user *cdread_audio;
1143 struct cdrom_read_audio32 __user *cdread_audio32;
1144 __u32 data;
1145 void __user *datap;
1147 cdread_audio = compat_alloc_user_space(sizeof(*cdread_audio));
1148 cdread_audio32 = compat_ptr(arg);
1150 if (copy_in_user(&cdread_audio->addr,
1151 &cdread_audio32->addr,
1152 (sizeof(*cdread_audio32) -
1153 sizeof(compat_caddr_t))))
1154 return -EFAULT;
1156 if (get_user(data, &cdread_audio32->buf))
1157 return -EFAULT;
1158 datap = compat_ptr(data);
1159 if (put_user(datap, &cdread_audio->buf))
1160 return -EFAULT;
1162 return sys_ioctl(fd, cmd, (unsigned long) cdread_audio);
1165 static int cdrom_do_generic_command(unsigned int fd, unsigned int cmd, unsigned long arg)
1167 struct cdrom_generic_command __user *cgc;
1168 struct cdrom_generic_command32 __user *cgc32;
1169 u32 data;
1170 unsigned char dir;
1171 int itmp;
1173 cgc = compat_alloc_user_space(sizeof(*cgc));
1174 cgc32 = compat_ptr(arg);
1176 if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) ||
1177 get_user(data, &cgc32->buffer) ||
1178 put_user(compat_ptr(data), &cgc->buffer) ||
1179 copy_in_user(&cgc->buflen, &cgc32->buflen,
1180 (sizeof(unsigned int) + sizeof(int))) ||
1181 get_user(data, &cgc32->sense) ||
1182 put_user(compat_ptr(data), &cgc->sense) ||
1183 get_user(dir, &cgc32->data_direction) ||
1184 put_user(dir, &cgc->data_direction) ||
1185 get_user(itmp, &cgc32->quiet) ||
1186 put_user(itmp, &cgc->quiet) ||
1187 get_user(itmp, &cgc32->timeout) ||
1188 put_user(itmp, &cgc->timeout) ||
1189 get_user(data, &cgc32->reserved[0]) ||
1190 put_user(compat_ptr(data), &cgc->reserved[0]))
1191 return -EFAULT;
1193 return sys_ioctl(fd, cmd, (unsigned long) cgc);
1196 static int cdrom_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1198 int err;
1200 switch(cmd) {
1201 case CDROMREADAUDIO:
1202 err = cdrom_do_read_audio(fd, cmd, arg);
1203 break;
1205 case CDROM_SEND_PACKET:
1206 err = cdrom_do_generic_command(fd, cmd, arg);
1207 break;
1209 default:
1210 do {
1211 static int count;
1212 if (++count <= 20)
1213 printk("cdrom_ioctl: Unknown cmd fd(%d) "
1214 "cmd(%08x) arg(%08x)\n",
1215 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1216 } while(0);
1217 err = -EINVAL;
1218 break;
1219 };
1221 return err;
1224 struct loop_info32 {
1225 compat_int_t lo_number; /* ioctl r/o */
1226 compat_dev_t lo_device; /* ioctl r/o */
1227 compat_ulong_t lo_inode; /* ioctl r/o */
1228 compat_dev_t lo_rdevice; /* ioctl r/o */
1229 compat_int_t lo_offset;
1230 compat_int_t lo_encrypt_type;
1231 compat_int_t lo_encrypt_key_size; /* ioctl w/o */
1232 compat_int_t lo_flags; /* ioctl r/o */
1233 char lo_name[LO_NAME_SIZE];
1234 unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
1235 compat_ulong_t lo_init[2];
1236 char reserved[4];
1237 };
1239 static int loop_status(unsigned int fd, unsigned int cmd, unsigned long arg)
1241 mm_segment_t old_fs = get_fs();
1242 struct loop_info l;
1243 struct loop_info32 __user *ul;
1244 int err = -EINVAL;
1246 ul = compat_ptr(arg);
1247 switch(cmd) {
1248 case LOOP_SET_STATUS:
1249 err = get_user(l.lo_number, &ul->lo_number);
1250 err |= __get_user(l.lo_device, &ul->lo_device);
1251 err |= __get_user(l.lo_inode, &ul->lo_inode);
1252 err |= __get_user(l.lo_rdevice, &ul->lo_rdevice);
1253 err |= __copy_from_user(&l.lo_offset, &ul->lo_offset,
1254 8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1255 if (err) {
1256 err = -EFAULT;
1257 } else {
1258 set_fs (KERNEL_DS);
1259 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1260 set_fs (old_fs);
1262 break;
1263 case LOOP_GET_STATUS:
1264 set_fs (KERNEL_DS);
1265 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1266 set_fs (old_fs);
1267 if (!err) {
1268 err = put_user(l.lo_number, &ul->lo_number);
1269 err |= __put_user(l.lo_device, &ul->lo_device);
1270 err |= __put_user(l.lo_inode, &ul->lo_inode);
1271 err |= __put_user(l.lo_rdevice, &ul->lo_rdevice);
1272 err |= __copy_to_user(&ul->lo_offset, &l.lo_offset,
1273 (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1274 if (err)
1275 err = -EFAULT;
1277 break;
1278 default: {
1279 static int count;
1280 if (++count <= 20)
1281 printk("%s: Unknown loop ioctl cmd, fd(%d) "
1282 "cmd(%08x) arg(%08lx)\n",
1283 __FUNCTION__, fd, cmd, arg);
1286 return err;
1289 extern int tty_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg);
1291 #ifdef CONFIG_VT
1293 static int vt_check(struct file *file)
1295 struct tty_struct *tty;
1296 struct inode *inode = file->f_dentry->d_inode;
1298 if (file->f_op->ioctl != tty_ioctl)
1299 return -EINVAL;
1301 tty = (struct tty_struct *)file->private_data;
1302 if (tty_paranoia_check(tty, inode, "tty_ioctl"))
1303 return -EINVAL;
1305 if (tty->driver->ioctl != vt_ioctl)
1306 return -EINVAL;
1308 /*
1309 * To have permissions to do most of the vt ioctls, we either have
1310 * to be the owner of the tty, or super-user.
1311 */
1312 if (current->signal->tty == tty || capable(CAP_SYS_ADMIN))
1313 return 1;
1314 return 0;
1317 struct consolefontdesc32 {
1318 unsigned short charcount; /* characters in font (256 or 512) */
1319 unsigned short charheight; /* scan lines per character (1-32) */
1320 compat_caddr_t chardata; /* font data in expanded form */
1321 };
1323 static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1325 struct consolefontdesc32 __user *user_cfd = compat_ptr(arg);
1326 struct console_font_op op;
1327 compat_caddr_t data;
1328 int i, perm;
1330 perm = vt_check(file);
1331 if (perm < 0) return perm;
1333 switch (cmd) {
1334 case PIO_FONTX:
1335 if (!perm)
1336 return -EPERM;
1337 op.op = KD_FONT_OP_SET;
1338 op.flags = 0;
1339 op.width = 8;
1340 if (get_user(op.height, &user_cfd->charheight) ||
1341 get_user(op.charcount, &user_cfd->charcount) ||
1342 get_user(data, &user_cfd->chardata))
1343 return -EFAULT;
1344 op.data = compat_ptr(data);
1345 return con_font_op(vc_cons[fg_console].d, &op);
1346 case GIO_FONTX:
1347 op.op = KD_FONT_OP_GET;
1348 op.flags = 0;
1349 op.width = 8;
1350 if (get_user(op.height, &user_cfd->charheight) ||
1351 get_user(op.charcount, &user_cfd->charcount) ||
1352 get_user(data, &user_cfd->chardata))
1353 return -EFAULT;
1354 if (!data)
1355 return 0;
1356 op.data = compat_ptr(data);
1357 i = con_font_op(vc_cons[fg_console].d, &op);
1358 if (i)
1359 return i;
1360 if (put_user(op.height, &user_cfd->charheight) ||
1361 put_user(op.charcount, &user_cfd->charcount) ||
1362 put_user((compat_caddr_t)(unsigned long)op.data,
1363 &user_cfd->chardata))
1364 return -EFAULT;
1365 return 0;
1367 return -EINVAL;
1370 struct console_font_op32 {
1371 compat_uint_t op; /* operation code KD_FONT_OP_* */
1372 compat_uint_t flags; /* KD_FONT_FLAG_* */
1373 compat_uint_t width, height; /* font size */
1374 compat_uint_t charcount;
1375 compat_caddr_t data; /* font data with height fixed to 32 */
1376 };
1378 static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1380 struct console_font_op op;
1381 struct console_font_op32 __user *fontop = compat_ptr(arg);
1382 int perm = vt_check(file), i;
1383 struct vc_data *vc;
1385 if (perm < 0) return perm;
1387 if (copy_from_user(&op, fontop, sizeof(struct console_font_op32)))
1388 return -EFAULT;
1389 if (!perm && op.op != KD_FONT_OP_GET)
1390 return -EPERM;
1391 op.data = compat_ptr(((struct console_font_op32 *)&op)->data);
1392 op.flags |= KD_FONT_FLAG_OLD;
1393 vc = ((struct tty_struct *)file->private_data)->driver_data;
1394 i = con_font_op(vc, &op);
1395 if (i)
1396 return i;
1397 ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
1398 if (copy_to_user(fontop, &op, sizeof(struct console_font_op32)))
1399 return -EFAULT;
1400 return 0;
1403 struct unimapdesc32 {
1404 unsigned short entry_ct;
1405 compat_caddr_t entries;
1406 };
1408 static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
1410 struct unimapdesc32 tmp;
1411 struct unimapdesc32 __user *user_ud = compat_ptr(arg);
1412 int perm = vt_check(file);
1414 if (perm < 0) return perm;
1415 if (copy_from_user(&tmp, user_ud, sizeof tmp))
1416 return -EFAULT;
1417 switch (cmd) {
1418 case PIO_UNIMAP:
1419 if (!perm) return -EPERM;
1420 return con_set_unimap(vc_cons[fg_console].d, tmp.entry_ct, compat_ptr(tmp.entries));
1421 case GIO_UNIMAP:
1422 return con_get_unimap(vc_cons[fg_console].d, tmp.entry_ct, &(user_ud->entry_ct), compat_ptr(tmp.entries));
1424 return 0;
1427 #endif /* CONFIG_VT */
1429 static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg)
1431 mm_segment_t old_fs = get_fs();
1432 __kernel_uid_t kuid;
1433 int err;
1435 cmd = SMB_IOC_GETMOUNTUID;
1437 set_fs(KERNEL_DS);
1438 err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
1439 set_fs(old_fs);
1441 if (err >= 0)
1442 err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg));
1444 return err;
1447 struct atmif_sioc32 {
1448 compat_int_t number;
1449 compat_int_t length;
1450 compat_caddr_t arg;
1451 };
1453 struct atm_iobuf32 {
1454 compat_int_t length;
1455 compat_caddr_t buffer;
1456 };
1458 #define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32)
1459 #define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32)
1460 #define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32)
1461 #define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32)
1462 #define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32)
1463 #define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32)
1464 #define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32)
1465 #define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32)
1466 #define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32)
1467 #define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32)
1468 #define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32)
1469 #define ATM_SETESIF32 _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32)
1470 #define ATM_GETSTAT32 _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32)
1471 #define ATM_GETSTATZ32 _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32)
1472 #define ATM_GETLOOP32 _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32)
1473 #define ATM_SETLOOP32 _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32)
1474 #define ATM_QUERYLOOP32 _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32)
1476 static struct {
1477 unsigned int cmd32;
1478 unsigned int cmd;
1479 } atm_ioctl_map[] = {
1480 { ATM_GETLINKRATE32, ATM_GETLINKRATE },
1481 { ATM_GETNAMES32, ATM_GETNAMES },
1482 { ATM_GETTYPE32, ATM_GETTYPE },
1483 { ATM_GETESI32, ATM_GETESI },
1484 { ATM_GETADDR32, ATM_GETADDR },
1485 { ATM_RSTADDR32, ATM_RSTADDR },
1486 { ATM_ADDADDR32, ATM_ADDADDR },
1487 { ATM_DELADDR32, ATM_DELADDR },
1488 { ATM_GETCIRANGE32, ATM_GETCIRANGE },
1489 { ATM_SETCIRANGE32, ATM_SETCIRANGE },
1490 { ATM_SETESI32, ATM_SETESI },
1491 { ATM_SETESIF32, ATM_SETESIF },
1492 { ATM_GETSTAT32, ATM_GETSTAT },
1493 { ATM_GETSTATZ32, ATM_GETSTATZ },
1494 { ATM_GETLOOP32, ATM_GETLOOP },
1495 { ATM_SETLOOP32, ATM_SETLOOP },
1496 { ATM_QUERYLOOP32, ATM_QUERYLOOP }
1497 };
1499 #define NR_ATM_IOCTL ARRAY_SIZE(atm_ioctl_map)
1501 static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg)
1503 struct atm_iobuf __user *iobuf;
1504 struct atm_iobuf32 __user *iobuf32;
1505 u32 data;
1506 void __user *datap;
1507 int len, err;
1509 iobuf = compat_alloc_user_space(sizeof(*iobuf));
1510 iobuf32 = compat_ptr(arg);
1512 if (get_user(len, &iobuf32->length) ||
1513 get_user(data, &iobuf32->buffer))
1514 return -EFAULT;
1515 datap = compat_ptr(data);
1516 if (put_user(len, &iobuf->length) ||
1517 put_user(datap, &iobuf->buffer))
1518 return -EFAULT;
1520 err = sys_ioctl(fd, cmd, (unsigned long)iobuf);
1522 if (!err) {
1523 if (copy_in_user(&iobuf32->length, &iobuf->length,
1524 sizeof(int)))
1525 err = -EFAULT;
1528 return err;
1531 static int do_atmif_sioc(unsigned int fd, unsigned int cmd, unsigned long arg)
1533 struct atmif_sioc __user *sioc;
1534 struct atmif_sioc32 __user *sioc32;
1535 u32 data;
1536 void __user *datap;
1537 int err;
1539 sioc = compat_alloc_user_space(sizeof(*sioc));
1540 sioc32 = compat_ptr(arg);
1542 if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) ||
1543 get_user(data, &sioc32->arg))
1544 return -EFAULT;
1545 datap = compat_ptr(data);
1546 if (put_user(datap, &sioc->arg))
1547 return -EFAULT;
1549 err = sys_ioctl(fd, cmd, (unsigned long) sioc);
1551 if (!err) {
1552 if (copy_in_user(&sioc32->length, &sioc->length,
1553 sizeof(int)))
1554 err = -EFAULT;
1556 return err;
1559 static int do_atm_ioctl(unsigned int fd, unsigned int cmd32, unsigned long arg)
1561 int i;
1562 unsigned int cmd = 0;
1564 switch (cmd32) {
1565 case SONET_GETSTAT:
1566 case SONET_GETSTATZ:
1567 case SONET_GETDIAG:
1568 case SONET_SETDIAG:
1569 case SONET_CLRDIAG:
1570 case SONET_SETFRAMING:
1571 case SONET_GETFRAMING:
1572 case SONET_GETFRSENSE:
1573 return do_atmif_sioc(fd, cmd32, arg);
1576 for (i = 0; i < NR_ATM_IOCTL; i++) {
1577 if (cmd32 == atm_ioctl_map[i].cmd32) {
1578 cmd = atm_ioctl_map[i].cmd;
1579 break;
1582 if (i == NR_ATM_IOCTL)
1583 return -EINVAL;
1585 switch (cmd) {
1586 case ATM_GETNAMES:
1587 return do_atm_iobuf(fd, cmd, arg);
1589 case ATM_GETLINKRATE:
1590 case ATM_GETTYPE:
1591 case ATM_GETESI:
1592 case ATM_GETADDR:
1593 case ATM_RSTADDR:
1594 case ATM_ADDADDR:
1595 case ATM_DELADDR:
1596 case ATM_GETCIRANGE:
1597 case ATM_SETCIRANGE:
1598 case ATM_SETESI:
1599 case ATM_SETESIF:
1600 case ATM_GETSTAT:
1601 case ATM_GETSTATZ:
1602 case ATM_GETLOOP:
1603 case ATM_SETLOOP:
1604 case ATM_QUERYLOOP:
1605 return do_atmif_sioc(fd, cmd, arg);
1608 return -EINVAL;
1611 static __attribute_used__ int
1612 ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
1614 return -EINVAL;
1617 static int broken_blkgetsize(unsigned int fd, unsigned int cmd, unsigned long arg)
1619 /* The mkswap binary hard codes it to Intel value :-((( */
1620 return w_long(fd, BLKGETSIZE, arg);
1623 struct blkpg_ioctl_arg32 {
1624 compat_int_t op;
1625 compat_int_t flags;
1626 compat_int_t datalen;
1627 compat_caddr_t data;
1628 };
1630 static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1632 struct blkpg_ioctl_arg32 __user *ua32 = compat_ptr(arg);
1633 struct blkpg_ioctl_arg __user *a = compat_alloc_user_space(sizeof(*a));
1634 compat_caddr_t udata;
1635 compat_int_t n;
1636 int err;
1638 err = get_user(n, &ua32->op);
1639 err |= put_user(n, &a->op);
1640 err |= get_user(n, &ua32->flags);
1641 err |= put_user(n, &a->flags);
1642 err |= get_user(n, &ua32->datalen);
1643 err |= put_user(n, &a->datalen);
1644 err |= get_user(udata, &ua32->data);
1645 err |= put_user(compat_ptr(udata), &a->data);
1646 if (err)
1647 return err;
1649 return sys_ioctl(fd, cmd, (unsigned long)a);
1652 static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
1654 return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
1657 /* Fix sizeof(sizeof()) breakage */
1658 #define BLKBSZGET_32 _IOR(0x12,112,int)
1659 #define BLKBSZSET_32 _IOW(0x12,113,int)
1660 #define BLKGETSIZE64_32 _IOR(0x12,114,int)
1662 static int do_blkbszget(unsigned int fd, unsigned int cmd, unsigned long arg)
1664 return sys_ioctl(fd, BLKBSZGET, (unsigned long)compat_ptr(arg));
1667 static int do_blkbszset(unsigned int fd, unsigned int cmd, unsigned long arg)
1669 return sys_ioctl(fd, BLKBSZSET, (unsigned long)compat_ptr(arg));
1672 static int do_blkgetsize64(unsigned int fd, unsigned int cmd,
1673 unsigned long arg)
1675 return sys_ioctl(fd, BLKGETSIZE64, (unsigned long)compat_ptr(arg));
1678 /* Bluetooth ioctls */
1679 #define HCIUARTSETPROTO _IOW('U', 200, int)
1680 #define HCIUARTGETPROTO _IOR('U', 201, int)
1682 #define BNEPCONNADD _IOW('B', 200, int)
1683 #define BNEPCONNDEL _IOW('B', 201, int)
1684 #define BNEPGETCONNLIST _IOR('B', 210, int)
1685 #define BNEPGETCONNINFO _IOR('B', 211, int)
1687 #define CMTPCONNADD _IOW('C', 200, int)
1688 #define CMTPCONNDEL _IOW('C', 201, int)
1689 #define CMTPGETCONNLIST _IOR('C', 210, int)
1690 #define CMTPGETCONNINFO _IOR('C', 211, int)
1692 #define HIDPCONNADD _IOW('H', 200, int)
1693 #define HIDPCONNDEL _IOW('H', 201, int)
1694 #define HIDPGETCONNLIST _IOR('H', 210, int)
1695 #define HIDPGETCONNINFO _IOR('H', 211, int)
1697 struct floppy_struct32 {
1698 compat_uint_t size;
1699 compat_uint_t sect;
1700 compat_uint_t head;
1701 compat_uint_t track;
1702 compat_uint_t stretch;
1703 unsigned char gap;
1704 unsigned char rate;
1705 unsigned char spec1;
1706 unsigned char fmt_gap;
1707 const compat_caddr_t name;
1708 };
1710 struct floppy_drive_params32 {
1711 char cmos;
1712 compat_ulong_t max_dtr;
1713 compat_ulong_t hlt;
1714 compat_ulong_t hut;
1715 compat_ulong_t srt;
1716 compat_ulong_t spinup;
1717 compat_ulong_t spindown;
1718 unsigned char spindown_offset;
1719 unsigned char select_delay;
1720 unsigned char rps;
1721 unsigned char tracks;
1722 compat_ulong_t timeout;
1723 unsigned char interleave_sect;
1724 struct floppy_max_errors max_errors;
1725 char flags;
1726 char read_track;
1727 short autodetect[8];
1728 compat_int_t checkfreq;
1729 compat_int_t native_format;
1730 };
1732 struct floppy_drive_struct32 {
1733 signed char flags;
1734 compat_ulong_t spinup_date;
1735 compat_ulong_t select_date;
1736 compat_ulong_t first_read_date;
1737 short probed_format;
1738 short track;
1739 short maxblock;
1740 short maxtrack;
1741 compat_int_t generation;
1742 compat_int_t keep_data;
1743 compat_int_t fd_ref;
1744 compat_int_t fd_device;
1745 compat_int_t last_checked;
1746 compat_caddr_t dmabuf;
1747 compat_int_t bufblocks;
1748 };
1750 struct floppy_fdc_state32 {
1751 compat_int_t spec1;
1752 compat_int_t spec2;
1753 compat_int_t dtr;
1754 unsigned char version;
1755 unsigned char dor;
1756 compat_ulong_t address;
1757 unsigned int rawcmd:2;
1758 unsigned int reset:1;
1759 unsigned int need_configure:1;
1760 unsigned int perp_mode:2;
1761 unsigned int has_fifo:1;
1762 unsigned int driver_version;
1763 unsigned char track[4];
1764 };
1766 struct floppy_write_errors32 {
1767 unsigned int write_errors;
1768 compat_ulong_t first_error_sector;
1769 compat_int_t first_error_generation;
1770 compat_ulong_t last_error_sector;
1771 compat_int_t last_error_generation;
1772 compat_uint_t badness;
1773 };
1775 #define FDSETPRM32 _IOW(2, 0x42, struct floppy_struct32)
1776 #define FDDEFPRM32 _IOW(2, 0x43, struct floppy_struct32)
1777 #define FDGETPRM32 _IOR(2, 0x04, struct floppy_struct32)
1778 #define FDSETDRVPRM32 _IOW(2, 0x90, struct floppy_drive_params32)
1779 #define FDGETDRVPRM32 _IOR(2, 0x11, struct floppy_drive_params32)
1780 #define FDGETDRVSTAT32 _IOR(2, 0x12, struct floppy_drive_struct32)
1781 #define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct floppy_drive_struct32)
1782 #define FDGETFDCSTAT32 _IOR(2, 0x15, struct floppy_fdc_state32)
1783 #define FDWERRORGET32 _IOR(2, 0x17, struct floppy_write_errors32)
1785 static struct {
1786 unsigned int cmd32;
1787 unsigned int cmd;
1788 } fd_ioctl_trans_table[] = {
1789 { FDSETPRM32, FDSETPRM },
1790 { FDDEFPRM32, FDDEFPRM },
1791 { FDGETPRM32, FDGETPRM },
1792 { FDSETDRVPRM32, FDSETDRVPRM },
1793 { FDGETDRVPRM32, FDGETDRVPRM },
1794 { FDGETDRVSTAT32, FDGETDRVSTAT },
1795 { FDPOLLDRVSTAT32, FDPOLLDRVSTAT },
1796 { FDGETFDCSTAT32, FDGETFDCSTAT },
1797 { FDWERRORGET32, FDWERRORGET }
1798 };
1800 #define NR_FD_IOCTL_TRANS ARRAY_SIZE(fd_ioctl_trans_table)
1802 static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1804 mm_segment_t old_fs = get_fs();
1805 void *karg = NULL;
1806 unsigned int kcmd = 0;
1807 int i, err;
1809 for (i = 0; i < NR_FD_IOCTL_TRANS; i++)
1810 if (cmd == fd_ioctl_trans_table[i].cmd32) {
1811 kcmd = fd_ioctl_trans_table[i].cmd;
1812 break;
1814 if (!kcmd)
1815 return -EINVAL;
1817 switch (cmd) {
1818 case FDSETPRM32:
1819 case FDDEFPRM32:
1820 case FDGETPRM32:
1822 compat_uptr_t name;
1823 struct floppy_struct32 __user *uf;
1824 struct floppy_struct *f;
1826 uf = compat_ptr(arg);
1827 f = karg = kmalloc(sizeof(struct floppy_struct), GFP_KERNEL);
1828 if (!karg)
1829 return -ENOMEM;
1830 if (cmd == FDGETPRM32)
1831 break;
1832 err = __get_user(f->size, &uf->size);
1833 err |= __get_user(f->sect, &uf->sect);
1834 err |= __get_user(f->head, &uf->head);
1835 err |= __get_user(f->track, &uf->track);
1836 err |= __get_user(f->stretch, &uf->stretch);
1837 err |= __get_user(f->gap, &uf->gap);
1838 err |= __get_user(f->rate, &uf->rate);
1839 err |= __get_user(f->spec1, &uf->spec1);
1840 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
1841 err |= __get_user(name, &uf->name);
1842 f->name = compat_ptr(name);
1843 if (err) {
1844 err = -EFAULT;
1845 goto out;
1847 break;
1849 case FDSETDRVPRM32:
1850 case FDGETDRVPRM32:
1852 struct floppy_drive_params32 __user *uf;
1853 struct floppy_drive_params *f;
1855 uf = compat_ptr(arg);
1856 f = karg = kmalloc(sizeof(struct floppy_drive_params), GFP_KERNEL);
1857 if (!karg)
1858 return -ENOMEM;
1859 if (cmd == FDGETDRVPRM32)
1860 break;
1861 err = __get_user(f->cmos, &uf->cmos);
1862 err |= __get_user(f->max_dtr, &uf->max_dtr);
1863 err |= __get_user(f->hlt, &uf->hlt);
1864 err |= __get_user(f->hut, &uf->hut);
1865 err |= __get_user(f->srt, &uf->srt);
1866 err |= __get_user(f->spinup, &uf->spinup);
1867 err |= __get_user(f->spindown, &uf->spindown);
1868 err |= __get_user(f->spindown_offset, &uf->spindown_offset);
1869 err |= __get_user(f->select_delay, &uf->select_delay);
1870 err |= __get_user(f->rps, &uf->rps);
1871 err |= __get_user(f->tracks, &uf->tracks);
1872 err |= __get_user(f->timeout, &uf->timeout);
1873 err |= __get_user(f->interleave_sect, &uf->interleave_sect);
1874 err |= __copy_from_user(&f->max_errors, &uf->max_errors, sizeof(f->max_errors));
1875 err |= __get_user(f->flags, &uf->flags);
1876 err |= __get_user(f->read_track, &uf->read_track);
1877 err |= __copy_from_user(f->autodetect, uf->autodetect, sizeof(f->autodetect));
1878 err |= __get_user(f->checkfreq, &uf->checkfreq);
1879 err |= __get_user(f->native_format, &uf->native_format);
1880 if (err) {
1881 err = -EFAULT;
1882 goto out;
1884 break;
1886 case FDGETDRVSTAT32:
1887 case FDPOLLDRVSTAT32:
1888 karg = kmalloc(sizeof(struct floppy_drive_struct), GFP_KERNEL);
1889 if (!karg)
1890 return -ENOMEM;
1891 break;
1892 case FDGETFDCSTAT32:
1893 karg = kmalloc(sizeof(struct floppy_fdc_state), GFP_KERNEL);
1894 if (!karg)
1895 return -ENOMEM;
1896 break;
1897 case FDWERRORGET32:
1898 karg = kmalloc(sizeof(struct floppy_write_errors), GFP_KERNEL);
1899 if (!karg)
1900 return -ENOMEM;
1901 break;
1902 default:
1903 return -EINVAL;
1905 set_fs (KERNEL_DS);
1906 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1907 set_fs (old_fs);
1908 if (err)
1909 goto out;
1910 switch (cmd) {
1911 case FDGETPRM32:
1913 struct floppy_struct *f = karg;
1914 struct floppy_struct32 __user *uf = compat_ptr(arg);
1916 err = __put_user(f->size, &uf->size);
1917 err |= __put_user(f->sect, &uf->sect);
1918 err |= __put_user(f->head, &uf->head);
1919 err |= __put_user(f->track, &uf->track);
1920 err |= __put_user(f->stretch, &uf->stretch);
1921 err |= __put_user(f->gap, &uf->gap);
1922 err |= __put_user(f->rate, &uf->rate);
1923 err |= __put_user(f->spec1, &uf->spec1);
1924 err |= __put_user(f->fmt_gap, &uf->fmt_gap);
1925 err |= __put_user((u64)f->name, (compat_caddr_t __user *)&uf->name);
1926 break;
1928 case FDGETDRVPRM32:
1930 struct floppy_drive_params32 __user *uf;
1931 struct floppy_drive_params *f = karg;
1933 uf = compat_ptr(arg);
1934 err = __put_user(f->cmos, &uf->cmos);
1935 err |= __put_user(f->max_dtr, &uf->max_dtr);
1936 err |= __put_user(f->hlt, &uf->hlt);
1937 err |= __put_user(f->hut, &uf->hut);
1938 err |= __put_user(f->srt, &uf->srt);
1939 err |= __put_user(f->spinup, &uf->spinup);
1940 err |= __put_user(f->spindown, &uf->spindown);
1941 err |= __put_user(f->spindown_offset, &uf->spindown_offset);
1942 err |= __put_user(f->select_delay, &uf->select_delay);
1943 err |= __put_user(f->rps, &uf->rps);
1944 err |= __put_user(f->tracks, &uf->tracks);
1945 err |= __put_user(f->timeout, &uf->timeout);
1946 err |= __put_user(f->interleave_sect, &uf->interleave_sect);
1947 err |= __copy_to_user(&uf->max_errors, &f->max_errors, sizeof(f->max_errors));
1948 err |= __put_user(f->flags, &uf->flags);
1949 err |= __put_user(f->read_track, &uf->read_track);
1950 err |= __copy_to_user(uf->autodetect, f->autodetect, sizeof(f->autodetect));
1951 err |= __put_user(f->checkfreq, &uf->checkfreq);
1952 err |= __put_user(f->native_format, &uf->native_format);
1953 break;
1955 case FDGETDRVSTAT32:
1956 case FDPOLLDRVSTAT32:
1958 struct floppy_drive_struct32 __user *uf;
1959 struct floppy_drive_struct *f = karg;
1961 uf = compat_ptr(arg);
1962 err = __put_user(f->flags, &uf->flags);
1963 err |= __put_user(f->spinup_date, &uf->spinup_date);
1964 err |= __put_user(f->select_date, &uf->select_date);
1965 err |= __put_user(f->first_read_date, &uf->first_read_date);
1966 err |= __put_user(f->probed_format, &uf->probed_format);
1967 err |= __put_user(f->track, &uf->track);
1968 err |= __put_user(f->maxblock, &uf->maxblock);
1969 err |= __put_user(f->maxtrack, &uf->maxtrack);
1970 err |= __put_user(f->generation, &uf->generation);
1971 err |= __put_user(f->keep_data, &uf->keep_data);
1972 err |= __put_user(f->fd_ref, &uf->fd_ref);
1973 err |= __put_user(f->fd_device, &uf->fd_device);
1974 err |= __put_user(f->last_checked, &uf->last_checked);
1975 err |= __put_user((u64)f->dmabuf, &uf->dmabuf);
1976 err |= __put_user((u64)f->bufblocks, &uf->bufblocks);
1977 break;
1979 case FDGETFDCSTAT32:
1981 struct floppy_fdc_state32 __user *uf;
1982 struct floppy_fdc_state *f = karg;
1984 uf = compat_ptr(arg);
1985 err = __put_user(f->spec1, &uf->spec1);
1986 err |= __put_user(f->spec2, &uf->spec2);
1987 err |= __put_user(f->dtr, &uf->dtr);
1988 err |= __put_user(f->version, &uf->version);
1989 err |= __put_user(f->dor, &uf->dor);
1990 err |= __put_user(f->address, &uf->address);
1991 err |= __copy_to_user((char __user *)&uf->address + sizeof(uf->address),
1992 (char *)&f->address + sizeof(f->address), sizeof(int));
1993 err |= __put_user(f->driver_version, &uf->driver_version);
1994 err |= __copy_to_user(uf->track, f->track, sizeof(f->track));
1995 break;
1997 case FDWERRORGET32:
1999 struct floppy_write_errors32 __user *uf;
2000 struct floppy_write_errors *f = karg;
2002 uf = compat_ptr(arg);
2003 err = __put_user(f->write_errors, &uf->write_errors);
2004 err |= __put_user(f->first_error_sector, &uf->first_error_sector);
2005 err |= __put_user(f->first_error_generation, &uf->first_error_generation);
2006 err |= __put_user(f->last_error_sector, &uf->last_error_sector);
2007 err |= __put_user(f->last_error_generation, &uf->last_error_generation);
2008 err |= __put_user(f->badness, &uf->badness);
2009 break;
2011 default:
2012 break;
2014 if (err)
2015 err = -EFAULT;
2017 out:
2018 kfree(karg);
2019 return err;
2022 struct mtd_oob_buf32 {
2023 u_int32_t start;
2024 u_int32_t length;
2025 compat_caddr_t ptr; /* unsigned char* */
2026 };
2028 #define MEMWRITEOOB32 _IOWR('M',3,struct mtd_oob_buf32)
2029 #define MEMREADOOB32 _IOWR('M',4,struct mtd_oob_buf32)
2031 static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg)
2033 struct mtd_oob_buf __user *buf = compat_alloc_user_space(sizeof(*buf));
2034 struct mtd_oob_buf32 __user *buf32 = compat_ptr(arg);
2035 u32 data;
2036 char __user *datap;
2037 unsigned int real_cmd;
2038 int err;
2040 real_cmd = (cmd == MEMREADOOB32) ?
2041 MEMREADOOB : MEMWRITEOOB;
2043 if (copy_in_user(&buf->start, &buf32->start,
2044 2 * sizeof(u32)) ||
2045 get_user(data, &buf32->ptr))
2046 return -EFAULT;
2047 datap = compat_ptr(data);
2048 if (put_user(datap, &buf->ptr))
2049 return -EFAULT;
2051 err = sys_ioctl(fd, real_cmd, (unsigned long) buf);
2053 if (!err) {
2054 if (copy_in_user(&buf32->start, &buf->start,
2055 2 * sizeof(u32)))
2056 err = -EFAULT;
2059 return err;
2062 #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
2063 #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
2065 static long
2066 put_dirent32 (struct dirent *d, struct compat_dirent __user *d32)
2068 if (!access_ok(VERIFY_WRITE, d32, sizeof(struct compat_dirent)))
2069 return -EFAULT;
2071 __put_user(d->d_ino, &d32->d_ino);
2072 __put_user(d->d_off, &d32->d_off);
2073 __put_user(d->d_reclen, &d32->d_reclen);
2074 if (__copy_to_user(d32->d_name, d->d_name, d->d_reclen))
2075 return -EFAULT;
2077 return 0;
2080 static int vfat_ioctl32(unsigned fd, unsigned cmd, unsigned long arg)
2082 struct compat_dirent __user *p = compat_ptr(arg);
2083 int ret;
2084 mm_segment_t oldfs = get_fs();
2085 struct dirent d[2];
2087 switch(cmd)
2089 case VFAT_IOCTL_READDIR_BOTH32:
2090 cmd = VFAT_IOCTL_READDIR_BOTH;
2091 break;
2092 case VFAT_IOCTL_READDIR_SHORT32:
2093 cmd = VFAT_IOCTL_READDIR_SHORT;
2094 break;
2097 set_fs(KERNEL_DS);
2098 ret = sys_ioctl(fd,cmd,(unsigned long)&d);
2099 set_fs(oldfs);
2100 if (ret >= 0) {
2101 ret |= put_dirent32(&d[0], p);
2102 ret |= put_dirent32(&d[1], p + 1);
2104 return ret;
2107 #define REISERFS_IOC_UNPACK32 _IOW(0xCD,1,int)
2109 static int reiserfs_ioctl32(unsigned fd, unsigned cmd, unsigned long ptr)
2111 if (cmd == REISERFS_IOC_UNPACK32)
2112 cmd = REISERFS_IOC_UNPACK;
2114 return sys_ioctl(fd,cmd,ptr);
2117 struct raw32_config_request
2119 compat_int_t raw_minor;
2120 __u64 block_major;
2121 __u64 block_minor;
2122 } __attribute__((packed));
2124 static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
2126 int ret;
2128 if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request)))
2129 return -EFAULT;
2131 ret = __get_user(req->raw_minor, &user_req->raw_minor);
2132 ret |= __get_user(req->block_major, &user_req->block_major);
2133 ret |= __get_user(req->block_minor, &user_req->block_minor);
2135 return ret ? -EFAULT : 0;
2138 static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
2140 int ret;
2142 if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request)))
2143 return -EFAULT;
2145 ret = __put_user(req->raw_minor, &user_req->raw_minor);
2146 ret |= __put_user(req->block_major, &user_req->block_major);
2147 ret |= __put_user(req->block_minor, &user_req->block_minor);
2149 return ret ? -EFAULT : 0;
2152 static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2154 int ret;
2156 switch (cmd) {
2157 case RAW_SETBIND:
2158 case RAW_GETBIND: {
2159 struct raw_config_request req;
2160 struct raw32_config_request __user *user_req = compat_ptr(arg);
2161 mm_segment_t oldfs = get_fs();
2163 if ((ret = get_raw32_request(&req, user_req)))
2164 return ret;
2166 set_fs(KERNEL_DS);
2167 ret = sys_ioctl(fd,cmd,(unsigned long)&req);
2168 set_fs(oldfs);
2170 if ((!ret) && (cmd == RAW_GETBIND)) {
2171 ret = set_raw32_request(&req, user_req);
2173 break;
2175 default:
2176 ret = sys_ioctl(fd, cmd, arg);
2177 break;
2179 return ret;
2182 struct serial_struct32 {
2183 compat_int_t type;
2184 compat_int_t line;
2185 compat_uint_t port;
2186 compat_int_t irq;
2187 compat_int_t flags;
2188 compat_int_t xmit_fifo_size;
2189 compat_int_t custom_divisor;
2190 compat_int_t baud_base;
2191 unsigned short close_delay;
2192 char io_type;
2193 char reserved_char[1];
2194 compat_int_t hub6;
2195 unsigned short closing_wait; /* time to wait before closing */
2196 unsigned short closing_wait2; /* no longer used... */
2197 compat_uint_t iomem_base;
2198 unsigned short iomem_reg_shift;
2199 unsigned int port_high;
2200 /* compat_ulong_t iomap_base FIXME */
2201 compat_int_t reserved[1];
2202 };
2204 static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2206 typedef struct serial_struct SS;
2207 typedef struct serial_struct32 SS32;
2208 struct serial_struct32 __user *ss32 = compat_ptr(arg);
2209 int err;
2210 struct serial_struct ss;
2211 mm_segment_t oldseg = get_fs();
2212 __u32 udata;
2214 if (cmd == TIOCSSERIAL) {
2215 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
2216 return -EFAULT;
2217 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
2218 return -EFAULT;
2219 __get_user(udata, &ss32->iomem_base);
2220 ss.iomem_base = compat_ptr(udata);
2221 __get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift);
2222 __get_user(ss.port_high, &ss32->port_high);
2223 ss.iomap_base = 0UL;
2225 set_fs(KERNEL_DS);
2226 err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
2227 set_fs(oldseg);
2228 if (cmd == TIOCGSERIAL && err >= 0) {
2229 if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32)))
2230 return -EFAULT;
2231 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
2232 return -EFAULT;
2233 __put_user((unsigned long)ss.iomem_base >> 32 ?
2234 0xffffffff : (unsigned)(unsigned long)ss.iomem_base,
2235 &ss32->iomem_base);
2236 __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift);
2237 __put_user(ss.port_high, &ss32->port_high);
2240 return err;
2243 struct usbdevfs_ctrltransfer32 {
2244 u8 bRequestType;
2245 u8 bRequest;
2246 u16 wValue;
2247 u16 wIndex;
2248 u16 wLength;
2249 u32 timeout; /* in milliseconds */
2250 compat_caddr_t data;
2251 };
2253 #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
2255 static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
2257 struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg);
2258 struct usbdevfs_ctrltransfer __user *p;
2259 __u32 udata;
2260 p = compat_alloc_user_space(sizeof(*p));
2261 if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
2262 get_user(udata, &p32->data) ||
2263 put_user(compat_ptr(udata), &p->data))
2264 return -EFAULT;
2265 return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p);
2269 struct usbdevfs_bulktransfer32 {
2270 compat_uint_t ep;
2271 compat_uint_t len;
2272 compat_uint_t timeout; /* in milliseconds */
2273 compat_caddr_t data;
2274 };
2276 #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
2278 static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
2280 struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg);
2281 struct usbdevfs_bulktransfer __user *p;
2282 compat_uint_t n;
2283 compat_caddr_t addr;
2285 p = compat_alloc_user_space(sizeof(*p));
2287 if (get_user(n, &p32->ep) || put_user(n, &p->ep) ||
2288 get_user(n, &p32->len) || put_user(n, &p->len) ||
2289 get_user(n, &p32->timeout) || put_user(n, &p->timeout) ||
2290 get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data))
2291 return -EFAULT;
2293 return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p);
2297 /*
2298 * USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY
2299 * are handled in usbdevfs core. -Christopher Li
2300 */
2302 struct usbdevfs_disconnectsignal32 {
2303 compat_int_t signr;
2304 compat_caddr_t context;
2305 };
2307 #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
2309 static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
2311 struct usbdevfs_disconnectsignal kdis;
2312 struct usbdevfs_disconnectsignal32 __user *udis;
2313 mm_segment_t old_fs;
2314 u32 uctx;
2315 int err;
2317 udis = compat_ptr(arg);
2319 if (get_user(kdis.signr, &udis->signr) ||
2320 __get_user(uctx, &udis->context))
2321 return -EFAULT;
2323 kdis.context = compat_ptr(uctx);
2325 old_fs = get_fs();
2326 set_fs(KERNEL_DS);
2327 err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
2328 set_fs(old_fs);
2330 return err;
2333 /*
2334 * I2C layer ioctls
2335 */
2337 struct i2c_msg32 {
2338 u16 addr;
2339 u16 flags;
2340 u16 len;
2341 compat_caddr_t buf;
2342 };
2344 struct i2c_rdwr_ioctl_data32 {
2345 compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
2346 u32 nmsgs;
2347 };
2349 struct i2c_smbus_ioctl_data32 {
2350 u8 read_write;
2351 u8 command;
2352 u32 size;
2353 compat_caddr_t data; /* union i2c_smbus_data *data */
2354 };
2356 struct i2c_rdwr_aligned {
2357 struct i2c_rdwr_ioctl_data cmd;
2358 struct i2c_msg msgs[0];
2359 };
2361 static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2363 struct i2c_rdwr_ioctl_data32 __user *udata = compat_ptr(arg);
2364 struct i2c_rdwr_aligned __user *tdata;
2365 struct i2c_msg __user *tmsgs;
2366 struct i2c_msg32 __user *umsgs;
2367 compat_caddr_t datap;
2368 int nmsgs, i;
2370 if (get_user(nmsgs, &udata->nmsgs))
2371 return -EFAULT;
2372 if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
2373 return -EINVAL;
2375 if (get_user(datap, &udata->msgs))
2376 return -EFAULT;
2377 umsgs = compat_ptr(datap);
2379 tdata = compat_alloc_user_space(sizeof(*tdata) +
2380 nmsgs * sizeof(struct i2c_msg));
2381 tmsgs = &tdata->msgs[0];
2383 if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
2384 put_user(tmsgs, &tdata->cmd.msgs))
2385 return -EFAULT;
2387 for (i = 0; i < nmsgs; i++) {
2388 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
2389 return -EFAULT;
2390 if (get_user(datap, &umsgs[i].buf) ||
2391 put_user(compat_ptr(datap), &tmsgs[i].buf))
2392 return -EFAULT;
2394 return sys_ioctl(fd, cmd, (unsigned long)tdata);
2397 static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2399 struct i2c_smbus_ioctl_data __user *tdata;
2400 struct i2c_smbus_ioctl_data32 __user *udata;
2401 compat_caddr_t datap;
2403 tdata = compat_alloc_user_space(sizeof(*tdata));
2404 if (tdata == NULL)
2405 return -ENOMEM;
2406 if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
2407 return -EFAULT;
2409 udata = compat_ptr(arg);
2410 if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
2411 return -EFAULT;
2413 if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
2414 return -EFAULT;
2415 if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
2416 return -EFAULT;
2417 if (__get_user(datap, &udata->data) ||
2418 __put_user(compat_ptr(datap), &tdata->data))
2419 return -EFAULT;
2421 return sys_ioctl(fd, cmd, (unsigned long)tdata);
2424 struct compat_iw_point {
2425 compat_caddr_t pointer;
2426 __u16 length;
2427 __u16 flags;
2428 };
2430 static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2432 struct iwreq __user *iwr;
2433 struct iwreq __user *iwr_u;
2434 struct iw_point __user *iwp;
2435 struct compat_iw_point __user *iwp_u;
2436 compat_caddr_t pointer;
2437 __u16 length, flags;
2439 iwr_u = compat_ptr(arg);
2440 iwp_u = (struct compat_iw_point __user *) &iwr_u->u.data;
2441 iwr = compat_alloc_user_space(sizeof(*iwr));
2442 if (iwr == NULL)
2443 return -ENOMEM;
2445 iwp = &iwr->u.data;
2447 if (!access_ok(VERIFY_WRITE, iwr, sizeof(*iwr)))
2448 return -EFAULT;
2450 if (__copy_in_user(&iwr->ifr_ifrn.ifrn_name[0],
2451 &iwr_u->ifr_ifrn.ifrn_name[0],
2452 sizeof(iwr->ifr_ifrn.ifrn_name)))
2453 return -EFAULT;
2455 if (__get_user(pointer, &iwp_u->pointer) ||
2456 __get_user(length, &iwp_u->length) ||
2457 __get_user(flags, &iwp_u->flags))
2458 return -EFAULT;
2460 if (__put_user(compat_ptr(pointer), &iwp->pointer) ||
2461 __put_user(length, &iwp->length) ||
2462 __put_user(flags, &iwp->flags))
2463 return -EFAULT;
2465 return sys_ioctl(fd, cmd, (unsigned long) iwr);
2468 /* Since old style bridge ioctl's endup using SIOCDEVPRIVATE
2469 * for some operations; this forces use of the newer bridge-utils that
2470 * use compatiable ioctls
2471 */
2472 static int old_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2474 u32 tmp;
2476 if (get_user(tmp, (u32 __user *) arg))
2477 return -EFAULT;
2478 if (tmp == BRCTL_GET_VERSION)
2479 return BRCTL_VERSION + 1;
2480 return -EINVAL;
2483 #define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
2484 #define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t)
2485 #define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
2486 #define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t)
2488 static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2490 mm_segment_t oldfs = get_fs();
2491 compat_ulong_t val32;
2492 unsigned long kval;
2493 int ret;
2495 switch (cmd) {
2496 case RTC_IRQP_READ32:
2497 case RTC_EPOCH_READ32:
2498 set_fs(KERNEL_DS);
2499 ret = sys_ioctl(fd, (cmd == RTC_IRQP_READ32) ?
2500 RTC_IRQP_READ : RTC_EPOCH_READ,
2501 (unsigned long)&kval);
2502 set_fs(oldfs);
2503 if (ret)
2504 return ret;
2505 val32 = kval;
2506 return put_user(val32, (unsigned int __user *)arg);
2507 case RTC_IRQP_SET32:
2508 return sys_ioctl(fd, RTC_IRQP_SET, arg);
2509 case RTC_EPOCH_SET32:
2510 return sys_ioctl(fd, RTC_EPOCH_SET, arg);
2511 default:
2512 /* unreached */
2513 return -ENOIOCTLCMD;
2517 #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
2518 struct ncp_ioctl_request_32 {
2519 u32 function;
2520 u32 size;
2521 compat_caddr_t data;
2522 };
2524 struct ncp_fs_info_v2_32 {
2525 s32 version;
2526 u32 mounted_uid;
2527 u32 connection;
2528 u32 buffer_size;
2530 u32 volume_number;
2531 u32 directory_id;
2533 u32 dummy1;
2534 u32 dummy2;
2535 u32 dummy3;
2536 };
2538 struct ncp_objectname_ioctl_32
2540 s32 auth_type;
2541 u32 object_name_len;
2542 compat_caddr_t object_name; /* an userspace data, in most cases user name */
2543 };
2545 struct ncp_privatedata_ioctl_32
2547 u32 len;
2548 compat_caddr_t data; /* ~1000 for NDS */
2549 };
2551 #define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct ncp_ioctl_request_32)
2552 #define NCP_IOC_GETMOUNTUID2_32 _IOW('n', 2, u32)
2553 #define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct ncp_fs_info_v2_32)
2554 #define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct ncp_objectname_ioctl_32)
2555 #define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct ncp_objectname_ioctl_32)
2556 #define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct ncp_privatedata_ioctl_32)
2557 #define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct ncp_privatedata_ioctl_32)
2559 static int do_ncp_ncprequest(unsigned int fd, unsigned int cmd, unsigned long arg)
2561 struct ncp_ioctl_request_32 n32;
2562 struct ncp_ioctl_request __user *p = compat_alloc_user_space(sizeof(*p));
2564 if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)) ||
2565 put_user(n32.function, &p->function) ||
2566 put_user(n32.size, &p->size) ||
2567 put_user(compat_ptr(n32.data), &p->data))
2568 return -EFAULT;
2570 return sys_ioctl(fd, NCP_IOC_NCPREQUEST, (unsigned long)p);
2573 static int do_ncp_getmountuid2(unsigned int fd, unsigned int cmd, unsigned long arg)
2575 mm_segment_t old_fs = get_fs();
2576 __kernel_uid_t kuid;
2577 int err;
2579 cmd = NCP_IOC_GETMOUNTUID2;
2581 set_fs(KERNEL_DS);
2582 err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
2583 set_fs(old_fs);
2585 if (!err)
2586 err = put_user(kuid,
2587 (unsigned int __user *) compat_ptr(arg));
2589 return err;
2592 static int do_ncp_getfsinfo2(unsigned int fd, unsigned int cmd, unsigned long arg)
2594 mm_segment_t old_fs = get_fs();
2595 struct ncp_fs_info_v2_32 n32;
2596 struct ncp_fs_info_v2 n;
2597 int err;
2599 if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)))
2600 return -EFAULT;
2601 if (n32.version != NCP_GET_FS_INFO_VERSION_V2)
2602 return -EINVAL;
2603 n.version = NCP_GET_FS_INFO_VERSION_V2;
2605 set_fs(KERNEL_DS);
2606 err = sys_ioctl(fd, NCP_IOC_GET_FS_INFO_V2, (unsigned long)&n);
2607 set_fs(old_fs);
2609 if (!err) {
2610 n32.version = n.version;
2611 n32.mounted_uid = n.mounted_uid;
2612 n32.connection = n.connection;
2613 n32.buffer_size = n.buffer_size;
2614 n32.volume_number = n.volume_number;
2615 n32.directory_id = n.directory_id;
2616 n32.dummy1 = n.dummy1;
2617 n32.dummy2 = n.dummy2;
2618 n32.dummy3 = n.dummy3;
2619 err = copy_to_user(compat_ptr(arg), &n32, sizeof(n32)) ? -EFAULT : 0;
2621 return err;
2624 static int do_ncp_getobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
2626 struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2627 struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
2628 s32 auth_type;
2629 u32 name_len;
2630 int err;
2632 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2633 put_user(n32.object_name_len, &p->object_name_len) ||
2634 put_user(compat_ptr(n32.object_name), &p->object_name))
2635 return -EFAULT;
2637 err = sys_ioctl(fd, NCP_IOC_GETOBJECTNAME, (unsigned long)p);
2638 if (err)
2639 return err;
2641 if (get_user(auth_type, &p->auth_type) ||
2642 put_user(auth_type, &p32->auth_type) ||
2643 get_user(name_len, &p->object_name_len) ||
2644 put_user(name_len, &p32->object_name_len))
2645 return -EFAULT;
2647 return 0;
2650 static int do_ncp_setobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
2652 struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2653 struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
2655 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2656 put_user(n32.auth_type, &p->auth_type) ||
2657 put_user(n32.object_name_len, &p->object_name_len) ||
2658 put_user(compat_ptr(n32.object_name), &p->object_name))
2659 return -EFAULT;
2661 return sys_ioctl(fd, NCP_IOC_SETOBJECTNAME, (unsigned long)p);
2664 static int do_ncp_getprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
2666 struct ncp_privatedata_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2667 struct ncp_privatedata_ioctl __user *p =
2668 compat_alloc_user_space(sizeof(*p));
2669 u32 len;
2670 int err;
2672 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2673 put_user(n32.len, &p->len) ||
2674 put_user(compat_ptr(n32.data), &p->data))
2675 return -EFAULT;
2677 err = sys_ioctl(fd, NCP_IOC_GETPRIVATEDATA, (unsigned long)p);
2678 if (err)
2679 return err;
2681 if (get_user(len, &p->len) ||
2682 put_user(len, &p32->len))
2683 return -EFAULT;
2685 return 0;
2688 static int do_ncp_setprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
2690 struct ncp_privatedata_ioctl_32 n32;
2691 struct ncp_privatedata_ioctl_32 __user *p32 = compat_ptr(arg);
2692 struct ncp_privatedata_ioctl __user *p =
2693 compat_alloc_user_space(sizeof(*p));
2695 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2696 put_user(n32.len, &p->len) ||
2697 put_user(compat_ptr(n32.data), &p->data))
2698 return -EFAULT;
2700 return sys_ioctl(fd, NCP_IOC_SETPRIVATEDATA, (unsigned long)p);
2702 #endif
2704 static int
2705 lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
2707 struct compat_timeval __user *tc = (struct compat_timeval __user *)arg;
2708 struct timeval __user *tn = compat_alloc_user_space(sizeof(struct timeval));
2709 struct timeval ts;
2710 if (get_user(ts.tv_sec, &tc->tv_sec) ||
2711 get_user(ts.tv_usec, &tc->tv_usec) ||
2712 put_user(ts.tv_sec, &tn->tv_sec) ||
2713 put_user(ts.tv_usec, &tn->tv_usec))
2714 return -EFAULT;
2715 return sys_ioctl(fd, cmd, (unsigned long)tn);
2718 #define HANDLE_IOCTL(cmd,handler) \
2719 { (cmd), (ioctl_trans_handler_t)(handler) },
2721 /* pointer to compatible structure or no argument */
2722 #define COMPATIBLE_IOCTL(cmd) \
2723 { (cmd), do_ioctl32_pointer },
2725 /* argument is an unsigned long integer, not a pointer */
2726 #define ULONG_IOCTL(cmd) \
2727 { (cmd), (ioctl_trans_handler_t)sys_ioctl },
2730 struct ioctl_trans ioctl_start[] = {
2731 #include <linux/compat_ioctl.h>
2732 HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob)
2733 HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob)
2734 #ifdef CONFIG_NET
2735 HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
2736 HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)
2737 HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc)
2738 HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc)
2739 HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc)
2740 HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc)
2741 HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc)
2742 HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc)
2743 HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc)
2744 HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc)
2745 HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc)
2746 HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc)
2747 HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc)
2748 HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc)
2749 HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc)
2750 HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc)
2751 HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
2752 HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
2753 HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
2755 /* ioctls used by appletalk ddp.c */
2756 HANDLE_IOCTL(SIOCATALKDIFADDR, dev_ifsioc)
2757 HANDLE_IOCTL(SIOCDIFADDR, dev_ifsioc)
2758 HANDLE_IOCTL(SIOCSARP, dev_ifsioc)
2759 HANDLE_IOCTL(SIOCDARP, dev_ifsioc)
2761 HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc)
2762 HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc)
2763 HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc)
2764 HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc)
2765 HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc)
2766 HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc)
2767 HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc)
2768 HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc)
2769 HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc)
2770 HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc)
2771 HANDLE_IOCTL(TUNSETIFF, dev_ifsioc)
2772 HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl)
2773 HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl)
2774 HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl)
2775 HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl)
2776 HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl)
2777 HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl)
2778 HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl)
2779 HANDLE_IOCTL(SIOCADDRT, routing_ioctl)
2780 HANDLE_IOCTL(SIOCDELRT, routing_ioctl)
2781 HANDLE_IOCTL(SIOCBRADDIF, dev_ifsioc)
2782 HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc)
2783 /* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
2784 HANDLE_IOCTL(SIOCRTMSG, ret_einval)
2785 HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
2786 #endif
2787 HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo)
2788 HANDLE_IOCTL(BLKRAGET, w_long)
2789 HANDLE_IOCTL(BLKGETSIZE, w_long)
2790 HANDLE_IOCTL(0x1260, broken_blkgetsize)
2791 HANDLE_IOCTL(BLKFRAGET, w_long)
2792 HANDLE_IOCTL(BLKSECTGET, w_long)
2793 HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
2794 HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans)
2795 HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans)
2796 HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans)
2797 HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans)
2798 HANDLE_IOCTL(HDIO_GET_MULTCOUNT, hdio_ioctl_trans)
2799 HANDLE_IOCTL(HDIO_GET_NOWERR, hdio_ioctl_trans)
2800 HANDLE_IOCTL(HDIO_GET_NICE, hdio_ioctl_trans)
2801 HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans)
2802 HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans)
2803 HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans)
2804 HANDLE_IOCTL(FDSETDRVPRM32, fd_ioctl_trans)
2805 HANDLE_IOCTL(FDGETDRVPRM32, fd_ioctl_trans)
2806 HANDLE_IOCTL(FDGETDRVSTAT32, fd_ioctl_trans)
2807 HANDLE_IOCTL(FDPOLLDRVSTAT32, fd_ioctl_trans)
2808 HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans)
2809 HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans)
2810 HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
2811 HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans)
2812 HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans)
2813 HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans)
2814 HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans)
2815 HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans)
2816 HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans)
2817 HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans)
2818 HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans)
2819 HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans)
2820 HANDLE_IOCTL(LOOP_SET_STATUS, loop_status)
2821 HANDLE_IOCTL(LOOP_GET_STATUS, loop_status)
2822 #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
2823 HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout)
2824 #ifdef CONFIG_VT
2825 HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl)
2826 HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl)
2827 HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl)
2828 HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl)
2829 HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl)
2830 #endif
2831 HANDLE_IOCTL(EXT2_IOC32_GETFLAGS, do_ext2_ioctl)
2832 HANDLE_IOCTL(EXT2_IOC32_SETFLAGS, do_ext2_ioctl)
2833 HANDLE_IOCTL(EXT2_IOC32_GETVERSION, do_ext2_ioctl)
2834 HANDLE_IOCTL(EXT2_IOC32_SETVERSION, do_ext2_ioctl)
2835 HANDLE_IOCTL(EXT3_IOC32_GETVERSION, do_ext3_ioctl)
2836 HANDLE_IOCTL(EXT3_IOC32_SETVERSION, do_ext3_ioctl)
2837 HANDLE_IOCTL(EXT3_IOC32_GETRSVSZ, do_ext3_ioctl)
2838 HANDLE_IOCTL(EXT3_IOC32_SETRSVSZ, do_ext3_ioctl)
2839 HANDLE_IOCTL(EXT3_IOC32_GROUP_EXTEND, do_ext3_ioctl)
2840 COMPATIBLE_IOCTL(EXT3_IOC_GROUP_ADD)
2841 #ifdef CONFIG_JBD_DEBUG
2842 HANDLE_IOCTL(EXT3_IOC32_WAIT_FOR_READONLY, do_ext3_ioctl)
2843 #endif
2844 /* One SMB ioctl needs translations. */
2845 #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
2846 HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
2847 HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl)
2848 HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl)
2849 HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl)
2850 HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl)
2851 HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl)
2852 HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl)
2853 HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl)
2854 HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl)
2855 HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl)
2856 HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl)
2857 HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl)
2858 HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl)
2859 HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl)
2860 HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl)
2861 HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl)
2862 HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl)
2863 HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl)
2864 HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl)
2865 HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl)
2866 HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl)
2867 HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl)
2868 HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl)
2869 HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl)
2870 HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl)
2871 HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl)
2872 /* block stuff */
2873 HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget)
2874 HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset)
2875 HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64)
2876 /* vfat */
2877 HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32)
2878 HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32, vfat_ioctl32)
2879 HANDLE_IOCTL(REISERFS_IOC_UNPACK32, reiserfs_ioctl32)
2880 /* Raw devices */
2881 HANDLE_IOCTL(RAW_SETBIND, raw_ioctl)
2882 HANDLE_IOCTL(RAW_GETBIND, raw_ioctl)
2883 /* Serial */
2884 HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl)
2885 HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl)
2886 #ifdef TIOCGLTC
2887 COMPATIBLE_IOCTL(TIOCGLTC)
2888 COMPATIBLE_IOCTL(TIOCSLTC)
2889 #endif
2890 #ifdef TIOCSTART
2891 /*
2892 * For these two we have defintions in ioctls.h and/or termios.h on
2893 * some architectures but no actual implemention. Some applications
2894 * like bash call them if they are defined in the headers, so we provide
2895 * entries here to avoid syslog message spew.
2896 */
2897 COMPATIBLE_IOCTL(TIOCSTART)
2898 COMPATIBLE_IOCTL(TIOCSTOP)
2899 #endif
2900 /* Usbdevfs */
2901 HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
2902 HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
2903 HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
2904 COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
2905 /* i2c */
2906 HANDLE_IOCTL(I2C_FUNCS, w_long)
2907 HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
2908 HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
2909 /* wireless */
2910 HANDLE_IOCTL(SIOCGIWRANGE, do_wireless_ioctl)
2911 HANDLE_IOCTL(SIOCSIWSPY, do_wireless_ioctl)
2912 HANDLE_IOCTL(SIOCGIWSPY, do_wireless_ioctl)
2913 HANDLE_IOCTL(SIOCSIWTHRSPY, do_wireless_ioctl)
2914 HANDLE_IOCTL(SIOCGIWTHRSPY, do_wireless_ioctl)
2915 HANDLE_IOCTL(SIOCGIWAPLIST, do_wireless_ioctl)
2916 HANDLE_IOCTL(SIOCGIWSCAN, do_wireless_ioctl)
2917 HANDLE_IOCTL(SIOCSIWESSID, do_wireless_ioctl)
2918 HANDLE_IOCTL(SIOCGIWESSID, do_wireless_ioctl)
2919 HANDLE_IOCTL(SIOCSIWNICKN, do_wireless_ioctl)
2920 HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl)
2921 HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl)
2922 HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl)
2923 HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl)
2924 HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl)
2925 HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl)
2926 HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl)
2927 HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl)
2928 HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl)
2930 #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
2931 HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest)
2932 HANDLE_IOCTL(NCP_IOC_GETMOUNTUID2_32, do_ncp_getmountuid2)
2933 HANDLE_IOCTL(NCP_IOC_GET_FS_INFO_V2_32, do_ncp_getfsinfo2)
2934 HANDLE_IOCTL(NCP_IOC_GETOBJECTNAME_32, do_ncp_getobjectname)
2935 HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32, do_ncp_setobjectname)
2936 HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata)
2937 HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata)
2938 #endif
2940 /* dvb */
2941 HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event)
2942 HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture)
2943 HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette)
2945 /* parport */
2946 COMPATIBLE_IOCTL(LPTIME)
2947 COMPATIBLE_IOCTL(LPCHAR)
2948 COMPATIBLE_IOCTL(LPABORTOPEN)
2949 COMPATIBLE_IOCTL(LPCAREFUL)
2950 COMPATIBLE_IOCTL(LPWAIT)
2951 COMPATIBLE_IOCTL(LPSETIRQ)
2952 COMPATIBLE_IOCTL(LPGETSTATUS)
2953 COMPATIBLE_IOCTL(LPGETSTATUS)
2954 COMPATIBLE_IOCTL(LPRESET)
2955 /*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/
2956 COMPATIBLE_IOCTL(LPGETFLAGS)
2957 HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans)
2959 #ifdef CONFIG_XEN
2960 HANDLE_IOCTL(IOCTL_PRIVCMD_MMAP_32, privcmd_ioctl_32)
2961 HANDLE_IOCTL(IOCTL_PRIVCMD_MMAPBATCH_32, privcmd_ioctl_32)
2962 COMPATIBLE_IOCTL(IOCTL_PRIVCMD_HYPERCALL)
2963 COMPATIBLE_IOCTL(IOCTL_EVTCHN_BIND_VIRQ)
2964 COMPATIBLE_IOCTL(IOCTL_EVTCHN_BIND_INTERDOMAIN)
2965 COMPATIBLE_IOCTL(IOCTL_EVTCHN_BIND_UNBOUND_PORT)
2966 COMPATIBLE_IOCTL(IOCTL_EVTCHN_UNBIND)
2967 COMPATIBLE_IOCTL(IOCTL_EVTCHN_NOTIFY)
2968 COMPATIBLE_IOCTL(IOCTL_EVTCHN_RESET)
2969 #endif
2970 };
2972 int ioctl_table_size = ARRAY_SIZE(ioctl_start);