Import 2.3.13
[davej-history.git] / arch / sparc64 / kernel / ioctl32.c
blob1fbdad83594ec250f16d08cca4793f3cf9c6d342
1 /* $Id: ioctl32.c,v 1.66 1999/08/08 01:37:06 davem Exp $
2 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
4 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
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/types.h>
12 #include <linux/kernel.h>
13 #include <linux/sched.h>
14 #include <linux/smp.h>
15 #include <linux/smp_lock.h>
16 #include <linux/ioctl.h>
17 #include <linux/if.h>
18 #include <linux/malloc.h>
19 #include <linux/hdreg.h>
20 #include <linux/md.h>
21 #include <linux/kd.h>
22 #include <linux/route.h>
23 #include <linux/skbuff.h>
24 #include <linux/netlink.h>
25 #include <linux/vt.h>
26 #include <linux/fs.h>
27 #include <linux/file.h>
28 #include <linux/fd.h>
29 #include <linux/ppp_defs.h>
30 #include <linux/if_ppp.h>
31 #include <linux/mtio.h>
32 #include <linux/cdrom.h>
33 #include <linux/loop.h>
34 #include <linux/auto_fs.h>
35 #include <linux/tty.h>
36 #include <linux/vt_kern.h>
37 #include <linux/fb.h>
38 #include <linux/ext2_fs.h>
39 #include <linux/videodev.h>
40 #include <linux/netdevice.h>
41 #include <linux/raw.h>
43 #include <scsi/scsi.h>
44 /* Ugly hack. */
45 #undef __KERNEL__
46 #include <scsi/scsi_ioctl.h>
47 #define __KERNEL__
48 #include <scsi/sg.h>
50 #include <asm/types.h>
51 #include <asm/uaccess.h>
52 #include <asm/fbio.h>
53 #include <asm/kbio.h>
54 #include <asm/vuid_event.h>
55 #include <asm/rtc.h>
56 #include <asm/openpromio.h>
57 #include <asm/envctrl.h>
58 #include <asm/audioio.h>
59 #include <asm/ethtool.h>
61 #include <linux/soundcard.h>
63 /* Use this to get at 32-bit user passed pointers.
64 See sys_sparc32.c for description about these. */
65 #define A(__x) ((unsigned long)(__x))
66 #define AA(__x) \
67 ({ unsigned long __ret; \
68 __asm__ ("srl %0, 0, %0" \
69 : "=r" (__ret) \
70 : "0" (__x)); \
71 __ret; \
74 /* Aiee. Someone does not find a difference between int and long */
75 #define EXT2_IOC32_GETFLAGS _IOR('f', 1, int)
76 #define EXT2_IOC32_SETFLAGS _IOW('f', 2, int)
77 #define EXT2_IOC32_GETVERSION _IOR('v', 1, int)
78 #define EXT2_IOC32_SETVERSION _IOW('v', 2, int)
80 extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
82 static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
84 mm_segment_t old_fs = get_fs();
85 int err;
86 unsigned long val;
88 set_fs (KERNEL_DS);
89 err = sys_ioctl(fd, cmd, (unsigned long)&val);
90 set_fs (old_fs);
91 if (!err && put_user(val, (u32 *)arg))
92 return -EFAULT;
93 return err;
96 static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg)
98 mm_segment_t old_fs = get_fs();
99 int err;
100 unsigned long val;
102 if(get_user(val, (u32 *)arg))
103 return -EFAULT;
104 set_fs (KERNEL_DS);
105 err = sys_ioctl(fd, cmd, (unsigned long)&val);
106 set_fs (old_fs);
107 if (!err && put_user(val, (u32 *)arg))
108 return -EFAULT;
109 return err;
112 static int do_ext2_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
114 /* These are just misnamed, they actually get/put from/to user an int */
115 switch (cmd) {
116 case EXT2_IOC32_GETFLAGS: cmd = EXT2_IOC_GETFLAGS; break;
117 case EXT2_IOC32_SETFLAGS: cmd = EXT2_IOC_SETFLAGS; break;
118 case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; break;
119 case EXT2_IOC32_SETVERSION: cmd = EXT2_IOC_SETVERSION; break;
121 return sys_ioctl(fd, cmd, arg);
124 struct video_tuner32 {
125 s32 tuner;
126 u8 name[32];
127 u32 rangelow, rangehigh;
128 u32 flags;
129 u16 mode, signal;
132 static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 *up)
134 int i;
136 if(get_user(kp->tuner, &up->tuner))
137 return -EFAULT;
138 for(i = 0; i < 32; i++)
139 __get_user(kp->name[i], &up->name[i]);
140 __get_user(kp->rangelow, &up->rangelow);
141 __get_user(kp->rangehigh, &up->rangehigh);
142 __get_user(kp->flags, &up->flags);
143 __get_user(kp->mode, &up->mode);
144 __get_user(kp->signal, &up->signal);
145 return 0;
148 static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 *up)
150 int i;
152 if(put_user(kp->tuner, &up->tuner))
153 return -EFAULT;
154 for(i = 0; i < 32; i++)
155 __put_user(kp->name[i], &up->name[i]);
156 __put_user(kp->rangelow, &up->rangelow);
157 __put_user(kp->rangehigh, &up->rangehigh);
158 __put_user(kp->flags, &up->flags);
159 __put_user(kp->mode, &up->mode);
160 __put_user(kp->signal, &up->signal);
161 return 0;
164 struct video_buffer32 {
165 /* void * */ u32 base;
166 s32 height, width, depth, bytesperline;
169 static int get_video_buffer32(struct video_buffer *kp, struct video_buffer32 *up)
171 u32 tmp;
173 if(get_user(tmp, &up->base))
174 return -EFAULT;
175 kp->base = (void *) ((unsigned long)tmp);
176 __get_user(kp->height, &up->height);
177 __get_user(kp->width, &up->width);
178 __get_user(kp->depth, &up->depth);
179 __get_user(kp->bytesperline, &up->bytesperline);
180 return 0;
183 static int put_video_buffer32(struct video_buffer *kp, struct video_buffer32 *up)
185 u32 tmp = (u32)((unsigned long)kp->base);
187 if(put_user(tmp, &up->base))
188 return -EFAULT;
189 __put_user(kp->height, &up->height);
190 __put_user(kp->width, &up->width);
191 __put_user(kp->depth, &up->depth);
192 __put_user(kp->bytesperline, &up->bytesperline);
193 return 0;
196 struct video_clip32 {
197 s32 x, y, width, height;
198 /* struct video_clip32 * */ u32 next;
201 struct video_window32 {
202 u32 x, y, width, height, chromakey, flags;
203 /* struct video_clip32 * */ u32 clips;
204 s32 clipcount;
207 static void free_kvideo_clips(struct video_window *kp)
209 struct video_clip *cp;
211 cp = kp->clips;
212 if(cp != NULL)
213 kfree(cp);
216 static int get_video_window32(struct video_window *kp, struct video_window32 *up)
218 struct video_clip32 *ucp;
219 struct video_clip *kcp;
220 int nclips, err, i;
221 u32 tmp;
223 if(get_user(kp->x, &up->x))
224 return -EFAULT;
225 __get_user(kp->y, &up->y);
226 __get_user(kp->width, &up->width);
227 __get_user(kp->height, &up->height);
228 __get_user(kp->chromakey, &up->chromakey);
229 __get_user(kp->flags, &up->flags);
230 __get_user(kp->clipcount, &up->clipcount);
231 __get_user(tmp, &up->clips);
232 ucp = (struct video_clip32 *)A(tmp);
233 kp->clips = NULL;
235 nclips = kp->clipcount;
236 if(nclips == 0)
237 return 0;
239 if(ucp == 0)
240 return -EINVAL;
242 /* Peculiar interface... */
243 if(nclips < 0)
244 nclips = VIDEO_CLIPMAP_SIZE;
246 kcp = kmalloc(nclips * sizeof(struct video_clip), GFP_KERNEL);
247 err = -ENOMEM;
248 if(kcp == NULL)
249 goto cleanup_and_err;
251 kp->clips = kcp;
252 for(i = 0; i < nclips; i++) {
253 __get_user(kcp[i].x, &ucp[i].x);
254 __get_user(kcp[i].y, &ucp[i].y);
255 __get_user(kcp[i].width, &ucp[i].width);
256 __get_user(kcp[i].height, &ucp[i].height);
257 kcp[nclips].next = NULL;
260 return 0;
262 cleanup_and_err:
263 free_kvideo_clips(kp);
264 return err;
267 /* You get back everything except the clips... */
268 static int put_video_window32(struct video_window *kp, struct video_window32 *up)
270 if(put_user(kp->x, &up->x))
271 return -EFAULT;
272 __put_user(kp->y, &up->y);
273 __put_user(kp->width, &up->width);
274 __put_user(kp->height, &up->height);
275 __put_user(kp->chromakey, &up->chromakey);
276 __put_user(kp->flags, &up->flags);
277 __put_user(kp->clipcount, &up->clipcount);
278 return 0;
281 #define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32)
282 #define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32)
283 #define VIDIOCGWIN32 _IOR('v',9, struct video_window32)
284 #define VIDIOCSWIN32 _IOW('v',10, struct video_window32)
285 #define VIDIOCGFBUF32 _IOR('v',11, struct video_buffer32)
286 #define VIDIOCSFBUF32 _IOW('v',12, struct video_buffer32)
287 #define VIDIOCGFREQ32 _IOR('v',14, u32)
288 #define VIDIOCSFREQ32 _IOW('v',15, u32)
290 static int do_video_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
292 union {
293 struct video_tuner vt;
294 struct video_buffer vb;
295 struct video_window vw;
296 unsigned long vx;
297 } karg;
298 mm_segment_t old_fs = get_fs();
299 void *up = (void *)arg;
300 int err = 0;
302 /* First, convert the command. */
303 switch(cmd) {
304 case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break;
305 case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break;
306 case VIDIOCGWIN32: cmd = VIDIOCGWIN; break;
307 case VIDIOCSWIN32: cmd = VIDIOCSWIN; break;
308 case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break;
309 case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break;
310 case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break;
311 case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break;
314 switch(cmd) {
315 case VIDIOCSTUNER:
316 case VIDIOCGTUNER:
317 err = get_video_tuner32(&karg.vt, up);
318 break;
320 case VIDIOCSWIN:
321 err = get_video_window32(&karg.vw, up);
322 break;
324 case VIDIOCSFBUF:
325 err = get_video_buffer32(&karg.vb, up);
326 break;
328 case VIDIOCSFREQ:
329 err = get_user(karg.vx, (u32 *)up);
330 break;
332 if(err)
333 goto out;
335 set_fs(KERNEL_DS);
336 err = sys_ioctl(fd, cmd, (unsigned long)&karg);
337 set_fs(old_fs);
339 if(cmd == VIDIOCSWIN)
340 free_kvideo_clips(&karg.vw);
342 if(err == 0) {
343 switch(cmd) {
344 case VIDIOCGTUNER:
345 err = put_video_tuner32(&karg.vt, up);
346 break;
348 case VIDIOCGWIN:
349 err = put_video_window32(&karg.vw, up);
350 break;
352 case VIDIOCGFBUF:
353 err = put_video_buffer32(&karg.vb, up);
354 break;
356 case VIDIOCGFREQ:
357 err = put_user(((u32)karg.vx), (u32 *)up);
358 break;
361 out:
362 return err;
365 struct timeval32 {
366 int tv_sec;
367 int tv_usec;
370 static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
372 struct timeval32 *up = (struct timeval32 *)arg;
373 struct timeval ktv;
374 mm_segment_t old_fs = get_fs();
375 int err;
377 set_fs(KERNEL_DS);
378 err = sys_ioctl(fd, cmd, (unsigned long)&ktv);
379 set_fs(old_fs);
380 if(!err) {
381 err = put_user(ktv.tv_sec, &up->tv_sec);
382 err |= __put_user(ktv.tv_usec, &up->tv_usec);
384 return err;
387 struct ifmap32 {
388 u32 mem_start;
389 u32 mem_end;
390 unsigned short base_addr;
391 unsigned char irq;
392 unsigned char dma;
393 unsigned char port;
396 struct ifreq32 {
397 #define IFHWADDRLEN 6
398 #define IFNAMSIZ 16
399 union {
400 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
401 } ifr_ifrn;
402 union {
403 struct sockaddr ifru_addr;
404 struct sockaddr ifru_dstaddr;
405 struct sockaddr ifru_broadaddr;
406 struct sockaddr ifru_netmask;
407 struct sockaddr ifru_hwaddr;
408 short ifru_flags;
409 int ifru_ivalue;
410 int ifru_mtu;
411 struct ifmap32 ifru_map;
412 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
413 __kernel_caddr_t32 ifru_data;
414 } ifr_ifru;
417 struct ifconf32 {
418 int ifc_len; /* size of buffer */
419 __kernel_caddr_t32 ifcbuf;
422 static int dev_ifname32(unsigned int fd, unsigned long arg)
424 struct device *dev;
425 struct ifreq32 ifr32;
426 int err;
428 if (copy_from_user(&ifr32, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
429 return -EFAULT;
431 dev = dev_get_by_index(ifr32.ifr_ifindex);
432 if (!dev)
433 return -ENODEV;
435 err = copy_to_user((struct ifreq32 *)arg, &ifr32, sizeof(struct ifreq32));
436 return (err ? -EFAULT : 0);
439 static inline int dev_ifconf(unsigned int fd, unsigned long arg)
441 struct ifconf32 ifc32;
442 struct ifconf ifc;
443 struct ifreq32 *ifr32;
444 struct ifreq *ifr;
445 mm_segment_t old_fs;
446 unsigned int i, j;
447 int err;
449 if (copy_from_user(&ifc32, (struct ifconf32 *)arg, sizeof(struct ifconf32)))
450 return -EFAULT;
452 if(ifc32.ifcbuf == 0) {
453 ifc32.ifc_len = 0;
454 ifc.ifc_len = 0;
455 ifc.ifc_buf = NULL;
456 } else {
457 ifc.ifc_len = ((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) *
458 sizeof (struct ifreq);
459 ifc.ifc_buf = kmalloc (ifc.ifc_len, GFP_KERNEL);
460 if (!ifc.ifc_buf)
461 return -ENOMEM;
463 ifr = ifc.ifc_req;
464 ifr32 = (struct ifreq32 *)A(ifc32.ifcbuf);
465 for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) {
466 if (copy_from_user(ifr++, ifr32++, sizeof (struct ifreq32))) {
467 kfree (ifc.ifc_buf);
468 return -EFAULT;
471 old_fs = get_fs(); set_fs (KERNEL_DS);
472 err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)&ifc);
473 set_fs (old_fs);
474 if (!err) {
475 ifr = ifc.ifc_req;
476 ifr32 = (struct ifreq32 *)A(ifc32.ifcbuf);
477 for (i = 0, j = 0; i < ifc32.ifc_len && j < ifc.ifc_len;
478 i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
479 if (copy_to_user(ifr32++, ifr++, sizeof (struct ifreq32))) {
480 err = -EFAULT;
481 break;
484 if (!err) {
485 if (i <= ifc32.ifc_len)
486 ifc32.ifc_len = i;
487 else
488 ifc32.ifc_len = i - sizeof (struct ifreq32);
489 if (copy_to_user((struct ifconf32 *)arg, &ifc32, sizeof(struct ifconf32)))
490 err = -EFAULT;
493 if(ifc.ifc_buf != NULL)
494 kfree (ifc.ifc_buf);
495 return err;
498 static inline int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg)
500 struct ifreq ifr;
501 mm_segment_t old_fs;
502 int err;
504 switch (cmd) {
505 case SIOCSIFMAP:
506 err = copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(ifr.ifr_name));
507 err |= __get_user(ifr.ifr_map.mem_start, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_start));
508 err |= __get_user(ifr.ifr_map.mem_end, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_end));
509 err |= __get_user(ifr.ifr_map.base_addr, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.base_addr));
510 err |= __get_user(ifr.ifr_map.irq, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.irq));
511 err |= __get_user(ifr.ifr_map.dma, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.dma));
512 err |= __get_user(ifr.ifr_map.port, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.port));
513 if (err)
514 return -EFAULT;
515 break;
516 case SIOCGPPPSTATS:
517 case SIOCGPPPCSTATS:
518 case SIOCGPPPVER:
519 case SIOCETHTOOL:
520 if (copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
521 return -EFAULT;
522 ifr.ifr_data = (__kernel_caddr_t)get_free_page(GFP_KERNEL);
523 if (!ifr.ifr_data)
524 return -EAGAIN;
525 if(cmd == SIOCETHTOOL) {
526 u32 data;
528 __get_user(data, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_data));
529 if(copy_from_user(ifr.ifr_data,
530 (char *)A(data),
531 sizeof(struct ethtool_cmd))) {
532 free_page((unsigned long)ifr.ifr_data);
533 return -EFAULT;
536 break;
537 default:
538 if (copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
539 return -EFAULT;
540 break;
542 old_fs = get_fs();
543 set_fs (KERNEL_DS);
544 err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
545 set_fs (old_fs);
546 if (!err) {
547 switch (cmd) {
548 case SIOCGIFFLAGS:
549 case SIOCGIFMETRIC:
550 case SIOCGIFMTU:
551 case SIOCGIFMEM:
552 case SIOCGIFHWADDR:
553 case SIOCGIFINDEX:
554 case SIOCGIFADDR:
555 case SIOCGIFBRDADDR:
556 case SIOCGIFDSTADDR:
557 case SIOCGIFNETMASK:
558 case SIOCGIFTXQLEN:
559 if (copy_to_user((struct ifreq32 *)arg, &ifr, sizeof(struct ifreq32)))
560 return -EFAULT;
561 break;
562 case SIOCGPPPSTATS:
563 case SIOCGPPPCSTATS:
564 case SIOCGPPPVER:
565 case SIOCETHTOOL:
567 u32 data;
568 int len;
570 __get_user(data, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_data));
571 if(cmd == SIOCETHTOOL)
572 len = sizeof(struct ethtool_cmd);
573 if(cmd == SIOCGPPPVER)
574 len = strlen((char *)ifr.ifr_data) + 1;
575 else if(cmd == SIOCGPPPCSTATS)
576 len = sizeof(struct ppp_comp_stats);
577 else
578 len = sizeof(struct ppp_stats);
580 len = copy_to_user((char *)A(data), ifr.ifr_data, len);
581 free_page((unsigned long)ifr.ifr_data);
582 if(len)
583 return -EFAULT;
584 break;
586 case SIOCGIFMAP:
587 err = copy_to_user((struct ifreq32 *)arg, &ifr, sizeof(ifr.ifr_name));
588 err |= __put_user(ifr.ifr_map.mem_start, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_start));
589 err |= __put_user(ifr.ifr_map.mem_end, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_end));
590 err |= __put_user(ifr.ifr_map.base_addr, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.base_addr));
591 err |= __put_user(ifr.ifr_map.irq, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.irq));
592 err |= __put_user(ifr.ifr_map.dma, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.dma));
593 err |= __put_user(ifr.ifr_map.port, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.port));
594 break;
597 return err;
600 struct rtentry32 {
601 u32 rt_pad1;
602 struct sockaddr rt_dst; /* target address */
603 struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
604 struct sockaddr rt_genmask; /* target network mask (IP) */
605 unsigned short rt_flags;
606 short rt_pad2;
607 u32 rt_pad3;
608 unsigned char rt_tos;
609 unsigned char rt_class;
610 short rt_pad4;
611 short rt_metric; /* +1 for binary compatibility! */
612 /* char * */ u32 rt_dev; /* forcing the device at add */
613 u32 rt_mtu; /* per route MTU/Window */
614 u32 rt_window; /* Window clamping */
615 unsigned short rt_irtt; /* Initial RTT */
619 static inline int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
621 struct rtentry r;
622 char devname[16];
623 u32 rtdev;
624 int ret;
625 mm_segment_t old_fs = get_fs();
627 ret = copy_from_user (&r.rt_dst, &(((struct rtentry32 *)arg)->rt_dst), 3 * sizeof(struct sockaddr));
628 ret |= __get_user (r.rt_flags, &(((struct rtentry32 *)arg)->rt_flags));
629 ret |= __get_user (r.rt_metric, &(((struct rtentry32 *)arg)->rt_metric));
630 ret |= __get_user (r.rt_mtu, &(((struct rtentry32 *)arg)->rt_mtu));
631 ret |= __get_user (r.rt_window, &(((struct rtentry32 *)arg)->rt_window));
632 ret |= __get_user (r.rt_irtt, &(((struct rtentry32 *)arg)->rt_irtt));
633 ret |= __get_user (rtdev, &(((struct rtentry32 *)arg)->rt_dev));
634 if (rtdev) {
635 ret |= copy_from_user (devname, (char *)A(rtdev), 15);
636 r.rt_dev = devname; devname[15] = 0;
637 } else
638 r.rt_dev = 0;
639 if (ret)
640 return -EFAULT;
641 set_fs (KERNEL_DS);
642 ret = sys_ioctl (fd, cmd, (long)&r);
643 set_fs (old_fs);
644 return ret;
647 struct hd_geometry32 {
648 unsigned char heads;
649 unsigned char sectors;
650 unsigned short cylinders;
651 u32 start;
654 static inline int hdio_getgeo(unsigned int fd, unsigned long arg)
656 mm_segment_t old_fs = get_fs();
657 struct hd_geometry geo;
658 int err;
660 set_fs (KERNEL_DS);
661 err = sys_ioctl(fd, HDIO_GETGEO, (unsigned long)&geo);
662 set_fs (old_fs);
663 if (!err) {
664 err = copy_to_user ((struct hd_geometry32 *)arg, &geo, 4);
665 err |= __put_user (geo.start, &(((struct hd_geometry32 *)arg)->start));
667 return err;
670 struct fbcmap32 {
671 int index; /* first element (0 origin) */
672 int count;
673 u32 red;
674 u32 green;
675 u32 blue;
678 #define FBIOPUTCMAP32 _IOW('F', 3, struct fbcmap32)
679 #define FBIOGETCMAP32 _IOW('F', 4, struct fbcmap32)
681 static inline int fbiogetputcmap(unsigned int fd, unsigned int cmd, unsigned long arg)
683 struct fbcmap f;
684 int ret;
685 char red[256], green[256], blue[256];
686 u32 r, g, b;
687 mm_segment_t old_fs = get_fs();
689 ret = get_user(f.index, &(((struct fbcmap32 *)arg)->index));
690 ret |= __get_user(f.count, &(((struct fbcmap32 *)arg)->count));
691 ret |= __get_user(r, &(((struct fbcmap32 *)arg)->red));
692 ret |= __get_user(g, &(((struct fbcmap32 *)arg)->green));
693 ret |= __get_user(b, &(((struct fbcmap32 *)arg)->blue));
694 if (ret)
695 return -EFAULT;
696 if ((f.index < 0) || (f.index > 255)) return -EINVAL;
697 if (f.index + f.count > 256)
698 f.count = 256 - f.index;
699 if (cmd == FBIOPUTCMAP32) {
700 ret = copy_from_user (red, (char *)A(r), f.count);
701 ret |= copy_from_user (green, (char *)A(g), f.count);
702 ret |= copy_from_user (blue, (char *)A(b), f.count);
703 if (ret)
704 return -EFAULT;
706 f.red = red; f.green = green; f.blue = blue;
707 set_fs (KERNEL_DS);
708 ret = sys_ioctl (fd, (cmd == FBIOPUTCMAP32) ? FBIOPUTCMAP_SPARC : FBIOGETCMAP_SPARC, (long)&f);
709 set_fs (old_fs);
710 if (!ret && cmd == FBIOGETCMAP32) {
711 ret = copy_to_user ((char *)A(r), red, f.count);
712 ret |= copy_to_user ((char *)A(g), green, f.count);
713 ret |= copy_to_user ((char *)A(b), blue, f.count);
715 return ret;
718 struct fbcursor32 {
719 short set; /* what to set, choose from the list above */
720 short enable; /* cursor on/off */
721 struct fbcurpos pos; /* cursor position */
722 struct fbcurpos hot; /* cursor hot spot */
723 struct fbcmap32 cmap; /* color map info */
724 struct fbcurpos size; /* cursor bit map size */
725 u32 image; /* cursor image bits */
726 u32 mask; /* cursor mask bits */
729 #define FBIOSCURSOR32 _IOW('F', 24, struct fbcursor32)
730 #define FBIOGCURSOR32 _IOW('F', 25, struct fbcursor32)
732 static inline int fbiogscursor(unsigned int fd, unsigned int cmd, unsigned long arg)
734 struct fbcursor f;
735 int ret;
736 char red[2], green[2], blue[2];
737 char image[128], mask[128];
738 u32 r, g, b;
739 u32 m, i;
740 mm_segment_t old_fs = get_fs();
742 ret = copy_from_user (&f, (struct fbcursor32 *)arg, 2 * sizeof (short) + 2 * sizeof(struct fbcurpos));
743 ret |= __get_user(f.size.fbx, &(((struct fbcursor32 *)arg)->size.fbx));
744 ret |= __get_user(f.size.fby, &(((struct fbcursor32 *)arg)->size.fby));
745 ret |= __get_user(f.cmap.index, &(((struct fbcursor32 *)arg)->cmap.index));
746 ret |= __get_user(f.cmap.count, &(((struct fbcursor32 *)arg)->cmap.count));
747 ret |= __get_user(r, &(((struct fbcursor32 *)arg)->cmap.red));
748 ret |= __get_user(g, &(((struct fbcursor32 *)arg)->cmap.green));
749 ret |= __get_user(b, &(((struct fbcursor32 *)arg)->cmap.blue));
750 ret |= __get_user(m, &(((struct fbcursor32 *)arg)->mask));
751 ret |= __get_user(i, &(((struct fbcursor32 *)arg)->image));
752 if (ret)
753 return -EFAULT;
754 if (f.set & FB_CUR_SETCMAP) {
755 if ((uint) f.size.fby > 32)
756 return -EINVAL;
757 ret = copy_from_user (mask, (char *)A(m), f.size.fby * 4);
758 ret |= copy_from_user (image, (char *)A(i), f.size.fby * 4);
759 if (ret)
760 return -EFAULT;
761 f.image = image; f.mask = mask;
763 if (f.set & FB_CUR_SETCMAP) {
764 ret = copy_from_user (red, (char *)A(r), 2);
765 ret |= copy_from_user (green, (char *)A(g), 2);
766 ret |= copy_from_user (blue, (char *)A(b), 2);
767 if (ret)
768 return -EFAULT;
769 f.cmap.red = red; f.cmap.green = green; f.cmap.blue = blue;
771 set_fs (KERNEL_DS);
772 ret = sys_ioctl (fd, FBIOSCURSOR, (long)&f);
773 set_fs (old_fs);
774 return ret;
777 struct fb_fix_screeninfo32 {
778 char id[16];
779 __kernel_caddr_t32 smem_start;
780 __u32 smem_len;
781 __u32 type;
782 __u32 type_aux;
783 __u32 visual;
784 __u16 xpanstep;
785 __u16 ypanstep;
786 __u16 ywrapstep;
787 __u32 line_length;
788 __kernel_caddr_t32 mmio_start;
789 __u32 mmio_len;
790 __u32 accel;
791 __u16 reserved[3];
794 struct fb_cmap32 {
795 __u32 start;
796 __u32 len;
797 __kernel_caddr_t32 red;
798 __kernel_caddr_t32 green;
799 __kernel_caddr_t32 blue;
800 __kernel_caddr_t32 transp;
803 static int fb_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
805 mm_segment_t old_fs = get_fs();
806 u32 red = 0, green = 0, blue = 0, transp = 0;
807 struct fb_fix_screeninfo fix;
808 struct fb_cmap cmap;
809 void *karg;
810 int err = 0;
812 memset(&cmap, 0, sizeof(cmap));
813 switch (cmd) {
814 case FBIOGET_FSCREENINFO:
815 karg = &fix;
816 break;
817 case FBIOGETCMAP:
818 case FBIOPUTCMAP:
819 karg = &cmap;
820 err = __get_user(cmap.start, &((struct fb_cmap32 *)arg)->start);
821 err |= __get_user(cmap.len, &((struct fb_cmap32 *)arg)->len);
822 err |= __get_user(red, &((struct fb_cmap32 *)arg)->red);
823 err |= __get_user(green, &((struct fb_cmap32 *)arg)->green);
824 err |= __get_user(blue, &((struct fb_cmap32 *)arg)->blue);
825 err |= __get_user(transp, &((struct fb_cmap32 *)arg)->transp);
826 if (err)
827 goto out;
828 err = -ENOMEM;
829 cmap.red = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
830 if (!cmap.red)
831 goto out;
832 cmap.green = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
833 if (!cmap.green)
834 goto out;
835 cmap.blue = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
836 if (!cmap.blue)
837 goto out;
838 if (transp) {
839 cmap.transp = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
840 if (!cmap.transp)
841 goto out;
844 if (cmd == FBIOGETCMAP)
845 break;
847 err = __copy_from_user(cmap.red, (char *)A(red), cmap.len * sizeof(__u16));
848 err |= __copy_from_user(cmap.green, (char *)A(green), cmap.len * sizeof(__u16));
849 err |= __copy_from_user(cmap.blue, (char *)A(blue), cmap.len * sizeof(__u16));
850 if (cmap.transp) err |= __copy_from_user(cmap.transp, (char *)A(transp), cmap.len * sizeof(__u16));
851 if (err)
852 goto out;
853 break;
854 default:
855 do {
856 static int count = 0;
857 if (++count <= 20)
858 printk("%s: Unknown fb ioctl cmd fd(%d) "
859 "cmd(%08x) arg(%08lx)\n",
860 __FUNCTION__, fd, cmd, arg);
861 } while(0);
862 return -ENOSYS;
864 set_fs(KERNEL_DS);
865 err = sys_ioctl(fd, cmd, (unsigned long)karg);
866 set_fs(old_fs);
867 if (err)
868 goto out;
869 switch (cmd) {
870 case FBIOGET_FSCREENINFO:
871 err = __copy_to_user((char *)((struct fb_fix_screeninfo32 *)arg)->id, (char *)fix.id, sizeof(fix.id));
872 err |= __put_user((__u32)(unsigned long)fix.smem_start, &((struct fb_fix_screeninfo32 *)arg)->smem_start);
873 err |= __put_user(fix.smem_len, &((struct fb_fix_screeninfo32 *)arg)->smem_len);
874 err |= __put_user(fix.type, &((struct fb_fix_screeninfo32 *)arg)->type);
875 err |= __put_user(fix.type_aux, &((struct fb_fix_screeninfo32 *)arg)->type_aux);
876 err |= __put_user(fix.visual, &((struct fb_fix_screeninfo32 *)arg)->visual);
877 err |= __put_user(fix.xpanstep, &((struct fb_fix_screeninfo32 *)arg)->xpanstep);
878 err |= __put_user(fix.ypanstep, &((struct fb_fix_screeninfo32 *)arg)->ypanstep);
879 err |= __put_user(fix.ywrapstep, &((struct fb_fix_screeninfo32 *)arg)->ywrapstep);
880 err |= __put_user(fix.line_length, &((struct fb_fix_screeninfo32 *)arg)->line_length);
881 err |= __put_user((__u32)(unsigned long)fix.mmio_start, &((struct fb_fix_screeninfo32 *)arg)->mmio_start);
882 err |= __put_user(fix.mmio_len, &((struct fb_fix_screeninfo32 *)arg)->mmio_len);
883 err |= __put_user(fix.accel, &((struct fb_fix_screeninfo32 *)arg)->accel);
884 err |= __copy_to_user((char *)((struct fb_fix_screeninfo32 *)arg)->reserved, (char *)fix.reserved, sizeof(fix.reserved));
885 break;
886 case FBIOGETCMAP:
887 err = __copy_to_user((char *)A(red), cmap.red, cmap.len * sizeof(__u16));
888 err |= __copy_to_user((char *)A(green), cmap.blue, cmap.len * sizeof(__u16));
889 err |= __copy_to_user((char *)A(blue), cmap.blue, cmap.len * sizeof(__u16));
890 if (cmap.transp)
891 err |= __copy_to_user((char *)A(transp), cmap.transp, cmap.len * sizeof(__u16));
892 break;
893 case FBIOPUTCMAP:
894 break;
896 out: if (cmap.red) kfree(cmap.red);
897 if (cmap.green) kfree(cmap.green);
898 if (cmap.blue) kfree(cmap.blue);
899 if (cmap.transp) kfree(cmap.transp);
900 return err;
903 static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
905 mm_segment_t old_fs = get_fs();
906 unsigned long kval;
907 unsigned int *uvp;
908 int error;
910 set_fs(KERNEL_DS);
911 error = sys_ioctl(fd, cmd, (long)&kval);
912 set_fs(old_fs);
914 if(error == 0) {
915 uvp = (unsigned int *)arg;
916 if(put_user(kval, uvp))
917 error = -EFAULT;
919 return error;
922 struct floppy_struct32 {
923 unsigned int size;
924 unsigned int sect;
925 unsigned int head;
926 unsigned int track;
927 unsigned int stretch;
928 unsigned char gap;
929 unsigned char rate;
930 unsigned char spec1;
931 unsigned char fmt_gap;
932 const __kernel_caddr_t32 name;
935 struct floppy_drive_params32 {
936 char cmos;
937 u32 max_dtr;
938 u32 hlt;
939 u32 hut;
940 u32 srt;
941 u32 spinup;
942 u32 spindown;
943 unsigned char spindown_offset;
944 unsigned char select_delay;
945 unsigned char rps;
946 unsigned char tracks;
947 u32 timeout;
948 unsigned char interleave_sect;
949 struct floppy_max_errors max_errors;
950 char flags;
951 char read_track;
952 short autodetect[8];
953 int checkfreq;
954 int native_format;
957 struct floppy_drive_struct32 {
958 signed char flags;
959 u32 spinup_date;
960 u32 select_date;
961 u32 first_read_date;
962 short probed_format;
963 short track;
964 short maxblock;
965 short maxtrack;
966 int generation;
967 int keep_data;
968 int fd_ref;
969 int fd_device;
970 int last_checked;
971 __kernel_caddr_t32 dmabuf;
972 int bufblocks;
975 struct floppy_fdc_state32 {
976 int spec1;
977 int spec2;
978 int dtr;
979 unsigned char version;
980 unsigned char dor;
981 u32 address;
982 unsigned int rawcmd:2;
983 unsigned int reset:1;
984 unsigned int need_configure:1;
985 unsigned int perp_mode:2;
986 unsigned int has_fifo:1;
987 unsigned int driver_version;
988 unsigned char track[4];
991 struct floppy_write_errors32 {
992 unsigned int write_errors;
993 u32 first_error_sector;
994 int first_error_generation;
995 u32 last_error_sector;
996 int last_error_generation;
997 unsigned int badness;
1000 #define FDSETPRM32 _IOW(2, 0x42, struct floppy_struct32)
1001 #define FDDEFPRM32 _IOW(2, 0x43, struct floppy_struct32)
1002 #define FDGETPRM32 _IOR(2, 0x04, struct floppy_struct32)
1003 #define FDSETDRVPRM32 _IOW(2, 0x90, struct floppy_drive_params32)
1004 #define FDGETDRVPRM32 _IOR(2, 0x11, struct floppy_drive_params32)
1005 #define FDGETDRVSTAT32 _IOR(2, 0x12, struct floppy_drive_struct32)
1006 #define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct floppy_drive_struct32)
1007 #define FDGETFDCSTAT32 _IOR(2, 0x15, struct floppy_fdc_state32)
1008 #define FDWERRORGET32 _IOR(2, 0x17, struct floppy_write_errors32)
1010 static struct {
1011 unsigned int cmd32;
1012 unsigned int cmd;
1013 } fd_ioctl_trans_table[] = {
1014 { FDSETPRM32, FDSETPRM },
1015 { FDDEFPRM32, FDDEFPRM },
1016 { FDGETPRM32, FDGETPRM },
1017 { FDSETDRVPRM32, FDSETDRVPRM },
1018 { FDGETDRVPRM32, FDGETDRVPRM },
1019 { FDGETDRVSTAT32, FDGETDRVSTAT },
1020 { FDPOLLDRVSTAT32, FDPOLLDRVSTAT },
1021 { FDGETFDCSTAT32, FDGETFDCSTAT },
1022 { FDWERRORGET32, FDWERRORGET }
1025 #define NR_FD_IOCTL_TRANS (sizeof(fd_ioctl_trans_table)/sizeof(fd_ioctl_trans_table[0]))
1027 static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1029 mm_segment_t old_fs = get_fs();
1030 void *karg = NULL;
1031 unsigned int kcmd = 0;
1032 int i, err;
1034 for (i = 0; i < NR_FD_IOCTL_TRANS; i++)
1035 if (cmd == fd_ioctl_trans_table[i].cmd32) {
1036 kcmd = fd_ioctl_trans_table[i].cmd;
1037 break;
1039 if (!kcmd)
1040 return -EINVAL;
1042 switch (cmd) {
1043 case FDSETPRM32:
1044 case FDDEFPRM32:
1045 case FDGETPRM32:
1047 struct floppy_struct *f;
1049 f = karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_struct));
1050 if (!karg)
1051 return -ENOMEM;
1052 if (cmd == FDGETPRM32)
1053 break;
1054 err = __get_user(f->size, &((struct floppy_struct32 *)arg)->size);
1055 err |= __get_user(f->sect, &((struct floppy_struct32 *)arg)->sect);
1056 err |= __get_user(f->head, &((struct floppy_struct32 *)arg)->head);
1057 err |= __get_user(f->track, &((struct floppy_struct32 *)arg)->track);
1058 err |= __get_user(f->stretch, &((struct floppy_struct32 *)arg)->stretch);
1059 err |= __get_user(f->gap, &((struct floppy_struct32 *)arg)->gap);
1060 err |= __get_user(f->rate, &((struct floppy_struct32 *)arg)->rate);
1061 err |= __get_user(f->spec1, &((struct floppy_struct32 *)arg)->spec1);
1062 err |= __get_user(f->fmt_gap, &((struct floppy_struct32 *)arg)->fmt_gap);
1063 err |= __get_user((u64)f->name, &((struct floppy_struct32 *)arg)->name);
1064 if (err)
1065 goto out;
1066 break;
1068 case FDSETDRVPRM32:
1069 case FDGETDRVPRM32:
1071 struct floppy_drive_params *f;
1073 f = karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_drive_params));
1074 if (!karg)
1075 return -ENOMEM;
1076 if (cmd == FDGETDRVPRM32)
1077 break;
1078 err = __get_user(f->cmos, &((struct floppy_drive_params32 *)arg)->cmos);
1079 err |= __get_user(f->max_dtr, &((struct floppy_drive_params32 *)arg)->max_dtr);
1080 err |= __get_user(f->hlt, &((struct floppy_drive_params32 *)arg)->hlt);
1081 err |= __get_user(f->hut, &((struct floppy_drive_params32 *)arg)->hut);
1082 err |= __get_user(f->srt, &((struct floppy_drive_params32 *)arg)->srt);
1083 err |= __get_user(f->spinup, &((struct floppy_drive_params32 *)arg)->spinup);
1084 err |= __get_user(f->spindown, &((struct floppy_drive_params32 *)arg)->spindown);
1085 err |= __get_user(f->spindown_offset, &((struct floppy_drive_params32 *)arg)->spindown_offset);
1086 err |= __get_user(f->select_delay, &((struct floppy_drive_params32 *)arg)->select_delay);
1087 err |= __get_user(f->rps, &((struct floppy_drive_params32 *)arg)->rps);
1088 err |= __get_user(f->tracks, &((struct floppy_drive_params32 *)arg)->tracks);
1089 err |= __get_user(f->timeout, &((struct floppy_drive_params32 *)arg)->timeout);
1090 err |= __get_user(f->interleave_sect, &((struct floppy_drive_params32 *)arg)->interleave_sect);
1091 err |= __copy_from_user(&f->max_errors, &((struct floppy_drive_params32 *)arg)->max_errors, sizeof(f->max_errors));
1092 err |= __get_user(f->flags, &((struct floppy_drive_params32 *)arg)->flags);
1093 err |= __get_user(f->read_track, &((struct floppy_drive_params32 *)arg)->read_track);
1094 err |= __copy_from_user(f->autodetect, ((struct floppy_drive_params32 *)arg)->autodetect, sizeof(f->autodetect));
1095 err |= __get_user(f->checkfreq, &((struct floppy_drive_params32 *)arg)->checkfreq);
1096 err |= __get_user(f->native_format, &((struct floppy_drive_params32 *)arg)->native_format);
1097 if (err)
1098 goto out;
1099 break;
1101 case FDGETDRVSTAT32:
1102 case FDPOLLDRVSTAT32:
1103 karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_drive_struct));
1104 if (!karg)
1105 return -ENOMEM;
1106 break;
1107 case FDGETFDCSTAT32:
1108 karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_fdc_state));
1109 if (!karg)
1110 return -ENOMEM;
1111 break;
1112 case FDWERRORGET32:
1113 karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_write_errors));
1114 if (!karg)
1115 return -ENOMEM;
1116 break;
1117 default:
1118 return -EINVAL;
1120 set_fs (KERNEL_DS);
1121 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1122 set_fs (old_fs);
1123 if (err)
1124 goto out;
1125 switch (cmd) {
1126 case FDGETPRM32:
1128 struct floppy_struct *f = karg;
1130 err = __put_user(f->size, &((struct floppy_struct32 *)arg)->size);
1131 err |= __put_user(f->sect, &((struct floppy_struct32 *)arg)->sect);
1132 err |= __put_user(f->head, &((struct floppy_struct32 *)arg)->head);
1133 err |= __put_user(f->track, &((struct floppy_struct32 *)arg)->track);
1134 err |= __put_user(f->stretch, &((struct floppy_struct32 *)arg)->stretch);
1135 err |= __put_user(f->gap, &((struct floppy_struct32 *)arg)->gap);
1136 err |= __put_user(f->rate, &((struct floppy_struct32 *)arg)->rate);
1137 err |= __put_user(f->spec1, &((struct floppy_struct32 *)arg)->spec1);
1138 err |= __put_user(f->fmt_gap, &((struct floppy_struct32 *)arg)->fmt_gap);
1139 err |= __put_user((u64)f->name, &((struct floppy_struct32 *)arg)->name);
1140 break;
1142 case FDGETDRVPRM32:
1144 struct floppy_drive_params *f = karg;
1146 err = __put_user(f->cmos, &((struct floppy_drive_params32 *)arg)->cmos);
1147 err |= __put_user(f->max_dtr, &((struct floppy_drive_params32 *)arg)->max_dtr);
1148 err |= __put_user(f->hlt, &((struct floppy_drive_params32 *)arg)->hlt);
1149 err |= __put_user(f->hut, &((struct floppy_drive_params32 *)arg)->hut);
1150 err |= __put_user(f->srt, &((struct floppy_drive_params32 *)arg)->srt);
1151 err |= __put_user(f->spinup, &((struct floppy_drive_params32 *)arg)->spinup);
1152 err |= __put_user(f->spindown, &((struct floppy_drive_params32 *)arg)->spindown);
1153 err |= __put_user(f->spindown_offset, &((struct floppy_drive_params32 *)arg)->spindown_offset);
1154 err |= __put_user(f->select_delay, &((struct floppy_drive_params32 *)arg)->select_delay);
1155 err |= __put_user(f->rps, &((struct floppy_drive_params32 *)arg)->rps);
1156 err |= __put_user(f->tracks, &((struct floppy_drive_params32 *)arg)->tracks);
1157 err |= __put_user(f->timeout, &((struct floppy_drive_params32 *)arg)->timeout);
1158 err |= __put_user(f->interleave_sect, &((struct floppy_drive_params32 *)arg)->interleave_sect);
1159 err |= __copy_to_user(&((struct floppy_drive_params32 *)arg)->max_errors, &f->max_errors, sizeof(f->max_errors));
1160 err |= __put_user(f->flags, &((struct floppy_drive_params32 *)arg)->flags);
1161 err |= __put_user(f->read_track, &((struct floppy_drive_params32 *)arg)->read_track);
1162 err |= __copy_to_user(((struct floppy_drive_params32 *)arg)->autodetect, f->autodetect, sizeof(f->autodetect));
1163 err |= __put_user(f->checkfreq, &((struct floppy_drive_params32 *)arg)->checkfreq);
1164 err |= __put_user(f->native_format, &((struct floppy_drive_params32 *)arg)->native_format);
1165 break;
1167 case FDGETDRVSTAT32:
1168 case FDPOLLDRVSTAT32:
1170 struct floppy_drive_struct *f = karg;
1172 err = __put_user(f->flags, &((struct floppy_drive_struct32 *)arg)->flags);
1173 err |= __put_user(f->spinup_date, &((struct floppy_drive_struct32 *)arg)->spinup_date);
1174 err |= __put_user(f->select_date, &((struct floppy_drive_struct32 *)arg)->select_date);
1175 err |= __put_user(f->first_read_date, &((struct floppy_drive_struct32 *)arg)->first_read_date);
1176 err |= __put_user(f->probed_format, &((struct floppy_drive_struct32 *)arg)->probed_format);
1177 err |= __put_user(f->track, &((struct floppy_drive_struct32 *)arg)->track);
1178 err |= __put_user(f->maxblock, &((struct floppy_drive_struct32 *)arg)->maxblock);
1179 err |= __put_user(f->maxtrack, &((struct floppy_drive_struct32 *)arg)->maxtrack);
1180 err |= __put_user(f->generation, &((struct floppy_drive_struct32 *)arg)->generation);
1181 err |= __put_user(f->keep_data, &((struct floppy_drive_struct32 *)arg)->keep_data);
1182 err |= __put_user(f->fd_ref, &((struct floppy_drive_struct32 *)arg)->fd_ref);
1183 err |= __put_user(f->fd_device, &((struct floppy_drive_struct32 *)arg)->fd_device);
1184 err |= __put_user(f->last_checked, &((struct floppy_drive_struct32 *)arg)->last_checked);
1185 err |= __put_user((u64)f->dmabuf, &((struct floppy_drive_struct32 *)arg)->dmabuf);
1186 err |= __put_user((u64)f->bufblocks, &((struct floppy_drive_struct32 *)arg)->bufblocks);
1187 break;
1189 case FDGETFDCSTAT32:
1191 struct floppy_fdc_state *f = karg;
1193 err = __put_user(f->spec1, &((struct floppy_fdc_state32 *)arg)->spec1);
1194 err |= __put_user(f->spec2, &((struct floppy_fdc_state32 *)arg)->spec2);
1195 err |= __put_user(f->dtr, &((struct floppy_fdc_state32 *)arg)->dtr);
1196 err |= __put_user(f->version, &((struct floppy_fdc_state32 *)arg)->version);
1197 err |= __put_user(f->dor, &((struct floppy_fdc_state32 *)arg)->dor);
1198 err |= __put_user(f->address, &((struct floppy_fdc_state32 *)arg)->address);
1199 err |= __copy_to_user((char *)&((struct floppy_fdc_state32 *)arg)->address
1200 + sizeof(((struct floppy_fdc_state32 *)arg)->address),
1201 (char *)&f->address + sizeof(f->address), sizeof(int));
1202 err |= __put_user(f->driver_version, &((struct floppy_fdc_state32 *)arg)->driver_version);
1203 err |= __copy_to_user(((struct floppy_fdc_state32 *)arg)->track, f->track, sizeof(f->track));
1204 break;
1206 case FDWERRORGET32:
1208 struct floppy_write_errors *f = karg;
1210 err = __put_user(f->write_errors, &((struct floppy_write_errors32 *)arg)->write_errors);
1211 err |= __put_user(f->first_error_sector, &((struct floppy_write_errors32 *)arg)->first_error_sector);
1212 err |= __put_user(f->first_error_generation, &((struct floppy_write_errors32 *)arg)->first_error_generation);
1213 err |= __put_user(f->last_error_sector, &((struct floppy_write_errors32 *)arg)->last_error_sector);
1214 err |= __put_user(f->last_error_generation, &((struct floppy_write_errors32 *)arg)->last_error_generation);
1215 err |= __put_user(f->badness, &((struct floppy_write_errors32 *)arg)->badness);
1216 break;
1218 default:
1219 break;
1221 out: if (karg) kfree(karg);
1222 return err;
1225 struct ppp_option_data32 {
1226 __kernel_caddr_t32 ptr;
1227 __u32 length;
1228 int transmit;
1230 #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
1232 struct ppp_idle32 {
1233 __kernel_time_t32 xmit_idle;
1234 __kernel_time_t32 recv_idle;
1236 #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
1238 static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1240 mm_segment_t old_fs = get_fs();
1241 struct ppp_option_data32 data32;
1242 struct ppp_option_data data;
1243 struct ppp_idle32 idle32;
1244 struct ppp_idle idle;
1245 unsigned int kcmd;
1246 void *karg;
1247 int err = 0;
1249 switch (cmd) {
1250 case PPPIOCGIDLE32:
1251 kcmd = PPPIOCGIDLE;
1252 karg = &idle;
1253 break;
1254 case PPPIOCSCOMPRESS32:
1255 if (copy_from_user(&data32, (struct ppp_option_data32 *)arg, sizeof(struct ppp_option_data32)))
1256 return -EFAULT;
1257 data.ptr = kmalloc (data32.length, GFP_KERNEL);
1258 if (!data.ptr)
1259 return -ENOMEM;
1260 if (copy_from_user(data.ptr, (__u8 *)A(data32.ptr), data32.length)) {
1261 kfree(data.ptr);
1262 return -EFAULT;
1264 data.length = data32.length;
1265 data.transmit = data32.transmit;
1266 kcmd = PPPIOCSCOMPRESS;
1267 karg = &data;
1268 break;
1269 default:
1270 do {
1271 static int count = 0;
1272 if (++count <= 20)
1273 printk("ppp_ioctl: Unknown cmd fd(%d) "
1274 "cmd(%08x) arg(%08x)\n",
1275 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1276 } while(0);
1277 return -EINVAL;
1279 set_fs (KERNEL_DS);
1280 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1281 set_fs (old_fs);
1282 switch (cmd) {
1283 case PPPIOCGIDLE32:
1284 if (err)
1285 return err;
1286 idle32.xmit_idle = idle.xmit_idle;
1287 idle32.recv_idle = idle.recv_idle;
1288 if (copy_to_user((struct ppp_idle32 *)arg, &idle32, sizeof(struct ppp_idle32)))
1289 return -EFAULT;
1290 break;
1291 case PPPIOCSCOMPRESS32:
1292 kfree(data.ptr);
1293 break;
1294 default:
1295 break;
1297 return err;
1301 struct mtget32 {
1302 __u32 mt_type;
1303 __u32 mt_resid;
1304 __u32 mt_dsreg;
1305 __u32 mt_gstat;
1306 __u32 mt_erreg;
1307 __kernel_daddr_t32 mt_fileno;
1308 __kernel_daddr_t32 mt_blkno;
1310 #define MTIOCGET32 _IOR('m', 2, struct mtget32)
1312 struct mtpos32 {
1313 __u32 mt_blkno;
1315 #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
1317 struct mtconfiginfo32 {
1318 __u32 mt_type;
1319 __u32 ifc_type;
1320 __u16 irqnr;
1321 __u16 dmanr;
1322 __u16 port;
1323 __u32 debug;
1324 __u32 have_dens:1;
1325 __u32 have_bsf:1;
1326 __u32 have_fsr:1;
1327 __u32 have_bsr:1;
1328 __u32 have_eod:1;
1329 __u32 have_seek:1;
1330 __u32 have_tell:1;
1331 __u32 have_ras1:1;
1332 __u32 have_ras2:1;
1333 __u32 have_ras3:1;
1334 __u32 have_qfa:1;
1335 __u32 pad1:5;
1336 char reserved[10];
1338 #define MTIOCGETCONFIG32 _IOR('m', 4, struct mtconfiginfo32)
1339 #define MTIOCSETCONFIG32 _IOW('m', 5, struct mtconfiginfo32)
1341 static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1343 mm_segment_t old_fs = get_fs();
1344 struct mtconfiginfo info;
1345 struct mtget get;
1346 struct mtpos pos;
1347 unsigned long kcmd;
1348 void *karg;
1349 int err = 0;
1351 switch(cmd) {
1352 case MTIOCPOS32:
1353 kcmd = MTIOCPOS;
1354 karg = &pos;
1355 break;
1356 case MTIOCGET32:
1357 kcmd = MTIOCGET;
1358 karg = &get;
1359 break;
1360 case MTIOCGETCONFIG32:
1361 kcmd = MTIOCGETCONFIG;
1362 karg = &info;
1363 break;
1364 case MTIOCSETCONFIG32:
1365 kcmd = MTIOCSETCONFIG;
1366 karg = &info;
1367 err = __get_user(info.mt_type, &((struct mtconfiginfo32 *)arg)->mt_type);
1368 err |= __get_user(info.ifc_type, &((struct mtconfiginfo32 *)arg)->ifc_type);
1369 err |= __get_user(info.irqnr, &((struct mtconfiginfo32 *)arg)->irqnr);
1370 err |= __get_user(info.dmanr, &((struct mtconfiginfo32 *)arg)->dmanr);
1371 err |= __get_user(info.port, &((struct mtconfiginfo32 *)arg)->port);
1372 err |= __get_user(info.debug, &((struct mtconfiginfo32 *)arg)->debug);
1373 err |= __copy_from_user((char *)&info.debug + sizeof(info.debug),
1374 (char *)&((struct mtconfiginfo32 *)arg)->debug
1375 + sizeof(((struct mtconfiginfo32 *)arg)->debug), sizeof(__u32));
1376 if (err)
1377 return -EFAULT;
1378 break;
1379 default:
1380 do {
1381 static int count = 0;
1382 if (++count <= 20)
1383 printk("mt_ioctl: Unknown cmd fd(%d) "
1384 "cmd(%08x) arg(%08x)\n",
1385 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1386 } while(0);
1387 return -EINVAL;
1389 set_fs (KERNEL_DS);
1390 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1391 set_fs (old_fs);
1392 if (err)
1393 return err;
1394 switch (cmd) {
1395 case MTIOCPOS32:
1396 if (__put_user(pos.mt_blkno, &((struct mtpos32 *)arg)->mt_blkno))
1397 return -EFAULT;
1398 break;
1399 case MTIOCGET32:
1400 err = __put_user(get.mt_type, &((struct mtget32 *)arg)->mt_type);
1401 err |= __put_user(get.mt_resid, &((struct mtget32 *)arg)->mt_resid);
1402 err |= __put_user(get.mt_dsreg, &((struct mtget32 *)arg)->mt_dsreg);
1403 err |= __put_user(get.mt_gstat, &((struct mtget32 *)arg)->mt_gstat);
1404 err |= __put_user(get.mt_erreg, &((struct mtget32 *)arg)->mt_erreg);
1405 err |= __put_user(get.mt_fileno, &((struct mtget32 *)arg)->mt_fileno);
1406 err |= __put_user(get.mt_blkno, &((struct mtget32 *)arg)->mt_blkno);
1407 break;
1408 case MTIOCGETCONFIG32:
1409 err = __put_user(info.mt_type, &((struct mtconfiginfo32 *)arg)->mt_type);
1410 err |= __put_user(info.ifc_type, &((struct mtconfiginfo32 *)arg)->ifc_type);
1411 err |= __put_user(info.irqnr, &((struct mtconfiginfo32 *)arg)->irqnr);
1412 err |= __put_user(info.dmanr, &((struct mtconfiginfo32 *)arg)->dmanr);
1413 err |= __put_user(info.port, &((struct mtconfiginfo32 *)arg)->port);
1414 err |= __put_user(info.debug, &((struct mtconfiginfo32 *)arg)->debug);
1415 err |= __copy_to_user((char *)&((struct mtconfiginfo32 *)arg)->debug
1416 + sizeof(((struct mtconfiginfo32 *)arg)->debug),
1417 (char *)&info.debug + sizeof(info.debug), sizeof(__u32));
1418 break;
1419 case MTIOCSETCONFIG32:
1420 break;
1422 return err;
1425 struct cdrom_read32 {
1426 int cdread_lba;
1427 __kernel_caddr_t32 cdread_bufaddr;
1428 int cdread_buflen;
1431 struct cdrom_read_audio32 {
1432 union cdrom_addr addr;
1433 u_char addr_format;
1434 int nframes;
1435 __kernel_caddr_t32 buf;
1438 static int cdrom_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1440 mm_segment_t old_fs = get_fs();
1441 struct cdrom_read cdread;
1442 struct cdrom_read_audio cdreadaudio;
1443 __kernel_caddr_t32 addr;
1444 char *data = 0;
1445 void *karg;
1446 int err = 0;
1448 switch(cmd) {
1449 case CDROMREADMODE2:
1450 case CDROMREADMODE1:
1451 case CDROMREADRAW:
1452 case CDROMREADCOOKED:
1453 karg = &cdread;
1454 err = __get_user(cdread.cdread_lba, &((struct cdrom_read32 *)arg)->cdread_lba);
1455 err |= __get_user(addr, &((struct cdrom_read32 *)arg)->cdread_bufaddr);
1456 err |= __get_user(cdread.cdread_buflen, &((struct cdrom_read32 *)arg)->cdread_buflen);
1457 if (err)
1458 return -EFAULT;
1459 data = kmalloc(cdread.cdread_buflen, GFP_KERNEL);
1460 if (!data)
1461 return -ENOMEM;
1462 cdread.cdread_bufaddr = data;
1463 break;
1464 case CDROMREADAUDIO:
1465 karg = &cdreadaudio;
1466 err = copy_from_user(&cdreadaudio.addr, &((struct cdrom_read_audio32 *)arg)->addr, sizeof(cdreadaudio.addr));
1467 err |= __get_user(cdreadaudio.addr_format, &((struct cdrom_read_audio32 *)arg)->addr_format);
1468 err |= __get_user(cdreadaudio.nframes, &((struct cdrom_read_audio32 *)arg)->nframes);
1469 err |= __get_user(addr, &((struct cdrom_read_audio32 *)arg)->buf);
1470 if (err)
1471 return -EFAULT;
1472 data = kmalloc(cdreadaudio.nframes * 2352, GFP_KERNEL);
1473 if (!data)
1474 return -ENOMEM;
1475 cdreadaudio.buf = data;
1476 break;
1477 default:
1478 do {
1479 static int count = 0;
1480 if (++count <= 20)
1481 printk("cdrom_ioctl: Unknown cmd fd(%d) "
1482 "cmd(%08x) arg(%08x)\n",
1483 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1484 } while(0);
1485 return -EINVAL;
1487 set_fs (KERNEL_DS);
1488 err = sys_ioctl (fd, cmd, (unsigned long)karg);
1489 set_fs (old_fs);
1490 if (err)
1491 goto out;
1492 switch (cmd) {
1493 case CDROMREADMODE2:
1494 case CDROMREADMODE1:
1495 case CDROMREADRAW:
1496 case CDROMREADCOOKED:
1497 err = copy_to_user((char *)A(addr), data, cdread.cdread_buflen);
1498 break;
1499 case CDROMREADAUDIO:
1500 err = copy_to_user((char *)A(addr), data, cdreadaudio.nframes * 2352);
1501 break;
1502 default:
1503 break;
1505 out: if (data) kfree(data);
1506 return err;
1509 struct loop_info32 {
1510 int lo_number; /* ioctl r/o */
1511 __kernel_dev_t32 lo_device; /* ioctl r/o */
1512 unsigned int lo_inode; /* ioctl r/o */
1513 __kernel_dev_t32 lo_rdevice; /* ioctl r/o */
1514 int lo_offset;
1515 int lo_encrypt_type;
1516 int lo_encrypt_key_size; /* ioctl w/o */
1517 int lo_flags; /* ioctl r/o */
1518 char lo_name[LO_NAME_SIZE];
1519 unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
1520 unsigned int lo_init[2];
1521 char reserved[4];
1524 static int loop_status(unsigned int fd, unsigned int cmd, unsigned long arg)
1526 mm_segment_t old_fs = get_fs();
1527 struct loop_info l;
1528 int err = 0;
1530 switch(cmd) {
1531 case LOOP_SET_STATUS:
1532 err = get_user(l.lo_number, &((struct loop_info32 *)arg)->lo_number);
1533 err |= __get_user(l.lo_device, &((struct loop_info32 *)arg)->lo_device);
1534 err |= __get_user(l.lo_inode, &((struct loop_info32 *)arg)->lo_inode);
1535 err |= __get_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice);
1536 err |= __copy_from_user((char *)&l.lo_offset, (char *)&((struct loop_info32 *)arg)->lo_offset,
1537 8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1538 if (err)
1539 return -EFAULT;
1540 set_fs (KERNEL_DS);
1541 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1542 set_fs (old_fs);
1543 break;
1544 case LOOP_GET_STATUS:
1545 set_fs (KERNEL_DS);
1546 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1547 set_fs (old_fs);
1548 if (!err) {
1549 err = put_user(l.lo_number, &((struct loop_info32 *)arg)->lo_number);
1550 err |= __put_user(l.lo_device, &((struct loop_info32 *)arg)->lo_device);
1551 err |= __put_user(l.lo_inode, &((struct loop_info32 *)arg)->lo_inode);
1552 err |= __put_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice);
1553 err |= __copy_to_user((char *)&((struct loop_info32 *)arg)->lo_offset,
1554 (char *)&l.lo_offset, (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1556 break;
1558 return err;
1561 extern int tty_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg);
1563 static int vt_check(struct file *file)
1565 struct tty_struct *tty;
1566 struct inode *inode = file->f_dentry->d_inode;
1568 if (file->f_op->ioctl != tty_ioctl)
1569 return -EINVAL;
1571 tty = (struct tty_struct *)file->private_data;
1572 if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
1573 return -EINVAL;
1575 if (tty->driver.ioctl != vt_ioctl)
1576 return -EINVAL;
1579 * To have permissions to do most of the vt ioctls, we either have
1580 * to be the owner of the tty, or super-user.
1582 if (current->tty == tty || suser())
1583 return 1;
1584 return 0;
1587 struct consolefontdesc32 {
1588 unsigned short charcount; /* characters in font (256 or 512) */
1589 unsigned short charheight; /* scan lines per character (1-32) */
1590 u32 chardata; /* font data in expanded form */
1593 static int do_fontx_ioctl(struct file *file, int cmd, struct consolefontdesc32 *user_cfd)
1595 struct consolefontdesc cfdarg;
1596 struct console_font_op op;
1597 int i, perm;
1599 perm = vt_check(file);
1600 if (perm < 0) return perm;
1602 if (copy_from_user(&cfdarg, user_cfd, sizeof(struct consolefontdesc32)))
1603 return -EFAULT;
1605 cfdarg.chardata = (unsigned char *)A(((struct consolefontdesc32 *)&cfdarg)->chardata);
1607 switch (cmd) {
1608 case PIO_FONTX:
1609 if (!perm)
1610 return -EPERM;
1611 op.op = KD_FONT_OP_SET;
1612 op.flags = 0;
1613 op.width = 8;
1614 op.height = cfdarg.charheight;
1615 op.charcount = cfdarg.charcount;
1616 op.data = cfdarg.chardata;
1617 return con_font_op(fg_console, &op);
1618 case GIO_FONTX:
1619 if (!cfdarg.chardata)
1620 return 0;
1621 op.op = KD_FONT_OP_GET;
1622 op.flags = 0;
1623 op.width = 8;
1624 op.height = cfdarg.charheight;
1625 op.charcount = cfdarg.charcount;
1626 op.data = cfdarg.chardata;
1627 i = con_font_op(fg_console, &op);
1628 if (i)
1629 return i;
1630 cfdarg.charheight = op.height;
1631 cfdarg.charcount = op.charcount;
1632 ((struct consolefontdesc32 *)&cfdarg)->chardata = (unsigned long)cfdarg.chardata;
1633 if (copy_to_user(user_cfd, &cfdarg, sizeof(struct consolefontdesc32)))
1634 return -EFAULT;
1635 return 0;
1637 return -EINVAL;
1640 struct console_font_op32 {
1641 unsigned int op; /* operation code KD_FONT_OP_* */
1642 unsigned int flags; /* KD_FONT_FLAG_* */
1643 unsigned int width, height; /* font size */
1644 unsigned int charcount;
1645 u32 data; /* font data with height fixed to 32 */
1648 static int do_kdfontop_ioctl(struct file *file, struct console_font_op32 *fontop)
1650 struct console_font_op op;
1651 int perm = vt_check(file), i;
1652 struct vt_struct *vt;
1654 if (perm < 0) return perm;
1656 if (copy_from_user(&op, (void *) fontop, sizeof(struct console_font_op32)))
1657 return -EFAULT;
1658 if (!perm && op.op != KD_FONT_OP_GET)
1659 return -EPERM;
1660 op.data = (unsigned char *)A(((struct console_font_op32 *)&op)->data);
1661 op.flags |= KD_FONT_FLAG_OLD;
1662 vt = (struct vt_struct *)((struct tty_struct *)file->private_data)->driver_data;
1663 i = con_font_op(vt->vc_num, &op);
1664 if (i) return i;
1665 ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
1666 if (copy_to_user((void *) fontop, &op, sizeof(struct console_font_op32)))
1667 return -EFAULT;
1668 return 0;
1671 struct unimapdesc32 {
1672 unsigned short entry_ct;
1673 u32 entries;
1676 static int do_unimap_ioctl(struct file *file, int cmd, struct unimapdesc32 *user_ud)
1678 struct unimapdesc32 tmp;
1679 int perm = vt_check(file);
1681 if (perm < 0) return perm;
1682 if (copy_from_user(&tmp, user_ud, sizeof tmp))
1683 return -EFAULT;
1684 switch (cmd) {
1685 case PIO_UNIMAP:
1686 if (!perm) return -EPERM;
1687 return con_set_unimap(fg_console, tmp.entry_ct, (struct unipair *)A(tmp.entries));
1688 case GIO_UNIMAP:
1689 return con_get_unimap(fg_console, tmp.entry_ct, &(user_ud->entry_ct), (struct unipair *)A(tmp.entries));
1691 return 0;
1694 asmlinkage int sys32_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
1696 struct file * filp;
1697 int error = -EBADF;
1699 lock_kernel();
1700 filp = fget(fd);
1701 if(!filp)
1702 goto out2;
1704 if (!filp->f_op || !filp->f_op->ioctl) {
1705 error = sys_ioctl (fd, cmd, arg);
1706 goto out;
1708 switch (cmd) {
1709 case SIOCGIFNAME:
1710 error = dev_ifname32(fd, arg);
1711 goto out;
1713 case SIOCGIFCONF:
1714 error = dev_ifconf(fd, arg);
1715 goto out;
1717 case SIOCGIFFLAGS:
1718 case SIOCSIFFLAGS:
1719 case SIOCGIFMETRIC:
1720 case SIOCSIFMETRIC:
1721 case SIOCGIFMTU:
1722 case SIOCSIFMTU:
1723 case SIOCGIFMEM:
1724 case SIOCSIFMEM:
1725 case SIOCGIFHWADDR:
1726 case SIOCSIFHWADDR:
1727 case SIOCADDMULTI:
1728 case SIOCDELMULTI:
1729 case SIOCGIFINDEX:
1730 case SIOCGIFMAP:
1731 case SIOCSIFMAP:
1732 case SIOCGIFADDR:
1733 case SIOCSIFADDR:
1734 case SIOCGIFBRDADDR:
1735 case SIOCSIFBRDADDR:
1736 case SIOCGIFDSTADDR:
1737 case SIOCSIFDSTADDR:
1738 case SIOCGIFNETMASK:
1739 case SIOCSIFNETMASK:
1740 case SIOCSIFPFLAGS:
1741 case SIOCGIFPFLAGS:
1742 case SIOCGPPPSTATS:
1743 case SIOCGPPPCSTATS:
1744 case SIOCGPPPVER:
1745 case SIOCGIFTXQLEN:
1746 case SIOCSIFTXQLEN:
1747 case SIOCETHTOOL:
1748 error = dev_ifsioc(fd, cmd, arg);
1749 goto out;
1751 case SIOCADDRT:
1752 case SIOCDELRT:
1753 error = routing_ioctl(fd, cmd, arg);
1754 goto out;
1756 case SIOCRTMSG: /* Note SIOCRTMSG is no longer, so this is safe and
1757 * the user would have seen just an -EINVAL anyways.
1759 error = -EINVAL;
1760 goto out;
1762 case SIOCGSTAMP:
1763 /* Sorry, timeval in the kernel is different now. */
1764 error = do_siocgstamp(fd, cmd, arg);
1765 goto out;
1767 case HDIO_GETGEO:
1768 error = hdio_getgeo(fd, arg);
1769 goto out;
1771 case BLKRAGET:
1772 case BLKGETSIZE:
1773 case 0x1260:
1774 /* The mkswap binary hard codes it to Intel value :-((( */
1775 if(cmd == 0x1260)
1776 cmd = BLKGETSIZE;
1777 error = w_long(fd, cmd, arg);
1778 goto out;
1780 case FBIOPUTCMAP32:
1781 case FBIOGETCMAP32:
1782 error = fbiogetputcmap(fd, cmd, arg);
1783 goto out;
1785 case FBIOSCURSOR32:
1786 error = fbiogscursor(fd, cmd, arg);
1787 goto out;
1789 case FBIOGET_FSCREENINFO:
1790 case FBIOGETCMAP:
1791 case FBIOPUTCMAP:
1792 error = fb_ioctl_trans(fd, cmd, arg);
1793 goto out;
1795 case HDIO_GET_KEEPSETTINGS:
1796 case HDIO_GET_UNMASKINTR:
1797 case HDIO_GET_DMA:
1798 case HDIO_GET_32BIT:
1799 case HDIO_GET_MULTCOUNT:
1800 case HDIO_GET_NOWERR:
1801 case HDIO_GET_NICE:
1802 error = hdio_ioctl_trans(fd, cmd, arg);
1803 goto out;
1805 case FDSETPRM32:
1806 case FDDEFPRM32:
1807 case FDGETPRM32:
1808 case FDSETDRVPRM32:
1809 case FDGETDRVPRM32:
1810 case FDGETDRVSTAT32:
1811 case FDPOLLDRVSTAT32:
1812 case FDGETFDCSTAT32:
1813 case FDWERRORGET32:
1814 error = fd_ioctl_trans(fd, cmd, arg);
1815 goto out;
1817 case PPPIOCGIDLE32:
1818 case PPPIOCSCOMPRESS32:
1819 error = ppp_ioctl_trans(fd, cmd, arg);
1820 goto out;
1822 case MTIOCGET32:
1823 case MTIOCPOS32:
1824 case MTIOCGETCONFIG32:
1825 case MTIOCSETCONFIG32:
1826 error = mt_ioctl_trans(fd, cmd, arg);
1827 goto out;
1829 case CDROMREADMODE2:
1830 case CDROMREADMODE1:
1831 case CDROMREADRAW:
1832 case CDROMREADCOOKED:
1833 case CDROMREADAUDIO:
1834 case CDROMREADALL:
1835 error = cdrom_ioctl_trans(fd, cmd, arg);
1836 goto out;
1838 case LOOP_SET_STATUS:
1839 case LOOP_GET_STATUS:
1840 error = loop_status(fd, cmd, arg);
1841 goto out;
1843 #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
1844 case AUTOFS_IOC_SETTIMEOUT32:
1845 error = rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
1846 goto out;
1848 case PIO_FONTX:
1849 case GIO_FONTX:
1850 error = do_fontx_ioctl(filp, cmd, (struct consolefontdesc32 *)arg);
1851 goto out;
1853 case PIO_UNIMAP:
1854 case GIO_UNIMAP:
1855 error = do_unimap_ioctl(filp, cmd, (struct unimapdesc32 *)arg);
1856 goto out;
1858 case KDFONTOP:
1859 error = do_kdfontop_ioctl(filp, (struct console_font_op32 *)arg);
1860 goto out;
1862 case EXT2_IOC32_GETFLAGS:
1863 case EXT2_IOC32_SETFLAGS:
1864 case EXT2_IOC32_GETVERSION:
1865 case EXT2_IOC32_SETVERSION:
1866 error = do_ext2_ioctl(fd, cmd, arg);
1867 goto out;
1869 case VIDIOCGTUNER32:
1870 case VIDIOCSTUNER32:
1871 case VIDIOCGWIN32:
1872 case VIDIOCSWIN32:
1873 case VIDIOCGFBUF32:
1874 case VIDIOCSFBUF32:
1875 case VIDIOCGFREQ32:
1876 case VIDIOCSFREQ32:
1877 error = do_video_ioctl(fd, cmd, arg);
1878 goto out;
1880 /* List here exlicitly which ioctl's are known to have
1881 * compatable types passed or none at all...
1884 /* Big T */
1885 case TCGETA:
1886 case TCSETA:
1887 case TCSETAW:
1888 case TCSETAF:
1889 case TCSBRK:
1890 case TCXONC:
1891 case TCFLSH:
1892 case TCGETS:
1893 case TCSETS:
1894 case TCSETSW:
1895 case TCSETSF:
1896 case TIOCLINUX:
1898 /* Little t */
1899 case TIOCGETD:
1900 case TIOCSETD:
1901 case TIOCEXCL:
1902 case TIOCNXCL:
1903 case TIOCCONS:
1904 case TIOCGSOFTCAR:
1905 case TIOCSSOFTCAR:
1906 case TIOCSWINSZ:
1907 case TIOCGWINSZ:
1908 case TIOCMGET:
1909 case TIOCMBIC:
1910 case TIOCMBIS:
1911 case TIOCMSET:
1912 case TIOCPKT:
1913 case TIOCNOTTY:
1914 case TIOCSTI:
1915 case TIOCOUTQ:
1916 case TIOCSPGRP:
1917 case TIOCGPGRP:
1918 case TIOCSCTTY:
1919 case TIOCGPTN:
1920 case TIOCSPTLCK:
1922 /* Big F */
1923 case FBIOGTYPE:
1924 case FBIOSATTR:
1925 case FBIOGATTR:
1926 case FBIOSVIDEO:
1927 case FBIOGVIDEO:
1928 case FBIOGCURSOR32: /* This is not implemented yet. Later it should be converted... */
1929 case FBIOSCURPOS:
1930 case FBIOGCURPOS:
1931 case FBIOGCURMAX:
1933 case FBIOGET_VSCREENINFO:
1934 case FBIOPUT_VSCREENINFO:
1935 case FBIOPAN_DISPLAY:
1936 case FBIOGET_FCURSORINFO:
1937 case FBIOGET_VCURSORINFO:
1938 case FBIOPUT_VCURSORINFO:
1939 case FBIOGET_CURSORSTATE:
1940 case FBIOPUT_CURSORSTATE:
1941 case FBIOGET_CON2FBMAP:
1942 case FBIOPUT_CON2FBMAP:
1944 /* Little f */
1945 case FIOCLEX:
1946 case FIONCLEX:
1947 case FIOASYNC:
1948 case FIONBIO:
1949 case FIONREAD: /* This is also TIOCINQ */
1951 /* 0x00 */
1952 case FIBMAP:
1953 case FIGETBSZ:
1955 /* 0x03 -- HD/IDE ioctl's used by hdparm and friends.
1956 * Some need translations, these do not.
1958 case HDIO_GET_IDENTITY:
1959 case HDIO_SET_DMA:
1960 case HDIO_SET_KEEPSETTINGS:
1961 case HDIO_SET_UNMASKINTR:
1962 case HDIO_SET_NOWERR:
1963 case HDIO_SET_32BIT:
1964 case HDIO_SET_MULTCOUNT:
1965 case HDIO_DRIVE_CMD:
1966 case HDIO_SET_PIO_MODE:
1967 case HDIO_SCAN_HWIF:
1968 case HDIO_SET_NICE:
1969 case BLKROSET:
1970 case BLKROGET:
1972 /* 0x02 -- Floppy ioctls */
1973 case FDMSGON:
1974 case FDMSGOFF:
1975 case FDSETEMSGTRESH:
1976 case FDFLUSH:
1977 case FDWERRORCLR:
1978 case FDSETMAXERRS:
1979 case FDGETMAXERRS:
1980 case FDGETDRVTYP:
1981 case FDEJECT:
1982 case FDCLRPRM:
1983 case FDFMTBEG:
1984 case FDFMTEND:
1985 case FDRESET:
1986 case FDTWADDLE:
1987 case FDFMTTRK:
1988 case FDRAWCMD:
1990 /* 0x12 */
1991 case BLKRRPART:
1992 case BLKFLSBUF:
1993 case BLKRASET:
1995 /* 0x09 */
1996 case REGISTER_DEV:
1997 case REGISTER_DEV_NEW:
1998 case START_MD:
1999 case STOP_MD:
2001 /* Big K */
2002 case PIO_FONT:
2003 case GIO_FONT:
2004 case KDSIGACCEPT:
2005 case KDGETKEYCODE:
2006 case KDSETKEYCODE:
2007 case KIOCSOUND:
2008 case KDMKTONE:
2009 case KDGKBTYPE:
2010 case KDSETMODE:
2011 case KDGETMODE:
2012 case KDSKBMODE:
2013 case KDGKBMODE:
2014 case KDSKBMETA:
2015 case KDGKBMETA:
2016 case KDGKBENT:
2017 case KDSKBENT:
2018 case KDGKBSENT:
2019 case KDSKBSENT:
2020 case KDGKBDIACR:
2021 case KDSKBDIACR:
2022 case KDGKBLED:
2023 case KDSKBLED:
2024 case KDGETLED:
2025 case KDSETLED:
2026 case GIO_SCRNMAP:
2027 case PIO_SCRNMAP:
2028 case GIO_UNISCRNMAP:
2029 case PIO_UNISCRNMAP:
2030 case PIO_FONTRESET:
2031 case PIO_UNIMAPCLR:
2033 /* Little k */
2034 case KIOCTYPE:
2035 case KIOCLAYOUT:
2036 case KIOCGTRANS:
2037 case KIOCTRANS:
2038 case KIOCCMD:
2039 case KIOCSDIRECT:
2040 case KIOCSLED:
2041 case KIOCGLED:
2042 case KIOCSRATE:
2043 case KIOCGRATE:
2045 /* Big S */
2046 case SCSI_IOCTL_GET_IDLUN:
2047 case SCSI_IOCTL_DOORLOCK:
2048 case SCSI_IOCTL_DOORUNLOCK:
2049 case SCSI_IOCTL_TEST_UNIT_READY:
2050 case SCSI_IOCTL_TAGGED_ENABLE:
2051 case SCSI_IOCTL_TAGGED_DISABLE:
2052 case SCSI_IOCTL_GET_BUS_NUMBER:
2053 case SCSI_IOCTL_SEND_COMMAND:
2055 /* Big V */
2056 case VT_SETMODE:
2057 case VT_GETMODE:
2058 case VT_GETSTATE:
2059 case VT_OPENQRY:
2060 case VT_ACTIVATE:
2061 case VT_WAITACTIVE:
2062 case VT_RELDISP:
2063 case VT_DISALLOCATE:
2064 case VT_RESIZE:
2065 case VT_RESIZEX:
2066 case VT_LOCKSWITCH:
2067 case VT_UNLOCKSWITCH:
2069 /* Little v */
2070 case VUIDSFORMAT:
2071 case VUIDGFORMAT:
2073 /* Little v, the video4linux ioctls */
2074 case VIDIOCGCAP:
2075 case VIDIOCGCHAN:
2076 case VIDIOCSCHAN:
2077 case VIDIOCGPICT:
2078 case VIDIOCSPICT:
2079 case VIDIOCCAPTURE:
2080 case VIDIOCKEY:
2081 case VIDIOCGAUDIO:
2082 case VIDIOCSAUDIO:
2083 case VIDIOCSYNC:
2084 case VIDIOCMCAPTURE:
2085 case VIDIOCGMBUF:
2086 case VIDIOCGUNIT:
2087 case VIDIOCGCAPTURE:
2088 case VIDIOCSCAPTURE:
2090 /* BTTV specific... */
2091 case _IOW('v', BASE_VIDIOCPRIVATE+0, char [256]):
2092 case _IOR('v', BASE_VIDIOCPRIVATE+1, char [256]):
2093 case _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int):
2094 case _IOW('v' , BASE_VIDIOCPRIVATE+3, char [16]): /* struct bttv_pll_info */
2095 case _IOR('v' , BASE_VIDIOCPRIVATE+4, int):
2096 case _IOR('v' , BASE_VIDIOCPRIVATE+5, int):
2097 case _IOR('v' , BASE_VIDIOCPRIVATE+6, int):
2098 case _IOR('v' , BASE_VIDIOCPRIVATE+7, int):
2100 /* Little p (/dev/rtc, /dev/envctrl, etc.) */
2101 case RTCGET:
2102 case RTCSET:
2103 case I2CIOCSADR:
2104 case I2CIOCGADR:
2106 /* Little m */
2107 case MTIOCTOP:
2109 /* OPENPROMIO, SunOS/Solaris only, the NetBSD one's have
2110 * embedded pointers in the arg which we'd need to clean up...
2112 case OPROMGETOPT:
2113 case OPROMSETOPT:
2114 case OPROMNXTOPT:
2115 case OPROMSETOPT2:
2116 case OPROMNEXT:
2117 case OPROMCHILD:
2118 case OPROMGETPROP:
2119 case OPROMNXTPROP:
2120 case OPROMU2P:
2121 case OPROMGETCONS:
2122 case OPROMGETFBNAME:
2123 case OPROMGETBOOTARGS:
2125 /* Socket level stuff */
2126 case FIOSETOWN:
2127 case SIOCSPGRP:
2128 case FIOGETOWN:
2129 case SIOCGPGRP:
2130 case SIOCATMARK:
2131 case SIOCSIFLINK:
2132 case SIOCSIFENCAP:
2133 case SIOCGIFENCAP:
2134 case SIOCSIFBR:
2135 case SIOCGIFBR:
2136 case SIOCSARP:
2137 case SIOCGARP:
2138 case SIOCDARP:
2139 #if 0 /* XXX No longer exist in new routing code. XXX */
2140 case OLD_SIOCSARP:
2141 case OLD_SIOCGARP:
2142 case OLD_SIOCDARP:
2143 #endif
2144 case SIOCSRARP:
2145 case SIOCGRARP:
2146 case SIOCDRARP:
2147 case SIOCADDDLCI:
2148 case SIOCDELDLCI:
2150 /* SG stuff */
2151 case SG_SET_TIMEOUT:
2152 case SG_GET_TIMEOUT:
2153 case SG_EMULATED_HOST:
2154 case SG_SET_TRANSFORM:
2155 case SG_GET_TRANSFORM:
2157 /* PPP stuff */
2158 case PPPIOCGFLAGS:
2159 case PPPIOCSFLAGS:
2160 case PPPIOCGASYNCMAP:
2161 case PPPIOCSASYNCMAP:
2162 case PPPIOCGUNIT:
2163 case PPPIOCGRASYNCMAP:
2164 case PPPIOCSRASYNCMAP:
2165 case PPPIOCGMRU:
2166 case PPPIOCSMRU:
2167 case PPPIOCSMAXCID:
2168 case PPPIOCGXASYNCMAP:
2169 case PPPIOCSXASYNCMAP:
2170 case PPPIOCXFERUNIT:
2171 case PPPIOCGNPMODE:
2172 case PPPIOCSNPMODE:
2173 case PPPIOCGDEBUG:
2174 case PPPIOCSDEBUG:
2176 /* CDROM stuff */
2177 case CDROMPAUSE:
2178 case CDROMRESUME:
2179 case CDROMPLAYMSF:
2180 case CDROMPLAYTRKIND:
2181 case CDROMREADTOCHDR:
2182 case CDROMREADTOCENTRY:
2183 case CDROMSTOP:
2184 case CDROMSTART:
2185 case CDROMEJECT:
2186 case CDROMVOLCTRL:
2187 case CDROMSUBCHNL:
2188 case CDROMEJECT_SW:
2189 case CDROMMULTISESSION:
2190 case CDROM_GET_MCN:
2191 case CDROMRESET:
2192 case CDROMVOLREAD:
2193 case CDROMSEEK:
2194 case CDROMPLAYBLK:
2195 case CDROMCLOSETRAY:
2196 case CDROM_SET_OPTIONS:
2197 case CDROM_CLEAR_OPTIONS:
2198 case CDROM_SELECT_SPEED:
2199 case CDROM_SELECT_DISC:
2200 case CDROM_MEDIA_CHANGED:
2201 case CDROM_DRIVE_STATUS:
2202 case CDROM_DISC_STATUS:
2203 case CDROM_CHANGER_NSLOTS:
2205 /* Big L */
2206 case LOOP_SET_FD:
2207 case LOOP_CLR_FD:
2209 /* Big A */
2210 case AUDIO_GETINFO:
2211 case AUDIO_SETINFO:
2212 case AUDIO_DRAIN:
2213 case AUDIO_GETDEV:
2214 case AUDIO_GETDEV_SUNOS:
2215 case AUDIO_FLUSH:
2217 /* Big Q for sound/OSS */
2218 case SNDCTL_SEQ_RESET:
2219 case SNDCTL_SEQ_SYNC:
2220 case SNDCTL_SYNTH_INFO:
2221 case SNDCTL_SEQ_CTRLRATE:
2222 case SNDCTL_SEQ_GETOUTCOUNT:
2223 case SNDCTL_SEQ_GETINCOUNT:
2224 case SNDCTL_SEQ_PERCMODE:
2225 case SNDCTL_FM_LOAD_INSTR:
2226 case SNDCTL_SEQ_TESTMIDI:
2227 case SNDCTL_SEQ_RESETSAMPLES:
2228 case SNDCTL_SEQ_NRSYNTHS:
2229 case SNDCTL_SEQ_NRMIDIS:
2230 case SNDCTL_MIDI_INFO:
2231 case SNDCTL_SEQ_THRESHOLD:
2232 case SNDCTL_SYNTH_MEMAVL:
2233 case SNDCTL_FM_4OP_ENABLE:
2234 case SNDCTL_SEQ_PANIC:
2235 case SNDCTL_SEQ_OUTOFBAND:
2236 case SNDCTL_SEQ_GETTIME:
2237 case SNDCTL_SYNTH_ID:
2238 case SNDCTL_SYNTH_CONTROL:
2239 case SNDCTL_SYNTH_REMOVESAMPLE:
2241 /* Big T for sound/OSS */
2242 case SNDCTL_TMR_TIMEBASE:
2243 case SNDCTL_TMR_START:
2244 case SNDCTL_TMR_STOP:
2245 case SNDCTL_TMR_CONTINUE:
2246 case SNDCTL_TMR_TEMPO:
2247 case SNDCTL_TMR_SOURCE:
2248 case SNDCTL_TMR_METRONOME:
2249 case SNDCTL_TMR_SELECT:
2251 /* Little m for sound/OSS */
2252 case SNDCTL_MIDI_PRETIME:
2253 case SNDCTL_MIDI_MPUMODE:
2254 case SNDCTL_MIDI_MPUCMD:
2256 /* Big P for sound/OSS */
2257 case SNDCTL_DSP_RESET:
2258 case SNDCTL_DSP_SYNC:
2259 case SNDCTL_DSP_SPEED:
2260 case SNDCTL_DSP_STEREO:
2261 case SNDCTL_DSP_GETBLKSIZE:
2262 case SNDCTL_DSP_CHANNELS:
2263 case SOUND_PCM_WRITE_FILTER:
2264 case SNDCTL_DSP_POST:
2265 case SNDCTL_DSP_SUBDIVIDE:
2266 case SNDCTL_DSP_SETFRAGMENT:
2267 case SNDCTL_DSP_GETFMTS:
2268 case SNDCTL_DSP_SETFMT:
2269 case SNDCTL_DSP_GETOSPACE:
2270 case SNDCTL_DSP_GETISPACE:
2271 case SNDCTL_DSP_NONBLOCK:
2272 case SNDCTL_DSP_GETCAPS:
2273 case SNDCTL_DSP_GETTRIGGER:
2274 case SNDCTL_DSP_SETTRIGGER:
2275 case SNDCTL_DSP_GETIPTR:
2276 case SNDCTL_DSP_GETOPTR:
2277 /* case SNDCTL_DSP_MAPINBUF: XXX needs translation */
2278 /* case SNDCTL_DSP_MAPOUTBUF: XXX needs translation */
2279 case SNDCTL_DSP_SETSYNCRO:
2280 case SNDCTL_DSP_SETDUPLEX:
2281 case SNDCTL_DSP_GETODELAY:
2282 case SNDCTL_DSP_PROFILE:
2284 case SOUND_PCM_READ_RATE:
2285 case SOUND_PCM_READ_CHANNELS:
2286 case SOUND_PCM_READ_BITS:
2287 case SOUND_PCM_READ_FILTER:
2289 /* Big C for sound/OSS */
2290 case SNDCTL_COPR_RESET:
2291 case SNDCTL_COPR_LOAD:
2292 case SNDCTL_COPR_RDATA:
2293 case SNDCTL_COPR_RCODE:
2294 case SNDCTL_COPR_WDATA:
2295 case SNDCTL_COPR_WCODE:
2296 case SNDCTL_COPR_RUN:
2297 case SNDCTL_COPR_HALT:
2298 case SNDCTL_COPR_SENDMSG:
2299 case SNDCTL_COPR_RCVMSG:
2301 /* Big M for sound/OSS */
2302 case SOUND_MIXER_READ_VOLUME:
2303 case SOUND_MIXER_READ_BASS:
2304 case SOUND_MIXER_READ_TREBLE:
2305 case SOUND_MIXER_READ_SYNTH:
2306 case SOUND_MIXER_READ_PCM:
2307 case SOUND_MIXER_READ_SPEAKER:
2308 case SOUND_MIXER_READ_LINE:
2309 case SOUND_MIXER_READ_MIC:
2310 case SOUND_MIXER_READ_CD:
2311 case SOUND_MIXER_READ_IMIX:
2312 case SOUND_MIXER_READ_ALTPCM:
2313 case SOUND_MIXER_READ_RECLEV:
2314 case SOUND_MIXER_READ_IGAIN:
2315 case SOUND_MIXER_READ_OGAIN:
2316 case SOUND_MIXER_READ_LINE1:
2317 case SOUND_MIXER_READ_LINE2:
2318 case SOUND_MIXER_READ_LINE3:
2319 case SOUND_MIXER_READ_MUTE:
2320 /* case SOUND_MIXER_READ_ENHANCE: same value as READ_MUTE */
2321 /* case SOUND_MIXER_READ_LOUD: same value as READ_MUTE */
2322 case SOUND_MIXER_READ_RECSRC:
2323 case SOUND_MIXER_READ_DEVMASK:
2324 case SOUND_MIXER_READ_RECMASK:
2325 case SOUND_MIXER_READ_STEREODEVS:
2326 case SOUND_MIXER_READ_CAPS:
2328 case SOUND_MIXER_WRITE_VOLUME:
2329 case SOUND_MIXER_WRITE_BASS:
2330 case SOUND_MIXER_WRITE_TREBLE:
2331 case SOUND_MIXER_WRITE_SYNTH:
2332 case SOUND_MIXER_WRITE_PCM:
2333 case SOUND_MIXER_WRITE_SPEAKER:
2334 case SOUND_MIXER_WRITE_LINE:
2335 case SOUND_MIXER_WRITE_MIC:
2336 case SOUND_MIXER_WRITE_CD:
2337 case SOUND_MIXER_WRITE_IMIX:
2338 case SOUND_MIXER_WRITE_ALTPCM:
2339 case SOUND_MIXER_WRITE_RECLEV:
2340 case SOUND_MIXER_WRITE_IGAIN:
2341 case SOUND_MIXER_WRITE_OGAIN:
2342 case SOUND_MIXER_WRITE_LINE1:
2343 case SOUND_MIXER_WRITE_LINE2:
2344 case SOUND_MIXER_WRITE_LINE3:
2345 case SOUND_MIXER_WRITE_MUTE:
2346 /* case SOUND_MIXER_WRITE_ENHANCE: same value as WRITE_MUTE */
2347 /* case SOUND_MIXER_WRITE_LOUD: same value as WRITE_MUTE */
2348 case SOUND_MIXER_WRITE_RECSRC:
2350 case SOUND_MIXER_INFO:
2351 case SOUND_OLD_MIXER_INFO:
2352 case SOUND_MIXER_ACCESS:
2353 case SOUND_MIXER_PRIVATE1:
2354 case SOUND_MIXER_PRIVATE2:
2355 case SOUND_MIXER_PRIVATE3:
2356 case SOUND_MIXER_PRIVATE4:
2357 case SOUND_MIXER_PRIVATE5:
2358 case SOUND_MIXER_GETLEVELS:
2359 case SOUND_MIXER_SETLEVELS:
2361 case OSS_GETVERSION:
2363 /* AUTOFS */
2364 case AUTOFS_IOC_READY:
2365 case AUTOFS_IOC_FAIL:
2366 case AUTOFS_IOC_CATATONIC:
2367 case AUTOFS_IOC_PROTOVER:
2368 case AUTOFS_IOC_EXPIRE:
2370 /* Raw devices */
2371 case RAW_SETBIND:
2372 case RAW_GETBIND:
2374 error = sys_ioctl (fd, cmd, arg);
2375 goto out;
2377 default:
2378 do {
2379 static int count = 0;
2380 if (++count <= 20)
2381 printk("sys32_ioctl: Unknown cmd fd(%d) "
2382 "cmd(%08x) arg(%08x)\n",
2383 (int)fd, (unsigned int)cmd, (unsigned int)arg);
2384 } while(0);
2385 error = -EINVAL;
2386 break;
2388 out:
2389 fput(filp);
2390 out2:
2391 unlock_kernel();
2392 return error;