- Kai Germaschewski: ISDN update (including Makefiles)
[davej-history.git] / arch / sparc64 / kernel / ioctl32.c
bloba510c2affcffba1cd638b209b3eb404eb1a7e4a4
1 /* $Id: ioctl32.c,v 1.103 2000/11/10 05:44:33 davem Exp $
2 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
4 * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
5 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
7 * These routines maintain argument size conversion between 32bit and 64bit
8 * ioctls.
9 */
11 #include <linux/config.h>
12 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/sched.h>
15 #include <linux/smp.h>
16 #include <linux/smp_lock.h>
17 #include <linux/ioctl.h>
18 #include <linux/if.h>
19 #include <linux/malloc.h>
20 #include <linux/hdreg.h>
21 #include <linux/raid/md.h>
22 #include <linux/kd.h>
23 #include <linux/route.h>
24 #include <linux/in6.h>
25 #include <linux/ipv6_route.h>
26 #include <linux/skbuff.h>
27 #include <linux/netlink.h>
28 #include <linux/vt.h>
29 #include <linux/fs.h>
30 #include <linux/file.h>
31 #include <linux/fd.h>
32 #include <linux/ppp_defs.h>
33 #include <linux/if_ppp.h>
34 #include <linux/if_pppox.h>
35 #include <linux/mtio.h>
36 #include <linux/cdrom.h>
37 #include <linux/loop.h>
38 #include <linux/auto_fs.h>
39 #include <linux/devfs_fs.h>
40 #include <linux/tty.h>
41 #include <linux/vt_kern.h>
42 #include <linux/fb.h>
43 #include <linux/ext2_fs.h>
44 #include <linux/videodev.h>
45 #include <linux/netdevice.h>
46 #include <linux/raw.h>
47 #include <linux/smb_fs.h>
48 #include <linux/blkpg.h>
49 #include <linux/blk.h>
50 #include <linux/elevator.h>
51 #if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
52 /* Ugh. This header really is not clean */
53 #define min min
54 #define max max
55 #include <linux/lvm.h>
56 #endif /* LVM */
58 #include <scsi/scsi.h>
59 /* Ugly hack. */
60 #undef __KERNEL__
61 #include <scsi/scsi_ioctl.h>
62 #define __KERNEL__
63 #include <scsi/sg.h>
65 #include <asm/types.h>
66 #include <asm/uaccess.h>
67 #include <asm/fbio.h>
68 #include <asm/kbio.h>
69 #include <asm/vuid_event.h>
70 #include <asm/rtc.h>
71 #include <asm/openpromio.h>
72 #include <asm/envctrl.h>
73 #include <asm/audioio.h>
74 #include <linux/ethtool.h>
75 #include <asm/display7seg.h>
76 #include <asm/module.h>
77 #include <linux/soundcard.h>
79 #include <linux/atm.h>
80 #include <linux/atmarp.h>
81 #include <linux/atmclip.h>
82 #include <linux/atmdev.h>
83 #include <linux/atmioc.h>
84 #include <linux/atmlec.h>
85 #include <linux/atmmpc.h>
86 #include <linux/atmsvc.h>
87 #include <linux/atm_tcp.h>
88 #include <linux/sonet.h>
89 #include <linux/atm_suni.h>
91 /* Use this to get at 32-bit user passed pointers.
92 See sys_sparc32.c for description about these. */
93 #define A(__x) ((unsigned long)(__x))
94 #define AA(__x) \
95 ({ unsigned long __ret; \
96 __asm__ ("srl %0, 0, %0" \
97 : "=r" (__ret) \
98 : "0" (__x)); \
99 __ret; \
102 /* Aiee. Someone does not find a difference between int and long */
103 #define EXT2_IOC32_GETFLAGS _IOR('f', 1, int)
104 #define EXT2_IOC32_SETFLAGS _IOW('f', 2, int)
105 #define EXT2_IOC32_GETVERSION _IOR('v', 1, int)
106 #define EXT2_IOC32_SETVERSION _IOW('v', 2, int)
108 extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
110 static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
112 mm_segment_t old_fs = get_fs();
113 int err;
114 unsigned long val;
116 set_fs (KERNEL_DS);
117 err = sys_ioctl(fd, cmd, (unsigned long)&val);
118 set_fs (old_fs);
119 if (!err && put_user(val, (u32 *)arg))
120 return -EFAULT;
121 return err;
124 static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg)
126 mm_segment_t old_fs = get_fs();
127 int err;
128 unsigned long val;
130 if(get_user(val, (u32 *)arg))
131 return -EFAULT;
132 set_fs (KERNEL_DS);
133 err = sys_ioctl(fd, cmd, (unsigned long)&val);
134 set_fs (old_fs);
135 if (!err && put_user(val, (u32 *)arg))
136 return -EFAULT;
137 return err;
140 static int do_ext2_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
142 /* These are just misnamed, they actually get/put from/to user an int */
143 switch (cmd) {
144 case EXT2_IOC32_GETFLAGS: cmd = EXT2_IOC_GETFLAGS; break;
145 case EXT2_IOC32_SETFLAGS: cmd = EXT2_IOC_SETFLAGS; break;
146 case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; break;
147 case EXT2_IOC32_SETVERSION: cmd = EXT2_IOC_SETVERSION; break;
149 return sys_ioctl(fd, cmd, arg);
152 struct video_tuner32 {
153 s32 tuner;
154 u8 name[32];
155 u32 rangelow, rangehigh;
156 u32 flags;
157 u16 mode, signal;
160 static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 *up)
162 int i;
164 if(get_user(kp->tuner, &up->tuner))
165 return -EFAULT;
166 for(i = 0; i < 32; i++)
167 __get_user(kp->name[i], &up->name[i]);
168 __get_user(kp->rangelow, &up->rangelow);
169 __get_user(kp->rangehigh, &up->rangehigh);
170 __get_user(kp->flags, &up->flags);
171 __get_user(kp->mode, &up->mode);
172 __get_user(kp->signal, &up->signal);
173 return 0;
176 static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 *up)
178 int i;
180 if(put_user(kp->tuner, &up->tuner))
181 return -EFAULT;
182 for(i = 0; i < 32; i++)
183 __put_user(kp->name[i], &up->name[i]);
184 __put_user(kp->rangelow, &up->rangelow);
185 __put_user(kp->rangehigh, &up->rangehigh);
186 __put_user(kp->flags, &up->flags);
187 __put_user(kp->mode, &up->mode);
188 __put_user(kp->signal, &up->signal);
189 return 0;
192 struct video_buffer32 {
193 /* void * */ u32 base;
194 s32 height, width, depth, bytesperline;
197 static int get_video_buffer32(struct video_buffer *kp, struct video_buffer32 *up)
199 u32 tmp;
201 if(get_user(tmp, &up->base))
202 return -EFAULT;
203 kp->base = (void *) ((unsigned long)tmp);
204 __get_user(kp->height, &up->height);
205 __get_user(kp->width, &up->width);
206 __get_user(kp->depth, &up->depth);
207 __get_user(kp->bytesperline, &up->bytesperline);
208 return 0;
211 static int put_video_buffer32(struct video_buffer *kp, struct video_buffer32 *up)
213 u32 tmp = (u32)((unsigned long)kp->base);
215 if(put_user(tmp, &up->base))
216 return -EFAULT;
217 __put_user(kp->height, &up->height);
218 __put_user(kp->width, &up->width);
219 __put_user(kp->depth, &up->depth);
220 __put_user(kp->bytesperline, &up->bytesperline);
221 return 0;
224 struct video_clip32 {
225 s32 x, y, width, height;
226 /* struct video_clip32 * */ u32 next;
229 struct video_window32 {
230 u32 x, y, width, height, chromakey, flags;
231 /* struct video_clip32 * */ u32 clips;
232 s32 clipcount;
235 static void free_kvideo_clips(struct video_window *kp)
237 struct video_clip *cp;
239 cp = kp->clips;
240 if(cp != NULL)
241 kfree(cp);
244 static int get_video_window32(struct video_window *kp, struct video_window32 *up)
246 struct video_clip32 *ucp;
247 struct video_clip *kcp;
248 int nclips, err, i;
249 u32 tmp;
251 if(get_user(kp->x, &up->x))
252 return -EFAULT;
253 __get_user(kp->y, &up->y);
254 __get_user(kp->width, &up->width);
255 __get_user(kp->height, &up->height);
256 __get_user(kp->chromakey, &up->chromakey);
257 __get_user(kp->flags, &up->flags);
258 __get_user(kp->clipcount, &up->clipcount);
259 __get_user(tmp, &up->clips);
260 ucp = (struct video_clip32 *)A(tmp);
261 kp->clips = NULL;
263 nclips = kp->clipcount;
264 if(nclips == 0)
265 return 0;
267 if(ucp == 0)
268 return -EINVAL;
270 /* Peculiar interface... */
271 if(nclips < 0)
272 nclips = VIDEO_CLIPMAP_SIZE;
274 kcp = kmalloc(nclips * sizeof(struct video_clip), GFP_KERNEL);
275 err = -ENOMEM;
276 if(kcp == NULL)
277 goto cleanup_and_err;
279 kp->clips = kcp;
280 for(i = 0; i < nclips; i++) {
281 __get_user(kcp[i].x, &ucp[i].x);
282 __get_user(kcp[i].y, &ucp[i].y);
283 __get_user(kcp[i].width, &ucp[i].width);
284 __get_user(kcp[i].height, &ucp[i].height);
285 kcp[nclips].next = NULL;
288 return 0;
290 cleanup_and_err:
291 free_kvideo_clips(kp);
292 return err;
295 /* You get back everything except the clips... */
296 static int put_video_window32(struct video_window *kp, struct video_window32 *up)
298 if(put_user(kp->x, &up->x))
299 return -EFAULT;
300 __put_user(kp->y, &up->y);
301 __put_user(kp->width, &up->width);
302 __put_user(kp->height, &up->height);
303 __put_user(kp->chromakey, &up->chromakey);
304 __put_user(kp->flags, &up->flags);
305 __put_user(kp->clipcount, &up->clipcount);
306 return 0;
309 #define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32)
310 #define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32)
311 #define VIDIOCGWIN32 _IOR('v',9, struct video_window32)
312 #define VIDIOCSWIN32 _IOW('v',10, struct video_window32)
313 #define VIDIOCGFBUF32 _IOR('v',11, struct video_buffer32)
314 #define VIDIOCSFBUF32 _IOW('v',12, struct video_buffer32)
315 #define VIDIOCGFREQ32 _IOR('v',14, u32)
316 #define VIDIOCSFREQ32 _IOW('v',15, u32)
318 static int do_video_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
320 union {
321 struct video_tuner vt;
322 struct video_buffer vb;
323 struct video_window vw;
324 unsigned long vx;
325 } karg;
326 mm_segment_t old_fs = get_fs();
327 void *up = (void *)arg;
328 int err = 0;
330 /* First, convert the command. */
331 switch(cmd) {
332 case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break;
333 case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break;
334 case VIDIOCGWIN32: cmd = VIDIOCGWIN; break;
335 case VIDIOCSWIN32: cmd = VIDIOCSWIN; break;
336 case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break;
337 case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break;
338 case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break;
339 case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break;
342 switch(cmd) {
343 case VIDIOCSTUNER:
344 case VIDIOCGTUNER:
345 err = get_video_tuner32(&karg.vt, up);
346 break;
348 case VIDIOCSWIN:
349 err = get_video_window32(&karg.vw, up);
350 break;
352 case VIDIOCSFBUF:
353 err = get_video_buffer32(&karg.vb, up);
354 break;
356 case VIDIOCSFREQ:
357 err = get_user(karg.vx, (u32 *)up);
358 break;
360 if(err)
361 goto out;
363 set_fs(KERNEL_DS);
364 err = sys_ioctl(fd, cmd, (unsigned long)&karg);
365 set_fs(old_fs);
367 if(cmd == VIDIOCSWIN)
368 free_kvideo_clips(&karg.vw);
370 if(err == 0) {
371 switch(cmd) {
372 case VIDIOCGTUNER:
373 err = put_video_tuner32(&karg.vt, up);
374 break;
376 case VIDIOCGWIN:
377 err = put_video_window32(&karg.vw, up);
378 break;
380 case VIDIOCGFBUF:
381 err = put_video_buffer32(&karg.vb, up);
382 break;
384 case VIDIOCGFREQ:
385 err = put_user(((u32)karg.vx), (u32 *)up);
386 break;
389 out:
390 return err;
393 struct timeval32 {
394 int tv_sec;
395 int tv_usec;
398 static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
400 struct timeval32 *up = (struct timeval32 *)arg;
401 struct timeval ktv;
402 mm_segment_t old_fs = get_fs();
403 int err;
405 set_fs(KERNEL_DS);
406 err = sys_ioctl(fd, cmd, (unsigned long)&ktv);
407 set_fs(old_fs);
408 if(!err) {
409 err = put_user(ktv.tv_sec, &up->tv_sec);
410 err |= __put_user(ktv.tv_usec, &up->tv_usec);
412 return err;
415 struct ifmap32 {
416 u32 mem_start;
417 u32 mem_end;
418 unsigned short base_addr;
419 unsigned char irq;
420 unsigned char dma;
421 unsigned char port;
424 struct ifreq32 {
425 #define IFHWADDRLEN 6
426 #define IFNAMSIZ 16
427 union {
428 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
429 } ifr_ifrn;
430 union {
431 struct sockaddr ifru_addr;
432 struct sockaddr ifru_dstaddr;
433 struct sockaddr ifru_broadaddr;
434 struct sockaddr ifru_netmask;
435 struct sockaddr ifru_hwaddr;
436 short ifru_flags;
437 int ifru_ivalue;
438 int ifru_mtu;
439 struct ifmap32 ifru_map;
440 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
441 char ifru_newname[IFNAMSIZ];
442 __kernel_caddr_t32 ifru_data;
443 } ifr_ifru;
446 struct ifconf32 {
447 int ifc_len; /* size of buffer */
448 __kernel_caddr_t32 ifcbuf;
451 static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
453 struct net_device *dev;
454 struct ifreq32 ifr32;
455 int err;
457 if (copy_from_user(&ifr32, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
458 return -EFAULT;
460 dev = dev_get_by_index(ifr32.ifr_ifindex);
461 if (!dev)
462 return -ENODEV;
464 strcpy(ifr32.ifr_name, dev->name);
466 err = copy_to_user((struct ifreq32 *)arg, &ifr32, sizeof(struct ifreq32));
467 return (err ? -EFAULT : 0);
470 static inline int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)
472 struct ifconf32 ifc32;
473 struct ifconf ifc;
474 struct ifreq32 *ifr32;
475 struct ifreq *ifr;
476 mm_segment_t old_fs;
477 unsigned int i, j;
478 int err;
480 if (copy_from_user(&ifc32, (struct ifconf32 *)arg, sizeof(struct ifconf32)))
481 return -EFAULT;
483 if(ifc32.ifcbuf == 0) {
484 ifc32.ifc_len = 0;
485 ifc.ifc_len = 0;
486 ifc.ifc_buf = NULL;
487 } else {
488 ifc.ifc_len = ((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) *
489 sizeof (struct ifreq);
490 ifc.ifc_buf = kmalloc (ifc.ifc_len, GFP_KERNEL);
491 if (!ifc.ifc_buf)
492 return -ENOMEM;
494 ifr = ifc.ifc_req;
495 ifr32 = (struct ifreq32 *)A(ifc32.ifcbuf);
496 for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) {
497 if (copy_from_user(ifr++, ifr32++, sizeof (struct ifreq32))) {
498 kfree (ifc.ifc_buf);
499 return -EFAULT;
502 old_fs = get_fs(); set_fs (KERNEL_DS);
503 err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)&ifc);
504 set_fs (old_fs);
505 if (!err) {
506 ifr = ifc.ifc_req;
507 ifr32 = (struct ifreq32 *)A(ifc32.ifcbuf);
508 for (i = 0, j = 0; i < ifc32.ifc_len && j < ifc.ifc_len;
509 i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
510 if (copy_to_user(ifr32++, ifr++, sizeof (struct ifreq32))) {
511 err = -EFAULT;
512 break;
515 if (!err) {
516 if (i <= ifc32.ifc_len)
517 ifc32.ifc_len = i;
518 else
519 ifc32.ifc_len = i - sizeof (struct ifreq32);
520 if (copy_to_user((struct ifconf32 *)arg, &ifc32, sizeof(struct ifconf32)))
521 err = -EFAULT;
524 if(ifc.ifc_buf != NULL)
525 kfree (ifc.ifc_buf);
526 return err;
529 static inline int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg)
531 struct ifreq ifr;
532 mm_segment_t old_fs;
533 int err;
535 switch (cmd) {
536 case SIOCSIFMAP:
537 err = copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(ifr.ifr_name));
538 err |= __get_user(ifr.ifr_map.mem_start, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_start));
539 err |= __get_user(ifr.ifr_map.mem_end, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_end));
540 err |= __get_user(ifr.ifr_map.base_addr, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.base_addr));
541 err |= __get_user(ifr.ifr_map.irq, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.irq));
542 err |= __get_user(ifr.ifr_map.dma, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.dma));
543 err |= __get_user(ifr.ifr_map.port, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.port));
544 if (err)
545 return -EFAULT;
546 break;
547 case SIOCGPPPSTATS:
548 case SIOCGPPPCSTATS:
549 case SIOCGPPPVER:
550 case SIOCETHTOOL:
551 if (copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
552 return -EFAULT;
553 ifr.ifr_data = (__kernel_caddr_t)get_free_page(GFP_KERNEL);
554 if (!ifr.ifr_data)
555 return -EAGAIN;
556 if(cmd == SIOCETHTOOL) {
557 u32 data;
559 __get_user(data, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_data));
560 if(copy_from_user(ifr.ifr_data,
561 (char *)A(data),
562 sizeof(struct ethtool_cmd))) {
563 free_page((unsigned long)ifr.ifr_data);
564 return -EFAULT;
567 break;
568 default:
569 if (copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
570 return -EFAULT;
571 break;
573 old_fs = get_fs();
574 set_fs (KERNEL_DS);
575 err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
576 set_fs (old_fs);
577 if (!err) {
578 switch (cmd) {
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((struct ifreq32 *)arg, &ifr, sizeof(struct ifreq32)))
591 return -EFAULT;
592 break;
593 case SIOCGPPPSTATS:
594 case SIOCGPPPCSTATS:
595 case SIOCGPPPVER:
596 case SIOCETHTOOL:
598 u32 data;
599 int len;
601 __get_user(data, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_data));
602 if(cmd == SIOCETHTOOL)
603 len = sizeof(struct ethtool_cmd);
604 if(cmd == SIOCGPPPVER)
605 len = strlen((char *)ifr.ifr_data) + 1;
606 else if(cmd == SIOCGPPPCSTATS)
607 len = sizeof(struct ppp_comp_stats);
608 else
609 len = sizeof(struct ppp_stats);
611 len = copy_to_user((char *)A(data), ifr.ifr_data, len);
612 free_page((unsigned long)ifr.ifr_data);
613 if(len)
614 return -EFAULT;
615 break;
617 case SIOCGIFMAP:
618 err = copy_to_user((struct ifreq32 *)arg, &ifr, sizeof(ifr.ifr_name));
619 err |= __put_user(ifr.ifr_map.mem_start, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_start));
620 err |= __put_user(ifr.ifr_map.mem_end, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_end));
621 err |= __put_user(ifr.ifr_map.base_addr, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.base_addr));
622 err |= __put_user(ifr.ifr_map.irq, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.irq));
623 err |= __put_user(ifr.ifr_map.dma, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.dma));
624 err |= __put_user(ifr.ifr_map.port, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.port));
625 if (err)
626 err = -EFAULT;
627 break;
630 return err;
633 struct rtentry32 {
634 u32 rt_pad1;
635 struct sockaddr rt_dst; /* target address */
636 struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
637 struct sockaddr rt_genmask; /* target network mask (IP) */
638 unsigned short rt_flags;
639 short rt_pad2;
640 u32 rt_pad3;
641 unsigned char rt_tos;
642 unsigned char rt_class;
643 short rt_pad4;
644 short rt_metric; /* +1 for binary compatibility! */
645 /* char * */ u32 rt_dev; /* forcing the device at add */
646 u32 rt_mtu; /* per route MTU/Window */
647 u32 rt_window; /* Window clamping */
648 unsigned short rt_irtt; /* Initial RTT */
652 struct in6_rtmsg32 {
653 struct in6_addr rtmsg_dst;
654 struct in6_addr rtmsg_src;
655 struct in6_addr rtmsg_gateway;
656 u32 rtmsg_type;
657 u16 rtmsg_dst_len;
658 u16 rtmsg_src_len;
659 u32 rtmsg_metric;
660 u32 rtmsg_info;
661 u32 rtmsg_flags;
662 s32 rtmsg_ifindex;
665 extern struct socket *sockfd_lookup(int fd, int *err);
667 static inline int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
669 int ret;
670 void *r = NULL;
671 struct in6_rtmsg r6;
672 struct rtentry r4;
673 char devname[16];
674 u32 rtdev;
675 mm_segment_t old_fs = get_fs();
677 struct socket *mysock = sockfd_lookup(fd, &ret);
679 if (mysock && mysock->sk && mysock->sk->family == AF_INET6) { /* ipv6 */
680 ret = copy_from_user (&r6.rtmsg_dst, &(((struct in6_rtmsg32 *)arg)->rtmsg_dst),
681 3 * sizeof(struct in6_addr));
682 ret |= __get_user (r6.rtmsg_type, &(((struct in6_rtmsg32 *)arg)->rtmsg_type));
683 ret |= __get_user (r6.rtmsg_dst_len, &(((struct in6_rtmsg32 *)arg)->rtmsg_dst_len));
684 ret |= __get_user (r6.rtmsg_src_len, &(((struct in6_rtmsg32 *)arg)->rtmsg_src_len));
685 ret |= __get_user (r6.rtmsg_metric, &(((struct in6_rtmsg32 *)arg)->rtmsg_metric));
686 ret |= __get_user (r6.rtmsg_info, &(((struct in6_rtmsg32 *)arg)->rtmsg_info));
687 ret |= __get_user (r6.rtmsg_flags, &(((struct in6_rtmsg32 *)arg)->rtmsg_flags));
688 ret |= __get_user (r6.rtmsg_ifindex, &(((struct in6_rtmsg32 *)arg)->rtmsg_ifindex));
690 r = (void *) &r6;
691 } else { /* ipv4 */
692 ret = copy_from_user (&r4.rt_dst, &(((struct rtentry32 *)arg)->rt_dst), 3 * sizeof(struct sockaddr));
693 ret |= __get_user (r4.rt_flags, &(((struct rtentry32 *)arg)->rt_flags));
694 ret |= __get_user (r4.rt_metric, &(((struct rtentry32 *)arg)->rt_metric));
695 ret |= __get_user (r4.rt_mtu, &(((struct rtentry32 *)arg)->rt_mtu));
696 ret |= __get_user (r4.rt_window, &(((struct rtentry32 *)arg)->rt_window));
697 ret |= __get_user (r4.rt_irtt, &(((struct rtentry32 *)arg)->rt_irtt));
698 ret |= __get_user (rtdev, &(((struct rtentry32 *)arg)->rt_dev));
699 if (rtdev) {
700 ret |= copy_from_user (devname, (char *)A(rtdev), 15);
701 r4.rt_dev = devname; devname[15] = 0;
702 } else
703 r4.rt_dev = 0;
705 r = (void *) &r4;
708 if (ret)
709 return -EFAULT;
711 set_fs (KERNEL_DS);
712 ret = sys_ioctl (fd, cmd, (long) r);
713 set_fs (old_fs);
715 return ret;
718 struct hd_geometry32 {
719 unsigned char heads;
720 unsigned char sectors;
721 unsigned short cylinders;
722 u32 start;
725 static inline int hdio_getgeo(unsigned int fd, unsigned int cmd, unsigned long arg)
727 mm_segment_t old_fs = get_fs();
728 struct hd_geometry geo;
729 int err;
731 set_fs (KERNEL_DS);
732 err = sys_ioctl(fd, HDIO_GETGEO, (unsigned long)&geo);
733 set_fs (old_fs);
734 if (!err) {
735 err = copy_to_user ((struct hd_geometry32 *)arg, &geo, 4);
736 err |= __put_user (geo.start, &(((struct hd_geometry32 *)arg)->start));
738 return err ? -EFAULT : 0;
741 struct fbcmap32 {
742 int index; /* first element (0 origin) */
743 int count;
744 u32 red;
745 u32 green;
746 u32 blue;
749 #define FBIOPUTCMAP32 _IOW('F', 3, struct fbcmap32)
750 #define FBIOGETCMAP32 _IOW('F', 4, struct fbcmap32)
752 static inline int fbiogetputcmap(unsigned int fd, unsigned int cmd, unsigned long arg)
754 struct fbcmap f;
755 int ret;
756 char red[256], green[256], blue[256];
757 u32 r, g, b;
758 mm_segment_t old_fs = get_fs();
760 ret = get_user(f.index, &(((struct fbcmap32 *)arg)->index));
761 ret |= __get_user(f.count, &(((struct fbcmap32 *)arg)->count));
762 ret |= __get_user(r, &(((struct fbcmap32 *)arg)->red));
763 ret |= __get_user(g, &(((struct fbcmap32 *)arg)->green));
764 ret |= __get_user(b, &(((struct fbcmap32 *)arg)->blue));
765 if (ret)
766 return -EFAULT;
767 if ((f.index < 0) || (f.index > 255)) return -EINVAL;
768 if (f.index + f.count > 256)
769 f.count = 256 - f.index;
770 if (cmd == FBIOPUTCMAP32) {
771 ret = copy_from_user (red, (char *)A(r), f.count);
772 ret |= copy_from_user (green, (char *)A(g), f.count);
773 ret |= copy_from_user (blue, (char *)A(b), f.count);
774 if (ret)
775 return -EFAULT;
777 f.red = red; f.green = green; f.blue = blue;
778 set_fs (KERNEL_DS);
779 ret = sys_ioctl (fd, (cmd == FBIOPUTCMAP32) ? FBIOPUTCMAP_SPARC : FBIOGETCMAP_SPARC, (long)&f);
780 set_fs (old_fs);
781 if (!ret && cmd == FBIOGETCMAP32) {
782 ret = copy_to_user ((char *)A(r), red, f.count);
783 ret |= copy_to_user ((char *)A(g), green, f.count);
784 ret |= copy_to_user ((char *)A(b), blue, f.count);
786 return ret ? -EFAULT : 0;
789 struct fbcursor32 {
790 short set; /* what to set, choose from the list above */
791 short enable; /* cursor on/off */
792 struct fbcurpos pos; /* cursor position */
793 struct fbcurpos hot; /* cursor hot spot */
794 struct fbcmap32 cmap; /* color map info */
795 struct fbcurpos size; /* cursor bit map size */
796 u32 image; /* cursor image bits */
797 u32 mask; /* cursor mask bits */
800 #define FBIOSCURSOR32 _IOW('F', 24, struct fbcursor32)
801 #define FBIOGCURSOR32 _IOW('F', 25, struct fbcursor32)
803 static inline int fbiogscursor(unsigned int fd, unsigned int cmd, unsigned long arg)
805 struct fbcursor f;
806 int ret;
807 char red[2], green[2], blue[2];
808 char image[128], mask[128];
809 u32 r, g, b;
810 u32 m, i;
811 mm_segment_t old_fs = get_fs();
813 ret = copy_from_user (&f, (struct fbcursor32 *)arg, 2 * sizeof (short) + 2 * sizeof(struct fbcurpos));
814 ret |= __get_user(f.size.fbx, &(((struct fbcursor32 *)arg)->size.fbx));
815 ret |= __get_user(f.size.fby, &(((struct fbcursor32 *)arg)->size.fby));
816 ret |= __get_user(f.cmap.index, &(((struct fbcursor32 *)arg)->cmap.index));
817 ret |= __get_user(f.cmap.count, &(((struct fbcursor32 *)arg)->cmap.count));
818 ret |= __get_user(r, &(((struct fbcursor32 *)arg)->cmap.red));
819 ret |= __get_user(g, &(((struct fbcursor32 *)arg)->cmap.green));
820 ret |= __get_user(b, &(((struct fbcursor32 *)arg)->cmap.blue));
821 ret |= __get_user(m, &(((struct fbcursor32 *)arg)->mask));
822 ret |= __get_user(i, &(((struct fbcursor32 *)arg)->image));
823 if (ret)
824 return -EFAULT;
825 if (f.set & FB_CUR_SETCMAP) {
826 if ((uint) f.size.fby > 32)
827 return -EINVAL;
828 ret = copy_from_user (mask, (char *)A(m), f.size.fby * 4);
829 ret |= copy_from_user (image, (char *)A(i), f.size.fby * 4);
830 if (ret)
831 return -EFAULT;
832 f.image = image; f.mask = mask;
834 if (f.set & FB_CUR_SETCMAP) {
835 ret = copy_from_user (red, (char *)A(r), 2);
836 ret |= copy_from_user (green, (char *)A(g), 2);
837 ret |= copy_from_user (blue, (char *)A(b), 2);
838 if (ret)
839 return -EFAULT;
840 f.cmap.red = red; f.cmap.green = green; f.cmap.blue = blue;
842 set_fs (KERNEL_DS);
843 ret = sys_ioctl (fd, FBIOSCURSOR, (long)&f);
844 set_fs (old_fs);
845 return ret;
848 struct fb_fix_screeninfo32 {
849 char id[16];
850 __kernel_caddr_t32 smem_start;
851 __u32 smem_len;
852 __u32 type;
853 __u32 type_aux;
854 __u32 visual;
855 __u16 xpanstep;
856 __u16 ypanstep;
857 __u16 ywrapstep;
858 __u32 line_length;
859 __kernel_caddr_t32 mmio_start;
860 __u32 mmio_len;
861 __u32 accel;
862 __u16 reserved[3];
865 struct fb_cmap32 {
866 __u32 start;
867 __u32 len;
868 __kernel_caddr_t32 red;
869 __kernel_caddr_t32 green;
870 __kernel_caddr_t32 blue;
871 __kernel_caddr_t32 transp;
874 static int fb_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
876 mm_segment_t old_fs = get_fs();
877 u32 red = 0, green = 0, blue = 0, transp = 0;
878 struct fb_fix_screeninfo fix;
879 struct fb_cmap cmap;
880 void *karg;
881 int err = 0;
883 memset(&cmap, 0, sizeof(cmap));
884 switch (cmd) {
885 case FBIOGET_FSCREENINFO:
886 karg = &fix;
887 break;
888 case FBIOGETCMAP:
889 case FBIOPUTCMAP:
890 karg = &cmap;
891 err = __get_user(cmap.start, &((struct fb_cmap32 *)arg)->start);
892 err |= __get_user(cmap.len, &((struct fb_cmap32 *)arg)->len);
893 err |= __get_user(red, &((struct fb_cmap32 *)arg)->red);
894 err |= __get_user(green, &((struct fb_cmap32 *)arg)->green);
895 err |= __get_user(blue, &((struct fb_cmap32 *)arg)->blue);
896 err |= __get_user(transp, &((struct fb_cmap32 *)arg)->transp);
897 if (err) {
898 err = -EFAULT;
899 goto out;
901 err = -ENOMEM;
902 cmap.red = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
903 if (!cmap.red)
904 goto out;
905 cmap.green = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
906 if (!cmap.green)
907 goto out;
908 cmap.blue = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
909 if (!cmap.blue)
910 goto out;
911 if (transp) {
912 cmap.transp = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
913 if (!cmap.transp)
914 goto out;
917 if (cmd == FBIOGETCMAP)
918 break;
920 err = __copy_from_user(cmap.red, (char *)A(red), cmap.len * sizeof(__u16));
921 err |= __copy_from_user(cmap.green, (char *)A(green), cmap.len * sizeof(__u16));
922 err |= __copy_from_user(cmap.blue, (char *)A(blue), cmap.len * sizeof(__u16));
923 if (cmap.transp) err |= __copy_from_user(cmap.transp, (char *)A(transp), cmap.len * sizeof(__u16));
924 if (err) {
925 err = -EFAULT;
926 goto out;
928 break;
929 default:
930 do {
931 static int count = 0;
932 if (++count <= 20)
933 printk("%s: Unknown fb ioctl cmd fd(%d) "
934 "cmd(%08x) arg(%08lx)\n",
935 __FUNCTION__, fd, cmd, arg);
936 } while(0);
937 return -ENOSYS;
939 set_fs(KERNEL_DS);
940 err = sys_ioctl(fd, cmd, (unsigned long)karg);
941 set_fs(old_fs);
942 if (err)
943 goto out;
944 switch (cmd) {
945 case FBIOGET_FSCREENINFO:
946 err = __copy_to_user((char *)((struct fb_fix_screeninfo32 *)arg)->id, (char *)fix.id, sizeof(fix.id));
947 err |= __put_user((__u32)(unsigned long)fix.smem_start, &((struct fb_fix_screeninfo32 *)arg)->smem_start);
948 err |= __put_user(fix.smem_len, &((struct fb_fix_screeninfo32 *)arg)->smem_len);
949 err |= __put_user(fix.type, &((struct fb_fix_screeninfo32 *)arg)->type);
950 err |= __put_user(fix.type_aux, &((struct fb_fix_screeninfo32 *)arg)->type_aux);
951 err |= __put_user(fix.visual, &((struct fb_fix_screeninfo32 *)arg)->visual);
952 err |= __put_user(fix.xpanstep, &((struct fb_fix_screeninfo32 *)arg)->xpanstep);
953 err |= __put_user(fix.ypanstep, &((struct fb_fix_screeninfo32 *)arg)->ypanstep);
954 err |= __put_user(fix.ywrapstep, &((struct fb_fix_screeninfo32 *)arg)->ywrapstep);
955 err |= __put_user(fix.line_length, &((struct fb_fix_screeninfo32 *)arg)->line_length);
956 err |= __put_user((__u32)(unsigned long)fix.mmio_start, &((struct fb_fix_screeninfo32 *)arg)->mmio_start);
957 err |= __put_user(fix.mmio_len, &((struct fb_fix_screeninfo32 *)arg)->mmio_len);
958 err |= __put_user(fix.accel, &((struct fb_fix_screeninfo32 *)arg)->accel);
959 err |= __copy_to_user((char *)((struct fb_fix_screeninfo32 *)arg)->reserved, (char *)fix.reserved, sizeof(fix.reserved));
960 break;
961 case FBIOGETCMAP:
962 err = __copy_to_user((char *)A(red), cmap.red, cmap.len * sizeof(__u16));
963 err |= __copy_to_user((char *)A(green), cmap.blue, cmap.len * sizeof(__u16));
964 err |= __copy_to_user((char *)A(blue), cmap.blue, cmap.len * sizeof(__u16));
965 if (cmap.transp)
966 err |= __copy_to_user((char *)A(transp), cmap.transp, cmap.len * sizeof(__u16));
967 break;
968 case FBIOPUTCMAP:
969 break;
971 if (err)
972 err = -EFAULT;
974 out: if (cmap.red) kfree(cmap.red);
975 if (cmap.green) kfree(cmap.green);
976 if (cmap.blue) kfree(cmap.blue);
977 if (cmap.transp) kfree(cmap.transp);
978 return err;
981 static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
983 mm_segment_t old_fs = get_fs();
984 unsigned long kval;
985 unsigned int *uvp;
986 int error;
988 set_fs(KERNEL_DS);
989 error = sys_ioctl(fd, cmd, (long)&kval);
990 set_fs(old_fs);
992 if(error == 0) {
993 uvp = (unsigned int *)arg;
994 if(put_user(kval, uvp))
995 error = -EFAULT;
997 return error;
1000 struct floppy_struct32 {
1001 unsigned int size;
1002 unsigned int sect;
1003 unsigned int head;
1004 unsigned int track;
1005 unsigned int stretch;
1006 unsigned char gap;
1007 unsigned char rate;
1008 unsigned char spec1;
1009 unsigned char fmt_gap;
1010 const __kernel_caddr_t32 name;
1013 struct floppy_drive_params32 {
1014 char cmos;
1015 u32 max_dtr;
1016 u32 hlt;
1017 u32 hut;
1018 u32 srt;
1019 u32 spinup;
1020 u32 spindown;
1021 unsigned char spindown_offset;
1022 unsigned char select_delay;
1023 unsigned char rps;
1024 unsigned char tracks;
1025 u32 timeout;
1026 unsigned char interleave_sect;
1027 struct floppy_max_errors max_errors;
1028 char flags;
1029 char read_track;
1030 short autodetect[8];
1031 int checkfreq;
1032 int native_format;
1035 struct floppy_drive_struct32 {
1036 signed char flags;
1037 u32 spinup_date;
1038 u32 select_date;
1039 u32 first_read_date;
1040 short probed_format;
1041 short track;
1042 short maxblock;
1043 short maxtrack;
1044 int generation;
1045 int keep_data;
1046 int fd_ref;
1047 int fd_device;
1048 int last_checked;
1049 __kernel_caddr_t32 dmabuf;
1050 int bufblocks;
1053 struct floppy_fdc_state32 {
1054 int spec1;
1055 int spec2;
1056 int dtr;
1057 unsigned char version;
1058 unsigned char dor;
1059 u32 address;
1060 unsigned int rawcmd:2;
1061 unsigned int reset:1;
1062 unsigned int need_configure:1;
1063 unsigned int perp_mode:2;
1064 unsigned int has_fifo:1;
1065 unsigned int driver_version;
1066 unsigned char track[4];
1069 struct floppy_write_errors32 {
1070 unsigned int write_errors;
1071 u32 first_error_sector;
1072 int first_error_generation;
1073 u32 last_error_sector;
1074 int last_error_generation;
1075 unsigned int badness;
1078 #define FDSETPRM32 _IOW(2, 0x42, struct floppy_struct32)
1079 #define FDDEFPRM32 _IOW(2, 0x43, struct floppy_struct32)
1080 #define FDGETPRM32 _IOR(2, 0x04, struct floppy_struct32)
1081 #define FDSETDRVPRM32 _IOW(2, 0x90, struct floppy_drive_params32)
1082 #define FDGETDRVPRM32 _IOR(2, 0x11, struct floppy_drive_params32)
1083 #define FDGETDRVSTAT32 _IOR(2, 0x12, struct floppy_drive_struct32)
1084 #define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct floppy_drive_struct32)
1085 #define FDGETFDCSTAT32 _IOR(2, 0x15, struct floppy_fdc_state32)
1086 #define FDWERRORGET32 _IOR(2, 0x17, struct floppy_write_errors32)
1088 static struct {
1089 unsigned int cmd32;
1090 unsigned int cmd;
1091 } fd_ioctl_trans_table[] = {
1092 { FDSETPRM32, FDSETPRM },
1093 { FDDEFPRM32, FDDEFPRM },
1094 { FDGETPRM32, FDGETPRM },
1095 { FDSETDRVPRM32, FDSETDRVPRM },
1096 { FDGETDRVPRM32, FDGETDRVPRM },
1097 { FDGETDRVSTAT32, FDGETDRVSTAT },
1098 { FDPOLLDRVSTAT32, FDPOLLDRVSTAT },
1099 { FDGETFDCSTAT32, FDGETFDCSTAT },
1100 { FDWERRORGET32, FDWERRORGET }
1103 #define NR_FD_IOCTL_TRANS (sizeof(fd_ioctl_trans_table)/sizeof(fd_ioctl_trans_table[0]))
1105 static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1107 mm_segment_t old_fs = get_fs();
1108 void *karg = NULL;
1109 unsigned int kcmd = 0;
1110 int i, err;
1112 for (i = 0; i < NR_FD_IOCTL_TRANS; i++)
1113 if (cmd == fd_ioctl_trans_table[i].cmd32) {
1114 kcmd = fd_ioctl_trans_table[i].cmd;
1115 break;
1117 if (!kcmd)
1118 return -EINVAL;
1120 switch (cmd) {
1121 case FDSETPRM32:
1122 case FDDEFPRM32:
1123 case FDGETPRM32:
1125 struct floppy_struct *f;
1127 f = karg = kmalloc(sizeof(struct floppy_struct), GFP_KERNEL);
1128 if (!karg)
1129 return -ENOMEM;
1130 if (cmd == FDGETPRM32)
1131 break;
1132 err = __get_user(f->size, &((struct floppy_struct32 *)arg)->size);
1133 err |= __get_user(f->sect, &((struct floppy_struct32 *)arg)->sect);
1134 err |= __get_user(f->head, &((struct floppy_struct32 *)arg)->head);
1135 err |= __get_user(f->track, &((struct floppy_struct32 *)arg)->track);
1136 err |= __get_user(f->stretch, &((struct floppy_struct32 *)arg)->stretch);
1137 err |= __get_user(f->gap, &((struct floppy_struct32 *)arg)->gap);
1138 err |= __get_user(f->rate, &((struct floppy_struct32 *)arg)->rate);
1139 err |= __get_user(f->spec1, &((struct floppy_struct32 *)arg)->spec1);
1140 err |= __get_user(f->fmt_gap, &((struct floppy_struct32 *)arg)->fmt_gap);
1141 err |= __get_user((u64)f->name, &((struct floppy_struct32 *)arg)->name);
1142 if (err) {
1143 err = -EFAULT;
1144 goto out;
1146 break;
1148 case FDSETDRVPRM32:
1149 case FDGETDRVPRM32:
1151 struct floppy_drive_params *f;
1153 f = karg = kmalloc(sizeof(struct floppy_drive_params), GFP_KERNEL);
1154 if (!karg)
1155 return -ENOMEM;
1156 if (cmd == FDGETDRVPRM32)
1157 break;
1158 err = __get_user(f->cmos, &((struct floppy_drive_params32 *)arg)->cmos);
1159 err |= __get_user(f->max_dtr, &((struct floppy_drive_params32 *)arg)->max_dtr);
1160 err |= __get_user(f->hlt, &((struct floppy_drive_params32 *)arg)->hlt);
1161 err |= __get_user(f->hut, &((struct floppy_drive_params32 *)arg)->hut);
1162 err |= __get_user(f->srt, &((struct floppy_drive_params32 *)arg)->srt);
1163 err |= __get_user(f->spinup, &((struct floppy_drive_params32 *)arg)->spinup);
1164 err |= __get_user(f->spindown, &((struct floppy_drive_params32 *)arg)->spindown);
1165 err |= __get_user(f->spindown_offset, &((struct floppy_drive_params32 *)arg)->spindown_offset);
1166 err |= __get_user(f->select_delay, &((struct floppy_drive_params32 *)arg)->select_delay);
1167 err |= __get_user(f->rps, &((struct floppy_drive_params32 *)arg)->rps);
1168 err |= __get_user(f->tracks, &((struct floppy_drive_params32 *)arg)->tracks);
1169 err |= __get_user(f->timeout, &((struct floppy_drive_params32 *)arg)->timeout);
1170 err |= __get_user(f->interleave_sect, &((struct floppy_drive_params32 *)arg)->interleave_sect);
1171 err |= __copy_from_user(&f->max_errors, &((struct floppy_drive_params32 *)arg)->max_errors, sizeof(f->max_errors));
1172 err |= __get_user(f->flags, &((struct floppy_drive_params32 *)arg)->flags);
1173 err |= __get_user(f->read_track, &((struct floppy_drive_params32 *)arg)->read_track);
1174 err |= __copy_from_user(f->autodetect, ((struct floppy_drive_params32 *)arg)->autodetect, sizeof(f->autodetect));
1175 err |= __get_user(f->checkfreq, &((struct floppy_drive_params32 *)arg)->checkfreq);
1176 err |= __get_user(f->native_format, &((struct floppy_drive_params32 *)arg)->native_format);
1177 if (err) {
1178 err = -EFAULT;
1179 goto out;
1181 break;
1183 case FDGETDRVSTAT32:
1184 case FDPOLLDRVSTAT32:
1185 karg = kmalloc(sizeof(struct floppy_drive_struct), GFP_KERNEL);
1186 if (!karg)
1187 return -ENOMEM;
1188 break;
1189 case FDGETFDCSTAT32:
1190 karg = kmalloc(sizeof(struct floppy_fdc_state), GFP_KERNEL);
1191 if (!karg)
1192 return -ENOMEM;
1193 break;
1194 case FDWERRORGET32:
1195 karg = kmalloc(sizeof(struct floppy_write_errors), GFP_KERNEL);
1196 if (!karg)
1197 return -ENOMEM;
1198 break;
1199 default:
1200 return -EINVAL;
1202 set_fs (KERNEL_DS);
1203 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1204 set_fs (old_fs);
1205 if (err)
1206 goto out;
1207 switch (cmd) {
1208 case FDGETPRM32:
1210 struct floppy_struct *f = karg;
1212 err = __put_user(f->size, &((struct floppy_struct32 *)arg)->size);
1213 err |= __put_user(f->sect, &((struct floppy_struct32 *)arg)->sect);
1214 err |= __put_user(f->head, &((struct floppy_struct32 *)arg)->head);
1215 err |= __put_user(f->track, &((struct floppy_struct32 *)arg)->track);
1216 err |= __put_user(f->stretch, &((struct floppy_struct32 *)arg)->stretch);
1217 err |= __put_user(f->gap, &((struct floppy_struct32 *)arg)->gap);
1218 err |= __put_user(f->rate, &((struct floppy_struct32 *)arg)->rate);
1219 err |= __put_user(f->spec1, &((struct floppy_struct32 *)arg)->spec1);
1220 err |= __put_user(f->fmt_gap, &((struct floppy_struct32 *)arg)->fmt_gap);
1221 err |= __put_user((u64)f->name, &((struct floppy_struct32 *)arg)->name);
1222 break;
1224 case FDGETDRVPRM32:
1226 struct floppy_drive_params *f = karg;
1228 err = __put_user(f->cmos, &((struct floppy_drive_params32 *)arg)->cmos);
1229 err |= __put_user(f->max_dtr, &((struct floppy_drive_params32 *)arg)->max_dtr);
1230 err |= __put_user(f->hlt, &((struct floppy_drive_params32 *)arg)->hlt);
1231 err |= __put_user(f->hut, &((struct floppy_drive_params32 *)arg)->hut);
1232 err |= __put_user(f->srt, &((struct floppy_drive_params32 *)arg)->srt);
1233 err |= __put_user(f->spinup, &((struct floppy_drive_params32 *)arg)->spinup);
1234 err |= __put_user(f->spindown, &((struct floppy_drive_params32 *)arg)->spindown);
1235 err |= __put_user(f->spindown_offset, &((struct floppy_drive_params32 *)arg)->spindown_offset);
1236 err |= __put_user(f->select_delay, &((struct floppy_drive_params32 *)arg)->select_delay);
1237 err |= __put_user(f->rps, &((struct floppy_drive_params32 *)arg)->rps);
1238 err |= __put_user(f->tracks, &((struct floppy_drive_params32 *)arg)->tracks);
1239 err |= __put_user(f->timeout, &((struct floppy_drive_params32 *)arg)->timeout);
1240 err |= __put_user(f->interleave_sect, &((struct floppy_drive_params32 *)arg)->interleave_sect);
1241 err |= __copy_to_user(&((struct floppy_drive_params32 *)arg)->max_errors, &f->max_errors, sizeof(f->max_errors));
1242 err |= __put_user(f->flags, &((struct floppy_drive_params32 *)arg)->flags);
1243 err |= __put_user(f->read_track, &((struct floppy_drive_params32 *)arg)->read_track);
1244 err |= __copy_to_user(((struct floppy_drive_params32 *)arg)->autodetect, f->autodetect, sizeof(f->autodetect));
1245 err |= __put_user(f->checkfreq, &((struct floppy_drive_params32 *)arg)->checkfreq);
1246 err |= __put_user(f->native_format, &((struct floppy_drive_params32 *)arg)->native_format);
1247 break;
1249 case FDGETDRVSTAT32:
1250 case FDPOLLDRVSTAT32:
1252 struct floppy_drive_struct *f = karg;
1254 err = __put_user(f->flags, &((struct floppy_drive_struct32 *)arg)->flags);
1255 err |= __put_user(f->spinup_date, &((struct floppy_drive_struct32 *)arg)->spinup_date);
1256 err |= __put_user(f->select_date, &((struct floppy_drive_struct32 *)arg)->select_date);
1257 err |= __put_user(f->first_read_date, &((struct floppy_drive_struct32 *)arg)->first_read_date);
1258 err |= __put_user(f->probed_format, &((struct floppy_drive_struct32 *)arg)->probed_format);
1259 err |= __put_user(f->track, &((struct floppy_drive_struct32 *)arg)->track);
1260 err |= __put_user(f->maxblock, &((struct floppy_drive_struct32 *)arg)->maxblock);
1261 err |= __put_user(f->maxtrack, &((struct floppy_drive_struct32 *)arg)->maxtrack);
1262 err |= __put_user(f->generation, &((struct floppy_drive_struct32 *)arg)->generation);
1263 err |= __put_user(f->keep_data, &((struct floppy_drive_struct32 *)arg)->keep_data);
1264 err |= __put_user(f->fd_ref, &((struct floppy_drive_struct32 *)arg)->fd_ref);
1265 err |= __put_user(f->fd_device, &((struct floppy_drive_struct32 *)arg)->fd_device);
1266 err |= __put_user(f->last_checked, &((struct floppy_drive_struct32 *)arg)->last_checked);
1267 err |= __put_user((u64)f->dmabuf, &((struct floppy_drive_struct32 *)arg)->dmabuf);
1268 err |= __put_user((u64)f->bufblocks, &((struct floppy_drive_struct32 *)arg)->bufblocks);
1269 break;
1271 case FDGETFDCSTAT32:
1273 struct floppy_fdc_state *f = karg;
1275 err = __put_user(f->spec1, &((struct floppy_fdc_state32 *)arg)->spec1);
1276 err |= __put_user(f->spec2, &((struct floppy_fdc_state32 *)arg)->spec2);
1277 err |= __put_user(f->dtr, &((struct floppy_fdc_state32 *)arg)->dtr);
1278 err |= __put_user(f->version, &((struct floppy_fdc_state32 *)arg)->version);
1279 err |= __put_user(f->dor, &((struct floppy_fdc_state32 *)arg)->dor);
1280 err |= __put_user(f->address, &((struct floppy_fdc_state32 *)arg)->address);
1281 err |= __copy_to_user((char *)&((struct floppy_fdc_state32 *)arg)->address
1282 + sizeof(((struct floppy_fdc_state32 *)arg)->address),
1283 (char *)&f->address + sizeof(f->address), sizeof(int));
1284 err |= __put_user(f->driver_version, &((struct floppy_fdc_state32 *)arg)->driver_version);
1285 err |= __copy_to_user(((struct floppy_fdc_state32 *)arg)->track, f->track, sizeof(f->track));
1286 break;
1288 case FDWERRORGET32:
1290 struct floppy_write_errors *f = karg;
1292 err = __put_user(f->write_errors, &((struct floppy_write_errors32 *)arg)->write_errors);
1293 err |= __put_user(f->first_error_sector, &((struct floppy_write_errors32 *)arg)->first_error_sector);
1294 err |= __put_user(f->first_error_generation, &((struct floppy_write_errors32 *)arg)->first_error_generation);
1295 err |= __put_user(f->last_error_sector, &((struct floppy_write_errors32 *)arg)->last_error_sector);
1296 err |= __put_user(f->last_error_generation, &((struct floppy_write_errors32 *)arg)->last_error_generation);
1297 err |= __put_user(f->badness, &((struct floppy_write_errors32 *)arg)->badness);
1298 break;
1300 default:
1301 break;
1303 if (err)
1304 err = -EFAULT;
1306 out: if (karg) kfree(karg);
1307 return err;
1310 struct ppp_option_data32 {
1311 __kernel_caddr_t32 ptr;
1312 __u32 length;
1313 int transmit;
1315 #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
1317 struct ppp_idle32 {
1318 __kernel_time_t32 xmit_idle;
1319 __kernel_time_t32 recv_idle;
1321 #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
1323 static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1325 mm_segment_t old_fs = get_fs();
1326 struct ppp_option_data32 data32;
1327 struct ppp_option_data data;
1328 struct ppp_idle32 idle32;
1329 struct ppp_idle idle;
1330 unsigned int kcmd;
1331 void *karg;
1332 int err = 0;
1334 switch (cmd) {
1335 case PPPIOCGIDLE32:
1336 kcmd = PPPIOCGIDLE;
1337 karg = &idle;
1338 break;
1339 case PPPIOCSCOMPRESS32:
1340 if (copy_from_user(&data32, (struct ppp_option_data32 *)arg, sizeof(struct ppp_option_data32)))
1341 return -EFAULT;
1342 data.ptr = kmalloc (data32.length, GFP_KERNEL);
1343 if (!data.ptr)
1344 return -ENOMEM;
1345 if (copy_from_user(data.ptr, (__u8 *)A(data32.ptr), data32.length)) {
1346 kfree(data.ptr);
1347 return -EFAULT;
1349 data.length = data32.length;
1350 data.transmit = data32.transmit;
1351 kcmd = PPPIOCSCOMPRESS;
1352 karg = &data;
1353 break;
1354 default:
1355 do {
1356 static int count = 0;
1357 if (++count <= 20)
1358 printk("ppp_ioctl: Unknown cmd fd(%d) "
1359 "cmd(%08x) arg(%08x)\n",
1360 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1361 } while(0);
1362 return -EINVAL;
1364 set_fs (KERNEL_DS);
1365 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1366 set_fs (old_fs);
1367 switch (cmd) {
1368 case PPPIOCGIDLE32:
1369 if (err)
1370 return err;
1371 idle32.xmit_idle = idle.xmit_idle;
1372 idle32.recv_idle = idle.recv_idle;
1373 if (copy_to_user((struct ppp_idle32 *)arg, &idle32, sizeof(struct ppp_idle32)))
1374 return -EFAULT;
1375 break;
1376 case PPPIOCSCOMPRESS32:
1377 kfree(data.ptr);
1378 break;
1379 default:
1380 break;
1382 return err;
1386 struct mtget32 {
1387 __u32 mt_type;
1388 __u32 mt_resid;
1389 __u32 mt_dsreg;
1390 __u32 mt_gstat;
1391 __u32 mt_erreg;
1392 __kernel_daddr_t32 mt_fileno;
1393 __kernel_daddr_t32 mt_blkno;
1395 #define MTIOCGET32 _IOR('m', 2, struct mtget32)
1397 struct mtpos32 {
1398 __u32 mt_blkno;
1400 #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
1402 struct mtconfiginfo32 {
1403 __u32 mt_type;
1404 __u32 ifc_type;
1405 __u16 irqnr;
1406 __u16 dmanr;
1407 __u16 port;
1408 __u32 debug;
1409 __u32 have_dens:1;
1410 __u32 have_bsf:1;
1411 __u32 have_fsr:1;
1412 __u32 have_bsr:1;
1413 __u32 have_eod:1;
1414 __u32 have_seek:1;
1415 __u32 have_tell:1;
1416 __u32 have_ras1:1;
1417 __u32 have_ras2:1;
1418 __u32 have_ras3:1;
1419 __u32 have_qfa:1;
1420 __u32 pad1:5;
1421 char reserved[10];
1423 #define MTIOCGETCONFIG32 _IOR('m', 4, struct mtconfiginfo32)
1424 #define MTIOCSETCONFIG32 _IOW('m', 5, struct mtconfiginfo32)
1426 static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1428 mm_segment_t old_fs = get_fs();
1429 struct mtconfiginfo info;
1430 struct mtget get;
1431 struct mtpos pos;
1432 unsigned long kcmd;
1433 void *karg;
1434 int err = 0;
1436 switch(cmd) {
1437 case MTIOCPOS32:
1438 kcmd = MTIOCPOS;
1439 karg = &pos;
1440 break;
1441 case MTIOCGET32:
1442 kcmd = MTIOCGET;
1443 karg = &get;
1444 break;
1445 case MTIOCGETCONFIG32:
1446 kcmd = MTIOCGETCONFIG;
1447 karg = &info;
1448 break;
1449 case MTIOCSETCONFIG32:
1450 kcmd = MTIOCSETCONFIG;
1451 karg = &info;
1452 err = __get_user(info.mt_type, &((struct mtconfiginfo32 *)arg)->mt_type);
1453 err |= __get_user(info.ifc_type, &((struct mtconfiginfo32 *)arg)->ifc_type);
1454 err |= __get_user(info.irqnr, &((struct mtconfiginfo32 *)arg)->irqnr);
1455 err |= __get_user(info.dmanr, &((struct mtconfiginfo32 *)arg)->dmanr);
1456 err |= __get_user(info.port, &((struct mtconfiginfo32 *)arg)->port);
1457 err |= __get_user(info.debug, &((struct mtconfiginfo32 *)arg)->debug);
1458 err |= __copy_from_user((char *)&info.debug + sizeof(info.debug),
1459 (char *)&((struct mtconfiginfo32 *)arg)->debug
1460 + sizeof(((struct mtconfiginfo32 *)arg)->debug), sizeof(__u32));
1461 if (err)
1462 return -EFAULT;
1463 break;
1464 default:
1465 do {
1466 static int count = 0;
1467 if (++count <= 20)
1468 printk("mt_ioctl: Unknown cmd fd(%d) "
1469 "cmd(%08x) arg(%08x)\n",
1470 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1471 } while(0);
1472 return -EINVAL;
1474 set_fs (KERNEL_DS);
1475 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1476 set_fs (old_fs);
1477 if (err)
1478 return err;
1479 switch (cmd) {
1480 case MTIOCPOS32:
1481 err = __put_user(pos.mt_blkno, &((struct mtpos32 *)arg)->mt_blkno);
1482 break;
1483 case MTIOCGET32:
1484 err = __put_user(get.mt_type, &((struct mtget32 *)arg)->mt_type);
1485 err |= __put_user(get.mt_resid, &((struct mtget32 *)arg)->mt_resid);
1486 err |= __put_user(get.mt_dsreg, &((struct mtget32 *)arg)->mt_dsreg);
1487 err |= __put_user(get.mt_gstat, &((struct mtget32 *)arg)->mt_gstat);
1488 err |= __put_user(get.mt_erreg, &((struct mtget32 *)arg)->mt_erreg);
1489 err |= __put_user(get.mt_fileno, &((struct mtget32 *)arg)->mt_fileno);
1490 err |= __put_user(get.mt_blkno, &((struct mtget32 *)arg)->mt_blkno);
1491 break;
1492 case MTIOCGETCONFIG32:
1493 err = __put_user(info.mt_type, &((struct mtconfiginfo32 *)arg)->mt_type);
1494 err |= __put_user(info.ifc_type, &((struct mtconfiginfo32 *)arg)->ifc_type);
1495 err |= __put_user(info.irqnr, &((struct mtconfiginfo32 *)arg)->irqnr);
1496 err |= __put_user(info.dmanr, &((struct mtconfiginfo32 *)arg)->dmanr);
1497 err |= __put_user(info.port, &((struct mtconfiginfo32 *)arg)->port);
1498 err |= __put_user(info.debug, &((struct mtconfiginfo32 *)arg)->debug);
1499 err |= __copy_to_user((char *)&((struct mtconfiginfo32 *)arg)->debug
1500 + sizeof(((struct mtconfiginfo32 *)arg)->debug),
1501 (char *)&info.debug + sizeof(info.debug), sizeof(__u32));
1502 break;
1503 case MTIOCSETCONFIG32:
1504 break;
1506 return err ? -EFAULT: 0;
1509 struct cdrom_read32 {
1510 int cdread_lba;
1511 __kernel_caddr_t32 cdread_bufaddr;
1512 int cdread_buflen;
1515 struct cdrom_read_audio32 {
1516 union cdrom_addr addr;
1517 u_char addr_format;
1518 int nframes;
1519 __kernel_caddr_t32 buf;
1522 struct cdrom_generic_command32 {
1523 unsigned char cmd[CDROM_PACKET_SIZE];
1524 __kernel_caddr_t32 buffer;
1525 unsigned int buflen;
1526 int stat;
1527 __kernel_caddr_t32 sense;
1528 __kernel_caddr_t32 reserved[3];
1531 static int cdrom_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1533 mm_segment_t old_fs = get_fs();
1534 struct cdrom_read cdread;
1535 struct cdrom_read_audio cdreadaudio;
1536 struct cdrom_generic_command cgc;
1537 __kernel_caddr_t32 addr;
1538 char *data = 0;
1539 void *karg;
1540 int err = 0;
1542 switch(cmd) {
1543 case CDROMREADMODE2:
1544 case CDROMREADMODE1:
1545 case CDROMREADRAW:
1546 case CDROMREADCOOKED:
1547 karg = &cdread;
1548 err = __get_user(cdread.cdread_lba, &((struct cdrom_read32 *)arg)->cdread_lba);
1549 err |= __get_user(addr, &((struct cdrom_read32 *)arg)->cdread_bufaddr);
1550 err |= __get_user(cdread.cdread_buflen, &((struct cdrom_read32 *)arg)->cdread_buflen);
1551 if (err)
1552 return -EFAULT;
1553 data = kmalloc(cdread.cdread_buflen, GFP_KERNEL);
1554 if (!data)
1555 return -ENOMEM;
1556 cdread.cdread_bufaddr = data;
1557 break;
1558 case CDROMREADAUDIO:
1559 karg = &cdreadaudio;
1560 err = copy_from_user(&cdreadaudio.addr, &((struct cdrom_read_audio32 *)arg)->addr, sizeof(cdreadaudio.addr));
1561 err |= __get_user(cdreadaudio.addr_format, &((struct cdrom_read_audio32 *)arg)->addr_format);
1562 err |= __get_user(cdreadaudio.nframes, &((struct cdrom_read_audio32 *)arg)->nframes);
1563 err |= __get_user(addr, &((struct cdrom_read_audio32 *)arg)->buf);
1564 if (err)
1565 return -EFAULT;
1566 data = kmalloc(cdreadaudio.nframes * 2352, GFP_KERNEL);
1567 if (!data)
1568 return -ENOMEM;
1569 cdreadaudio.buf = data;
1570 break;
1571 case CDROM_SEND_PACKET:
1572 karg = &cgc;
1573 err = copy_from_user(cgc.cmd, &((struct cdrom_generic_command32 *)arg)->cmd, sizeof(cgc.cmd));
1574 err |= __get_user(addr, &((struct cdrom_generic_command32 *)arg)->buffer);
1575 err |= __get_user(cgc.buflen, &((struct cdrom_generic_command32 *)arg)->buflen);
1576 if (err)
1577 return -EFAULT;
1578 if ((data = kmalloc(cgc.buflen, GFP_KERNEL)) == NULL)
1579 return -ENOMEM;
1580 cgc.buffer = data;
1581 break;
1582 default:
1583 do {
1584 static int count = 0;
1585 if (++count <= 20)
1586 printk("cdrom_ioctl: Unknown cmd fd(%d) "
1587 "cmd(%08x) arg(%08x)\n",
1588 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1589 } while(0);
1590 return -EINVAL;
1592 set_fs (KERNEL_DS);
1593 err = sys_ioctl (fd, cmd, (unsigned long)karg);
1594 set_fs (old_fs);
1595 if (err)
1596 goto out;
1597 switch (cmd) {
1598 case CDROMREADMODE2:
1599 case CDROMREADMODE1:
1600 case CDROMREADRAW:
1601 case CDROMREADCOOKED:
1602 err = copy_to_user((char *)A(addr), data, cdread.cdread_buflen);
1603 break;
1604 case CDROMREADAUDIO:
1605 err = copy_to_user((char *)A(addr), data, cdreadaudio.nframes * 2352);
1606 break;
1607 case CDROM_SEND_PACKET:
1608 err = copy_to_user((char *)A(addr), data, cgc.buflen);
1609 break;
1610 default:
1611 break;
1613 out: if (data)
1614 kfree(data);
1615 return err ? -EFAULT : 0;
1618 struct loop_info32 {
1619 int lo_number; /* ioctl r/o */
1620 __kernel_dev_t32 lo_device; /* ioctl r/o */
1621 unsigned int lo_inode; /* ioctl r/o */
1622 __kernel_dev_t32 lo_rdevice; /* ioctl r/o */
1623 int lo_offset;
1624 int lo_encrypt_type;
1625 int lo_encrypt_key_size; /* ioctl w/o */
1626 int lo_flags; /* ioctl r/o */
1627 char lo_name[LO_NAME_SIZE];
1628 unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
1629 unsigned int lo_init[2];
1630 char reserved[4];
1633 static int loop_status(unsigned int fd, unsigned int cmd, unsigned long arg)
1635 mm_segment_t old_fs = get_fs();
1636 struct loop_info l;
1637 int err = -EINVAL;
1639 switch(cmd) {
1640 case LOOP_SET_STATUS:
1641 err = get_user(l.lo_number, &((struct loop_info32 *)arg)->lo_number);
1642 err |= __get_user(l.lo_device, &((struct loop_info32 *)arg)->lo_device);
1643 err |= __get_user(l.lo_inode, &((struct loop_info32 *)arg)->lo_inode);
1644 err |= __get_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice);
1645 err |= __copy_from_user((char *)&l.lo_offset, (char *)&((struct loop_info32 *)arg)->lo_offset,
1646 8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1647 if (err) {
1648 err = -EFAULT;
1649 } else {
1650 set_fs (KERNEL_DS);
1651 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1652 set_fs (old_fs);
1654 break;
1655 case LOOP_GET_STATUS:
1656 set_fs (KERNEL_DS);
1657 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1658 set_fs (old_fs);
1659 if (!err) {
1660 err = put_user(l.lo_number, &((struct loop_info32 *)arg)->lo_number);
1661 err |= __put_user(l.lo_device, &((struct loop_info32 *)arg)->lo_device);
1662 err |= __put_user(l.lo_inode, &((struct loop_info32 *)arg)->lo_inode);
1663 err |= __put_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice);
1664 err |= __copy_to_user((char *)&((struct loop_info32 *)arg)->lo_offset,
1665 (char *)&l.lo_offset, (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1666 if (err)
1667 err = -EFAULT;
1669 break;
1670 default: {
1671 static int count = 0;
1672 if (++count <= 20)
1673 printk("%s: Unknown loop ioctl cmd, fd(%d) "
1674 "cmd(%08x) arg(%08lx)\n",
1675 __FUNCTION__, fd, cmd, arg);
1678 return err;
1681 extern int tty_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg);
1683 static int vt_check(struct file *file)
1685 struct tty_struct *tty;
1686 struct inode *inode = file->f_dentry->d_inode;
1688 if (file->f_op->ioctl != tty_ioctl)
1689 return -EINVAL;
1691 tty = (struct tty_struct *)file->private_data;
1692 if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
1693 return -EINVAL;
1695 if (tty->driver.ioctl != vt_ioctl)
1696 return -EINVAL;
1699 * To have permissions to do most of the vt ioctls, we either have
1700 * to be the owner of the tty, or super-user.
1702 if (current->tty == tty || suser())
1703 return 1;
1704 return 0;
1707 struct consolefontdesc32 {
1708 unsigned short charcount; /* characters in font (256 or 512) */
1709 unsigned short charheight; /* scan lines per character (1-32) */
1710 u32 chardata; /* font data in expanded form */
1713 static int do_fontx_ioctl(unsigned int fd, int cmd, struct consolefontdesc32 *user_cfd, struct file *file)
1715 struct consolefontdesc cfdarg;
1716 struct console_font_op op;
1717 int i, perm;
1719 perm = vt_check(file);
1720 if (perm < 0) return perm;
1722 if (copy_from_user(&cfdarg, user_cfd, sizeof(struct consolefontdesc32)))
1723 return -EFAULT;
1725 cfdarg.chardata = (unsigned char *)A(((struct consolefontdesc32 *)&cfdarg)->chardata);
1727 switch (cmd) {
1728 case PIO_FONTX:
1729 if (!perm)
1730 return -EPERM;
1731 op.op = KD_FONT_OP_SET;
1732 op.flags = 0;
1733 op.width = 8;
1734 op.height = cfdarg.charheight;
1735 op.charcount = cfdarg.charcount;
1736 op.data = cfdarg.chardata;
1737 return con_font_op(fg_console, &op);
1738 case GIO_FONTX:
1739 if (!cfdarg.chardata)
1740 return 0;
1741 op.op = KD_FONT_OP_GET;
1742 op.flags = 0;
1743 op.width = 8;
1744 op.height = cfdarg.charheight;
1745 op.charcount = cfdarg.charcount;
1746 op.data = cfdarg.chardata;
1747 i = con_font_op(fg_console, &op);
1748 if (i)
1749 return i;
1750 cfdarg.charheight = op.height;
1751 cfdarg.charcount = op.charcount;
1752 ((struct consolefontdesc32 *)&cfdarg)->chardata = (unsigned long)cfdarg.chardata;
1753 if (copy_to_user(user_cfd, &cfdarg, sizeof(struct consolefontdesc32)))
1754 return -EFAULT;
1755 return 0;
1757 return -EINVAL;
1760 struct console_font_op32 {
1761 unsigned int op; /* operation code KD_FONT_OP_* */
1762 unsigned int flags; /* KD_FONT_FLAG_* */
1763 unsigned int width, height; /* font size */
1764 unsigned int charcount;
1765 u32 data; /* font data with height fixed to 32 */
1768 static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, struct console_font_op32 *fontop, struct file *file)
1770 struct console_font_op op;
1771 int perm = vt_check(file), i;
1772 struct vt_struct *vt;
1774 if (perm < 0) return perm;
1776 if (copy_from_user(&op, (void *) fontop, sizeof(struct console_font_op32)))
1777 return -EFAULT;
1778 if (!perm && op.op != KD_FONT_OP_GET)
1779 return -EPERM;
1780 op.data = (unsigned char *)A(((struct console_font_op32 *)&op)->data);
1781 op.flags |= KD_FONT_FLAG_OLD;
1782 vt = (struct vt_struct *)((struct tty_struct *)file->private_data)->driver_data;
1783 i = con_font_op(vt->vc_num, &op);
1784 if (i) return i;
1785 ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
1786 if (copy_to_user((void *) fontop, &op, sizeof(struct console_font_op32)))
1787 return -EFAULT;
1788 return 0;
1791 struct unimapdesc32 {
1792 unsigned short entry_ct;
1793 u32 entries;
1796 static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, struct unimapdesc32 *user_ud, struct file *file)
1798 struct unimapdesc32 tmp;
1799 int perm = vt_check(file);
1801 if (perm < 0) return perm;
1802 if (copy_from_user(&tmp, user_ud, sizeof tmp))
1803 return -EFAULT;
1804 switch (cmd) {
1805 case PIO_UNIMAP:
1806 if (!perm) return -EPERM;
1807 return con_set_unimap(fg_console, tmp.entry_ct, (struct unipair *)A(tmp.entries));
1808 case GIO_UNIMAP:
1809 return con_get_unimap(fg_console, tmp.entry_ct, &(user_ud->entry_ct), (struct unipair *)A(tmp.entries));
1811 return 0;
1814 static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg)
1816 mm_segment_t old_fs = get_fs();
1817 __kernel_uid_t kuid;
1818 int err;
1820 cmd = SMB_IOC_GETMOUNTUID;
1822 set_fs(KERNEL_DS);
1823 err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
1824 set_fs(old_fs);
1826 if (err >= 0)
1827 err = put_user(kuid, (__kernel_uid_t32 *)arg);
1829 return err;
1832 struct atmif_sioc32 {
1833 int number;
1834 int length;
1835 __kernel_caddr_t32 arg;
1838 struct atm_iobuf32 {
1839 int length;
1840 __kernel_caddr_t32 buffer;
1843 #define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32)
1844 #define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32)
1845 #define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32)
1846 #define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32)
1847 #define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32)
1848 #define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32)
1849 #define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32)
1850 #define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32)
1851 #define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32)
1852 #define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32)
1853 #define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32)
1854 #define ATM_SETESIF32 _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32)
1855 #define ATM_GETSTAT32 _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32)
1856 #define ATM_GETSTATZ32 _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32)
1857 #define ATM_GETLOOP32 _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32)
1858 #define ATM_SETLOOP32 _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32)
1859 #define ATM_QUERYLOOP32 _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32)
1861 static struct {
1862 unsigned int cmd32;
1863 unsigned int cmd;
1864 } atm_ioctl_map[] = {
1865 { ATM_GETLINKRATE32, ATM_GETLINKRATE },
1866 { ATM_GETNAMES32, ATM_GETNAMES },
1867 { ATM_GETTYPE32, ATM_GETTYPE },
1868 { ATM_GETESI32, ATM_GETESI },
1869 { ATM_GETADDR32, ATM_GETADDR },
1870 { ATM_RSTADDR32, ATM_RSTADDR },
1871 { ATM_ADDADDR32, ATM_ADDADDR },
1872 { ATM_DELADDR32, ATM_DELADDR },
1873 { ATM_GETCIRANGE32, ATM_GETCIRANGE },
1874 { ATM_SETCIRANGE32, ATM_SETCIRANGE },
1875 { ATM_SETESI32, ATM_SETESI },
1876 { ATM_SETESIF32, ATM_SETESIF },
1877 { ATM_GETSTAT32, ATM_GETSTAT },
1878 { ATM_GETSTATZ32, ATM_GETSTATZ },
1879 { ATM_GETLOOP32, ATM_GETLOOP },
1880 { ATM_SETLOOP32, ATM_SETLOOP },
1881 { ATM_QUERYLOOP32, ATM_QUERYLOOP }
1884 #define NR_ATM_IOCTL (sizeof(atm_ioctl_map)/sizeof(atm_ioctl_map[0]))
1887 static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg)
1889 struct atm_iobuf32 iobuf32;
1890 struct atm_iobuf iobuf = { 0, NULL };
1891 mm_segment_t old_fs;
1892 int err;
1894 err = copy_from_user(&iobuf32, (struct atm_iobuf32*)arg,
1895 sizeof(struct atm_iobuf32));
1896 if (err)
1897 return -EFAULT;
1899 iobuf.length = iobuf32.length;
1901 if (iobuf32.buffer == (__kernel_caddr_t32) NULL || iobuf32.length == 0) {
1902 iobuf.buffer = (void*)(unsigned long)iobuf32.buffer;
1903 } else {
1904 iobuf.buffer = kmalloc(iobuf.length, GFP_KERNEL);
1905 if (iobuf.buffer == NULL) {
1906 err = -ENOMEM;
1907 goto out;
1910 err = copy_from_user(iobuf.buffer, A(iobuf32.buffer), iobuf.length);
1911 if (err) {
1912 err = -EFAULT;
1913 goto out;
1917 old_fs = get_fs(); set_fs (KERNEL_DS);
1918 err = sys_ioctl (fd, cmd, (unsigned long)&iobuf);
1919 set_fs (old_fs);
1920 if(err)
1921 goto out;
1923 if(iobuf.buffer && iobuf.length > 0) {
1924 err = copy_to_user(A(iobuf32.buffer), iobuf.buffer, iobuf.length);
1925 if (err) {
1926 err = -EFAULT;
1927 goto out;
1930 err = __put_user(iobuf.length, &(((struct atm_iobuf32*)arg)->length));
1932 out:
1933 if(iobuf32.buffer && iobuf32.length > 0)
1934 kfree(iobuf.buffer);
1936 return err;
1940 static int do_atmif_sioc(unsigned int fd, unsigned int cmd, unsigned long arg)
1942 struct atmif_sioc32 sioc32;
1943 struct atmif_sioc sioc = { 0, 0, NULL };
1944 mm_segment_t old_fs;
1945 int err;
1947 err = copy_from_user(&sioc32, (struct atmif_sioc32*)arg,
1948 sizeof(struct atmif_sioc32));
1949 if (err)
1950 return -EFAULT;
1952 sioc.number = sioc32.number;
1953 sioc.length = sioc32.length;
1955 if (sioc32.arg == (__kernel_caddr_t32) NULL || sioc32.length == 0) {
1956 sioc.arg = (void*)(unsigned long)sioc32.arg;
1957 } else {
1958 sioc.arg = kmalloc(sioc.length, GFP_KERNEL);
1959 if (sioc.arg == NULL) {
1960 err = -ENOMEM;
1961 goto out;
1964 err = copy_from_user(sioc.arg, A(sioc32.arg), sioc32.length);
1965 if (err) {
1966 err = -EFAULT;
1967 goto out;
1971 old_fs = get_fs(); set_fs (KERNEL_DS);
1972 err = sys_ioctl (fd, cmd, (unsigned long)&sioc);
1973 set_fs (old_fs);
1974 if(err) {
1975 goto out;
1978 if(sioc.arg && sioc.length > 0) {
1979 err = copy_to_user(A(sioc32.arg), sioc.arg, sioc.length);
1980 if (err) {
1981 err = -EFAULT;
1982 goto out;
1985 err = __put_user(sioc.length, &(((struct atmif_sioc32*)arg)->length));
1987 out:
1988 if(sioc32.arg && sioc32.length > 0)
1989 kfree(sioc.arg);
1991 return err;
1995 static int do_atm_ioctl(unsigned int fd, unsigned int cmd32, unsigned long arg)
1997 int i;
1998 unsigned int cmd = 0;
2000 switch (cmd32) {
2001 case SONET_GETSTAT:
2002 case SONET_GETSTATZ:
2003 case SONET_GETDIAG:
2004 case SONET_SETDIAG:
2005 case SONET_CLRDIAG:
2006 case SONET_SETFRAMING:
2007 case SONET_GETFRAMING:
2008 case SONET_GETFRSENSE:
2009 return do_atmif_sioc(fd, cmd32, arg);
2012 for (i = 0; i < NR_ATM_IOCTL; i++) {
2013 if (cmd32 == atm_ioctl_map[i].cmd32) {
2014 cmd = atm_ioctl_map[i].cmd;
2015 break;
2018 if (i == NR_ATM_IOCTL) {
2019 return -EINVAL;
2022 switch (cmd) {
2023 case ATM_GETNAMES:
2024 return do_atm_iobuf(fd, cmd, arg);
2026 case ATM_GETLINKRATE:
2027 case ATM_GETTYPE:
2028 case ATM_GETESI:
2029 case ATM_GETADDR:
2030 case ATM_RSTADDR:
2031 case ATM_ADDADDR:
2032 case ATM_DELADDR:
2033 case ATM_GETCIRANGE:
2034 case ATM_SETCIRANGE:
2035 case ATM_SETESI:
2036 case ATM_SETESIF:
2037 case ATM_GETSTAT:
2038 case ATM_GETSTATZ:
2039 case ATM_GETLOOP:
2040 case ATM_SETLOOP:
2041 case ATM_QUERYLOOP:
2042 return do_atmif_sioc(fd, cmd, arg);
2045 return -EINVAL;
2048 #if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
2049 /* Ugh, LVM. Pitty it was not cleaned up before accepted :((. */
2050 typedef struct {
2051 uint8_t vg_name[NAME_LEN];
2052 uint32_t vg_number;
2053 uint32_t vg_access;
2054 uint32_t vg_status;
2055 uint32_t lv_max;
2056 uint32_t lv_cur;
2057 uint32_t lv_open;
2058 uint32_t pv_max;
2059 uint32_t pv_cur;
2060 uint32_t pv_act;
2061 uint32_t dummy;
2062 uint32_t vgda;
2063 uint32_t pe_size;
2064 uint32_t pe_total;
2065 uint32_t pe_allocated;
2066 uint32_t pvg_total;
2067 u32 proc;
2068 u32 pv[ABS_MAX_PV + 1];
2069 u32 lv[ABS_MAX_LV + 1];
2070 } vg32_t;
2072 typedef struct {
2073 uint8_t id[2];
2074 uint16_t version;
2075 lvm_disk_data_t pv_on_disk;
2076 lvm_disk_data_t vg_on_disk;
2077 lvm_disk_data_t pv_namelist_on_disk;
2078 lvm_disk_data_t lv_on_disk;
2079 lvm_disk_data_t pe_on_disk;
2080 uint8_t pv_name[NAME_LEN];
2081 uint8_t vg_name[NAME_LEN];
2082 uint8_t system_id[NAME_LEN];
2083 kdev_t pv_dev;
2084 uint32_t pv_number;
2085 uint32_t pv_status;
2086 uint32_t pv_allocatable;
2087 uint32_t pv_size;
2088 uint32_t lv_cur;
2089 uint32_t pe_size;
2090 uint32_t pe_total;
2091 uint32_t pe_allocated;
2092 uint32_t pe_stale;
2093 u32 pe;
2094 u32 inode;
2095 } pv32_t;
2097 typedef struct {
2098 char lv_name[NAME_LEN];
2099 u32 lv;
2100 } lv_req32_t;
2102 typedef struct {
2103 u32 lv_index;
2104 u32 lv;
2105 } lv_status_byindex_req32_t;
2107 typedef struct {
2108 uint8_t lv_name[NAME_LEN];
2109 kdev_t old_dev;
2110 kdev_t new_dev;
2111 u32 old_pe;
2112 u32 new_pe;
2113 } le_remap_req32_t;
2115 typedef struct {
2116 char pv_name[NAME_LEN];
2117 u32 pv;
2118 } pv_status_req32_t;
2120 typedef struct {
2121 uint8_t lv_name[NAME_LEN];
2122 uint8_t vg_name[NAME_LEN];
2123 uint32_t lv_access;
2124 uint32_t lv_status;
2125 uint32_t lv_open;
2126 kdev_t lv_dev;
2127 uint32_t lv_number;
2128 uint32_t lv_mirror_copies;
2129 uint32_t lv_recovery;
2130 uint32_t lv_schedule;
2131 uint32_t lv_size;
2132 u32 lv_current_pe;
2133 uint32_t lv_current_le;
2134 uint32_t lv_allocated_le;
2135 uint32_t lv_stripes;
2136 uint32_t lv_stripesize;
2137 uint32_t lv_badblock;
2138 uint32_t lv_allocation;
2139 uint32_t lv_io_timeout;
2140 uint32_t lv_read_ahead;
2141 /* delta to version 1 starts here */
2142 u32 lv_snapshot_org;
2143 u32 lv_snapshot_prev;
2144 u32 lv_snapshot_next;
2145 u32 lv_block_exception;
2146 uint32_t lv_remap_ptr;
2147 uint32_t lv_remap_end;
2148 uint32_t lv_chunk_size;
2149 uint32_t lv_snapshot_minor;
2150 char dummy[200];
2151 } lv32_t;
2153 typedef struct {
2154 u32 hash[2];
2155 u32 rsector_org;
2156 kdev_t rdev_org;
2157 u32 rsector_new;
2158 kdev_t rdev_new;
2159 } lv_block_exception32_t;
2161 static void put_lv_t(lv_t *l)
2163 if (l->lv_current_pe) vfree(l->lv_current_pe);
2164 if (l->lv_block_exception) vfree(l->lv_block_exception);
2165 kfree(l);
2168 static lv_t *get_lv_t(u32 p, int *errp)
2170 int err, i;
2171 u32 ptr1, ptr2;
2172 size_t size;
2173 lv_block_exception32_t *lbe32;
2174 lv_block_exception_t *lbe;
2175 lv32_t *ul = (lv32_t *)A(p);
2176 lv_t *l = (lv_t *)kmalloc(sizeof(lv_t), GFP_KERNEL);
2177 if (!l) {
2178 *errp = -ENOMEM;
2179 return NULL;
2181 memset(l, 0, sizeof(lv_t));
2182 err = copy_from_user(l, ul, (long)&((lv32_t *)0)->lv_current_pe);
2183 err |= __copy_from_user(&l->lv_current_le, &ul->lv_current_le,
2184 ((long)&ul->lv_snapshot_org) - ((long)&ul->lv_current_le));
2185 err |= __copy_from_user(&l->lv_remap_ptr, &ul->lv_remap_ptr,
2186 ((long)&ul->dummy[0]) - ((long)&ul->lv_remap_ptr));
2187 err |= __get_user(ptr1, &ul->lv_current_pe);
2188 err |= __get_user(ptr2, &ul->lv_block_exception);
2189 if (err) {
2190 kfree(l);
2191 *errp = -EFAULT;
2192 return NULL;
2194 if (ptr1) {
2195 size = l->lv_allocated_le * sizeof(pe_t);
2196 l->lv_current_pe = vmalloc(size);
2197 if (l->lv_current_pe)
2198 err = copy_from_user(l->lv_current_pe, (void *)A(ptr1), size);
2200 if (!err && ptr2) {
2201 size = l->lv_remap_end * sizeof(lv_block_exception_t);
2202 l->lv_block_exception = lbe = vmalloc(size);
2203 if (l->lv_block_exception) {
2204 lbe32 = (lv_block_exception32_t *)A(ptr2);
2205 memset(lbe, 0, size);
2206 for (i = 0; i < l->lv_remap_end; i++, lbe++, lbe32++) {
2207 err |= get_user(lbe->rsector_org, &lbe32->rsector_org);
2208 err |= __get_user(lbe->rdev_org, &lbe32->rdev_org);
2209 err |= __get_user(lbe->rsector_new, &lbe32->rsector_new);
2210 err |= __get_user(lbe->rdev_new, &lbe32->rdev_new);
2214 if (err || (ptr1 && !l->lv_current_pe) || (ptr2 && !l->lv_block_exception)) {
2215 if (!err)
2216 *errp = -ENOMEM;
2217 else
2218 *errp = -EFAULT;
2219 put_lv_t(l);
2220 return NULL;
2222 return l;
2225 static int copy_lv_t(u32 ptr, lv_t *l)
2227 int err;
2228 lv32_t *ul = (lv32_t *)A(ptr);
2229 u32 ptr1;
2230 size_t size;
2232 err = get_user(ptr1, &ul->lv_current_pe);
2233 if (err)
2234 return -EFAULT;
2235 err = copy_to_user(ul, l, (long)&((lv32_t *)0)->lv_current_pe);
2236 err |= __copy_to_user(&ul->lv_current_le, &l->lv_current_le,
2237 ((long)&ul->lv_snapshot_org) - ((long)&ul->lv_current_le));
2238 err |= __copy_to_user(&ul->lv_remap_ptr, &l->lv_remap_ptr,
2239 ((long)&ul->dummy[0]) - ((long)&ul->lv_remap_ptr));
2240 size = l->lv_allocated_le * sizeof(pe_t);
2241 err |= __copy_to_user((void *)A(ptr1), l->lv_current_pe, size);
2242 return -EFAULT;
2245 static int do_lvm_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
2247 vg_t *v;
2248 union {
2249 lv_req_t lv_req;
2250 le_remap_req_t le_remap;
2251 lv_status_byindex_req_t lv_byindex;
2252 pv_status_req32_t pv_status;
2253 } u;
2254 pv_t p;
2255 int err;
2256 u32 ptr = 0;
2257 int i;
2258 mm_segment_t old_fs;
2259 void *karg = &u;
2261 switch (cmd) {
2262 case VG_STATUS:
2263 v = kmalloc(sizeof(vg_t), GFP_KERNEL);
2264 if (!v) return -ENOMEM;
2265 karg = v;
2266 break;
2267 case VG_CREATE:
2268 v = kmalloc(sizeof(vg_t), GFP_KERNEL);
2269 if (!v) return -ENOMEM;
2270 if (copy_from_user(v, (void *)arg, (long)&((vg32_t *)0)->proc) ||
2271 __get_user(v->proc, &((vg32_t *)arg)->proc)) {
2272 kfree(v);
2273 return -EFAULT;
2275 karg = v;
2276 memset(v->pv, 0, sizeof(v->pv) + sizeof(v->lv));
2277 if (v->pv_max > ABS_MAX_PV || v->lv_max == ABS_MAX_LV) return -EPERM;
2278 for (i = 0; i < v->pv_max; i++) {
2279 err = __get_user(ptr, &((vg32_t *)arg)->pv[i]);
2280 if (err) break;
2281 if (ptr) {
2282 v->pv[i] = kmalloc(sizeof(pv_t), GFP_KERNEL);
2283 if (!v->pv[i]) {
2284 err = -ENOMEM;
2285 break;
2287 err = copy_from_user(v->pv[i], (void *)A(ptr), sizeof(pv32_t) - 8);
2288 if (err) {
2289 err = -EFAULT;
2290 break;
2292 v->pv[i]->pe = NULL; v->pv[i]->inode = NULL;
2295 if (!err) {
2296 for (i = 0; i < v->lv_max; i++) {
2297 err = __get_user(ptr, &((vg32_t *)arg)->lv[i]);
2298 if (err) break;
2299 if (ptr) {
2300 v->lv[i] = get_lv_t(ptr, &err);
2301 if (err) break;
2305 break;
2306 case LV_CREATE:
2307 case LV_EXTEND:
2308 case LV_REDUCE:
2309 case LV_REMOVE:
2310 case LV_STATUS_BYNAME:
2311 err = copy_from_user(&u.pv_status, arg, sizeof(u.pv_status.pv_name));
2312 if (err) return -EFAULT;
2313 if (cmd != LV_REMOVE) {
2314 err = __get_user(ptr, &((lv_req32_t *)arg)->lv);
2315 if (err) return err;
2316 u.lv_req.lv = get_lv_t(ptr, &err);
2317 } else
2318 u.lv_req.lv = NULL;
2319 break;
2320 case LV_STATUS_BYINDEX:
2321 err = get_user(u.lv_byindex.lv_index, &((lv_status_byindex_req32_t *)arg)->lv_index);
2322 err |= __get_user(ptr, &((lv_status_byindex_req32_t *)arg)->lv);
2323 if (err) return err;
2324 u.lv_byindex.lv = get_lv_t(ptr, &err);
2325 break;
2326 case VG_EXTEND:
2327 err = copy_from_user(&p, (void *)arg, sizeof(pv32_t) - 8);
2328 if (err) return -EFAULT;
2329 p.pe = NULL; p.inode = NULL;
2330 karg = &p;
2331 break;
2332 case LE_REMAP:
2333 err = copy_from_user(&u.le_remap, (void *)arg, sizeof(le_remap_req32_t));
2334 if (err) return -EFAULT;
2335 u.le_remap.new_pe = ((le_remap_req32_t *)&u.le_remap)->new_pe;
2336 u.le_remap.old_pe = ((le_remap_req32_t *)&u.le_remap)->old_pe;
2337 break;
2338 case PV_CHANGE:
2339 case PV_STATUS:
2340 err = copy_from_user(&u.pv_status, arg, sizeof(u.lv_req.lv_name));
2341 if (err) return -EFAULT;
2342 err = __get_user(ptr, &((pv_status_req32_t *)arg)->pv);
2343 if (err) return err;
2344 u.pv_status.pv = &p;
2345 if (cmd == PV_CHANGE) {
2346 err = copy_from_user(&p, (void *)A(ptr), sizeof(pv32_t) - 8);
2347 if (err) return -EFAULT;
2348 p.pe = NULL; p.inode = NULL;
2350 break;
2352 old_fs = get_fs(); set_fs (KERNEL_DS);
2353 err = sys_ioctl (fd, cmd, (unsigned long)karg);
2354 set_fs (old_fs);
2355 switch (cmd) {
2356 case VG_STATUS:
2357 if (!err) {
2358 if (copy_to_user((void *)arg, v, (long)&((vg32_t *)0)->proc) ||
2359 clear_user(&((vg32_t *)arg)->proc, sizeof(vg32_t) - (long)&((vg32_t *)0)->proc))
2360 err = -EFAULT;
2362 kfree(v);
2363 break;
2364 case VG_CREATE:
2365 for (i = 0; i < v->pv_max; i++)
2366 if (v->pv[i]) kfree(v->pv[i]);
2367 for (i = 0; i < v->lv_max; i++)
2368 if (v->lv[i]) put_lv_t(v->lv[i]);
2369 kfree(v);
2370 break;
2371 case LV_STATUS_BYNAME:
2372 if (!err && u.lv_req.lv) err = copy_lv_t(ptr, u.lv_req.lv);
2373 /* Fall through */
2374 case LV_CREATE:
2375 case LV_EXTEND:
2376 case LV_REDUCE:
2377 if (u.lv_req.lv) put_lv_t(u.lv_req.lv);
2378 break;
2379 case LV_STATUS_BYINDEX:
2380 if (u.lv_byindex.lv) {
2381 if (!err) err = copy_lv_t(ptr, u.lv_byindex.lv);
2382 put_lv_t(u.lv_byindex.lv);
2384 case PV_STATUS:
2385 if (!err) {
2386 err = copy_to_user((void *)A(ptr), &p, sizeof(pv32_t) - 8);
2387 if (err) return -EFAULT;
2389 break;
2391 return err;
2393 #endif
2395 #if defined(CONFIG_DRM) || defined(CONFIG_DRM_MODULE)
2396 /* This really belongs in include/linux/drm.h -DaveM */
2397 #include "../../../drivers/char/drm/drm.h"
2399 typedef struct drm32_version {
2400 int version_major; /* Major version */
2401 int version_minor; /* Minor version */
2402 int version_patchlevel;/* Patch level */
2403 int name_len; /* Length of name buffer */
2404 u32 name; /* Name of driver */
2405 int date_len; /* Length of date buffer */
2406 u32 date; /* User-space buffer to hold date */
2407 int desc_len; /* Length of desc buffer */
2408 u32 desc; /* User-space buffer to hold desc */
2409 } drm32_version_t;
2410 #define DRM32_IOCTL_VERSION DRM_IOWR(0x00, drm32_version_t)
2412 static int drm32_version(unsigned int fd, unsigned int cmd, unsigned long arg)
2414 drm32_version_t *uversion = (drm32_version_t *)arg;
2415 char *name_ptr, *date_ptr, *desc_ptr;
2416 u32 tmp1, tmp2, tmp3;
2417 drm_version_t kversion;
2418 mm_segment_t old_fs;
2419 int ret;
2421 memset(&kversion, 0, sizeof(kversion));
2422 if (get_user(kversion.name_len, &uversion->name_len) ||
2423 get_user(kversion.date_len, &uversion->date_len) ||
2424 get_user(kversion.desc_len, &uversion->desc_len) ||
2425 get_user(tmp1, &uversion->name) ||
2426 get_user(tmp2, &uversion->date) ||
2427 get_user(tmp3, &uversion->desc))
2428 return -EFAULT;
2430 name_ptr = (char *) A(tmp1);
2431 date_ptr = (char *) A(tmp2);
2432 desc_ptr = (char *) A(tmp3);
2434 ret = -ENOMEM;
2435 if (kversion.name_len && name_ptr) {
2436 kversion.name = kmalloc(kversion.name_len, GFP_KERNEL);
2437 if (!kversion.name)
2438 goto out;
2440 if (kversion.date_len && date_ptr) {
2441 kversion.date = kmalloc(kversion.date_len, GFP_KERNEL);
2442 if (!kversion.date)
2443 goto out;
2445 if (kversion.desc_len && desc_ptr) {
2446 kversion.desc = kmalloc(kversion.desc_len, GFP_KERNEL);
2447 if (!kversion.desc)
2448 goto out;
2451 old_fs = get_fs();
2452 set_fs(KERNEL_DS);
2453 ret = sys_ioctl (fd, DRM_IOCTL_VERSION, (unsigned long)&kversion);
2454 set_fs(old_fs);
2456 if (!ret) {
2457 if ((kversion.name &&
2458 copy_to_user(name_ptr, kversion.name, kversion.name_len)) ||
2459 (kversion.date &&
2460 copy_to_user(date_ptr, kversion.date, kversion.date_len)) ||
2461 (kversion.desc &&
2462 copy_to_user(desc_ptr, kversion.desc, kversion.desc_len)))
2463 ret = -EFAULT;
2464 if (put_user(kversion.version_major, &uversion->version_major) ||
2465 put_user(kversion.version_minor, &uversion->version_minor) ||
2466 put_user(kversion.version_patchlevel, &uversion->version_patchlevel) ||
2467 put_user(kversion.name_len, &uversion->name_len) ||
2468 put_user(kversion.date_len, &uversion->date_len) ||
2469 put_user(kversion.desc_len, &uversion->desc_len))
2470 ret = -EFAULT;
2473 out:
2474 if (kversion.name)
2475 kfree(kversion.name);
2476 if (kversion.date)
2477 kfree(kversion.date);
2478 if (kversion.desc)
2479 kfree(kversion.desc);
2480 return ret;
2483 typedef struct drm32_unique {
2484 int unique_len; /* Length of unique */
2485 u32 unique; /* Unique name for driver instantiation */
2486 } drm32_unique_t;
2487 #define DRM32_IOCTL_GET_UNIQUE DRM_IOWR(0x01, drm32_unique_t)
2488 #define DRM32_IOCTL_SET_UNIQUE DRM_IOW( 0x10, drm32_unique_t)
2490 static int drm32_getsetunique(unsigned int fd, unsigned int cmd, unsigned long arg)
2492 drm32_unique_t *uarg = (drm32_unique_t *)arg;
2493 drm_unique_t karg;
2494 mm_segment_t old_fs;
2495 char *uptr;
2496 u32 tmp;
2497 int ret;
2499 if (get_user(karg.unique_len, &uarg->unique_len))
2500 return -EFAULT;
2501 karg.unique = NULL;
2503 if (get_user(tmp, &uarg->unique))
2504 return -EFAULT;
2506 uptr = (char *) A(tmp);
2508 if (uptr) {
2509 karg.unique = kmalloc(karg.unique_len, GFP_KERNEL);
2510 if (!karg.unique)
2511 return -ENOMEM;
2512 if (cmd == DRM32_IOCTL_SET_UNIQUE &&
2513 copy_from_user(karg.unique, uptr, karg.unique_len)) {
2514 kfree(karg.unique);
2515 return -EFAULT;
2519 old_fs = get_fs();
2520 set_fs(KERNEL_DS);
2521 if (cmd == DRM32_IOCTL_GET_UNIQUE)
2522 ret = sys_ioctl (fd, DRM_IOCTL_GET_UNIQUE, (unsigned long)&karg);
2523 else
2524 ret = sys_ioctl (fd, DRM_IOCTL_SET_UNIQUE, (unsigned long)&karg);
2525 set_fs(old_fs);
2527 if (!ret) {
2528 if (cmd == DRM32_IOCTL_GET_UNIQUE &&
2529 uptr != NULL &&
2530 copy_to_user(uptr, karg.unique, karg.unique_len))
2531 ret = -EFAULT;
2532 if (put_user(karg.unique_len, &uarg->unique_len))
2533 ret = -EFAULT;
2536 if (karg.unique != NULL)
2537 kfree(karg.unique);
2539 return ret;
2542 typedef struct drm32_map {
2543 u32 offset; /* Requested physical address (0 for SAREA)*/
2544 u32 size; /* Requested physical size (bytes) */
2545 drm_map_type_t type; /* Type of memory to map */
2546 drm_map_flags_t flags; /* Flags */
2547 u32 handle; /* User-space: "Handle" to pass to mmap */
2548 /* Kernel-space: kernel-virtual address */
2549 int mtrr; /* MTRR slot used */
2550 /* Private data */
2551 } drm32_map_t;
2552 #define DRM32_IOCTL_ADD_MAP DRM_IOWR(0x15, drm32_map_t)
2554 static int drm32_addmap(unsigned int fd, unsigned int cmd, unsigned long arg)
2556 drm32_map_t *uarg = (drm32_map_t *) arg;
2557 drm_map_t karg;
2558 mm_segment_t old_fs;
2559 u32 tmp;
2560 int ret;
2562 ret = get_user(karg.offset, &uarg->offset);
2563 ret |= get_user(karg.size, &uarg->size);
2564 ret |= get_user(karg.type, &uarg->type);
2565 ret |= get_user(karg.flags, &uarg->flags);
2566 ret |= get_user(tmp, &uarg->handle);
2567 ret |= get_user(karg.mtrr, &uarg->mtrr);
2568 if (ret)
2569 return -EFAULT;
2571 karg.handle = (void *) A(tmp);
2573 old_fs = get_fs();
2574 set_fs(KERNEL_DS);
2575 ret = sys_ioctl(fd, DRM_IOCTL_ADD_MAP, (unsigned long) &karg);
2576 set_fs(old_fs);
2578 if (!ret) {
2579 ret = put_user(karg.offset, &uarg->offset);
2580 ret |= put_user(karg.size, &uarg->size);
2581 ret |= put_user(karg.type, &uarg->type);
2582 ret |= put_user(karg.flags, &uarg->flags);
2583 tmp = (u32) (long)karg.handle;
2584 ret |= put_user(tmp, &uarg->handle);
2585 ret |= put_user(karg.mtrr, &uarg->mtrr);
2586 if (ret)
2587 ret = -EFAULT;
2590 return ret;
2593 typedef struct drm32_buf_info {
2594 int count; /* Entries in list */
2595 u32 list; /* (drm_buf_desc_t *) */
2596 } drm32_buf_info_t;
2597 #define DRM32_IOCTL_INFO_BUFS DRM_IOWR(0x18, drm32_buf_info_t)
2599 static int drm32_info_bufs(unsigned int fd, unsigned int cmd, unsigned long arg)
2601 drm32_buf_info_t *uarg = (drm32_buf_info_t *)arg;
2602 drm_buf_desc_t *ulist;
2603 drm_buf_info_t karg;
2604 mm_segment_t old_fs;
2605 int orig_count, ret;
2606 u32 tmp;
2608 if (get_user(karg.count, &uarg->count) ||
2609 get_user(tmp, &uarg->list))
2610 return -EFAULT;
2612 ulist = (drm_buf_desc_t *) A(tmp);
2614 orig_count = karg.count;
2616 karg.list = kmalloc(karg.count * sizeof(drm_buf_desc_t), GFP_KERNEL);
2617 if (!karg.list)
2618 return -EFAULT;
2620 old_fs = get_fs();
2621 set_fs(KERNEL_DS);
2622 ret = sys_ioctl(fd, DRM_IOCTL_INFO_BUFS, (unsigned long) &karg);
2623 set_fs(old_fs);
2625 if (!ret) {
2626 if (karg.count <= orig_count &&
2627 (copy_to_user(ulist, karg.list,
2628 karg.count * sizeof(drm_buf_desc_t))))
2629 ret = -EFAULT;
2630 if (put_user(karg.count, &uarg->count))
2631 ret = -EFAULT;
2634 kfree(karg.list);
2636 return ret;
2639 typedef struct drm32_buf_free {
2640 int count;
2641 u32 list; /* (int *) */
2642 } drm32_buf_free_t;
2643 #define DRM32_IOCTL_FREE_BUFS DRM_IOW( 0x1a, drm32_buf_free_t)
2645 static int drm32_free_bufs(unsigned int fd, unsigned int cmd, unsigned long arg)
2647 drm32_buf_free_t *uarg = (drm32_buf_free_t *)arg;
2648 drm_buf_free_t karg;
2649 mm_segment_t old_fs;
2650 int *ulist;
2651 int ret;
2652 u32 tmp;
2654 if (get_user(karg.count, &uarg->count) ||
2655 get_user(tmp, &uarg->list))
2656 return -EFAULT;
2658 ulist = (int *) A(tmp);
2660 karg.list = kmalloc(karg.count * sizeof(int), GFP_KERNEL);
2661 if (!karg.list)
2662 return -ENOMEM;
2664 ret = -EFAULT;
2665 if (copy_from_user(karg.list, ulist, (karg.count * sizeof(int))))
2666 goto out;
2668 old_fs = get_fs();
2669 set_fs(KERNEL_DS);
2670 ret = sys_ioctl(fd, DRM_IOCTL_FREE_BUFS, (unsigned long) &karg);
2671 set_fs(old_fs);
2673 out:
2674 kfree(karg.list);
2676 return ret;
2679 typedef struct drm32_buf_pub {
2680 int idx; /* Index into master buflist */
2681 int total; /* Buffer size */
2682 int used; /* Amount of buffer in use (for DMA) */
2683 u32 address; /* Address of buffer (void *) */
2684 } drm32_buf_pub_t;
2686 typedef struct drm32_buf_map {
2687 int count; /* Length of buflist */
2688 u32 virtual; /* Mmaped area in user-virtual (void *) */
2689 u32 list; /* Buffer information (drm_buf_pub_t *) */
2690 } drm32_buf_map_t;
2691 #define DRM32_IOCTL_MAP_BUFS DRM_IOWR(0x19, drm32_buf_map_t)
2693 static int drm32_map_bufs(unsigned int fd, unsigned int cmd, unsigned long arg)
2695 drm32_buf_map_t *uarg = (drm32_buf_map_t *)arg;
2696 drm32_buf_pub_t *ulist;
2697 drm_buf_map_t karg;
2698 mm_segment_t old_fs;
2699 int orig_count, ret, i;
2700 u32 tmp1, tmp2;
2702 if (get_user(karg.count, &uarg->count) ||
2703 get_user(tmp1, &uarg->virtual) ||
2704 get_user(tmp2, &uarg->list))
2705 return -EFAULT;
2707 karg.virtual = (void *) A(tmp1);
2708 ulist = (drm32_buf_pub_t *) A(tmp2);
2710 orig_count = karg.count;
2712 karg.list = kmalloc(karg.count * sizeof(drm_buf_pub_t), GFP_KERNEL);
2713 if (!karg.list)
2714 return -ENOMEM;
2716 ret = -EFAULT;
2717 for (i = 0; i < karg.count; i++) {
2718 if (get_user(karg.list[i].idx, &ulist[i].idx) ||
2719 get_user(karg.list[i].total, &ulist[i].total) ||
2720 get_user(karg.list[i].used, &ulist[i].used) ||
2721 get_user(tmp1, &ulist[i].address))
2722 goto out;
2724 karg.list[i].address = (void *) A(tmp1);
2727 old_fs = get_fs();
2728 set_fs(KERNEL_DS);
2729 ret = sys_ioctl(fd, DRM_IOCTL_MAP_BUFS, (unsigned long) &karg);
2730 set_fs(old_fs);
2732 if (!ret) {
2733 for (i = 0; i < orig_count; i++) {
2734 tmp1 = (u32) (long) karg.list[i].address;
2735 if (put_user(karg.list[i].idx, &ulist[i].idx) ||
2736 put_user(karg.list[i].total, &ulist[i].total) ||
2737 put_user(karg.list[i].used, &ulist[i].used) ||
2738 put_user(tmp1, &ulist[i].address)) {
2739 ret = -EFAULT;
2740 goto out;
2743 if (put_user(karg.count, &uarg->count))
2744 ret = -EFAULT;
2747 out:
2748 kfree(karg.list);
2749 return ret;
2752 typedef struct drm32_dma {
2753 /* Indices here refer to the offset into
2754 buflist in drm_buf_get_t. */
2755 int context; /* Context handle */
2756 int send_count; /* Number of buffers to send */
2757 u32 send_indices; /* List of handles to buffers (int *) */
2758 u32 send_sizes; /* Lengths of data to send (int *) */
2759 drm_dma_flags_t flags; /* Flags */
2760 int request_count; /* Number of buffers requested */
2761 int request_size; /* Desired size for buffers */
2762 u32 request_indices; /* Buffer information (int *) */
2763 u32 request_sizes; /* (int *) */
2764 int granted_count; /* Number of buffers granted */
2765 } drm32_dma_t;
2766 #define DRM32_IOCTL_DMA DRM_IOWR(0x29, drm32_dma_t)
2768 /* RED PEN The DRM layer blindly dereferences the send/request
2769 * indice/size arrays even though they are userland
2770 * pointers. -DaveM
2772 static int drm32_dma(unsigned int fd, unsigned int cmd, unsigned long arg)
2774 drm32_dma_t *uarg = (drm32_dma_t *) arg;
2775 int *u_si, *u_ss, *u_ri, *u_rs;
2776 drm_dma_t karg;
2777 mm_segment_t old_fs;
2778 int ret;
2779 u32 tmp1, tmp2, tmp3, tmp4;
2781 karg.send_indices = karg.send_sizes = NULL;
2782 karg.request_indices = karg.request_sizes = NULL;
2784 if (get_user(karg.context, &uarg->context) ||
2785 get_user(karg.send_count, &uarg->send_count) ||
2786 get_user(tmp1, &uarg->send_indices) ||
2787 get_user(tmp2, &uarg->send_sizes) ||
2788 get_user(karg.flags, &uarg->flags) ||
2789 get_user(karg.request_count, &uarg->request_count) ||
2790 get_user(karg.request_size, &uarg->request_size) ||
2791 get_user(tmp3, &uarg->request_indices) ||
2792 get_user(tmp4, &uarg->request_sizes) ||
2793 get_user(karg.granted_count, &uarg->granted_count))
2794 return -EFAULT;
2796 u_si = (int *) A(tmp1);
2797 u_ss = (int *) A(tmp2);
2798 u_ri = (int *) A(tmp3);
2799 u_rs = (int *) A(tmp4);
2801 if (karg.send_count) {
2802 karg.send_indices = kmalloc(karg.send_count * sizeof(int), GFP_KERNEL);
2803 karg.send_sizes = kmalloc(karg.send_count * sizeof(int), GFP_KERNEL);
2805 ret = -ENOMEM;
2806 if (!karg.send_indices || !karg.send_sizes)
2807 goto out;
2809 ret = -EFAULT;
2810 if (copy_from_user(karg.send_indices, u_si,
2811 (karg.send_count * sizeof(int))) ||
2812 copy_from_user(karg.send_sizes, u_ss,
2813 (karg.send_count * sizeof(int))))
2814 goto out;
2817 if (karg.request_count) {
2818 karg.request_indices = kmalloc(karg.request_count * sizeof(int), GFP_KERNEL);
2819 karg.request_sizes = kmalloc(karg.request_count * sizeof(int), GFP_KERNEL);
2821 ret = -ENOMEM;
2822 if (!karg.request_indices || !karg.request_sizes)
2823 goto out;
2825 ret = -EFAULT;
2826 if (copy_from_user(karg.request_indices, u_ri,
2827 (karg.request_count * sizeof(int))) ||
2828 copy_from_user(karg.request_sizes, u_rs,
2829 (karg.request_count * sizeof(int))))
2830 goto out;
2833 old_fs = get_fs();
2834 set_fs(KERNEL_DS);
2835 ret = sys_ioctl(fd, DRM_IOCTL_DMA, (unsigned long) &karg);
2836 set_fs(old_fs);
2838 if (!ret) {
2839 if (put_user(karg.context, &uarg->context) ||
2840 put_user(karg.send_count, &uarg->send_count) ||
2841 put_user(karg.flags, &uarg->flags) ||
2842 put_user(karg.request_count, &uarg->request_count) ||
2843 put_user(karg.request_size, &uarg->request_size) ||
2844 put_user(karg.granted_count, &uarg->granted_count))
2845 ret = -EFAULT;
2847 if (karg.send_count) {
2848 if (copy_to_user(u_si, karg.send_indices,
2849 (karg.send_count * sizeof(int))) ||
2850 copy_to_user(u_ss, karg.send_sizes,
2851 (karg.send_count * sizeof(int))))
2852 ret = -EFAULT;
2854 if (karg.request_count) {
2855 if (copy_to_user(u_ri, karg.request_indices,
2856 (karg.request_count * sizeof(int))) ||
2857 copy_to_user(u_rs, karg.request_sizes,
2858 (karg.request_count * sizeof(int))))
2859 ret = -EFAULT;
2863 out:
2864 if (karg.send_indices)
2865 kfree(karg.send_indices);
2866 if (karg.send_sizes)
2867 kfree(karg.send_sizes);
2868 if (karg.request_indices)
2869 kfree(karg.request_indices);
2870 if (karg.request_sizes)
2871 kfree(karg.request_sizes);
2873 return ret;
2876 typedef struct drm32_ctx_res {
2877 int count;
2878 u32 contexts; /* (drm_ctx_t *) */
2879 } drm32_ctx_res_t;
2880 #define DRM32_IOCTL_RES_CTX DRM_IOWR(0x26, drm32_ctx_res_t)
2882 static int drm32_res_ctx(unsigned int fd, unsigned int cmd, unsigned long arg)
2884 drm32_ctx_res_t *uarg = (drm32_ctx_res_t *) arg;
2885 drm_ctx_t *ulist;
2886 drm_ctx_res_t karg;
2887 mm_segment_t old_fs;
2888 int orig_count, ret;
2889 u32 tmp;
2891 karg.contexts = NULL;
2892 if (get_user(karg.count, &uarg->count) ||
2893 get_user(tmp, &uarg->contexts))
2894 return -EFAULT;
2896 ulist = (drm_ctx_t *) A(tmp);
2898 orig_count = karg.count;
2899 if (karg.count && ulist) {
2900 karg.contexts = kmalloc((karg.count * sizeof(drm_ctx_t)), GFP_KERNEL);
2901 if (!karg.contexts)
2902 return -ENOMEM;
2903 if (copy_from_user(karg.contexts, ulist,
2904 (karg.count * sizeof(drm_ctx_t)))) {
2905 kfree(karg.contexts);
2906 return -EFAULT;
2910 old_fs = get_fs();
2911 set_fs(KERNEL_DS);
2912 ret = sys_ioctl(fd, DRM_IOCTL_RES_CTX, (unsigned long) &karg);
2913 set_fs(old_fs);
2915 if (!ret) {
2916 if (orig_count) {
2917 if (copy_to_user(ulist, karg.contexts,
2918 (orig_count * sizeof(drm_ctx_t))))
2919 ret = -EFAULT;
2921 if (put_user(karg.count, &uarg->count))
2922 ret = -EFAULT;
2925 if (karg.contexts)
2926 kfree(karg.contexts);
2928 return ret;
2931 #endif
2933 static int ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
2935 return -EINVAL;
2938 static int broken_blkgetsize(unsigned int fd, unsigned int cmd, unsigned long arg)
2940 /* The mkswap binary hard codes it to Intel value :-((( */
2941 return w_long(fd, BLKGETSIZE, arg);
2944 struct blkpg_ioctl_arg32 {
2945 int op;
2946 int flags;
2947 int datalen;
2948 u32 data;
2951 static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, struct blkpg_ioctl_arg32 *arg)
2953 struct blkpg_ioctl_arg a;
2954 struct blkpg_partition p;
2955 int err;
2956 mm_segment_t old_fs = get_fs();
2958 err = get_user(a.op, &arg->op);
2959 err |= __get_user(a.flags, &arg->flags);
2960 err |= __get_user(a.datalen, &arg->datalen);
2961 err |= __get_user((long)a.data, &arg->data);
2962 if (err) return err;
2963 switch (a.op) {
2964 case BLKPG_ADD_PARTITION:
2965 case BLKPG_DEL_PARTITION:
2966 if (a.datalen < sizeof(struct blkpg_partition))
2967 return -EINVAL;
2968 if (copy_from_user(&p, a.data, sizeof(struct blkpg_partition)))
2969 return -EFAULT;
2970 a.data = &p;
2971 set_fs (KERNEL_DS);
2972 err = sys_ioctl(fd, cmd, (unsigned long)&a);
2973 set_fs (old_fs);
2974 default:
2975 return -EINVAL;
2977 return err;
2980 static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
2982 return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
2985 struct ioctl_trans {
2986 unsigned int cmd;
2987 unsigned int handler;
2988 unsigned int next;
2991 #define COMPATIBLE_IOCTL(cmd) asm volatile(".word %0, sys_ioctl, 0" : : "i" (cmd));
2992 #define HANDLE_IOCTL(cmd,handler) asm volatile(".word %0, %1, 0" : : "i" (cmd), "i" (handler));
2993 #define IOCTL_TABLE_START void ioctl32_foo(void) { asm volatile(".data\nioctl_translations:");
2994 #define IOCTL_TABLE_END asm volatile("\nioctl_translations_end:\n\t.previous"); }
2996 IOCTL_TABLE_START
2997 /* List here exlicitly which ioctl's are known to have
2998 * compatable types passed or none at all...
3000 /* Big T */
3001 COMPATIBLE_IOCTL(TCGETA)
3002 COMPATIBLE_IOCTL(TCSETA)
3003 COMPATIBLE_IOCTL(TCSETAW)
3004 COMPATIBLE_IOCTL(TCSETAF)
3005 COMPATIBLE_IOCTL(TCSBRK)
3006 COMPATIBLE_IOCTL(TCXONC)
3007 COMPATIBLE_IOCTL(TCFLSH)
3008 COMPATIBLE_IOCTL(TCGETS)
3009 COMPATIBLE_IOCTL(TCSETS)
3010 COMPATIBLE_IOCTL(TCSETSW)
3011 COMPATIBLE_IOCTL(TCSETSF)
3012 COMPATIBLE_IOCTL(TIOCLINUX)
3013 /* Little t */
3014 COMPATIBLE_IOCTL(TIOCGETD)
3015 COMPATIBLE_IOCTL(TIOCSETD)
3016 COMPATIBLE_IOCTL(TIOCEXCL)
3017 COMPATIBLE_IOCTL(TIOCNXCL)
3018 COMPATIBLE_IOCTL(TIOCCONS)
3019 COMPATIBLE_IOCTL(TIOCGSOFTCAR)
3020 COMPATIBLE_IOCTL(TIOCSSOFTCAR)
3021 COMPATIBLE_IOCTL(TIOCSWINSZ)
3022 COMPATIBLE_IOCTL(TIOCGWINSZ)
3023 COMPATIBLE_IOCTL(TIOCMGET)
3024 COMPATIBLE_IOCTL(TIOCMBIC)
3025 COMPATIBLE_IOCTL(TIOCMBIS)
3026 COMPATIBLE_IOCTL(TIOCMSET)
3027 COMPATIBLE_IOCTL(TIOCPKT)
3028 COMPATIBLE_IOCTL(TIOCNOTTY)
3029 COMPATIBLE_IOCTL(TIOCSTI)
3030 COMPATIBLE_IOCTL(TIOCOUTQ)
3031 COMPATIBLE_IOCTL(TIOCSPGRP)
3032 COMPATIBLE_IOCTL(TIOCGPGRP)
3033 COMPATIBLE_IOCTL(TIOCSCTTY)
3034 COMPATIBLE_IOCTL(TIOCGPTN)
3035 COMPATIBLE_IOCTL(TIOCSPTLCK)
3036 COMPATIBLE_IOCTL(TIOCGSERIAL)
3037 COMPATIBLE_IOCTL(TIOCSSERIAL)
3038 COMPATIBLE_IOCTL(TIOCSERGETLSR)
3039 /* Big F */
3040 COMPATIBLE_IOCTL(FBIOGTYPE)
3041 COMPATIBLE_IOCTL(FBIOSATTR)
3042 COMPATIBLE_IOCTL(FBIOGATTR)
3043 COMPATIBLE_IOCTL(FBIOSVIDEO)
3044 COMPATIBLE_IOCTL(FBIOGVIDEO)
3045 COMPATIBLE_IOCTL(FBIOGCURSOR32) /* This is not implemented yet. Later it should be converted... */
3046 COMPATIBLE_IOCTL(FBIOSCURPOS)
3047 COMPATIBLE_IOCTL(FBIOGCURPOS)
3048 COMPATIBLE_IOCTL(FBIOGCURMAX)
3049 COMPATIBLE_IOCTL(FBIOGET_VSCREENINFO)
3050 COMPATIBLE_IOCTL(FBIOPUT_VSCREENINFO)
3051 COMPATIBLE_IOCTL(FBIOPAN_DISPLAY)
3052 COMPATIBLE_IOCTL(FBIOGET_FCURSORINFO)
3053 COMPATIBLE_IOCTL(FBIOGET_VCURSORINFO)
3054 COMPATIBLE_IOCTL(FBIOPUT_VCURSORINFO)
3055 COMPATIBLE_IOCTL(FBIOGET_CURSORSTATE)
3056 COMPATIBLE_IOCTL(FBIOPUT_CURSORSTATE)
3057 COMPATIBLE_IOCTL(FBIOGET_CON2FBMAP)
3058 COMPATIBLE_IOCTL(FBIOPUT_CON2FBMAP)
3059 /* Little f */
3060 COMPATIBLE_IOCTL(FIOCLEX)
3061 COMPATIBLE_IOCTL(FIONCLEX)
3062 COMPATIBLE_IOCTL(FIOASYNC)
3063 COMPATIBLE_IOCTL(FIONBIO)
3064 COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */
3065 /* 0x00 */
3066 COMPATIBLE_IOCTL(FIBMAP)
3067 COMPATIBLE_IOCTL(FIGETBSZ)
3068 /* 0x03 -- HD/IDE ioctl's used by hdparm and friends.
3069 * Some need translations, these do not.
3071 COMPATIBLE_IOCTL(HDIO_GET_IDENTITY)
3072 COMPATIBLE_IOCTL(HDIO_SET_DMA)
3073 COMPATIBLE_IOCTL(HDIO_SET_KEEPSETTINGS)
3074 COMPATIBLE_IOCTL(HDIO_SET_UNMASKINTR)
3075 COMPATIBLE_IOCTL(HDIO_SET_NOWERR)
3076 COMPATIBLE_IOCTL(HDIO_SET_32BIT)
3077 COMPATIBLE_IOCTL(HDIO_SET_MULTCOUNT)
3078 COMPATIBLE_IOCTL(HDIO_DRIVE_CMD)
3079 COMPATIBLE_IOCTL(HDIO_SET_PIO_MODE)
3080 COMPATIBLE_IOCTL(HDIO_SCAN_HWIF)
3081 COMPATIBLE_IOCTL(HDIO_SET_NICE)
3082 /* 0x02 -- Floppy ioctls */
3083 COMPATIBLE_IOCTL(FDMSGON)
3084 COMPATIBLE_IOCTL(FDMSGOFF)
3085 COMPATIBLE_IOCTL(FDSETEMSGTRESH)
3086 COMPATIBLE_IOCTL(FDFLUSH)
3087 COMPATIBLE_IOCTL(FDWERRORCLR)
3088 COMPATIBLE_IOCTL(FDSETMAXERRS)
3089 COMPATIBLE_IOCTL(FDGETMAXERRS)
3090 COMPATIBLE_IOCTL(FDGETDRVTYP)
3091 COMPATIBLE_IOCTL(FDEJECT)
3092 COMPATIBLE_IOCTL(FDCLRPRM)
3093 COMPATIBLE_IOCTL(FDFMTBEG)
3094 COMPATIBLE_IOCTL(FDFMTEND)
3095 COMPATIBLE_IOCTL(FDRESET)
3096 COMPATIBLE_IOCTL(FDTWADDLE)
3097 COMPATIBLE_IOCTL(FDFMTTRK)
3098 COMPATIBLE_IOCTL(FDRAWCMD)
3099 /* 0x12 */
3100 COMPATIBLE_IOCTL(BLKROSET)
3101 COMPATIBLE_IOCTL(BLKROGET)
3102 COMPATIBLE_IOCTL(BLKRRPART)
3103 COMPATIBLE_IOCTL(BLKFLSBUF)
3104 COMPATIBLE_IOCTL(BLKRASET)
3105 COMPATIBLE_IOCTL(BLKFRASET)
3106 COMPATIBLE_IOCTL(BLKSECTSET)
3107 COMPATIBLE_IOCTL(BLKSSZGET)
3109 /* RAID */
3110 COMPATIBLE_IOCTL(RAID_VERSION)
3111 COMPATIBLE_IOCTL(GET_ARRAY_INFO)
3112 COMPATIBLE_IOCTL(GET_DISK_INFO)
3113 COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
3114 COMPATIBLE_IOCTL(CLEAR_ARRAY)
3115 COMPATIBLE_IOCTL(ADD_NEW_DISK)
3116 COMPATIBLE_IOCTL(HOT_REMOVE_DISK)
3117 COMPATIBLE_IOCTL(SET_ARRAY_INFO)
3118 COMPATIBLE_IOCTL(SET_DISK_INFO)
3119 COMPATIBLE_IOCTL(WRITE_RAID_INFO)
3120 COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
3121 COMPATIBLE_IOCTL(PROTECT_ARRAY)
3122 COMPATIBLE_IOCTL(HOT_ADD_DISK)
3123 COMPATIBLE_IOCTL(SET_DISK_FAULTY)
3124 COMPATIBLE_IOCTL(RUN_ARRAY)
3125 COMPATIBLE_IOCTL(START_ARRAY)
3126 COMPATIBLE_IOCTL(STOP_ARRAY)
3127 COMPATIBLE_IOCTL(STOP_ARRAY_RO)
3128 COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
3130 /* Big K */
3131 COMPATIBLE_IOCTL(PIO_FONT)
3132 COMPATIBLE_IOCTL(GIO_FONT)
3133 COMPATIBLE_IOCTL(KDSIGACCEPT)
3134 COMPATIBLE_IOCTL(KDGETKEYCODE)
3135 COMPATIBLE_IOCTL(KDSETKEYCODE)
3136 COMPATIBLE_IOCTL(KIOCSOUND)
3137 COMPATIBLE_IOCTL(KDMKTONE)
3138 COMPATIBLE_IOCTL(KDGKBTYPE)
3139 COMPATIBLE_IOCTL(KDSETMODE)
3140 COMPATIBLE_IOCTL(KDGETMODE)
3141 COMPATIBLE_IOCTL(KDSKBMODE)
3142 COMPATIBLE_IOCTL(KDGKBMODE)
3143 COMPATIBLE_IOCTL(KDSKBMETA)
3144 COMPATIBLE_IOCTL(KDGKBMETA)
3145 COMPATIBLE_IOCTL(KDGKBENT)
3146 COMPATIBLE_IOCTL(KDSKBENT)
3147 COMPATIBLE_IOCTL(KDGKBSENT)
3148 COMPATIBLE_IOCTL(KDSKBSENT)
3149 COMPATIBLE_IOCTL(KDGKBDIACR)
3150 COMPATIBLE_IOCTL(KDSKBDIACR)
3151 COMPATIBLE_IOCTL(KDGKBLED)
3152 COMPATIBLE_IOCTL(KDSKBLED)
3153 COMPATIBLE_IOCTL(KDGETLED)
3154 COMPATIBLE_IOCTL(KDSETLED)
3155 COMPATIBLE_IOCTL(GIO_SCRNMAP)
3156 COMPATIBLE_IOCTL(PIO_SCRNMAP)
3157 COMPATIBLE_IOCTL(GIO_UNISCRNMAP)
3158 COMPATIBLE_IOCTL(PIO_UNISCRNMAP)
3159 COMPATIBLE_IOCTL(PIO_FONTRESET)
3160 COMPATIBLE_IOCTL(PIO_UNIMAPCLR)
3161 /* Little k */
3162 COMPATIBLE_IOCTL(KIOCTYPE)
3163 COMPATIBLE_IOCTL(KIOCLAYOUT)
3164 COMPATIBLE_IOCTL(KIOCGTRANS)
3165 COMPATIBLE_IOCTL(KIOCTRANS)
3166 COMPATIBLE_IOCTL(KIOCCMD)
3167 COMPATIBLE_IOCTL(KIOCSDIRECT)
3168 COMPATIBLE_IOCTL(KIOCSLED)
3169 COMPATIBLE_IOCTL(KIOCGLED)
3170 COMPATIBLE_IOCTL(KIOCSRATE)
3171 COMPATIBLE_IOCTL(KIOCGRATE)
3172 /* Big S */
3173 COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
3174 COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
3175 COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
3176 COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
3177 COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_ENABLE)
3178 COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_DISABLE)
3179 COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
3180 COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
3181 /* Big V */
3182 COMPATIBLE_IOCTL(VT_SETMODE)
3183 COMPATIBLE_IOCTL(VT_GETMODE)
3184 COMPATIBLE_IOCTL(VT_GETSTATE)
3185 COMPATIBLE_IOCTL(VT_OPENQRY)
3186 COMPATIBLE_IOCTL(VT_ACTIVATE)
3187 COMPATIBLE_IOCTL(VT_WAITACTIVE)
3188 COMPATIBLE_IOCTL(VT_RELDISP)
3189 COMPATIBLE_IOCTL(VT_DISALLOCATE)
3190 COMPATIBLE_IOCTL(VT_RESIZE)
3191 COMPATIBLE_IOCTL(VT_RESIZEX)
3192 COMPATIBLE_IOCTL(VT_LOCKSWITCH)
3193 COMPATIBLE_IOCTL(VT_UNLOCKSWITCH)
3194 /* Little v */
3195 COMPATIBLE_IOCTL(VUIDSFORMAT)
3196 COMPATIBLE_IOCTL(VUIDGFORMAT)
3197 /* Little v, the video4linux ioctls */
3198 COMPATIBLE_IOCTL(VIDIOCGCAP)
3199 COMPATIBLE_IOCTL(VIDIOCGCHAN)
3200 COMPATIBLE_IOCTL(VIDIOCSCHAN)
3201 COMPATIBLE_IOCTL(VIDIOCGPICT)
3202 COMPATIBLE_IOCTL(VIDIOCSPICT)
3203 COMPATIBLE_IOCTL(VIDIOCCAPTURE)
3204 COMPATIBLE_IOCTL(VIDIOCKEY)
3205 COMPATIBLE_IOCTL(VIDIOCGAUDIO)
3206 COMPATIBLE_IOCTL(VIDIOCSAUDIO)
3207 COMPATIBLE_IOCTL(VIDIOCSYNC)
3208 COMPATIBLE_IOCTL(VIDIOCMCAPTURE)
3209 COMPATIBLE_IOCTL(VIDIOCGMBUF)
3210 COMPATIBLE_IOCTL(VIDIOCGUNIT)
3211 COMPATIBLE_IOCTL(VIDIOCGCAPTURE)
3212 COMPATIBLE_IOCTL(VIDIOCSCAPTURE)
3213 /* BTTV specific... */
3214 COMPATIBLE_IOCTL(_IOW('v', BASE_VIDIOCPRIVATE+0, char [256]))
3215 COMPATIBLE_IOCTL(_IOR('v', BASE_VIDIOCPRIVATE+1, char [256]))
3216 COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int))
3217 COMPATIBLE_IOCTL(_IOW('v' , BASE_VIDIOCPRIVATE+3, char [16])) /* struct bttv_pll_info */
3218 COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+4, int))
3219 COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+5, int))
3220 COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+6, int))
3221 COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+7, int))
3222 /* Little p (/dev/rtc, /dev/envctrl, etc.) */
3223 COMPATIBLE_IOCTL(RTCGET)
3224 COMPATIBLE_IOCTL(RTCSET)
3225 COMPATIBLE_IOCTL(ENVCTRL_RD_WARNING_TEMPERATURE)
3226 COMPATIBLE_IOCTL(ENVCTRL_RD_SHUTDOWN_TEMPERATURE)
3227 COMPATIBLE_IOCTL(ENVCTRL_RD_CPU_TEMPERATURE)
3228 COMPATIBLE_IOCTL(ENVCTRL_RD_FAN_STATUS)
3229 COMPATIBLE_IOCTL(ENVCTRL_RD_VOLTAGE_STATUS)
3230 COMPATIBLE_IOCTL(ENVCTRL_RD_SCSI_TEMPERATURE)
3231 COMPATIBLE_IOCTL(ENVCTRL_RD_ETHERNET_TEMPERATURE)
3232 COMPATIBLE_IOCTL(ENVCTRL_RD_MTHRBD_TEMPERATURE)
3233 COMPATIBLE_IOCTL(ENVCTRL_RD_CPU_VOLTAGE)
3234 COMPATIBLE_IOCTL(ENVCTRL_RD_GLOBALADDRESS)
3235 /* COMPATIBLE_IOCTL(D7SIOCRD) same value as ENVCTRL_RD_VOLTAGE_STATUS */
3236 COMPATIBLE_IOCTL(D7SIOCWR)
3237 COMPATIBLE_IOCTL(D7SIOCTM)
3238 /* Little m */
3239 COMPATIBLE_IOCTL(MTIOCTOP)
3240 /* OPENPROMIO, SunOS/Solaris only, the NetBSD one's have
3241 * embedded pointers in the arg which we'd need to clean up...
3243 COMPATIBLE_IOCTL(OPROMGETOPT)
3244 COMPATIBLE_IOCTL(OPROMSETOPT)
3245 COMPATIBLE_IOCTL(OPROMNXTOPT)
3246 COMPATIBLE_IOCTL(OPROMSETOPT2)
3247 COMPATIBLE_IOCTL(OPROMNEXT)
3248 COMPATIBLE_IOCTL(OPROMCHILD)
3249 COMPATIBLE_IOCTL(OPROMGETPROP)
3250 COMPATIBLE_IOCTL(OPROMNXTPROP)
3251 COMPATIBLE_IOCTL(OPROMU2P)
3252 COMPATIBLE_IOCTL(OPROMGETCONS)
3253 COMPATIBLE_IOCTL(OPROMGETFBNAME)
3254 COMPATIBLE_IOCTL(OPROMGETBOOTARGS)
3255 COMPATIBLE_IOCTL(OPROMSETCUR)
3256 COMPATIBLE_IOCTL(OPROMPCI2NODE)
3257 COMPATIBLE_IOCTL(OPROMPATH2NODE)
3258 /* Socket level stuff */
3259 COMPATIBLE_IOCTL(FIOSETOWN)
3260 COMPATIBLE_IOCTL(SIOCSPGRP)
3261 COMPATIBLE_IOCTL(FIOGETOWN)
3262 COMPATIBLE_IOCTL(SIOCGPGRP)
3263 COMPATIBLE_IOCTL(SIOCATMARK)
3264 COMPATIBLE_IOCTL(SIOCSIFLINK)
3265 COMPATIBLE_IOCTL(SIOCSIFENCAP)
3266 COMPATIBLE_IOCTL(SIOCGIFENCAP)
3267 COMPATIBLE_IOCTL(SIOCSIFBR)
3268 COMPATIBLE_IOCTL(SIOCGIFBR)
3269 COMPATIBLE_IOCTL(SIOCSARP)
3270 COMPATIBLE_IOCTL(SIOCGARP)
3271 COMPATIBLE_IOCTL(SIOCDARP)
3272 #if 0 /* XXX No longer exist in new routing code. XXX */
3273 COMPATIBLE_IOCTL(OLD_SIOCSARP)
3274 COMPATIBLE_IOCTL(OLD_SIOCGARP)
3275 COMPATIBLE_IOCTL(OLD_SIOCDARP)
3276 #endif
3277 COMPATIBLE_IOCTL(SIOCSRARP)
3278 COMPATIBLE_IOCTL(SIOCGRARP)
3279 COMPATIBLE_IOCTL(SIOCDRARP)
3280 COMPATIBLE_IOCTL(SIOCADDDLCI)
3281 COMPATIBLE_IOCTL(SIOCDELDLCI)
3282 /* SG stuff */
3283 COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
3284 COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
3285 COMPATIBLE_IOCTL(SG_EMULATED_HOST)
3286 COMPATIBLE_IOCTL(SG_SET_TRANSFORM)
3287 COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
3288 COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
3289 COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
3290 COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
3291 COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
3292 COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
3293 COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
3294 COMPATIBLE_IOCTL(SG_GET_PACK_ID)
3295 COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
3296 COMPATIBLE_IOCTL(SG_SET_DEBUG)
3297 COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
3298 COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
3299 COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
3300 COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
3301 COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
3302 COMPATIBLE_IOCTL(SG_SCSI_RESET)
3303 COMPATIBLE_IOCTL(SG_IO)
3304 COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
3305 COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
3306 COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
3307 /* PPP stuff */
3308 COMPATIBLE_IOCTL(PPPIOCGFLAGS)
3309 COMPATIBLE_IOCTL(PPPIOCSFLAGS)
3310 COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
3311 COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
3312 COMPATIBLE_IOCTL(PPPIOCGUNIT)
3313 COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
3314 COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
3315 COMPATIBLE_IOCTL(PPPIOCGMRU)
3316 COMPATIBLE_IOCTL(PPPIOCSMRU)
3317 COMPATIBLE_IOCTL(PPPIOCSMAXCID)
3318 COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
3319 COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
3320 COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
3321 COMPATIBLE_IOCTL(PPPIOCGNPMODE)
3322 COMPATIBLE_IOCTL(PPPIOCSNPMODE)
3323 COMPATIBLE_IOCTL(PPPIOCGDEBUG)
3324 COMPATIBLE_IOCTL(PPPIOCSDEBUG)
3325 COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
3326 COMPATIBLE_IOCTL(PPPIOCATTACH)
3327 COMPATIBLE_IOCTL(PPPIOCDETACH)
3328 COMPATIBLE_IOCTL(PPPIOCSMRRU)
3329 COMPATIBLE_IOCTL(PPPIOCCONNECT)
3330 COMPATIBLE_IOCTL(PPPIOCDISCONN)
3331 COMPATIBLE_IOCTL(PPPIOCATTCHAN)
3332 /* PPPOX */
3333 COMPATIBLE_IOCTL(PPPOEIOCSFWD);
3334 COMPATIBLE_IOCTL(PPPOEIOCDFWD);
3335 /* CDROM stuff */
3336 COMPATIBLE_IOCTL(CDROMPAUSE)
3337 COMPATIBLE_IOCTL(CDROMRESUME)
3338 COMPATIBLE_IOCTL(CDROMPLAYMSF)
3339 COMPATIBLE_IOCTL(CDROMPLAYTRKIND)
3340 COMPATIBLE_IOCTL(CDROMREADTOCHDR)
3341 COMPATIBLE_IOCTL(CDROMREADTOCENTRY)
3342 COMPATIBLE_IOCTL(CDROMSTOP)
3343 COMPATIBLE_IOCTL(CDROMSTART)
3344 COMPATIBLE_IOCTL(CDROMEJECT)
3345 COMPATIBLE_IOCTL(CDROMVOLCTRL)
3346 COMPATIBLE_IOCTL(CDROMSUBCHNL)
3347 COMPATIBLE_IOCTL(CDROMEJECT_SW)
3348 COMPATIBLE_IOCTL(CDROMMULTISESSION)
3349 COMPATIBLE_IOCTL(CDROM_GET_MCN)
3350 COMPATIBLE_IOCTL(CDROMRESET)
3351 COMPATIBLE_IOCTL(CDROMVOLREAD)
3352 COMPATIBLE_IOCTL(CDROMSEEK)
3353 COMPATIBLE_IOCTL(CDROMPLAYBLK)
3354 COMPATIBLE_IOCTL(CDROMCLOSETRAY)
3355 COMPATIBLE_IOCTL(CDROM_SET_OPTIONS)
3356 COMPATIBLE_IOCTL(CDROM_CLEAR_OPTIONS)
3357 COMPATIBLE_IOCTL(CDROM_SELECT_SPEED)
3358 COMPATIBLE_IOCTL(CDROM_SELECT_DISC)
3359 COMPATIBLE_IOCTL(CDROM_MEDIA_CHANGED)
3360 COMPATIBLE_IOCTL(CDROM_DRIVE_STATUS)
3361 COMPATIBLE_IOCTL(CDROM_DISC_STATUS)
3362 COMPATIBLE_IOCTL(CDROM_CHANGER_NSLOTS)
3363 COMPATIBLE_IOCTL(CDROM_LOCKDOOR)
3364 COMPATIBLE_IOCTL(CDROM_DEBUG)
3365 COMPATIBLE_IOCTL(CDROM_GET_CAPABILITY)
3366 /* Big L */
3367 COMPATIBLE_IOCTL(LOOP_SET_FD)
3368 COMPATIBLE_IOCTL(LOOP_CLR_FD)
3369 /* Big A */
3370 COMPATIBLE_IOCTL(AUDIO_GETINFO)
3371 COMPATIBLE_IOCTL(AUDIO_SETINFO)
3372 COMPATIBLE_IOCTL(AUDIO_DRAIN)
3373 COMPATIBLE_IOCTL(AUDIO_GETDEV)
3374 COMPATIBLE_IOCTL(AUDIO_GETDEV_SUNOS)
3375 COMPATIBLE_IOCTL(AUDIO_FLUSH)
3376 /* Big Q for sound/OSS */
3377 COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
3378 COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
3379 COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
3380 COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
3381 COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
3382 COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
3383 COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
3384 COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
3385 COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
3386 COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
3387 COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
3388 COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
3389 COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
3390 COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
3391 COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
3392 COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
3393 COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
3394 COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
3395 COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
3396 COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
3397 COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
3398 COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
3399 /* Big T for sound/OSS */
3400 COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
3401 COMPATIBLE_IOCTL(SNDCTL_TMR_START)
3402 COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
3403 COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
3404 COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
3405 COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
3406 COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
3407 COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
3408 /* Little m for sound/OSS */
3409 COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
3410 COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
3411 COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
3412 /* Big P for sound/OSS */
3413 COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
3414 COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
3415 COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
3416 COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
3417 COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
3418 COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
3419 COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
3420 COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
3421 COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
3422 COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
3423 COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
3424 COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
3425 COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
3426 COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
3427 COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
3428 COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
3429 COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
3430 COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
3431 COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
3432 COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
3433 /* SNDCTL_DSP_MAPINBUF, XXX needs translation */
3434 /* SNDCTL_DSP_MAPOUTBUF, XXX needs translation */
3435 COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
3436 COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
3437 COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
3438 COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
3439 COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
3440 COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
3441 COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
3442 COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
3443 /* Big C for sound/OSS */
3444 COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
3445 COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
3446 COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
3447 COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
3448 COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
3449 COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
3450 COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
3451 COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
3452 COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
3453 COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
3454 /* Big M for sound/OSS */
3455 COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
3456 COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
3457 COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
3458 COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
3459 COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
3460 COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
3461 COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
3462 COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
3463 COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
3464 COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
3465 COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
3466 COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
3467 COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
3468 COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
3469 COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
3470 COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
3471 COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
3472 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
3473 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
3474 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
3475 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
3476 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
3477 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
3478 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
3479 COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
3480 COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
3481 /* SOUND_MIXER_READ_ENHANCE, same value as READ_MUTE */
3482 /* SOUND_MIXER_READ_LOUD, same value as READ_MUTE */
3483 COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
3484 COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
3485 COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
3486 COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
3487 COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
3488 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
3489 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
3490 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
3491 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
3492 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
3493 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
3494 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
3495 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
3496 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
3497 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
3498 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
3499 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
3500 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
3501 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
3502 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
3503 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
3504 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
3505 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
3506 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
3507 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
3508 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
3509 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
3510 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
3511 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
3512 COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
3513 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
3514 /* SOUND_MIXER_WRITE_ENHANCE, same value as WRITE_MUTE */
3515 /* SOUND_MIXER_WRITE_LOUD, same value as WRITE_MUTE */
3516 COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
3517 COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
3518 COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
3519 COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
3520 COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
3521 COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
3522 COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
3523 COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
3524 COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
3525 COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
3526 COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
3527 COMPATIBLE_IOCTL(OSS_GETVERSION)
3528 /* AUTOFS */
3529 COMPATIBLE_IOCTL(AUTOFS_IOC_READY)
3530 COMPATIBLE_IOCTL(AUTOFS_IOC_FAIL)
3531 COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
3532 COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
3533 COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
3534 /* DEVFS */
3535 COMPATIBLE_IOCTL(DEVFSDIOC_GET_PROTO_REV)
3536 COMPATIBLE_IOCTL(DEVFSDIOC_SET_EVENT_MASK)
3537 COMPATIBLE_IOCTL(DEVFSDIOC_RELEASE_EVENT_QUEUE)
3538 COMPATIBLE_IOCTL(DEVFSDIOC_SET_DEBUG_MASK)
3539 /* Raw devices */
3540 COMPATIBLE_IOCTL(RAW_SETBIND)
3541 COMPATIBLE_IOCTL(RAW_GETBIND)
3542 /* SMB ioctls which do not need any translations */
3543 COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
3544 /* Little a */
3545 COMPATIBLE_IOCTL(ATMSIGD_CTRL)
3546 COMPATIBLE_IOCTL(ATMARPD_CTRL)
3547 COMPATIBLE_IOCTL(ATMLEC_CTRL)
3548 COMPATIBLE_IOCTL(ATMLEC_MCAST)
3549 COMPATIBLE_IOCTL(ATMLEC_DATA)
3550 COMPATIBLE_IOCTL(ATM_SETSC)
3551 COMPATIBLE_IOCTL(SIOCSIFATMTCP)
3552 COMPATIBLE_IOCTL(SIOCMKCLIP)
3553 COMPATIBLE_IOCTL(ATMARP_MKIP)
3554 COMPATIBLE_IOCTL(ATMARP_SETENTRY)
3555 COMPATIBLE_IOCTL(ATMARP_ENCAP)
3556 COMPATIBLE_IOCTL(ATMTCP_CREATE)
3557 COMPATIBLE_IOCTL(ATMTCP_REMOVE)
3558 COMPATIBLE_IOCTL(ATMMPC_CTRL)
3559 COMPATIBLE_IOCTL(ATMMPC_DATA)
3560 #if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
3561 /* 0xfe - lvm */
3562 COMPATIBLE_IOCTL(VG_SET_EXTENDABLE)
3563 COMPATIBLE_IOCTL(VG_STATUS_GET_COUNT)
3564 COMPATIBLE_IOCTL(VG_STATUS_GET_NAMELIST)
3565 COMPATIBLE_IOCTL(VG_REMOVE)
3566 COMPATIBLE_IOCTL(VG_REDUCE)
3567 COMPATIBLE_IOCTL(PE_LOCK_UNLOCK)
3568 COMPATIBLE_IOCTL(PV_FLUSH)
3569 COMPATIBLE_IOCTL(LVM_LOCK_LVM)
3570 COMPATIBLE_IOCTL(LVM_GET_IOP_VERSION)
3571 #ifdef LVM_TOTAL_RESET
3572 COMPATIBLE_IOCTL(LVM_RESET)
3573 #endif
3574 COMPATIBLE_IOCTL(LV_SET_ACCESS)
3575 COMPATIBLE_IOCTL(LV_SET_STATUS)
3576 COMPATIBLE_IOCTL(LV_SET_ALLOCATION)
3577 #endif /* LVM */
3578 #if defined(CONFIG_DRM) || defined(CONFIG_DRM_MODULE)
3579 COMPATIBLE_IOCTL(DRM_IOCTL_GET_MAGIC)
3580 COMPATIBLE_IOCTL(DRM_IOCTL_IRQ_BUSID)
3581 COMPATIBLE_IOCTL(DRM_IOCTL_AUTH_MAGIC)
3582 COMPATIBLE_IOCTL(DRM_IOCTL_BLOCK)
3583 COMPATIBLE_IOCTL(DRM_IOCTL_UNBLOCK)
3584 COMPATIBLE_IOCTL(DRM_IOCTL_CONTROL)
3585 COMPATIBLE_IOCTL(DRM_IOCTL_ADD_BUFS)
3586 COMPATIBLE_IOCTL(DRM_IOCTL_MARK_BUFS)
3587 COMPATIBLE_IOCTL(DRM_IOCTL_ADD_CTX)
3588 COMPATIBLE_IOCTL(DRM_IOCTL_RM_CTX)
3589 COMPATIBLE_IOCTL(DRM_IOCTL_MOD_CTX)
3590 COMPATIBLE_IOCTL(DRM_IOCTL_GET_CTX)
3591 COMPATIBLE_IOCTL(DRM_IOCTL_SWITCH_CTX)
3592 COMPATIBLE_IOCTL(DRM_IOCTL_NEW_CTX)
3593 COMPATIBLE_IOCTL(DRM_IOCTL_ADD_DRAW)
3594 COMPATIBLE_IOCTL(DRM_IOCTL_RM_DRAW)
3595 COMPATIBLE_IOCTL(DRM_IOCTL_LOCK)
3596 COMPATIBLE_IOCTL(DRM_IOCTL_UNLOCK)
3597 COMPATIBLE_IOCTL(DRM_IOCTL_FINISH)
3598 #endif /* DRM */
3599 /* elevator */
3600 COMPATIBLE_IOCTL(BLKELVGET)
3601 COMPATIBLE_IOCTL(BLKELVSET)
3602 /* And these ioctls need translation */
3603 HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
3604 HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)
3605 HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc)
3606 HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc)
3607 HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc)
3608 HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc)
3609 HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc)
3610 HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc)
3611 HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc)
3612 HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc)
3613 HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc)
3614 HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc)
3615 HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc)
3616 HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc)
3617 HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc)
3618 HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc)
3619 HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
3620 HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
3621 HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
3622 HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc)
3623 HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc)
3624 HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc)
3625 HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc)
3626 HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc)
3627 HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc)
3628 HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc)
3629 HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc)
3630 HANDLE_IOCTL(SIOCGPPPSTATS, dev_ifsioc)
3631 HANDLE_IOCTL(SIOCGPPPCSTATS, dev_ifsioc)
3632 HANDLE_IOCTL(SIOCGPPPVER, dev_ifsioc)
3633 HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc)
3634 HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc)
3635 HANDLE_IOCTL(SIOCETHTOOL, dev_ifsioc)
3636 HANDLE_IOCTL(SIOCADDRT, routing_ioctl)
3637 HANDLE_IOCTL(SIOCDELRT, routing_ioctl)
3638 /* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
3639 HANDLE_IOCTL(SIOCRTMSG, ret_einval)
3640 HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
3641 HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo)
3642 HANDLE_IOCTL(BLKRAGET, w_long)
3643 HANDLE_IOCTL(BLKGETSIZE, w_long)
3644 HANDLE_IOCTL(0x1260, broken_blkgetsize)
3645 HANDLE_IOCTL(BLKFRAGET, w_long)
3646 HANDLE_IOCTL(BLKSECTGET, w_long)
3647 HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
3648 HANDLE_IOCTL(FBIOPUTCMAP32, fbiogetputcmap)
3649 HANDLE_IOCTL(FBIOGETCMAP32, fbiogetputcmap)
3650 HANDLE_IOCTL(FBIOSCURSOR32, fbiogscursor)
3651 HANDLE_IOCTL(FBIOGET_FSCREENINFO, fb_ioctl_trans)
3652 HANDLE_IOCTL(FBIOGETCMAP, fb_ioctl_trans)
3653 HANDLE_IOCTL(FBIOPUTCMAP, fb_ioctl_trans)
3654 HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans)
3655 HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans)
3656 HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans)
3657 HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans)
3658 HANDLE_IOCTL(HDIO_GET_MULTCOUNT, hdio_ioctl_trans)
3659 HANDLE_IOCTL(HDIO_GET_NOWERR, hdio_ioctl_trans)
3660 HANDLE_IOCTL(HDIO_GET_NICE, hdio_ioctl_trans)
3661 HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans)
3662 HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans)
3663 HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans)
3664 HANDLE_IOCTL(FDSETDRVPRM32, fd_ioctl_trans)
3665 HANDLE_IOCTL(FDGETDRVPRM32, fd_ioctl_trans)
3666 HANDLE_IOCTL(FDGETDRVSTAT32, fd_ioctl_trans)
3667 HANDLE_IOCTL(FDPOLLDRVSTAT32, fd_ioctl_trans)
3668 HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans)
3669 HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans)
3670 HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans)
3671 HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans)
3672 HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans)
3673 HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans)
3674 HANDLE_IOCTL(MTIOCGETCONFIG32, mt_ioctl_trans)
3675 HANDLE_IOCTL(MTIOCSETCONFIG32, mt_ioctl_trans)
3676 HANDLE_IOCTL(CDROMREADMODE2, cdrom_ioctl_trans)
3677 HANDLE_IOCTL(CDROMREADMODE1, cdrom_ioctl_trans)
3678 HANDLE_IOCTL(CDROMREADRAW, cdrom_ioctl_trans)
3679 HANDLE_IOCTL(CDROMREADCOOKED, cdrom_ioctl_trans)
3680 HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans)
3681 HANDLE_IOCTL(CDROMREADALL, cdrom_ioctl_trans)
3682 HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans)
3683 HANDLE_IOCTL(LOOP_SET_STATUS, loop_status)
3684 HANDLE_IOCTL(LOOP_GET_STATUS, loop_status)
3685 #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
3686 HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout)
3687 HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl)
3688 HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl)
3689 HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl)
3690 HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl)
3691 HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl)
3692 HANDLE_IOCTL(EXT2_IOC32_GETFLAGS, do_ext2_ioctl)
3693 HANDLE_IOCTL(EXT2_IOC32_SETFLAGS, do_ext2_ioctl)
3694 HANDLE_IOCTL(EXT2_IOC32_GETVERSION, do_ext2_ioctl)
3695 HANDLE_IOCTL(EXT2_IOC32_SETVERSION, do_ext2_ioctl)
3696 HANDLE_IOCTL(VIDIOCGTUNER32, do_video_ioctl)
3697 HANDLE_IOCTL(VIDIOCSTUNER32, do_video_ioctl)
3698 HANDLE_IOCTL(VIDIOCGWIN32, do_video_ioctl)
3699 HANDLE_IOCTL(VIDIOCSWIN32, do_video_ioctl)
3700 HANDLE_IOCTL(VIDIOCGFBUF32, do_video_ioctl)
3701 HANDLE_IOCTL(VIDIOCSFBUF32, do_video_ioctl)
3702 HANDLE_IOCTL(VIDIOCGFREQ32, do_video_ioctl)
3703 HANDLE_IOCTL(VIDIOCSFREQ32, do_video_ioctl)
3704 /* One SMB ioctl needs translations. */
3705 #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, __kernel_uid_t32)
3706 HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
3707 HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl)
3708 HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl)
3709 HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl)
3710 HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl)
3711 HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl)
3712 HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl)
3713 HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl)
3714 HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl)
3715 HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl)
3716 HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl)
3717 HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl)
3718 HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl)
3719 HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl)
3720 HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl)
3721 HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl)
3722 HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl)
3723 HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl)
3724 HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl)
3725 HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl)
3726 HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl)
3727 HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl)
3728 HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl)
3729 HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl)
3730 HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl)
3731 HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl)
3732 #if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
3733 HANDLE_IOCTL(VG_STATUS, do_lvm_ioctl)
3734 HANDLE_IOCTL(VG_CREATE, do_lvm_ioctl)
3735 HANDLE_IOCTL(VG_EXTEND, do_lvm_ioctl)
3736 HANDLE_IOCTL(LV_CREATE, do_lvm_ioctl)
3737 HANDLE_IOCTL(LV_REMOVE, do_lvm_ioctl)
3738 HANDLE_IOCTL(LV_EXTEND, do_lvm_ioctl)
3739 HANDLE_IOCTL(LV_REDUCE, do_lvm_ioctl)
3740 HANDLE_IOCTL(LV_STATUS_BYNAME, do_lvm_ioctl)
3741 HANDLE_IOCTL(LV_STATUS_BYINDEX, do_lvm_ioctl)
3742 HANDLE_IOCTL(LE_REMAP, do_lvm_ioctl)
3743 HANDLE_IOCTL(PV_CHANGE, do_lvm_ioctl)
3744 HANDLE_IOCTL(PV_STATUS, do_lvm_ioctl)
3745 #endif /* LVM */
3746 #if defined(CONFIG_DRM) || defined(CONFIG_DRM_MODULE)
3747 HANDLE_IOCTL(DRM32_IOCTL_VERSION, drm32_version);
3748 HANDLE_IOCTL(DRM32_IOCTL_GET_UNIQUE, drm32_getsetunique);
3749 HANDLE_IOCTL(DRM32_IOCTL_SET_UNIQUE, drm32_getsetunique);
3750 HANDLE_IOCTL(DRM32_IOCTL_ADD_MAP, drm32_addmap);
3751 HANDLE_IOCTL(DRM32_IOCTL_INFO_BUFS, drm32_info_bufs);
3752 HANDLE_IOCTL(DRM32_IOCTL_FREE_BUFS, drm32_free_bufs);
3753 HANDLE_IOCTL(DRM32_IOCTL_MAP_BUFS, drm32_map_bufs);
3754 HANDLE_IOCTL(DRM32_IOCTL_DMA, drm32_dma);
3755 HANDLE_IOCTL(DRM32_IOCTL_RES_CTX, drm32_res_ctx);
3756 #endif /* DRM */
3757 IOCTL_TABLE_END
3759 unsigned int ioctl32_hash_table[1024];
3761 extern inline unsigned long ioctl32_hash(unsigned long cmd)
3763 return ((cmd >> 6) ^ (cmd >> 4) ^ cmd) & 0x3ff;
3766 static void ioctl32_insert_translation(struct ioctl_trans *trans)
3768 unsigned long hash;
3769 struct ioctl_trans *t;
3771 hash = ioctl32_hash (trans->cmd);
3772 if (!ioctl32_hash_table[hash])
3773 ioctl32_hash_table[hash] = (u32)(long)trans;
3774 else {
3775 t = (struct ioctl_trans *)(long)ioctl32_hash_table[hash];
3776 while (t->next)
3777 t = (struct ioctl_trans *)(long)t->next;
3778 trans->next = 0;
3779 t->next = (u32)(long)trans;
3783 static int __init init_sys32_ioctl(void)
3785 int i;
3786 extern struct ioctl_trans ioctl_translations[], ioctl_translations_end[];
3788 for (i = 0; &ioctl_translations[i] < &ioctl_translations_end[0]; i++)
3789 ioctl32_insert_translation(&ioctl_translations[i]);
3790 return 0;
3793 __initcall(init_sys32_ioctl);
3795 static struct ioctl_trans *additional_ioctls;
3797 /* Always call these with kernel lock held! */
3799 int register_ioctl32_conversion(unsigned int cmd, int (*handler)(unsigned int, unsigned int, unsigned long, struct file *))
3801 int i;
3802 if (!additional_ioctls) {
3803 additional_ioctls = module_map(PAGE_SIZE);
3804 if (!additional_ioctls)
3805 return -ENOMEM;
3806 memset(additional_ioctls, 0, PAGE_SIZE);
3808 for (i = 0; i < PAGE_SIZE/sizeof(struct ioctl_trans); i++)
3809 if (!additional_ioctls[i].cmd)
3810 break;
3811 if (i == PAGE_SIZE/sizeof(struct ioctl_trans))
3812 return -ENOMEM;
3813 additional_ioctls[i].cmd = cmd;
3814 if (!handler)
3815 additional_ioctls[i].handler = (u32)(long)sys_ioctl;
3816 else
3817 additional_ioctls[i].handler = (u32)(long)handler;
3818 ioctl32_insert_translation(&additional_ioctls[i]);
3819 return 0;
3822 int unregister_ioctl32_conversion(unsigned int cmd)
3824 unsigned long hash = ioctl32_hash(cmd);
3825 struct ioctl_trans *t, *t1;
3827 t = (struct ioctl_trans *)(long)ioctl32_hash_table[hash];
3828 if (!t) return -EINVAL;
3829 if (t->cmd == cmd && t >= additional_ioctls &&
3830 (unsigned long)t < ((unsigned long)additional_ioctls) + PAGE_SIZE) {
3831 ioctl32_hash_table[hash] = t->next;
3832 t->cmd = 0;
3833 return 0;
3834 } else while (t->next) {
3835 t1 = (struct ioctl_trans *)(long)t->next;
3836 if (t1->cmd == cmd && t1 >= additional_ioctls &&
3837 (unsigned long)t1 < ((unsigned long)additional_ioctls) + PAGE_SIZE) {
3838 t1->cmd = 0;
3839 t->next = t1->next;
3840 return 0;
3842 t = t1;
3844 return -EINVAL;
3847 asmlinkage int sys32_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
3849 struct file * filp;
3850 int error = -EBADF;
3851 int (*handler)(unsigned int, unsigned int, unsigned long, struct file * filp);
3852 struct ioctl_trans *t;
3854 filp = fget(fd);
3855 if(!filp)
3856 goto out2;
3858 if (!filp->f_op || !filp->f_op->ioctl) {
3859 error = sys_ioctl (fd, cmd, arg);
3860 goto out;
3863 t = (struct ioctl_trans *)(long)ioctl32_hash_table [ioctl32_hash (cmd)];
3865 while (t && t->cmd != cmd)
3866 t = (struct ioctl_trans *)(long)t->next;
3867 if (t) {
3868 handler = (void *)(long)t->handler;
3869 error = handler(fd, cmd, arg, filp);
3870 } else {
3871 static int count = 0;
3872 if (++count <= 20)
3873 printk("sys32_ioctl: Unknown cmd fd(%d) "
3874 "cmd(%08x) arg(%08x)\n",
3875 (int)fd, (unsigned int)cmd, (unsigned int)arg);
3876 error = -EINVAL;
3878 out:
3879 fput(filp);
3880 out2:
3881 return error;