* better
[mascara-docs.git] / i386 / linux-2.3.21 / arch / sparc64 / kernel / ioctl32.c
blob0affcf0eb875ca3a83661cf60dba60ffc5a75b95
1 /* $Id: ioctl32.c,v 1.68 1999/09/10 05:59:25 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 char ifru_newname[IFNAMSIZ];
414 __kernel_caddr_t32 ifru_data;
415 } ifr_ifru;
418 struct ifconf32 {
419 int ifc_len; /* size of buffer */
420 __kernel_caddr_t32 ifcbuf;
423 static int dev_ifname32(unsigned int fd, unsigned long arg)
425 struct net_device *dev;
426 struct ifreq32 ifr32;
427 int err;
429 if (copy_from_user(&ifr32, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
430 return -EFAULT;
432 dev = dev_get_by_index(ifr32.ifr_ifindex);
433 if (!dev)
434 return -ENODEV;
436 strcpy(ifr32.ifr_name, dev->name);
438 err = copy_to_user((struct ifreq32 *)arg, &ifr32, sizeof(struct ifreq32));
439 return (err ? -EFAULT : 0);
442 static inline int dev_ifconf(unsigned int fd, unsigned long arg)
444 struct ifconf32 ifc32;
445 struct ifconf ifc;
446 struct ifreq32 *ifr32;
447 struct ifreq *ifr;
448 mm_segment_t old_fs;
449 unsigned int i, j;
450 int err;
452 if (copy_from_user(&ifc32, (struct ifconf32 *)arg, sizeof(struct ifconf32)))
453 return -EFAULT;
455 if(ifc32.ifcbuf == 0) {
456 ifc32.ifc_len = 0;
457 ifc.ifc_len = 0;
458 ifc.ifc_buf = NULL;
459 } else {
460 ifc.ifc_len = ((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) *
461 sizeof (struct ifreq);
462 ifc.ifc_buf = kmalloc (ifc.ifc_len, GFP_KERNEL);
463 if (!ifc.ifc_buf)
464 return -ENOMEM;
466 ifr = ifc.ifc_req;
467 ifr32 = (struct ifreq32 *)A(ifc32.ifcbuf);
468 for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) {
469 if (copy_from_user(ifr++, ifr32++, sizeof (struct ifreq32))) {
470 kfree (ifc.ifc_buf);
471 return -EFAULT;
474 old_fs = get_fs(); set_fs (KERNEL_DS);
475 err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)&ifc);
476 set_fs (old_fs);
477 if (!err) {
478 ifr = ifc.ifc_req;
479 ifr32 = (struct ifreq32 *)A(ifc32.ifcbuf);
480 for (i = 0, j = 0; i < ifc32.ifc_len && j < ifc.ifc_len;
481 i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
482 if (copy_to_user(ifr32++, ifr++, sizeof (struct ifreq32))) {
483 err = -EFAULT;
484 break;
487 if (!err) {
488 if (i <= ifc32.ifc_len)
489 ifc32.ifc_len = i;
490 else
491 ifc32.ifc_len = i - sizeof (struct ifreq32);
492 if (copy_to_user((struct ifconf32 *)arg, &ifc32, sizeof(struct ifconf32)))
493 err = -EFAULT;
496 if(ifc.ifc_buf != NULL)
497 kfree (ifc.ifc_buf);
498 return err;
501 static inline int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg)
503 struct ifreq ifr;
504 mm_segment_t old_fs;
505 int err;
507 switch (cmd) {
508 case SIOCSIFMAP:
509 err = copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(ifr.ifr_name));
510 err |= __get_user(ifr.ifr_map.mem_start, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_start));
511 err |= __get_user(ifr.ifr_map.mem_end, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_end));
512 err |= __get_user(ifr.ifr_map.base_addr, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.base_addr));
513 err |= __get_user(ifr.ifr_map.irq, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.irq));
514 err |= __get_user(ifr.ifr_map.dma, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.dma));
515 err |= __get_user(ifr.ifr_map.port, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.port));
516 if (err)
517 return -EFAULT;
518 break;
519 case SIOCGPPPSTATS:
520 case SIOCGPPPCSTATS:
521 case SIOCGPPPVER:
522 case SIOCETHTOOL:
523 if (copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
524 return -EFAULT;
525 ifr.ifr_data = (__kernel_caddr_t)get_free_page(GFP_KERNEL);
526 if (!ifr.ifr_data)
527 return -EAGAIN;
528 if(cmd == SIOCETHTOOL) {
529 u32 data;
531 __get_user(data, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_data));
532 if(copy_from_user(ifr.ifr_data,
533 (char *)A(data),
534 sizeof(struct ethtool_cmd))) {
535 free_page((unsigned long)ifr.ifr_data);
536 return -EFAULT;
539 break;
540 default:
541 if (copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
542 return -EFAULT;
543 break;
545 old_fs = get_fs();
546 set_fs (KERNEL_DS);
547 err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
548 set_fs (old_fs);
549 if (!err) {
550 switch (cmd) {
551 case SIOCGIFFLAGS:
552 case SIOCGIFMETRIC:
553 case SIOCGIFMTU:
554 case SIOCGIFMEM:
555 case SIOCGIFHWADDR:
556 case SIOCGIFINDEX:
557 case SIOCGIFADDR:
558 case SIOCGIFBRDADDR:
559 case SIOCGIFDSTADDR:
560 case SIOCGIFNETMASK:
561 case SIOCGIFTXQLEN:
562 if (copy_to_user((struct ifreq32 *)arg, &ifr, sizeof(struct ifreq32)))
563 return -EFAULT;
564 break;
565 case SIOCGPPPSTATS:
566 case SIOCGPPPCSTATS:
567 case SIOCGPPPVER:
568 case SIOCETHTOOL:
570 u32 data;
571 int len;
573 __get_user(data, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_data));
574 if(cmd == SIOCETHTOOL)
575 len = sizeof(struct ethtool_cmd);
576 if(cmd == SIOCGPPPVER)
577 len = strlen((char *)ifr.ifr_data) + 1;
578 else if(cmd == SIOCGPPPCSTATS)
579 len = sizeof(struct ppp_comp_stats);
580 else
581 len = sizeof(struct ppp_stats);
583 len = copy_to_user((char *)A(data), ifr.ifr_data, len);
584 free_page((unsigned long)ifr.ifr_data);
585 if(len)
586 return -EFAULT;
587 break;
589 case SIOCGIFMAP:
590 err = copy_to_user((struct ifreq32 *)arg, &ifr, sizeof(ifr.ifr_name));
591 err |= __put_user(ifr.ifr_map.mem_start, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_start));
592 err |= __put_user(ifr.ifr_map.mem_end, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_end));
593 err |= __put_user(ifr.ifr_map.base_addr, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.base_addr));
594 err |= __put_user(ifr.ifr_map.irq, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.irq));
595 err |= __put_user(ifr.ifr_map.dma, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.dma));
596 err |= __put_user(ifr.ifr_map.port, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.port));
597 break;
600 return err;
603 struct rtentry32 {
604 u32 rt_pad1;
605 struct sockaddr rt_dst; /* target address */
606 struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
607 struct sockaddr rt_genmask; /* target network mask (IP) */
608 unsigned short rt_flags;
609 short rt_pad2;
610 u32 rt_pad3;
611 unsigned char rt_tos;
612 unsigned char rt_class;
613 short rt_pad4;
614 short rt_metric; /* +1 for binary compatibility! */
615 /* char * */ u32 rt_dev; /* forcing the device at add */
616 u32 rt_mtu; /* per route MTU/Window */
617 u32 rt_window; /* Window clamping */
618 unsigned short rt_irtt; /* Initial RTT */
622 static inline int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
624 struct rtentry r;
625 char devname[16];
626 u32 rtdev;
627 int ret;
628 mm_segment_t old_fs = get_fs();
630 ret = copy_from_user (&r.rt_dst, &(((struct rtentry32 *)arg)->rt_dst), 3 * sizeof(struct sockaddr));
631 ret |= __get_user (r.rt_flags, &(((struct rtentry32 *)arg)->rt_flags));
632 ret |= __get_user (r.rt_metric, &(((struct rtentry32 *)arg)->rt_metric));
633 ret |= __get_user (r.rt_mtu, &(((struct rtentry32 *)arg)->rt_mtu));
634 ret |= __get_user (r.rt_window, &(((struct rtentry32 *)arg)->rt_window));
635 ret |= __get_user (r.rt_irtt, &(((struct rtentry32 *)arg)->rt_irtt));
636 ret |= __get_user (rtdev, &(((struct rtentry32 *)arg)->rt_dev));
637 if (rtdev) {
638 ret |= copy_from_user (devname, (char *)A(rtdev), 15);
639 r.rt_dev = devname; devname[15] = 0;
640 } else
641 r.rt_dev = 0;
642 if (ret)
643 return -EFAULT;
644 set_fs (KERNEL_DS);
645 ret = sys_ioctl (fd, cmd, (long)&r);
646 set_fs (old_fs);
647 return ret;
650 struct hd_geometry32 {
651 unsigned char heads;
652 unsigned char sectors;
653 unsigned short cylinders;
654 u32 start;
657 static inline int hdio_getgeo(unsigned int fd, unsigned long arg)
659 mm_segment_t old_fs = get_fs();
660 struct hd_geometry geo;
661 int err;
663 set_fs (KERNEL_DS);
664 err = sys_ioctl(fd, HDIO_GETGEO, (unsigned long)&geo);
665 set_fs (old_fs);
666 if (!err) {
667 err = copy_to_user ((struct hd_geometry32 *)arg, &geo, 4);
668 err |= __put_user (geo.start, &(((struct hd_geometry32 *)arg)->start));
670 return err;
673 struct fbcmap32 {
674 int index; /* first element (0 origin) */
675 int count;
676 u32 red;
677 u32 green;
678 u32 blue;
681 #define FBIOPUTCMAP32 _IOW('F', 3, struct fbcmap32)
682 #define FBIOGETCMAP32 _IOW('F', 4, struct fbcmap32)
684 static inline int fbiogetputcmap(unsigned int fd, unsigned int cmd, unsigned long arg)
686 struct fbcmap f;
687 int ret;
688 char red[256], green[256], blue[256];
689 u32 r, g, b;
690 mm_segment_t old_fs = get_fs();
692 ret = get_user(f.index, &(((struct fbcmap32 *)arg)->index));
693 ret |= __get_user(f.count, &(((struct fbcmap32 *)arg)->count));
694 ret |= __get_user(r, &(((struct fbcmap32 *)arg)->red));
695 ret |= __get_user(g, &(((struct fbcmap32 *)arg)->green));
696 ret |= __get_user(b, &(((struct fbcmap32 *)arg)->blue));
697 if (ret)
698 return -EFAULT;
699 if ((f.index < 0) || (f.index > 255)) return -EINVAL;
700 if (f.index + f.count > 256)
701 f.count = 256 - f.index;
702 if (cmd == FBIOPUTCMAP32) {
703 ret = copy_from_user (red, (char *)A(r), f.count);
704 ret |= copy_from_user (green, (char *)A(g), f.count);
705 ret |= copy_from_user (blue, (char *)A(b), f.count);
706 if (ret)
707 return -EFAULT;
709 f.red = red; f.green = green; f.blue = blue;
710 set_fs (KERNEL_DS);
711 ret = sys_ioctl (fd, (cmd == FBIOPUTCMAP32) ? FBIOPUTCMAP_SPARC : FBIOGETCMAP_SPARC, (long)&f);
712 set_fs (old_fs);
713 if (!ret && cmd == FBIOGETCMAP32) {
714 ret = copy_to_user ((char *)A(r), red, f.count);
715 ret |= copy_to_user ((char *)A(g), green, f.count);
716 ret |= copy_to_user ((char *)A(b), blue, f.count);
718 return ret;
721 struct fbcursor32 {
722 short set; /* what to set, choose from the list above */
723 short enable; /* cursor on/off */
724 struct fbcurpos pos; /* cursor position */
725 struct fbcurpos hot; /* cursor hot spot */
726 struct fbcmap32 cmap; /* color map info */
727 struct fbcurpos size; /* cursor bit map size */
728 u32 image; /* cursor image bits */
729 u32 mask; /* cursor mask bits */
732 #define FBIOSCURSOR32 _IOW('F', 24, struct fbcursor32)
733 #define FBIOGCURSOR32 _IOW('F', 25, struct fbcursor32)
735 static inline int fbiogscursor(unsigned int fd, unsigned int cmd, unsigned long arg)
737 struct fbcursor f;
738 int ret;
739 char red[2], green[2], blue[2];
740 char image[128], mask[128];
741 u32 r, g, b;
742 u32 m, i;
743 mm_segment_t old_fs = get_fs();
745 ret = copy_from_user (&f, (struct fbcursor32 *)arg, 2 * sizeof (short) + 2 * sizeof(struct fbcurpos));
746 ret |= __get_user(f.size.fbx, &(((struct fbcursor32 *)arg)->size.fbx));
747 ret |= __get_user(f.size.fby, &(((struct fbcursor32 *)arg)->size.fby));
748 ret |= __get_user(f.cmap.index, &(((struct fbcursor32 *)arg)->cmap.index));
749 ret |= __get_user(f.cmap.count, &(((struct fbcursor32 *)arg)->cmap.count));
750 ret |= __get_user(r, &(((struct fbcursor32 *)arg)->cmap.red));
751 ret |= __get_user(g, &(((struct fbcursor32 *)arg)->cmap.green));
752 ret |= __get_user(b, &(((struct fbcursor32 *)arg)->cmap.blue));
753 ret |= __get_user(m, &(((struct fbcursor32 *)arg)->mask));
754 ret |= __get_user(i, &(((struct fbcursor32 *)arg)->image));
755 if (ret)
756 return -EFAULT;
757 if (f.set & FB_CUR_SETCMAP) {
758 if ((uint) f.size.fby > 32)
759 return -EINVAL;
760 ret = copy_from_user (mask, (char *)A(m), f.size.fby * 4);
761 ret |= copy_from_user (image, (char *)A(i), f.size.fby * 4);
762 if (ret)
763 return -EFAULT;
764 f.image = image; f.mask = mask;
766 if (f.set & FB_CUR_SETCMAP) {
767 ret = copy_from_user (red, (char *)A(r), 2);
768 ret |= copy_from_user (green, (char *)A(g), 2);
769 ret |= copy_from_user (blue, (char *)A(b), 2);
770 if (ret)
771 return -EFAULT;
772 f.cmap.red = red; f.cmap.green = green; f.cmap.blue = blue;
774 set_fs (KERNEL_DS);
775 ret = sys_ioctl (fd, FBIOSCURSOR, (long)&f);
776 set_fs (old_fs);
777 return ret;
780 struct fb_fix_screeninfo32 {
781 char id[16];
782 __kernel_caddr_t32 smem_start;
783 __u32 smem_len;
784 __u32 type;
785 __u32 type_aux;
786 __u32 visual;
787 __u16 xpanstep;
788 __u16 ypanstep;
789 __u16 ywrapstep;
790 __u32 line_length;
791 __kernel_caddr_t32 mmio_start;
792 __u32 mmio_len;
793 __u32 accel;
794 __u16 reserved[3];
797 struct fb_cmap32 {
798 __u32 start;
799 __u32 len;
800 __kernel_caddr_t32 red;
801 __kernel_caddr_t32 green;
802 __kernel_caddr_t32 blue;
803 __kernel_caddr_t32 transp;
806 static int fb_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
808 mm_segment_t old_fs = get_fs();
809 u32 red = 0, green = 0, blue = 0, transp = 0;
810 struct fb_fix_screeninfo fix;
811 struct fb_cmap cmap;
812 void *karg;
813 int err = 0;
815 memset(&cmap, 0, sizeof(cmap));
816 switch (cmd) {
817 case FBIOGET_FSCREENINFO:
818 karg = &fix;
819 break;
820 case FBIOGETCMAP:
821 case FBIOPUTCMAP:
822 karg = &cmap;
823 err = __get_user(cmap.start, &((struct fb_cmap32 *)arg)->start);
824 err |= __get_user(cmap.len, &((struct fb_cmap32 *)arg)->len);
825 err |= __get_user(red, &((struct fb_cmap32 *)arg)->red);
826 err |= __get_user(green, &((struct fb_cmap32 *)arg)->green);
827 err |= __get_user(blue, &((struct fb_cmap32 *)arg)->blue);
828 err |= __get_user(transp, &((struct fb_cmap32 *)arg)->transp);
829 if (err)
830 goto out;
831 err = -ENOMEM;
832 cmap.red = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
833 if (!cmap.red)
834 goto out;
835 cmap.green = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
836 if (!cmap.green)
837 goto out;
838 cmap.blue = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
839 if (!cmap.blue)
840 goto out;
841 if (transp) {
842 cmap.transp = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
843 if (!cmap.transp)
844 goto out;
847 if (cmd == FBIOGETCMAP)
848 break;
850 err = __copy_from_user(cmap.red, (char *)A(red), cmap.len * sizeof(__u16));
851 err |= __copy_from_user(cmap.green, (char *)A(green), cmap.len * sizeof(__u16));
852 err |= __copy_from_user(cmap.blue, (char *)A(blue), cmap.len * sizeof(__u16));
853 if (cmap.transp) err |= __copy_from_user(cmap.transp, (char *)A(transp), cmap.len * sizeof(__u16));
854 if (err)
855 goto out;
856 break;
857 default:
858 do {
859 static int count = 0;
860 if (++count <= 20)
861 printk("%s: Unknown fb ioctl cmd fd(%d) "
862 "cmd(%08x) arg(%08lx)\n",
863 __FUNCTION__, fd, cmd, arg);
864 } while(0);
865 return -ENOSYS;
867 set_fs(KERNEL_DS);
868 err = sys_ioctl(fd, cmd, (unsigned long)karg);
869 set_fs(old_fs);
870 if (err)
871 goto out;
872 switch (cmd) {
873 case FBIOGET_FSCREENINFO:
874 err = __copy_to_user((char *)((struct fb_fix_screeninfo32 *)arg)->id, (char *)fix.id, sizeof(fix.id));
875 err |= __put_user((__u32)(unsigned long)fix.smem_start, &((struct fb_fix_screeninfo32 *)arg)->smem_start);
876 err |= __put_user(fix.smem_len, &((struct fb_fix_screeninfo32 *)arg)->smem_len);
877 err |= __put_user(fix.type, &((struct fb_fix_screeninfo32 *)arg)->type);
878 err |= __put_user(fix.type_aux, &((struct fb_fix_screeninfo32 *)arg)->type_aux);
879 err |= __put_user(fix.visual, &((struct fb_fix_screeninfo32 *)arg)->visual);
880 err |= __put_user(fix.xpanstep, &((struct fb_fix_screeninfo32 *)arg)->xpanstep);
881 err |= __put_user(fix.ypanstep, &((struct fb_fix_screeninfo32 *)arg)->ypanstep);
882 err |= __put_user(fix.ywrapstep, &((struct fb_fix_screeninfo32 *)arg)->ywrapstep);
883 err |= __put_user(fix.line_length, &((struct fb_fix_screeninfo32 *)arg)->line_length);
884 err |= __put_user((__u32)(unsigned long)fix.mmio_start, &((struct fb_fix_screeninfo32 *)arg)->mmio_start);
885 err |= __put_user(fix.mmio_len, &((struct fb_fix_screeninfo32 *)arg)->mmio_len);
886 err |= __put_user(fix.accel, &((struct fb_fix_screeninfo32 *)arg)->accel);
887 err |= __copy_to_user((char *)((struct fb_fix_screeninfo32 *)arg)->reserved, (char *)fix.reserved, sizeof(fix.reserved));
888 break;
889 case FBIOGETCMAP:
890 err = __copy_to_user((char *)A(red), cmap.red, cmap.len * sizeof(__u16));
891 err |= __copy_to_user((char *)A(green), cmap.blue, cmap.len * sizeof(__u16));
892 err |= __copy_to_user((char *)A(blue), cmap.blue, cmap.len * sizeof(__u16));
893 if (cmap.transp)
894 err |= __copy_to_user((char *)A(transp), cmap.transp, cmap.len * sizeof(__u16));
895 break;
896 case FBIOPUTCMAP:
897 break;
899 out: if (cmap.red) kfree(cmap.red);
900 if (cmap.green) kfree(cmap.green);
901 if (cmap.blue) kfree(cmap.blue);
902 if (cmap.transp) kfree(cmap.transp);
903 return err;
906 static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
908 mm_segment_t old_fs = get_fs();
909 unsigned long kval;
910 unsigned int *uvp;
911 int error;
913 set_fs(KERNEL_DS);
914 error = sys_ioctl(fd, cmd, (long)&kval);
915 set_fs(old_fs);
917 if(error == 0) {
918 uvp = (unsigned int *)arg;
919 if(put_user(kval, uvp))
920 error = -EFAULT;
922 return error;
925 struct floppy_struct32 {
926 unsigned int size;
927 unsigned int sect;
928 unsigned int head;
929 unsigned int track;
930 unsigned int stretch;
931 unsigned char gap;
932 unsigned char rate;
933 unsigned char spec1;
934 unsigned char fmt_gap;
935 const __kernel_caddr_t32 name;
938 struct floppy_drive_params32 {
939 char cmos;
940 u32 max_dtr;
941 u32 hlt;
942 u32 hut;
943 u32 srt;
944 u32 spinup;
945 u32 spindown;
946 unsigned char spindown_offset;
947 unsigned char select_delay;
948 unsigned char rps;
949 unsigned char tracks;
950 u32 timeout;
951 unsigned char interleave_sect;
952 struct floppy_max_errors max_errors;
953 char flags;
954 char read_track;
955 short autodetect[8];
956 int checkfreq;
957 int native_format;
960 struct floppy_drive_struct32 {
961 signed char flags;
962 u32 spinup_date;
963 u32 select_date;
964 u32 first_read_date;
965 short probed_format;
966 short track;
967 short maxblock;
968 short maxtrack;
969 int generation;
970 int keep_data;
971 int fd_ref;
972 int fd_device;
973 int last_checked;
974 __kernel_caddr_t32 dmabuf;
975 int bufblocks;
978 struct floppy_fdc_state32 {
979 int spec1;
980 int spec2;
981 int dtr;
982 unsigned char version;
983 unsigned char dor;
984 u32 address;
985 unsigned int rawcmd:2;
986 unsigned int reset:1;
987 unsigned int need_configure:1;
988 unsigned int perp_mode:2;
989 unsigned int has_fifo:1;
990 unsigned int driver_version;
991 unsigned char track[4];
994 struct floppy_write_errors32 {
995 unsigned int write_errors;
996 u32 first_error_sector;
997 int first_error_generation;
998 u32 last_error_sector;
999 int last_error_generation;
1000 unsigned int badness;
1003 #define FDSETPRM32 _IOW(2, 0x42, struct floppy_struct32)
1004 #define FDDEFPRM32 _IOW(2, 0x43, struct floppy_struct32)
1005 #define FDGETPRM32 _IOR(2, 0x04, struct floppy_struct32)
1006 #define FDSETDRVPRM32 _IOW(2, 0x90, struct floppy_drive_params32)
1007 #define FDGETDRVPRM32 _IOR(2, 0x11, struct floppy_drive_params32)
1008 #define FDGETDRVSTAT32 _IOR(2, 0x12, struct floppy_drive_struct32)
1009 #define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct floppy_drive_struct32)
1010 #define FDGETFDCSTAT32 _IOR(2, 0x15, struct floppy_fdc_state32)
1011 #define FDWERRORGET32 _IOR(2, 0x17, struct floppy_write_errors32)
1013 static struct {
1014 unsigned int cmd32;
1015 unsigned int cmd;
1016 } fd_ioctl_trans_table[] = {
1017 { FDSETPRM32, FDSETPRM },
1018 { FDDEFPRM32, FDDEFPRM },
1019 { FDGETPRM32, FDGETPRM },
1020 { FDSETDRVPRM32, FDSETDRVPRM },
1021 { FDGETDRVPRM32, FDGETDRVPRM },
1022 { FDGETDRVSTAT32, FDGETDRVSTAT },
1023 { FDPOLLDRVSTAT32, FDPOLLDRVSTAT },
1024 { FDGETFDCSTAT32, FDGETFDCSTAT },
1025 { FDWERRORGET32, FDWERRORGET }
1028 #define NR_FD_IOCTL_TRANS (sizeof(fd_ioctl_trans_table)/sizeof(fd_ioctl_trans_table[0]))
1030 static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1032 mm_segment_t old_fs = get_fs();
1033 void *karg = NULL;
1034 unsigned int kcmd = 0;
1035 int i, err;
1037 for (i = 0; i < NR_FD_IOCTL_TRANS; i++)
1038 if (cmd == fd_ioctl_trans_table[i].cmd32) {
1039 kcmd = fd_ioctl_trans_table[i].cmd;
1040 break;
1042 if (!kcmd)
1043 return -EINVAL;
1045 switch (cmd) {
1046 case FDSETPRM32:
1047 case FDDEFPRM32:
1048 case FDGETPRM32:
1050 struct floppy_struct *f;
1052 f = karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_struct));
1053 if (!karg)
1054 return -ENOMEM;
1055 if (cmd == FDGETPRM32)
1056 break;
1057 err = __get_user(f->size, &((struct floppy_struct32 *)arg)->size);
1058 err |= __get_user(f->sect, &((struct floppy_struct32 *)arg)->sect);
1059 err |= __get_user(f->head, &((struct floppy_struct32 *)arg)->head);
1060 err |= __get_user(f->track, &((struct floppy_struct32 *)arg)->track);
1061 err |= __get_user(f->stretch, &((struct floppy_struct32 *)arg)->stretch);
1062 err |= __get_user(f->gap, &((struct floppy_struct32 *)arg)->gap);
1063 err |= __get_user(f->rate, &((struct floppy_struct32 *)arg)->rate);
1064 err |= __get_user(f->spec1, &((struct floppy_struct32 *)arg)->spec1);
1065 err |= __get_user(f->fmt_gap, &((struct floppy_struct32 *)arg)->fmt_gap);
1066 err |= __get_user((u64)f->name, &((struct floppy_struct32 *)arg)->name);
1067 if (err)
1068 goto out;
1069 break;
1071 case FDSETDRVPRM32:
1072 case FDGETDRVPRM32:
1074 struct floppy_drive_params *f;
1076 f = karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_drive_params));
1077 if (!karg)
1078 return -ENOMEM;
1079 if (cmd == FDGETDRVPRM32)
1080 break;
1081 err = __get_user(f->cmos, &((struct floppy_drive_params32 *)arg)->cmos);
1082 err |= __get_user(f->max_dtr, &((struct floppy_drive_params32 *)arg)->max_dtr);
1083 err |= __get_user(f->hlt, &((struct floppy_drive_params32 *)arg)->hlt);
1084 err |= __get_user(f->hut, &((struct floppy_drive_params32 *)arg)->hut);
1085 err |= __get_user(f->srt, &((struct floppy_drive_params32 *)arg)->srt);
1086 err |= __get_user(f->spinup, &((struct floppy_drive_params32 *)arg)->spinup);
1087 err |= __get_user(f->spindown, &((struct floppy_drive_params32 *)arg)->spindown);
1088 err |= __get_user(f->spindown_offset, &((struct floppy_drive_params32 *)arg)->spindown_offset);
1089 err |= __get_user(f->select_delay, &((struct floppy_drive_params32 *)arg)->select_delay);
1090 err |= __get_user(f->rps, &((struct floppy_drive_params32 *)arg)->rps);
1091 err |= __get_user(f->tracks, &((struct floppy_drive_params32 *)arg)->tracks);
1092 err |= __get_user(f->timeout, &((struct floppy_drive_params32 *)arg)->timeout);
1093 err |= __get_user(f->interleave_sect, &((struct floppy_drive_params32 *)arg)->interleave_sect);
1094 err |= __copy_from_user(&f->max_errors, &((struct floppy_drive_params32 *)arg)->max_errors, sizeof(f->max_errors));
1095 err |= __get_user(f->flags, &((struct floppy_drive_params32 *)arg)->flags);
1096 err |= __get_user(f->read_track, &((struct floppy_drive_params32 *)arg)->read_track);
1097 err |= __copy_from_user(f->autodetect, ((struct floppy_drive_params32 *)arg)->autodetect, sizeof(f->autodetect));
1098 err |= __get_user(f->checkfreq, &((struct floppy_drive_params32 *)arg)->checkfreq);
1099 err |= __get_user(f->native_format, &((struct floppy_drive_params32 *)arg)->native_format);
1100 if (err)
1101 goto out;
1102 break;
1104 case FDGETDRVSTAT32:
1105 case FDPOLLDRVSTAT32:
1106 karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_drive_struct));
1107 if (!karg)
1108 return -ENOMEM;
1109 break;
1110 case FDGETFDCSTAT32:
1111 karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_fdc_state));
1112 if (!karg)
1113 return -ENOMEM;
1114 break;
1115 case FDWERRORGET32:
1116 karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_write_errors));
1117 if (!karg)
1118 return -ENOMEM;
1119 break;
1120 default:
1121 return -EINVAL;
1123 set_fs (KERNEL_DS);
1124 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1125 set_fs (old_fs);
1126 if (err)
1127 goto out;
1128 switch (cmd) {
1129 case FDGETPRM32:
1131 struct floppy_struct *f = karg;
1133 err = __put_user(f->size, &((struct floppy_struct32 *)arg)->size);
1134 err |= __put_user(f->sect, &((struct floppy_struct32 *)arg)->sect);
1135 err |= __put_user(f->head, &((struct floppy_struct32 *)arg)->head);
1136 err |= __put_user(f->track, &((struct floppy_struct32 *)arg)->track);
1137 err |= __put_user(f->stretch, &((struct floppy_struct32 *)arg)->stretch);
1138 err |= __put_user(f->gap, &((struct floppy_struct32 *)arg)->gap);
1139 err |= __put_user(f->rate, &((struct floppy_struct32 *)arg)->rate);
1140 err |= __put_user(f->spec1, &((struct floppy_struct32 *)arg)->spec1);
1141 err |= __put_user(f->fmt_gap, &((struct floppy_struct32 *)arg)->fmt_gap);
1142 err |= __put_user((u64)f->name, &((struct floppy_struct32 *)arg)->name);
1143 break;
1145 case FDGETDRVPRM32:
1147 struct floppy_drive_params *f = karg;
1149 err = __put_user(f->cmos, &((struct floppy_drive_params32 *)arg)->cmos);
1150 err |= __put_user(f->max_dtr, &((struct floppy_drive_params32 *)arg)->max_dtr);
1151 err |= __put_user(f->hlt, &((struct floppy_drive_params32 *)arg)->hlt);
1152 err |= __put_user(f->hut, &((struct floppy_drive_params32 *)arg)->hut);
1153 err |= __put_user(f->srt, &((struct floppy_drive_params32 *)arg)->srt);
1154 err |= __put_user(f->spinup, &((struct floppy_drive_params32 *)arg)->spinup);
1155 err |= __put_user(f->spindown, &((struct floppy_drive_params32 *)arg)->spindown);
1156 err |= __put_user(f->spindown_offset, &((struct floppy_drive_params32 *)arg)->spindown_offset);
1157 err |= __put_user(f->select_delay, &((struct floppy_drive_params32 *)arg)->select_delay);
1158 err |= __put_user(f->rps, &((struct floppy_drive_params32 *)arg)->rps);
1159 err |= __put_user(f->tracks, &((struct floppy_drive_params32 *)arg)->tracks);
1160 err |= __put_user(f->timeout, &((struct floppy_drive_params32 *)arg)->timeout);
1161 err |= __put_user(f->interleave_sect, &((struct floppy_drive_params32 *)arg)->interleave_sect);
1162 err |= __copy_to_user(&((struct floppy_drive_params32 *)arg)->max_errors, &f->max_errors, sizeof(f->max_errors));
1163 err |= __put_user(f->flags, &((struct floppy_drive_params32 *)arg)->flags);
1164 err |= __put_user(f->read_track, &((struct floppy_drive_params32 *)arg)->read_track);
1165 err |= __copy_to_user(((struct floppy_drive_params32 *)arg)->autodetect, f->autodetect, sizeof(f->autodetect));
1166 err |= __put_user(f->checkfreq, &((struct floppy_drive_params32 *)arg)->checkfreq);
1167 err |= __put_user(f->native_format, &((struct floppy_drive_params32 *)arg)->native_format);
1168 break;
1170 case FDGETDRVSTAT32:
1171 case FDPOLLDRVSTAT32:
1173 struct floppy_drive_struct *f = karg;
1175 err = __put_user(f->flags, &((struct floppy_drive_struct32 *)arg)->flags);
1176 err |= __put_user(f->spinup_date, &((struct floppy_drive_struct32 *)arg)->spinup_date);
1177 err |= __put_user(f->select_date, &((struct floppy_drive_struct32 *)arg)->select_date);
1178 err |= __put_user(f->first_read_date, &((struct floppy_drive_struct32 *)arg)->first_read_date);
1179 err |= __put_user(f->probed_format, &((struct floppy_drive_struct32 *)arg)->probed_format);
1180 err |= __put_user(f->track, &((struct floppy_drive_struct32 *)arg)->track);
1181 err |= __put_user(f->maxblock, &((struct floppy_drive_struct32 *)arg)->maxblock);
1182 err |= __put_user(f->maxtrack, &((struct floppy_drive_struct32 *)arg)->maxtrack);
1183 err |= __put_user(f->generation, &((struct floppy_drive_struct32 *)arg)->generation);
1184 err |= __put_user(f->keep_data, &((struct floppy_drive_struct32 *)arg)->keep_data);
1185 err |= __put_user(f->fd_ref, &((struct floppy_drive_struct32 *)arg)->fd_ref);
1186 err |= __put_user(f->fd_device, &((struct floppy_drive_struct32 *)arg)->fd_device);
1187 err |= __put_user(f->last_checked, &((struct floppy_drive_struct32 *)arg)->last_checked);
1188 err |= __put_user((u64)f->dmabuf, &((struct floppy_drive_struct32 *)arg)->dmabuf);
1189 err |= __put_user((u64)f->bufblocks, &((struct floppy_drive_struct32 *)arg)->bufblocks);
1190 break;
1192 case FDGETFDCSTAT32:
1194 struct floppy_fdc_state *f = karg;
1196 err = __put_user(f->spec1, &((struct floppy_fdc_state32 *)arg)->spec1);
1197 err |= __put_user(f->spec2, &((struct floppy_fdc_state32 *)arg)->spec2);
1198 err |= __put_user(f->dtr, &((struct floppy_fdc_state32 *)arg)->dtr);
1199 err |= __put_user(f->version, &((struct floppy_fdc_state32 *)arg)->version);
1200 err |= __put_user(f->dor, &((struct floppy_fdc_state32 *)arg)->dor);
1201 err |= __put_user(f->address, &((struct floppy_fdc_state32 *)arg)->address);
1202 err |= __copy_to_user((char *)&((struct floppy_fdc_state32 *)arg)->address
1203 + sizeof(((struct floppy_fdc_state32 *)arg)->address),
1204 (char *)&f->address + sizeof(f->address), sizeof(int));
1205 err |= __put_user(f->driver_version, &((struct floppy_fdc_state32 *)arg)->driver_version);
1206 err |= __copy_to_user(((struct floppy_fdc_state32 *)arg)->track, f->track, sizeof(f->track));
1207 break;
1209 case FDWERRORGET32:
1211 struct floppy_write_errors *f = karg;
1213 err = __put_user(f->write_errors, &((struct floppy_write_errors32 *)arg)->write_errors);
1214 err |= __put_user(f->first_error_sector, &((struct floppy_write_errors32 *)arg)->first_error_sector);
1215 err |= __put_user(f->first_error_generation, &((struct floppy_write_errors32 *)arg)->first_error_generation);
1216 err |= __put_user(f->last_error_sector, &((struct floppy_write_errors32 *)arg)->last_error_sector);
1217 err |= __put_user(f->last_error_generation, &((struct floppy_write_errors32 *)arg)->last_error_generation);
1218 err |= __put_user(f->badness, &((struct floppy_write_errors32 *)arg)->badness);
1219 break;
1221 default:
1222 break;
1224 out: if (karg) kfree(karg);
1225 return err;
1228 struct ppp_option_data32 {
1229 __kernel_caddr_t32 ptr;
1230 __u32 length;
1231 int transmit;
1233 #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
1235 struct ppp_idle32 {
1236 __kernel_time_t32 xmit_idle;
1237 __kernel_time_t32 recv_idle;
1239 #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
1241 static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1243 mm_segment_t old_fs = get_fs();
1244 struct ppp_option_data32 data32;
1245 struct ppp_option_data data;
1246 struct ppp_idle32 idle32;
1247 struct ppp_idle idle;
1248 unsigned int kcmd;
1249 void *karg;
1250 int err = 0;
1252 switch (cmd) {
1253 case PPPIOCGIDLE32:
1254 kcmd = PPPIOCGIDLE;
1255 karg = &idle;
1256 break;
1257 case PPPIOCSCOMPRESS32:
1258 if (copy_from_user(&data32, (struct ppp_option_data32 *)arg, sizeof(struct ppp_option_data32)))
1259 return -EFAULT;
1260 data.ptr = kmalloc (data32.length, GFP_KERNEL);
1261 if (!data.ptr)
1262 return -ENOMEM;
1263 if (copy_from_user(data.ptr, (__u8 *)A(data32.ptr), data32.length)) {
1264 kfree(data.ptr);
1265 return -EFAULT;
1267 data.length = data32.length;
1268 data.transmit = data32.transmit;
1269 kcmd = PPPIOCSCOMPRESS;
1270 karg = &data;
1271 break;
1272 default:
1273 do {
1274 static int count = 0;
1275 if (++count <= 20)
1276 printk("ppp_ioctl: Unknown cmd fd(%d) "
1277 "cmd(%08x) arg(%08x)\n",
1278 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1279 } while(0);
1280 return -EINVAL;
1282 set_fs (KERNEL_DS);
1283 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1284 set_fs (old_fs);
1285 switch (cmd) {
1286 case PPPIOCGIDLE32:
1287 if (err)
1288 return err;
1289 idle32.xmit_idle = idle.xmit_idle;
1290 idle32.recv_idle = idle.recv_idle;
1291 if (copy_to_user((struct ppp_idle32 *)arg, &idle32, sizeof(struct ppp_idle32)))
1292 return -EFAULT;
1293 break;
1294 case PPPIOCSCOMPRESS32:
1295 kfree(data.ptr);
1296 break;
1297 default:
1298 break;
1300 return err;
1304 struct mtget32 {
1305 __u32 mt_type;
1306 __u32 mt_resid;
1307 __u32 mt_dsreg;
1308 __u32 mt_gstat;
1309 __u32 mt_erreg;
1310 __kernel_daddr_t32 mt_fileno;
1311 __kernel_daddr_t32 mt_blkno;
1313 #define MTIOCGET32 _IOR('m', 2, struct mtget32)
1315 struct mtpos32 {
1316 __u32 mt_blkno;
1318 #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
1320 struct mtconfiginfo32 {
1321 __u32 mt_type;
1322 __u32 ifc_type;
1323 __u16 irqnr;
1324 __u16 dmanr;
1325 __u16 port;
1326 __u32 debug;
1327 __u32 have_dens:1;
1328 __u32 have_bsf:1;
1329 __u32 have_fsr:1;
1330 __u32 have_bsr:1;
1331 __u32 have_eod:1;
1332 __u32 have_seek:1;
1333 __u32 have_tell:1;
1334 __u32 have_ras1:1;
1335 __u32 have_ras2:1;
1336 __u32 have_ras3:1;
1337 __u32 have_qfa:1;
1338 __u32 pad1:5;
1339 char reserved[10];
1341 #define MTIOCGETCONFIG32 _IOR('m', 4, struct mtconfiginfo32)
1342 #define MTIOCSETCONFIG32 _IOW('m', 5, struct mtconfiginfo32)
1344 static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1346 mm_segment_t old_fs = get_fs();
1347 struct mtconfiginfo info;
1348 struct mtget get;
1349 struct mtpos pos;
1350 unsigned long kcmd;
1351 void *karg;
1352 int err = 0;
1354 switch(cmd) {
1355 case MTIOCPOS32:
1356 kcmd = MTIOCPOS;
1357 karg = &pos;
1358 break;
1359 case MTIOCGET32:
1360 kcmd = MTIOCGET;
1361 karg = &get;
1362 break;
1363 case MTIOCGETCONFIG32:
1364 kcmd = MTIOCGETCONFIG;
1365 karg = &info;
1366 break;
1367 case MTIOCSETCONFIG32:
1368 kcmd = MTIOCSETCONFIG;
1369 karg = &info;
1370 err = __get_user(info.mt_type, &((struct mtconfiginfo32 *)arg)->mt_type);
1371 err |= __get_user(info.ifc_type, &((struct mtconfiginfo32 *)arg)->ifc_type);
1372 err |= __get_user(info.irqnr, &((struct mtconfiginfo32 *)arg)->irqnr);
1373 err |= __get_user(info.dmanr, &((struct mtconfiginfo32 *)arg)->dmanr);
1374 err |= __get_user(info.port, &((struct mtconfiginfo32 *)arg)->port);
1375 err |= __get_user(info.debug, &((struct mtconfiginfo32 *)arg)->debug);
1376 err |= __copy_from_user((char *)&info.debug + sizeof(info.debug),
1377 (char *)&((struct mtconfiginfo32 *)arg)->debug
1378 + sizeof(((struct mtconfiginfo32 *)arg)->debug), sizeof(__u32));
1379 if (err)
1380 return -EFAULT;
1381 break;
1382 default:
1383 do {
1384 static int count = 0;
1385 if (++count <= 20)
1386 printk("mt_ioctl: Unknown cmd fd(%d) "
1387 "cmd(%08x) arg(%08x)\n",
1388 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1389 } while(0);
1390 return -EINVAL;
1392 set_fs (KERNEL_DS);
1393 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1394 set_fs (old_fs);
1395 if (err)
1396 return err;
1397 switch (cmd) {
1398 case MTIOCPOS32:
1399 if (__put_user(pos.mt_blkno, &((struct mtpos32 *)arg)->mt_blkno))
1400 return -EFAULT;
1401 break;
1402 case MTIOCGET32:
1403 err = __put_user(get.mt_type, &((struct mtget32 *)arg)->mt_type);
1404 err |= __put_user(get.mt_resid, &((struct mtget32 *)arg)->mt_resid);
1405 err |= __put_user(get.mt_dsreg, &((struct mtget32 *)arg)->mt_dsreg);
1406 err |= __put_user(get.mt_gstat, &((struct mtget32 *)arg)->mt_gstat);
1407 err |= __put_user(get.mt_erreg, &((struct mtget32 *)arg)->mt_erreg);
1408 err |= __put_user(get.mt_fileno, &((struct mtget32 *)arg)->mt_fileno);
1409 err |= __put_user(get.mt_blkno, &((struct mtget32 *)arg)->mt_blkno);
1410 break;
1411 case MTIOCGETCONFIG32:
1412 err = __put_user(info.mt_type, &((struct mtconfiginfo32 *)arg)->mt_type);
1413 err |= __put_user(info.ifc_type, &((struct mtconfiginfo32 *)arg)->ifc_type);
1414 err |= __put_user(info.irqnr, &((struct mtconfiginfo32 *)arg)->irqnr);
1415 err |= __put_user(info.dmanr, &((struct mtconfiginfo32 *)arg)->dmanr);
1416 err |= __put_user(info.port, &((struct mtconfiginfo32 *)arg)->port);
1417 err |= __put_user(info.debug, &((struct mtconfiginfo32 *)arg)->debug);
1418 err |= __copy_to_user((char *)&((struct mtconfiginfo32 *)arg)->debug
1419 + sizeof(((struct mtconfiginfo32 *)arg)->debug),
1420 (char *)&info.debug + sizeof(info.debug), sizeof(__u32));
1421 break;
1422 case MTIOCSETCONFIG32:
1423 break;
1425 return err;
1428 struct cdrom_read32 {
1429 int cdread_lba;
1430 __kernel_caddr_t32 cdread_bufaddr;
1431 int cdread_buflen;
1434 struct cdrom_read_audio32 {
1435 union cdrom_addr addr;
1436 u_char addr_format;
1437 int nframes;
1438 __kernel_caddr_t32 buf;
1441 static int cdrom_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1443 mm_segment_t old_fs = get_fs();
1444 struct cdrom_read cdread;
1445 struct cdrom_read_audio cdreadaudio;
1446 __kernel_caddr_t32 addr;
1447 char *data = 0;
1448 void *karg;
1449 int err = 0;
1451 switch(cmd) {
1452 case CDROMREADMODE2:
1453 case CDROMREADMODE1:
1454 case CDROMREADRAW:
1455 case CDROMREADCOOKED:
1456 karg = &cdread;
1457 err = __get_user(cdread.cdread_lba, &((struct cdrom_read32 *)arg)->cdread_lba);
1458 err |= __get_user(addr, &((struct cdrom_read32 *)arg)->cdread_bufaddr);
1459 err |= __get_user(cdread.cdread_buflen, &((struct cdrom_read32 *)arg)->cdread_buflen);
1460 if (err)
1461 return -EFAULT;
1462 data = kmalloc(cdread.cdread_buflen, GFP_KERNEL);
1463 if (!data)
1464 return -ENOMEM;
1465 cdread.cdread_bufaddr = data;
1466 break;
1467 case CDROMREADAUDIO:
1468 karg = &cdreadaudio;
1469 err = copy_from_user(&cdreadaudio.addr, &((struct cdrom_read_audio32 *)arg)->addr, sizeof(cdreadaudio.addr));
1470 err |= __get_user(cdreadaudio.addr_format, &((struct cdrom_read_audio32 *)arg)->addr_format);
1471 err |= __get_user(cdreadaudio.nframes, &((struct cdrom_read_audio32 *)arg)->nframes);
1472 err |= __get_user(addr, &((struct cdrom_read_audio32 *)arg)->buf);
1473 if (err)
1474 return -EFAULT;
1475 data = kmalloc(cdreadaudio.nframes * 2352, GFP_KERNEL);
1476 if (!data)
1477 return -ENOMEM;
1478 cdreadaudio.buf = data;
1479 break;
1480 default:
1481 do {
1482 static int count = 0;
1483 if (++count <= 20)
1484 printk("cdrom_ioctl: Unknown cmd fd(%d) "
1485 "cmd(%08x) arg(%08x)\n",
1486 (int)fd, (unsigned int)cmd, (unsigned int)arg);
1487 } while(0);
1488 return -EINVAL;
1490 set_fs (KERNEL_DS);
1491 err = sys_ioctl (fd, cmd, (unsigned long)karg);
1492 set_fs (old_fs);
1493 if (err)
1494 goto out;
1495 switch (cmd) {
1496 case CDROMREADMODE2:
1497 case CDROMREADMODE1:
1498 case CDROMREADRAW:
1499 case CDROMREADCOOKED:
1500 err = copy_to_user((char *)A(addr), data, cdread.cdread_buflen);
1501 break;
1502 case CDROMREADAUDIO:
1503 err = copy_to_user((char *)A(addr), data, cdreadaudio.nframes * 2352);
1504 break;
1505 default:
1506 break;
1508 out: if (data) kfree(data);
1509 return err;
1512 struct loop_info32 {
1513 int lo_number; /* ioctl r/o */
1514 __kernel_dev_t32 lo_device; /* ioctl r/o */
1515 unsigned int lo_inode; /* ioctl r/o */
1516 __kernel_dev_t32 lo_rdevice; /* ioctl r/o */
1517 int lo_offset;
1518 int lo_encrypt_type;
1519 int lo_encrypt_key_size; /* ioctl w/o */
1520 int lo_flags; /* ioctl r/o */
1521 char lo_name[LO_NAME_SIZE];
1522 unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
1523 unsigned int lo_init[2];
1524 char reserved[4];
1527 static int loop_status(unsigned int fd, unsigned int cmd, unsigned long arg)
1529 mm_segment_t old_fs = get_fs();
1530 struct loop_info l;
1531 int err = 0;
1533 switch(cmd) {
1534 case LOOP_SET_STATUS:
1535 err = get_user(l.lo_number, &((struct loop_info32 *)arg)->lo_number);
1536 err |= __get_user(l.lo_device, &((struct loop_info32 *)arg)->lo_device);
1537 err |= __get_user(l.lo_inode, &((struct loop_info32 *)arg)->lo_inode);
1538 err |= __get_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice);
1539 err |= __copy_from_user((char *)&l.lo_offset, (char *)&((struct loop_info32 *)arg)->lo_offset,
1540 8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1541 if (err)
1542 return -EFAULT;
1543 set_fs (KERNEL_DS);
1544 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1545 set_fs (old_fs);
1546 break;
1547 case LOOP_GET_STATUS:
1548 set_fs (KERNEL_DS);
1549 err = sys_ioctl (fd, cmd, (unsigned long)&l);
1550 set_fs (old_fs);
1551 if (!err) {
1552 err = put_user(l.lo_number, &((struct loop_info32 *)arg)->lo_number);
1553 err |= __put_user(l.lo_device, &((struct loop_info32 *)arg)->lo_device);
1554 err |= __put_user(l.lo_inode, &((struct loop_info32 *)arg)->lo_inode);
1555 err |= __put_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice);
1556 err |= __copy_to_user((char *)&((struct loop_info32 *)arg)->lo_offset,
1557 (char *)&l.lo_offset, (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1559 break;
1561 return err;
1564 extern int tty_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg);
1566 static int vt_check(struct file *file)
1568 struct tty_struct *tty;
1569 struct inode *inode = file->f_dentry->d_inode;
1571 if (file->f_op->ioctl != tty_ioctl)
1572 return -EINVAL;
1574 tty = (struct tty_struct *)file->private_data;
1575 if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
1576 return -EINVAL;
1578 if (tty->driver.ioctl != vt_ioctl)
1579 return -EINVAL;
1582 * To have permissions to do most of the vt ioctls, we either have
1583 * to be the owner of the tty, or super-user.
1585 if (current->tty == tty || suser())
1586 return 1;
1587 return 0;
1590 struct consolefontdesc32 {
1591 unsigned short charcount; /* characters in font (256 or 512) */
1592 unsigned short charheight; /* scan lines per character (1-32) */
1593 u32 chardata; /* font data in expanded form */
1596 static int do_fontx_ioctl(struct file *file, int cmd, struct consolefontdesc32 *user_cfd)
1598 struct consolefontdesc cfdarg;
1599 struct console_font_op op;
1600 int i, perm;
1602 perm = vt_check(file);
1603 if (perm < 0) return perm;
1605 if (copy_from_user(&cfdarg, user_cfd, sizeof(struct consolefontdesc32)))
1606 return -EFAULT;
1608 cfdarg.chardata = (unsigned char *)A(((struct consolefontdesc32 *)&cfdarg)->chardata);
1610 switch (cmd) {
1611 case PIO_FONTX:
1612 if (!perm)
1613 return -EPERM;
1614 op.op = KD_FONT_OP_SET;
1615 op.flags = 0;
1616 op.width = 8;
1617 op.height = cfdarg.charheight;
1618 op.charcount = cfdarg.charcount;
1619 op.data = cfdarg.chardata;
1620 return con_font_op(fg_console, &op);
1621 case GIO_FONTX:
1622 if (!cfdarg.chardata)
1623 return 0;
1624 op.op = KD_FONT_OP_GET;
1625 op.flags = 0;
1626 op.width = 8;
1627 op.height = cfdarg.charheight;
1628 op.charcount = cfdarg.charcount;
1629 op.data = cfdarg.chardata;
1630 i = con_font_op(fg_console, &op);
1631 if (i)
1632 return i;
1633 cfdarg.charheight = op.height;
1634 cfdarg.charcount = op.charcount;
1635 ((struct consolefontdesc32 *)&cfdarg)->chardata = (unsigned long)cfdarg.chardata;
1636 if (copy_to_user(user_cfd, &cfdarg, sizeof(struct consolefontdesc32)))
1637 return -EFAULT;
1638 return 0;
1640 return -EINVAL;
1643 struct console_font_op32 {
1644 unsigned int op; /* operation code KD_FONT_OP_* */
1645 unsigned int flags; /* KD_FONT_FLAG_* */
1646 unsigned int width, height; /* font size */
1647 unsigned int charcount;
1648 u32 data; /* font data with height fixed to 32 */
1651 static int do_kdfontop_ioctl(struct file *file, struct console_font_op32 *fontop)
1653 struct console_font_op op;
1654 int perm = vt_check(file), i;
1655 struct vt_struct *vt;
1657 if (perm < 0) return perm;
1659 if (copy_from_user(&op, (void *) fontop, sizeof(struct console_font_op32)))
1660 return -EFAULT;
1661 if (!perm && op.op != KD_FONT_OP_GET)
1662 return -EPERM;
1663 op.data = (unsigned char *)A(((struct console_font_op32 *)&op)->data);
1664 op.flags |= KD_FONT_FLAG_OLD;
1665 vt = (struct vt_struct *)((struct tty_struct *)file->private_data)->driver_data;
1666 i = con_font_op(vt->vc_num, &op);
1667 if (i) return i;
1668 ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
1669 if (copy_to_user((void *) fontop, &op, sizeof(struct console_font_op32)))
1670 return -EFAULT;
1671 return 0;
1674 struct unimapdesc32 {
1675 unsigned short entry_ct;
1676 u32 entries;
1679 static int do_unimap_ioctl(struct file *file, int cmd, struct unimapdesc32 *user_ud)
1681 struct unimapdesc32 tmp;
1682 int perm = vt_check(file);
1684 if (perm < 0) return perm;
1685 if (copy_from_user(&tmp, user_ud, sizeof tmp))
1686 return -EFAULT;
1687 switch (cmd) {
1688 case PIO_UNIMAP:
1689 if (!perm) return -EPERM;
1690 return con_set_unimap(fg_console, tmp.entry_ct, (struct unipair *)A(tmp.entries));
1691 case GIO_UNIMAP:
1692 return con_get_unimap(fg_console, tmp.entry_ct, &(user_ud->entry_ct), (struct unipair *)A(tmp.entries));
1694 return 0;
1697 asmlinkage int sys32_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
1699 struct file * filp;
1700 int error = -EBADF;
1702 lock_kernel();
1703 filp = fget(fd);
1704 if(!filp)
1705 goto out2;
1707 if (!filp->f_op || !filp->f_op->ioctl) {
1708 error = sys_ioctl (fd, cmd, arg);
1709 goto out;
1711 switch (cmd) {
1712 case SIOCGIFNAME:
1713 error = dev_ifname32(fd, arg);
1714 goto out;
1716 case SIOCGIFCONF:
1717 error = dev_ifconf(fd, arg);
1718 goto out;
1720 case SIOCGIFFLAGS:
1721 case SIOCSIFFLAGS:
1722 case SIOCGIFMETRIC:
1723 case SIOCSIFMETRIC:
1724 case SIOCGIFMTU:
1725 case SIOCSIFMTU:
1726 case SIOCGIFMEM:
1727 case SIOCSIFMEM:
1728 case SIOCGIFHWADDR:
1729 case SIOCSIFHWADDR:
1730 case SIOCADDMULTI:
1731 case SIOCDELMULTI:
1732 case SIOCGIFINDEX:
1733 case SIOCGIFMAP:
1734 case SIOCSIFMAP:
1735 case SIOCGIFADDR:
1736 case SIOCSIFADDR:
1737 case SIOCGIFBRDADDR:
1738 case SIOCSIFBRDADDR:
1739 case SIOCGIFDSTADDR:
1740 case SIOCSIFDSTADDR:
1741 case SIOCGIFNETMASK:
1742 case SIOCSIFNETMASK:
1743 case SIOCSIFPFLAGS:
1744 case SIOCGIFPFLAGS:
1745 case SIOCGPPPSTATS:
1746 case SIOCGPPPCSTATS:
1747 case SIOCGPPPVER:
1748 case SIOCGIFTXQLEN:
1749 case SIOCSIFTXQLEN:
1750 case SIOCETHTOOL:
1751 error = dev_ifsioc(fd, cmd, arg);
1752 goto out;
1754 case SIOCADDRT:
1755 case SIOCDELRT:
1756 error = routing_ioctl(fd, cmd, arg);
1757 goto out;
1759 case SIOCRTMSG: /* Note SIOCRTMSG is no longer, so this is safe and
1760 * the user would have seen just an -EINVAL anyways.
1762 error = -EINVAL;
1763 goto out;
1765 case SIOCGSTAMP:
1766 /* Sorry, timeval in the kernel is different now. */
1767 error = do_siocgstamp(fd, cmd, arg);
1768 goto out;
1770 case HDIO_GETGEO:
1771 error = hdio_getgeo(fd, arg);
1772 goto out;
1774 case BLKRAGET:
1775 case BLKGETSIZE:
1776 case 0x1260:
1777 /* The mkswap binary hard codes it to Intel value :-((( */
1778 if(cmd == 0x1260)
1779 cmd = BLKGETSIZE;
1780 error = w_long(fd, cmd, arg);
1781 goto out;
1783 case FBIOPUTCMAP32:
1784 case FBIOGETCMAP32:
1785 error = fbiogetputcmap(fd, cmd, arg);
1786 goto out;
1788 case FBIOSCURSOR32:
1789 error = fbiogscursor(fd, cmd, arg);
1790 goto out;
1792 case FBIOGET_FSCREENINFO:
1793 case FBIOGETCMAP:
1794 case FBIOPUTCMAP:
1795 error = fb_ioctl_trans(fd, cmd, arg);
1796 goto out;
1798 case HDIO_GET_KEEPSETTINGS:
1799 case HDIO_GET_UNMASKINTR:
1800 case HDIO_GET_DMA:
1801 case HDIO_GET_32BIT:
1802 case HDIO_GET_MULTCOUNT:
1803 case HDIO_GET_NOWERR:
1804 case HDIO_GET_NICE:
1805 error = hdio_ioctl_trans(fd, cmd, arg);
1806 goto out;
1808 case FDSETPRM32:
1809 case FDDEFPRM32:
1810 case FDGETPRM32:
1811 case FDSETDRVPRM32:
1812 case FDGETDRVPRM32:
1813 case FDGETDRVSTAT32:
1814 case FDPOLLDRVSTAT32:
1815 case FDGETFDCSTAT32:
1816 case FDWERRORGET32:
1817 error = fd_ioctl_trans(fd, cmd, arg);
1818 goto out;
1820 case PPPIOCGIDLE32:
1821 case PPPIOCSCOMPRESS32:
1822 error = ppp_ioctl_trans(fd, cmd, arg);
1823 goto out;
1825 case MTIOCGET32:
1826 case MTIOCPOS32:
1827 case MTIOCGETCONFIG32:
1828 case MTIOCSETCONFIG32:
1829 error = mt_ioctl_trans(fd, cmd, arg);
1830 goto out;
1832 case CDROMREADMODE2:
1833 case CDROMREADMODE1:
1834 case CDROMREADRAW:
1835 case CDROMREADCOOKED:
1836 case CDROMREADAUDIO:
1837 case CDROMREADALL:
1838 error = cdrom_ioctl_trans(fd, cmd, arg);
1839 goto out;
1841 case LOOP_SET_STATUS:
1842 case LOOP_GET_STATUS:
1843 error = loop_status(fd, cmd, arg);
1844 goto out;
1846 #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
1847 case AUTOFS_IOC_SETTIMEOUT32:
1848 error = rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
1849 goto out;
1851 case PIO_FONTX:
1852 case GIO_FONTX:
1853 error = do_fontx_ioctl(filp, cmd, (struct consolefontdesc32 *)arg);
1854 goto out;
1856 case PIO_UNIMAP:
1857 case GIO_UNIMAP:
1858 error = do_unimap_ioctl(filp, cmd, (struct unimapdesc32 *)arg);
1859 goto out;
1861 case KDFONTOP:
1862 error = do_kdfontop_ioctl(filp, (struct console_font_op32 *)arg);
1863 goto out;
1865 case EXT2_IOC32_GETFLAGS:
1866 case EXT2_IOC32_SETFLAGS:
1867 case EXT2_IOC32_GETVERSION:
1868 case EXT2_IOC32_SETVERSION:
1869 error = do_ext2_ioctl(fd, cmd, arg);
1870 goto out;
1872 case VIDIOCGTUNER32:
1873 case VIDIOCSTUNER32:
1874 case VIDIOCGWIN32:
1875 case VIDIOCSWIN32:
1876 case VIDIOCGFBUF32:
1877 case VIDIOCSFBUF32:
1878 case VIDIOCGFREQ32:
1879 case VIDIOCSFREQ32:
1880 error = do_video_ioctl(fd, cmd, arg);
1881 goto out;
1883 /* List here exlicitly which ioctl's are known to have
1884 * compatable types passed or none at all...
1887 /* Big T */
1888 case TCGETA:
1889 case TCSETA:
1890 case TCSETAW:
1891 case TCSETAF:
1892 case TCSBRK:
1893 case TCXONC:
1894 case TCFLSH:
1895 case TCGETS:
1896 case TCSETS:
1897 case TCSETSW:
1898 case TCSETSF:
1899 case TIOCLINUX:
1901 /* Little t */
1902 case TIOCGETD:
1903 case TIOCSETD:
1904 case TIOCEXCL:
1905 case TIOCNXCL:
1906 case TIOCCONS:
1907 case TIOCGSOFTCAR:
1908 case TIOCSSOFTCAR:
1909 case TIOCSWINSZ:
1910 case TIOCGWINSZ:
1911 case TIOCMGET:
1912 case TIOCMBIC:
1913 case TIOCMBIS:
1914 case TIOCMSET:
1915 case TIOCPKT:
1916 case TIOCNOTTY:
1917 case TIOCSTI:
1918 case TIOCOUTQ:
1919 case TIOCSPGRP:
1920 case TIOCGPGRP:
1921 case TIOCSCTTY:
1922 case TIOCGPTN:
1923 case TIOCSPTLCK:
1925 /* Big F */
1926 case FBIOGTYPE:
1927 case FBIOSATTR:
1928 case FBIOGATTR:
1929 case FBIOSVIDEO:
1930 case FBIOGVIDEO:
1931 case FBIOGCURSOR32: /* This is not implemented yet. Later it should be converted... */
1932 case FBIOSCURPOS:
1933 case FBIOGCURPOS:
1934 case FBIOGCURMAX:
1936 case FBIOGET_VSCREENINFO:
1937 case FBIOPUT_VSCREENINFO:
1938 case FBIOPAN_DISPLAY:
1939 case FBIOGET_FCURSORINFO:
1940 case FBIOGET_VCURSORINFO:
1941 case FBIOPUT_VCURSORINFO:
1942 case FBIOGET_CURSORSTATE:
1943 case FBIOPUT_CURSORSTATE:
1944 case FBIOGET_CON2FBMAP:
1945 case FBIOPUT_CON2FBMAP:
1947 /* Little f */
1948 case FIOCLEX:
1949 case FIONCLEX:
1950 case FIOASYNC:
1951 case FIONBIO:
1952 case FIONREAD: /* This is also TIOCINQ */
1954 /* 0x00 */
1955 case FIBMAP:
1956 case FIGETBSZ:
1958 /* 0x03 -- HD/IDE ioctl's used by hdparm and friends.
1959 * Some need translations, these do not.
1961 case HDIO_GET_IDENTITY:
1962 case HDIO_SET_DMA:
1963 case HDIO_SET_KEEPSETTINGS:
1964 case HDIO_SET_UNMASKINTR:
1965 case HDIO_SET_NOWERR:
1966 case HDIO_SET_32BIT:
1967 case HDIO_SET_MULTCOUNT:
1968 case HDIO_DRIVE_CMD:
1969 case HDIO_SET_PIO_MODE:
1970 case HDIO_SCAN_HWIF:
1971 case HDIO_SET_NICE:
1972 case BLKROSET:
1973 case BLKROGET:
1975 /* 0x02 -- Floppy ioctls */
1976 case FDMSGON:
1977 case FDMSGOFF:
1978 case FDSETEMSGTRESH:
1979 case FDFLUSH:
1980 case FDWERRORCLR:
1981 case FDSETMAXERRS:
1982 case FDGETMAXERRS:
1983 case FDGETDRVTYP:
1984 case FDEJECT:
1985 case FDCLRPRM:
1986 case FDFMTBEG:
1987 case FDFMTEND:
1988 case FDRESET:
1989 case FDTWADDLE:
1990 case FDFMTTRK:
1991 case FDRAWCMD:
1993 /* 0x12 */
1994 case BLKRRPART:
1995 case BLKFLSBUF:
1996 case BLKRASET:
1998 /* 0x09 */
1999 case REGISTER_DEV:
2000 case REGISTER_DEV_NEW:
2001 case START_MD:
2002 case STOP_MD:
2004 /* Big K */
2005 case PIO_FONT:
2006 case GIO_FONT:
2007 case KDSIGACCEPT:
2008 case KDGETKEYCODE:
2009 case KDSETKEYCODE:
2010 case KIOCSOUND:
2011 case KDMKTONE:
2012 case KDGKBTYPE:
2013 case KDSETMODE:
2014 case KDGETMODE:
2015 case KDSKBMODE:
2016 case KDGKBMODE:
2017 case KDSKBMETA:
2018 case KDGKBMETA:
2019 case KDGKBENT:
2020 case KDSKBENT:
2021 case KDGKBSENT:
2022 case KDSKBSENT:
2023 case KDGKBDIACR:
2024 case KDSKBDIACR:
2025 case KDGKBLED:
2026 case KDSKBLED:
2027 case KDGETLED:
2028 case KDSETLED:
2029 case GIO_SCRNMAP:
2030 case PIO_SCRNMAP:
2031 case GIO_UNISCRNMAP:
2032 case PIO_UNISCRNMAP:
2033 case PIO_FONTRESET:
2034 case PIO_UNIMAPCLR:
2036 /* Little k */
2037 case KIOCTYPE:
2038 case KIOCLAYOUT:
2039 case KIOCGTRANS:
2040 case KIOCTRANS:
2041 case KIOCCMD:
2042 case KIOCSDIRECT:
2043 case KIOCSLED:
2044 case KIOCGLED:
2045 case KIOCSRATE:
2046 case KIOCGRATE:
2048 /* Big S */
2049 case SCSI_IOCTL_GET_IDLUN:
2050 case SCSI_IOCTL_DOORLOCK:
2051 case SCSI_IOCTL_DOORUNLOCK:
2052 case SCSI_IOCTL_TEST_UNIT_READY:
2053 case SCSI_IOCTL_TAGGED_ENABLE:
2054 case SCSI_IOCTL_TAGGED_DISABLE:
2055 case SCSI_IOCTL_GET_BUS_NUMBER:
2056 case SCSI_IOCTL_SEND_COMMAND:
2058 /* Big V */
2059 case VT_SETMODE:
2060 case VT_GETMODE:
2061 case VT_GETSTATE:
2062 case VT_OPENQRY:
2063 case VT_ACTIVATE:
2064 case VT_WAITACTIVE:
2065 case VT_RELDISP:
2066 case VT_DISALLOCATE:
2067 case VT_RESIZE:
2068 case VT_RESIZEX:
2069 case VT_LOCKSWITCH:
2070 case VT_UNLOCKSWITCH:
2072 /* Little v */
2073 case VUIDSFORMAT:
2074 case VUIDGFORMAT:
2076 /* Little v, the video4linux ioctls */
2077 case VIDIOCGCAP:
2078 case VIDIOCGCHAN:
2079 case VIDIOCSCHAN:
2080 case VIDIOCGPICT:
2081 case VIDIOCSPICT:
2082 case VIDIOCCAPTURE:
2083 case VIDIOCKEY:
2084 case VIDIOCGAUDIO:
2085 case VIDIOCSAUDIO:
2086 case VIDIOCSYNC:
2087 case VIDIOCMCAPTURE:
2088 case VIDIOCGMBUF:
2089 case VIDIOCGUNIT:
2090 case VIDIOCGCAPTURE:
2091 case VIDIOCSCAPTURE:
2093 /* BTTV specific... */
2094 case _IOW('v', BASE_VIDIOCPRIVATE+0, char [256]):
2095 case _IOR('v', BASE_VIDIOCPRIVATE+1, char [256]):
2096 case _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int):
2097 case _IOW('v' , BASE_VIDIOCPRIVATE+3, char [16]): /* struct bttv_pll_info */
2098 case _IOR('v' , BASE_VIDIOCPRIVATE+4, int):
2099 case _IOR('v' , BASE_VIDIOCPRIVATE+5, int):
2100 case _IOR('v' , BASE_VIDIOCPRIVATE+6, int):
2101 case _IOR('v' , BASE_VIDIOCPRIVATE+7, int):
2103 /* Little p (/dev/rtc, /dev/envctrl, etc.) */
2104 case RTCGET:
2105 case RTCSET:
2106 case I2CIOCSADR:
2107 case I2CIOCGADR:
2109 /* Little m */
2110 case MTIOCTOP:
2112 /* OPENPROMIO, SunOS/Solaris only, the NetBSD one's have
2113 * embedded pointers in the arg which we'd need to clean up...
2115 case OPROMGETOPT:
2116 case OPROMSETOPT:
2117 case OPROMNXTOPT:
2118 case OPROMSETOPT2:
2119 case OPROMNEXT:
2120 case OPROMCHILD:
2121 case OPROMGETPROP:
2122 case OPROMNXTPROP:
2123 case OPROMU2P:
2124 case OPROMGETCONS:
2125 case OPROMGETFBNAME:
2126 case OPROMGETBOOTARGS:
2128 /* Socket level stuff */
2129 case FIOSETOWN:
2130 case SIOCSPGRP:
2131 case FIOGETOWN:
2132 case SIOCGPGRP:
2133 case SIOCATMARK:
2134 case SIOCSIFLINK:
2135 case SIOCSIFENCAP:
2136 case SIOCGIFENCAP:
2137 case SIOCSIFBR:
2138 case SIOCGIFBR:
2139 case SIOCSARP:
2140 case SIOCGARP:
2141 case SIOCDARP:
2142 #if 0 /* XXX No longer exist in new routing code. XXX */
2143 case OLD_SIOCSARP:
2144 case OLD_SIOCGARP:
2145 case OLD_SIOCDARP:
2146 #endif
2147 case SIOCSRARP:
2148 case SIOCGRARP:
2149 case SIOCDRARP:
2150 case SIOCADDDLCI:
2151 case SIOCDELDLCI:
2153 /* SG stuff */
2154 case SG_SET_TIMEOUT:
2155 case SG_GET_TIMEOUT:
2156 case SG_EMULATED_HOST:
2157 case SG_SET_TRANSFORM:
2158 case SG_GET_TRANSFORM:
2160 /* PPP stuff */
2161 case PPPIOCGFLAGS:
2162 case PPPIOCSFLAGS:
2163 case PPPIOCGASYNCMAP:
2164 case PPPIOCSASYNCMAP:
2165 case PPPIOCGUNIT:
2166 case PPPIOCGRASYNCMAP:
2167 case PPPIOCSRASYNCMAP:
2168 case PPPIOCGMRU:
2169 case PPPIOCSMRU:
2170 case PPPIOCSMAXCID:
2171 case PPPIOCGXASYNCMAP:
2172 case PPPIOCSXASYNCMAP:
2173 case PPPIOCXFERUNIT:
2174 case PPPIOCGNPMODE:
2175 case PPPIOCSNPMODE:
2176 case PPPIOCGDEBUG:
2177 case PPPIOCSDEBUG:
2179 /* CDROM stuff */
2180 case CDROMPAUSE:
2181 case CDROMRESUME:
2182 case CDROMPLAYMSF:
2183 case CDROMPLAYTRKIND:
2184 case CDROMREADTOCHDR:
2185 case CDROMREADTOCENTRY:
2186 case CDROMSTOP:
2187 case CDROMSTART:
2188 case CDROMEJECT:
2189 case CDROMVOLCTRL:
2190 case CDROMSUBCHNL:
2191 case CDROMEJECT_SW:
2192 case CDROMMULTISESSION:
2193 case CDROM_GET_MCN:
2194 case CDROMRESET:
2195 case CDROMVOLREAD:
2196 case CDROMSEEK:
2197 case CDROMPLAYBLK:
2198 case CDROMCLOSETRAY:
2199 case CDROM_SET_OPTIONS:
2200 case CDROM_CLEAR_OPTIONS:
2201 case CDROM_SELECT_SPEED:
2202 case CDROM_SELECT_DISC:
2203 case CDROM_MEDIA_CHANGED:
2204 case CDROM_DRIVE_STATUS:
2205 case CDROM_DISC_STATUS:
2206 case CDROM_CHANGER_NSLOTS:
2208 /* Big L */
2209 case LOOP_SET_FD:
2210 case LOOP_CLR_FD:
2212 /* Big A */
2213 case AUDIO_GETINFO:
2214 case AUDIO_SETINFO:
2215 case AUDIO_DRAIN:
2216 case AUDIO_GETDEV:
2217 case AUDIO_GETDEV_SUNOS:
2218 case AUDIO_FLUSH:
2220 /* Big Q for sound/OSS */
2221 case SNDCTL_SEQ_RESET:
2222 case SNDCTL_SEQ_SYNC:
2223 case SNDCTL_SYNTH_INFO:
2224 case SNDCTL_SEQ_CTRLRATE:
2225 case SNDCTL_SEQ_GETOUTCOUNT:
2226 case SNDCTL_SEQ_GETINCOUNT:
2227 case SNDCTL_SEQ_PERCMODE:
2228 case SNDCTL_FM_LOAD_INSTR:
2229 case SNDCTL_SEQ_TESTMIDI:
2230 case SNDCTL_SEQ_RESETSAMPLES:
2231 case SNDCTL_SEQ_NRSYNTHS:
2232 case SNDCTL_SEQ_NRMIDIS:
2233 case SNDCTL_MIDI_INFO:
2234 case SNDCTL_SEQ_THRESHOLD:
2235 case SNDCTL_SYNTH_MEMAVL:
2236 case SNDCTL_FM_4OP_ENABLE:
2237 case SNDCTL_SEQ_PANIC:
2238 case SNDCTL_SEQ_OUTOFBAND:
2239 case SNDCTL_SEQ_GETTIME:
2240 case SNDCTL_SYNTH_ID:
2241 case SNDCTL_SYNTH_CONTROL:
2242 case SNDCTL_SYNTH_REMOVESAMPLE:
2244 /* Big T for sound/OSS */
2245 case SNDCTL_TMR_TIMEBASE:
2246 case SNDCTL_TMR_START:
2247 case SNDCTL_TMR_STOP:
2248 case SNDCTL_TMR_CONTINUE:
2249 case SNDCTL_TMR_TEMPO:
2250 case SNDCTL_TMR_SOURCE:
2251 case SNDCTL_TMR_METRONOME:
2252 case SNDCTL_TMR_SELECT:
2254 /* Little m for sound/OSS */
2255 case SNDCTL_MIDI_PRETIME:
2256 case SNDCTL_MIDI_MPUMODE:
2257 case SNDCTL_MIDI_MPUCMD:
2259 /* Big P for sound/OSS */
2260 case SNDCTL_DSP_RESET:
2261 case SNDCTL_DSP_SYNC:
2262 case SNDCTL_DSP_SPEED:
2263 case SNDCTL_DSP_STEREO:
2264 case SNDCTL_DSP_GETBLKSIZE:
2265 case SNDCTL_DSP_CHANNELS:
2266 case SOUND_PCM_WRITE_FILTER:
2267 case SNDCTL_DSP_POST:
2268 case SNDCTL_DSP_SUBDIVIDE:
2269 case SNDCTL_DSP_SETFRAGMENT:
2270 case SNDCTL_DSP_GETFMTS:
2271 case SNDCTL_DSP_SETFMT:
2272 case SNDCTL_DSP_GETOSPACE:
2273 case SNDCTL_DSP_GETISPACE:
2274 case SNDCTL_DSP_NONBLOCK:
2275 case SNDCTL_DSP_GETCAPS:
2276 case SNDCTL_DSP_GETTRIGGER:
2277 case SNDCTL_DSP_SETTRIGGER:
2278 case SNDCTL_DSP_GETIPTR:
2279 case SNDCTL_DSP_GETOPTR:
2280 /* case SNDCTL_DSP_MAPINBUF: XXX needs translation */
2281 /* case SNDCTL_DSP_MAPOUTBUF: XXX needs translation */
2282 case SNDCTL_DSP_SETSYNCRO:
2283 case SNDCTL_DSP_SETDUPLEX:
2284 case SNDCTL_DSP_GETODELAY:
2285 case SNDCTL_DSP_PROFILE:
2287 case SOUND_PCM_READ_RATE:
2288 case SOUND_PCM_READ_CHANNELS:
2289 case SOUND_PCM_READ_BITS:
2290 case SOUND_PCM_READ_FILTER:
2292 /* Big C for sound/OSS */
2293 case SNDCTL_COPR_RESET:
2294 case SNDCTL_COPR_LOAD:
2295 case SNDCTL_COPR_RDATA:
2296 case SNDCTL_COPR_RCODE:
2297 case SNDCTL_COPR_WDATA:
2298 case SNDCTL_COPR_WCODE:
2299 case SNDCTL_COPR_RUN:
2300 case SNDCTL_COPR_HALT:
2301 case SNDCTL_COPR_SENDMSG:
2302 case SNDCTL_COPR_RCVMSG:
2304 /* Big M for sound/OSS */
2305 case SOUND_MIXER_READ_VOLUME:
2306 case SOUND_MIXER_READ_BASS:
2307 case SOUND_MIXER_READ_TREBLE:
2308 case SOUND_MIXER_READ_SYNTH:
2309 case SOUND_MIXER_READ_PCM:
2310 case SOUND_MIXER_READ_SPEAKER:
2311 case SOUND_MIXER_READ_LINE:
2312 case SOUND_MIXER_READ_MIC:
2313 case SOUND_MIXER_READ_CD:
2314 case SOUND_MIXER_READ_IMIX:
2315 case SOUND_MIXER_READ_ALTPCM:
2316 case SOUND_MIXER_READ_RECLEV:
2317 case SOUND_MIXER_READ_IGAIN:
2318 case SOUND_MIXER_READ_OGAIN:
2319 case SOUND_MIXER_READ_LINE1:
2320 case SOUND_MIXER_READ_LINE2:
2321 case SOUND_MIXER_READ_LINE3:
2322 case SOUND_MIXER_READ_MUTE:
2323 /* case SOUND_MIXER_READ_ENHANCE: same value as READ_MUTE */
2324 /* case SOUND_MIXER_READ_LOUD: same value as READ_MUTE */
2325 case SOUND_MIXER_READ_RECSRC:
2326 case SOUND_MIXER_READ_DEVMASK:
2327 case SOUND_MIXER_READ_RECMASK:
2328 case SOUND_MIXER_READ_STEREODEVS:
2329 case SOUND_MIXER_READ_CAPS:
2331 case SOUND_MIXER_WRITE_VOLUME:
2332 case SOUND_MIXER_WRITE_BASS:
2333 case SOUND_MIXER_WRITE_TREBLE:
2334 case SOUND_MIXER_WRITE_SYNTH:
2335 case SOUND_MIXER_WRITE_PCM:
2336 case SOUND_MIXER_WRITE_SPEAKER:
2337 case SOUND_MIXER_WRITE_LINE:
2338 case SOUND_MIXER_WRITE_MIC:
2339 case SOUND_MIXER_WRITE_CD:
2340 case SOUND_MIXER_WRITE_IMIX:
2341 case SOUND_MIXER_WRITE_ALTPCM:
2342 case SOUND_MIXER_WRITE_RECLEV:
2343 case SOUND_MIXER_WRITE_IGAIN:
2344 case SOUND_MIXER_WRITE_OGAIN:
2345 case SOUND_MIXER_WRITE_LINE1:
2346 case SOUND_MIXER_WRITE_LINE2:
2347 case SOUND_MIXER_WRITE_LINE3:
2348 case SOUND_MIXER_WRITE_MUTE:
2349 /* case SOUND_MIXER_WRITE_ENHANCE: same value as WRITE_MUTE */
2350 /* case SOUND_MIXER_WRITE_LOUD: same value as WRITE_MUTE */
2351 case SOUND_MIXER_WRITE_RECSRC:
2353 case SOUND_MIXER_INFO:
2354 case SOUND_OLD_MIXER_INFO:
2355 case SOUND_MIXER_ACCESS:
2356 case SOUND_MIXER_PRIVATE1:
2357 case SOUND_MIXER_PRIVATE2:
2358 case SOUND_MIXER_PRIVATE3:
2359 case SOUND_MIXER_PRIVATE4:
2360 case SOUND_MIXER_PRIVATE5:
2361 case SOUND_MIXER_GETLEVELS:
2362 case SOUND_MIXER_SETLEVELS:
2364 case OSS_GETVERSION:
2366 /* AUTOFS */
2367 case AUTOFS_IOC_READY:
2368 case AUTOFS_IOC_FAIL:
2369 case AUTOFS_IOC_CATATONIC:
2370 case AUTOFS_IOC_PROTOVER:
2371 case AUTOFS_IOC_EXPIRE:
2373 /* Raw devices */
2374 case RAW_SETBIND:
2375 case RAW_GETBIND:
2377 error = sys_ioctl (fd, cmd, arg);
2378 goto out;
2380 default:
2381 do {
2382 static int count = 0;
2383 if (++count <= 20)
2384 printk("sys32_ioctl: Unknown cmd fd(%d) "
2385 "cmd(%08x) arg(%08x)\n",
2386 (int)fd, (unsigned int)cmd, (unsigned int)arg);
2387 } while(0);
2388 error = -EINVAL;
2389 break;
2391 out:
2392 fput(filp);
2393 out2:
2394 unlock_kernel();
2395 return error;