Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / fs / compat_ioctl.c
index a14dc21..d2c3887 100644 (file)
  * ioctls.
  */
 
-#ifdef INCLUDES
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/compat.h>
 #include <linux/kernel.h>
+#include <linux/capability.h>
 #include <linux/compiler.h>
 #include <linux/sched.h>
 #include <linux/smp.h>
@@ -49,6 +49,8 @@
 #include <linux/vt_kern.h>
 #include <linux/fb.h>
 #include <linux/ext2_fs.h>
+#include <linux/ext3_jbd.h>
+#include <linux/ext3_fs.h>
 #include <linux/videodev.h>
 #include <linux/netdevice.h>
 #include <linux/raw.h>
@@ -70,6 +72,7 @@
 #include <linux/i2c-dev.h>
 #include <linux/wireless.h>
 #include <linux/atalk.h>
+#include <linux/blktrace_api.h>
 
 #include <net/sock.h>          /* siocdevprivate_ioctl */
 #include <net/bluetooth/bluetooth.h>
 #include <linux/capi.h>
 
 #include <scsi/scsi.h>
-/* Ugly hack. */
-#undef __KERNEL__
 #include <scsi/scsi_ioctl.h>
-#define __KERNEL__
 #include <scsi/sg.h>
 
-#include <asm/types.h>
 #include <asm/uaccess.h>
 #include <linux/ethtool.h>
 #include <linux/mii.h>
@@ -93,7 +92,6 @@
 #include <linux/watchdog.h>
 #include <linux/dm-ioctl.h>
 
-#include <asm/module.h>
 #include <linux/soundcard.h>
 #include <linux/lp.h>
 #include <linux/ppdev.h>
 
 #include <linux/hiddev.h>
 
-#undef INCLUDES
-#endif
-
-#ifdef CODE
+#include <linux/dvb/audio.h>
+#include <linux/dvb/dmx.h>
+#include <linux/dvb/frontend.h>
+#include <linux/dvb/video.h>
+#include <linux/lp.h>
 
 /* Aiee. Someone does not find a difference between int and long */
 #define EXT2_IOC32_GETFLAGS               _IOR('f', 1, int)
 #define EXT2_IOC32_SETFLAGS               _IOW('f', 2, int)
+#define EXT3_IOC32_GETVERSION             _IOR('f', 3, int)
+#define EXT3_IOC32_SETVERSION             _IOW('f', 4, int)
+#define EXT3_IOC32_GETRSVSZ               _IOR('f', 5, int)
+#define EXT3_IOC32_SETRSVSZ               _IOW('f', 6, int)
+#define EXT3_IOC32_GROUP_EXTEND           _IOW('f', 7, unsigned int)
+#ifdef CONFIG_JBD_DEBUG
+#define EXT3_IOC32_WAIT_FOR_READONLY      _IOR('f', 99, int)
+#endif
+
 #define EXT2_IOC32_GETVERSION             _IOR('v', 1, int)
 #define EXT2_IOC32_SETVERSION             _IOW('v', 2, int)
 
+static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
+                             unsigned long arg, struct file *f)
+{
+       return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
+}
+
 static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
        mm_segment_t old_fs = get_fs();
@@ -175,241 +189,141 @@ static int do_ext2_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
        return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
 }
 
-struct video_tuner32 {
-       compat_int_t tuner;
-       char name[32];
-       compat_ulong_t rangelow, rangehigh;
-       u32 flags;      /* It is really u32 in videodev.h */
-       u16 mode, signal;
-};
-
-static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up)
-{
-       int i;
-
-       if(get_user(kp->tuner, &up->tuner))
-               return -EFAULT;
-       for(i = 0; i < 32; i++)
-               __get_user(kp->name[i], &up->name[i]);
-       __get_user(kp->rangelow, &up->rangelow);
-       __get_user(kp->rangehigh, &up->rangehigh);
-       __get_user(kp->flags, &up->flags);
-       __get_user(kp->mode, &up->mode);
-       __get_user(kp->signal, &up->signal);
-       return 0;
-}
-
-static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up)
+static int do_ext3_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
-       int i;
-
-       if(put_user(kp->tuner, &up->tuner))
-               return -EFAULT;
-       for(i = 0; i < 32; i++)
-               __put_user(kp->name[i], &up->name[i]);
-       __put_user(kp->rangelow, &up->rangelow);
-       __put_user(kp->rangehigh, &up->rangehigh);
-       __put_user(kp->flags, &up->flags);
-       __put_user(kp->mode, &up->mode);
-       __put_user(kp->signal, &up->signal);
-       return 0;
+       /* These are just misnamed, they actually get/put from/to user an int */
+       switch (cmd) {
+       case EXT3_IOC32_GETVERSION: cmd = EXT3_IOC_GETVERSION; break;
+       case EXT3_IOC32_SETVERSION: cmd = EXT3_IOC_SETVERSION; break;
+       case EXT3_IOC32_GETRSVSZ: cmd = EXT3_IOC_GETRSVSZ; break;
+       case EXT3_IOC32_SETRSVSZ: cmd = EXT3_IOC_SETRSVSZ; break;
+       case EXT3_IOC32_GROUP_EXTEND: cmd = EXT3_IOC_GROUP_EXTEND; break;
+#ifdef CONFIG_JBD_DEBUG
+       case EXT3_IOC32_WAIT_FOR_READONLY: cmd = EXT3_IOC_WAIT_FOR_READONLY; break;
+#endif
+       }
+       return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
 }
 
-struct video_buffer32 {
-       compat_caddr_t base;
-       compat_int_t height, width, depth, bytesperline;
+struct compat_dmx_event {
+       dmx_event_t     event;
+       compat_time_t   timeStamp;
+       union
+       {
+               dmx_scrambling_status_t scrambling;
+       } u;
 };
 
-static int get_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up)
+static int do_dmx_get_event(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
-       u32 tmp;
-
-       if (get_user(tmp, &up->base))
-               return -EFAULT;
+       struct dmx_event kevent;
+       mm_segment_t old_fs = get_fs();
+       int err;
 
-       /* This is actually a physical address stored
-        * as a void pointer.
-        */
-       kp->base = (void *)(unsigned long) tmp;
+       set_fs(KERNEL_DS);
+       err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
+       set_fs(old_fs);
 
-       __get_user(kp->height, &up->height);
-       __get_user(kp->width, &up->width);
-       __get_user(kp->depth, &up->depth);
-       __get_user(kp->bytesperline, &up->bytesperline);
-       return 0;
-}
+       if (!err) {
+               struct compat_dmx_event __user *up = compat_ptr(arg);
 
-static int put_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up)
-{
-       u32 tmp = (u32)((unsigned long)kp->base);
+               err  = put_user(kevent.event, &up->event);
+               err |= put_user(kevent.timeStamp, &up->timeStamp);
+               err |= put_user(kevent.u.scrambling, &up->u.scrambling);
+               if (err)
+                       err = -EFAULT;
+       }
 
-       if(put_user(tmp, &up->base))
-               return -EFAULT;
-       __put_user(kp->height, &up->height);
-       __put_user(kp->width, &up->width);
-       __put_user(kp->depth, &up->depth);
-       __put_user(kp->bytesperline, &up->bytesperline);
-       return 0;
+       return err;
 }
 
-struct video_clip32 {
-       s32 x, y, width, height;        /* Its really s32 in videodev.h */
-       compat_caddr_t next;
-};
-
-struct video_window32 {
-       u32 x, y, width, height, chromakey, flags;
-       compat_caddr_t clips;
-       compat_int_t clipcount;
+struct compat_video_event {
+       int32_t         type;
+       compat_time_t   timestamp;
+       union {
+               video_size_t size;
+               unsigned int frame_rate;
+       } u;
 };
 
-/* You get back everything except the clips... */
-static int put_video_window32(struct video_window *kp, struct video_window32 __user *up)
+static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
-       if(put_user(kp->x, &up->x))
-               return -EFAULT;
-       __put_user(kp->y, &up->y);
-       __put_user(kp->width, &up->width);
-       __put_user(kp->height, &up->height);
-       __put_user(kp->chromakey, &up->chromakey);
-       __put_user(kp->flags, &up->flags);
-       __put_user(kp->clipcount, &up->clipcount);
-       return 0;
-}
+       struct video_event kevent;
+       mm_segment_t old_fs = get_fs();
+       int err;
+
+       set_fs(KERNEL_DS);
+       err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
+       set_fs(old_fs);
+
+       if (!err) {
+               struct compat_video_event __user *up = compat_ptr(arg);
+
+               err  = put_user(kevent.type, &up->type);
+               err |= put_user(kevent.timestamp, &up->timestamp);
+               err |= put_user(kevent.u.size.w, &up->u.size.w);
+               err |= put_user(kevent.u.size.h, &up->u.size.h);
+               err |= put_user(kevent.u.size.aspect_ratio,
+                               &up->u.size.aspect_ratio);
+               if (err)
+                       err = -EFAULT;
+       }
 
-#define VIDIOCGTUNER32         _IOWR('v',4, struct video_tuner32)
-#define VIDIOCSTUNER32         _IOW('v',5, struct video_tuner32)
-#define VIDIOCGWIN32           _IOR('v',9, struct video_window32)
-#define VIDIOCSWIN32           _IOW('v',10, struct video_window32)
-#define VIDIOCGFBUF32          _IOR('v',11, struct video_buffer32)
-#define VIDIOCSFBUF32          _IOW('v',12, struct video_buffer32)
-#define VIDIOCGFREQ32          _IOR('v',14, u32)
-#define VIDIOCSFREQ32          _IOW('v',15, u32)
+       return err;
+}
 
-enum {
-       MaxClips = (~0U-sizeof(struct video_window))/sizeof(struct video_clip)
+struct compat_video_still_picture {
+        compat_uptr_t iFrame;
+        int32_t size;
 };
 
-static int do_set_window(unsigned int fd, unsigned int cmd, unsigned long arg)
+static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
-       struct video_window32 __user *up = compat_ptr(arg);
-       struct video_window __user *vw;
-       struct video_clip __user *p;
-       int nclips;
-       u32 n;
+       struct compat_video_still_picture __user *up;
+       struct video_still_picture __user *up_native;
+       compat_uptr_t fp;
+       int32_t size;
+       int err;
 
-       if (get_user(nclips, &up->clipcount))
+       up = (struct compat_video_still_picture __user *) arg;
+       err  = get_user(fp, &up->iFrame);
+       err |= get_user(size, &up->size);
+       if (err)
                return -EFAULT;
 
-       /* Peculiar interface... */
-       if (nclips < 0)
-               nclips = VIDEO_CLIPMAP_SIZE;
-
-       if (nclips > MaxClips)
-               return -ENOMEM;
-
-       vw = compat_alloc_user_space(sizeof(struct video_window) +
-                                   nclips * sizeof(struct video_clip));
-
-       p = nclips ? (struct video_clip __user *)(vw + 1) : NULL;
+       up_native =
+               compat_alloc_user_space(sizeof(struct video_still_picture));
 
-       if (get_user(n, &up->x) || put_user(n, &vw->x) ||
-           get_user(n, &up->y) || put_user(n, &vw->y) ||
-           get_user(n, &up->width) || put_user(n, &vw->width) ||
-           get_user(n, &up->height) || put_user(n, &vw->height) ||
-           get_user(n, &up->chromakey) || put_user(n, &vw->chromakey) ||
-           get_user(n, &up->flags) || put_user(n, &vw->flags) ||
-           get_user(n, &up->clipcount) || put_user(n, &vw->clipcount) ||
-           get_user(n, &up->clips) || put_user(p, &vw->clips))
-               return -EFAULT;
+       put_user(compat_ptr(fp), &up_native->iFrame);
+       put_user(size, &up_native->size);
 
-       if (nclips) {
-               struct video_clip32 __user *u = compat_ptr(n);
-               int i;
-               if (!u)
-                       return -EINVAL;
-               for (i = 0; i < nclips; i++, u++, p++) {
-                       s32 v;
-                       if (get_user(v, &u->x) ||
-                           put_user(v, &p->x) ||
-                           get_user(v, &u->y) ||
-                           put_user(v, &p->y) ||
-                           get_user(v, &u->width) ||
-                           put_user(v, &p->width) ||
-                           get_user(v, &u->height) ||
-                           put_user(v, &p->height) ||
-                           put_user(NULL, &p->next))
-                               return -EFAULT;
-               }
-       }
+       err = sys_ioctl(fd, cmd, (unsigned long) up_native);
 
-       return sys_ioctl(fd, VIDIOCSWIN, (unsigned long)p);
+       return err;
 }
 
-static int do_video_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-       union {
-               struct video_tuner vt;
-               struct video_buffer vb;
-               struct video_window vw;
-               unsigned long vx;
-       } karg;
-       mm_segment_t old_fs = get_fs();
-       void __user *up = compat_ptr(arg);
-       int err = 0;
-
-       /* First, convert the command. */
-       switch(cmd) {
-       case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break;
-       case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break;
-       case VIDIOCGWIN32: cmd = VIDIOCGWIN; break;
-       case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break;
-       case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break;
-       case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break;
-       case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break;
-       };
-
-       switch(cmd) {
-       case VIDIOCSTUNER:
-       case VIDIOCGTUNER:
-               err = get_video_tuner32(&karg.vt, up);
-               break;
-
-       case VIDIOCSFBUF:
-               err = get_video_buffer32(&karg.vb, up);
-               break;
-
-       case VIDIOCSFREQ:
-               err = get_user(karg.vx, (u32 __user *)up);
-               break;
-       };
-       if(err)
-               goto out;
+struct compat_video_spu_palette {
+       int length;
+       compat_uptr_t palette;
+};
 
-       set_fs(KERNEL_DS);
-       err = sys_ioctl(fd, cmd, (unsigned long)&karg);
-       set_fs(old_fs);
+static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned long arg)
+{
+       struct compat_video_spu_palette __user *up;
+       struct video_spu_palette __user *up_native;
+       compat_uptr_t palp;
+       int length, err;
 
-       if(err == 0) {
-               switch(cmd) {
-               case VIDIOCGTUNER:
-                       err = put_video_tuner32(&karg.vt, up);
-                       break;
+       up = (struct compat_video_spu_palette __user *) arg;
+       err  = get_user(palp, &up->palette);
+       err |= get_user(length, &up->length);
 
-               case VIDIOCGWIN:
-                       err = put_video_window32(&karg.vw, up);
-                       break;
+       up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
+       put_user(compat_ptr(palp), &up_native->palette);
+       put_user(length, &up_native->length);
 
-               case VIDIOCGFBUF:
-                       err = put_video_buffer32(&karg.vb, up);
-                       break;
+       err = sys_ioctl(fd, cmd, (unsigned long) up_native);
 
-               case VIDIOCGFREQ:
-                       err = put_user(((u32)karg.vx), (u32 __user *)up);
-                       break;
-               };
-       }
-out:
        return err;
 }
 
@@ -532,7 +446,8 @@ static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)
 
        ifr = ifc.ifc_req;
        ifr32 = compat_ptr(ifc32.ifcbuf);
-       for (i = 0, j = 0; i < ifc32.ifc_len && j < ifc.ifc_len;
+       for (i = 0, j = 0;
+             i + sizeof (struct ifreq32) <= ifc32.ifc_len && j < ifc.ifc_len;
             i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
                if (copy_in_user(ifr32, ifr, sizeof (struct ifreq32)))
                        return -EFAULT;
@@ -548,10 +463,7 @@ static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)
                i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32));
                ifc32.ifc_len = i;
        } else {
-               if (i <= ifc32.ifc_len)
-                       ifc32.ifc_len = i;
-               else
-                       ifc32.ifc_len = i - sizeof (struct ifreq32);
+               ifc32.ifc_len = i;
        }
        if (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32)))
                return -EFAULT;
@@ -798,13 +710,16 @@ static int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
                r = (void *) &r4;
        }
 
-       if (ret)
-               return -EFAULT;
+       if (ret) {
+               ret = -EFAULT;
+               goto out;
+       }
 
        set_fs (KERNEL_DS);
        ret = sys_ioctl (fd, cmd, (unsigned long) r);
        set_fs (old_fs);
 
+out:
        if (mysock)
                sockfd_put(mysock);
 
@@ -837,146 +752,6 @@ static int hdio_getgeo(unsigned int fd, unsigned int cmd, unsigned long arg)
        return err ? -EFAULT : 0;
 }
 
-struct fb_fix_screeninfo32 {
-       char                    id[16];
-        compat_caddr_t smem_start;
-       u32                     smem_len;
-       u32                     type;
-       u32                     type_aux;
-       u32                     visual;
-       u16                     xpanstep;
-       u16                     ypanstep;
-       u16                     ywrapstep;
-       u32                     line_length;
-        compat_caddr_t mmio_start;
-       u32                     mmio_len;
-       u32                     accel;
-       u16                     reserved[3];
-};
-
-struct fb_cmap32 {
-       u32                     start;
-       u32                     len;
-       compat_caddr_t  red;
-       compat_caddr_t  green;
-       compat_caddr_t  blue;
-       compat_caddr_t  transp;
-};
-
-static int fb_getput_cmap(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-       struct fb_cmap_user __user *cmap;
-       struct fb_cmap32 __user *cmap32;
-       __u32 data;
-       int err;
-
-       cmap = compat_alloc_user_space(sizeof(*cmap));
-       cmap32 = compat_ptr(arg);
-
-       if (copy_in_user(&cmap->start, &cmap32->start, 2 * sizeof(__u32)))
-               return -EFAULT;
-
-       if (get_user(data, &cmap32->red) ||
-           put_user(compat_ptr(data), &cmap->red) ||
-           get_user(data, &cmap32->green) ||
-           put_user(compat_ptr(data), &cmap->green) ||
-           get_user(data, &cmap32->blue) ||
-           put_user(compat_ptr(data), &cmap->blue) ||
-           get_user(data, &cmap32->transp) ||
-           put_user(compat_ptr(data), &cmap->transp))
-               return -EFAULT;
-
-       err = sys_ioctl(fd, cmd, (unsigned long) cmap);
-
-       if (!err) {
-               if (copy_in_user(&cmap32->start,
-                                &cmap->start,
-                                2 * sizeof(__u32)))
-                       err = -EFAULT;
-       }
-       return err;
-}
-
-static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix,
-                                 struct fb_fix_screeninfo32 __user *fix32)
-{
-       __u32 data;
-       int err;
-
-       err = copy_to_user(&fix32->id, &fix->id, sizeof(fix32->id));
-
-       data = (__u32) (unsigned long) fix->smem_start;
-       err |= put_user(data, &fix32->smem_start);
-
-       err |= put_user(fix->smem_len, &fix32->smem_len);
-       err |= put_user(fix->type, &fix32->type);
-       err |= put_user(fix->type_aux, &fix32->type_aux);
-       err |= put_user(fix->visual, &fix32->visual);
-       err |= put_user(fix->xpanstep, &fix32->xpanstep);
-       err |= put_user(fix->ypanstep, &fix32->ypanstep);
-       err |= put_user(fix->ywrapstep, &fix32->ywrapstep);
-       err |= put_user(fix->line_length, &fix32->line_length);
-
-       data = (__u32) (unsigned long) fix->mmio_start;
-       err |= put_user(data, &fix32->mmio_start);
-
-       err |= put_user(fix->mmio_len, &fix32->mmio_len);
-       err |= put_user(fix->accel, &fix32->accel);
-       err |= copy_to_user(fix32->reserved, fix->reserved,
-                           sizeof(fix->reserved));
-
-       return err;
-}
-
-static int fb_get_fscreeninfo(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-       mm_segment_t old_fs;
-       struct fb_fix_screeninfo fix;
-       struct fb_fix_screeninfo32 __user *fix32;
-       int err;
-
-       fix32 = compat_ptr(arg);
-
-       old_fs = get_fs();
-       set_fs(KERNEL_DS);
-       err = sys_ioctl(fd, cmd, (unsigned long) &fix);
-       set_fs(old_fs);
-
-       if (!err)
-               err = do_fscreeninfo_to_user(&fix, fix32);
-
-       return err;
-}
-
-static int fb_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-       int err;
-
-       switch (cmd) {
-       case FBIOGET_FSCREENINFO:
-               err = fb_get_fscreeninfo(fd,cmd, arg);
-               break;
-
-       case FBIOGETCMAP:
-       case FBIOPUTCMAP:
-               err = fb_getput_cmap(fd, cmd, arg);
-               break;
-
-       default:
-               do {
-                       static int count;
-                       if (++count <= 20)
-                               printk("%s: Unknown fb ioctl cmd fd(%d) "
-                                      "cmd(%08x) arg(%08lx)\n",
-                                      __FUNCTION__, fd, cmd, arg);
-               } while(0);
-               err = -ENOSYS;
-               break;
-       };
-
-       return err;
-}
-
 static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
        mm_segment_t old_fs = get_fs();
@@ -1143,6 +918,40 @@ static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
        return err;
 }
 
+struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
+       char req_state;
+       char orphan;
+       char sg_io_owned;
+       char problem;
+       int pack_id;
+       compat_uptr_t usr_ptr;
+       unsigned int duration;
+       int unused;
+};
+
+static int sg_grt_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
+{
+       int err, i;
+       sg_req_info_t __user *r;
+       struct compat_sg_req_info __user *o = (void __user *)arg;
+       r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE);
+       err = sys_ioctl(fd,cmd,(unsigned long)r);
+       if (err < 0)
+               return err;
+       for (i = 0; i < SG_MAX_QUEUE; i++) {
+               void __user *ptr;
+               int d;
+
+               if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) ||
+                   get_user(ptr, &r[i].usr_ptr) ||
+                   get_user(d, &r[i].duration) ||
+                   put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) ||
+                   put_user(d, &o[i].duration))
+                       return -EFAULT;
+       }
+       return err;
+}
+
 struct sock_fprog32 {
        unsigned short  len;
        compat_caddr_t  filter;
@@ -1281,35 +1090,9 @@ struct mtpos32 {
 };
 #define MTIOCPOS32     _IOR('m', 3, struct mtpos32)
 
-struct mtconfiginfo32 {
-       compat_long_t   mt_type;
-       compat_long_t   ifc_type;
-       unsigned short  irqnr;
-       unsigned short  dmanr;
-       unsigned short  port;
-       compat_ulong_t  debug;
-       compat_uint_t   have_dens:1;
-       compat_uint_t   have_bsf:1;
-       compat_uint_t   have_fsr:1;
-       compat_uint_t   have_bsr:1;
-       compat_uint_t   have_eod:1;
-       compat_uint_t   have_seek:1;
-       compat_uint_t   have_tell:1;
-       compat_uint_t   have_ras1:1;
-       compat_uint_t   have_ras2:1;
-       compat_uint_t   have_ras3:1;
-       compat_uint_t   have_qfa:1;
-       compat_uint_t   pad1:5;
-       char    reserved[10];
-};
-#define        MTIOCGETCONFIG32        _IOR('m', 4, struct mtconfiginfo32)
-#define        MTIOCSETCONFIG32        _IOW('m', 5, struct mtconfiginfo32)
-
 static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
        mm_segment_t old_fs = get_fs();
-       struct mtconfiginfo info;
-       struct mtconfiginfo32 __user *uinfo32;
        struct mtget get;
        struct mtget32 __user *umget32;
        struct mtpos pos;
@@ -1327,27 +1110,6 @@ static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
                kcmd = MTIOCGET;
                karg = &get;
                break;
-       case MTIOCGETCONFIG32:
-               kcmd = MTIOCGETCONFIG;
-               karg = &info;
-               break;
-       case MTIOCSETCONFIG32:
-               kcmd = MTIOCSETCONFIG;
-               karg = &info;
-               uinfo32 = compat_ptr(arg);
-               err = __get_user(info.mt_type, &uinfo32->mt_type);
-               err |= __get_user(info.ifc_type, &uinfo32->ifc_type);
-               err |= __get_user(info.irqnr, &uinfo32->irqnr);
-               err |= __get_user(info.dmanr, &uinfo32->dmanr);
-               err |= __get_user(info.port, &uinfo32->port);
-               err |= __get_user(info.debug, &uinfo32->debug);
-               err |= __copy_from_user((char *)&info.debug
-                                    + sizeof(info.debug),
-                                    (char __user *)&uinfo32->debug
-                                    + sizeof(uinfo32->debug), sizeof(__u32));
-               if (err)
-                       return -EFAULT;
-               break;
        default:
                do {
                        static int count;
@@ -1378,20 +1140,6 @@ static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
                err |= __put_user(get.mt_fileno, &umget32->mt_fileno);
                err |= __put_user(get.mt_blkno, &umget32->mt_blkno);
                break;
-       case MTIOCGETCONFIG32:
-               uinfo32 = compat_ptr(arg);
-               err = __put_user(info.mt_type, &uinfo32->mt_type);
-               err |= __put_user(info.ifc_type, &uinfo32->ifc_type);
-               err |= __put_user(info.irqnr, &uinfo32->irqnr);
-               err |= __put_user(info.dmanr, &uinfo32->dmanr);
-               err |= __put_user(info.port, &uinfo32->port);
-               err |= __put_user(info.debug, &uinfo32->debug);
-               err |= __copy_to_user((char __user *)&uinfo32->debug
-                                          + sizeof(uinfo32->debug),
-                                          (char *)&info.debug + sizeof(info.debug), sizeof(__u32));
-               break;
-       case MTIOCSETCONFIG32:
-               break;
        }
        return err ? -EFAULT: 0;
 }
@@ -1620,7 +1368,7 @@ static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
                    get_user(data, &user_cfd->chardata))
                        return -EFAULT;
                op.data = compat_ptr(data);
-               return con_font_op(fg_console, &op);
+               return con_font_op(vc_cons[fg_console].d, &op);
        case GIO_FONTX:
                op.op = KD_FONT_OP_GET;
                op.flags = 0;
@@ -1632,7 +1380,7 @@ static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
                if (!data)
                        return 0;
                op.data = compat_ptr(data);
-               i = con_font_op(fg_console, &op);
+               i = con_font_op(vc_cons[fg_console].d, &op);
                if (i)
                        return i;
                if (put_user(op.height, &user_cfd->charheight) ||
@@ -1658,7 +1406,7 @@ static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long ar
        struct console_font_op op;
        struct console_font_op32 __user *fontop = compat_ptr(arg);
        int perm = vt_check(file), i;
-       struct vt_struct *vt;
+       struct vc_data *vc;
        
        if (perm < 0) return perm;
        
@@ -1668,9 +1416,10 @@ static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long ar
                return -EPERM;
        op.data = compat_ptr(((struct console_font_op32 *)&op)->data);
        op.flags |= KD_FONT_FLAG_OLD;
-       vt = (struct vt_struct *)((struct tty_struct *)file->private_data)->driver_data;
-       i = con_font_op(vt->vc_num, &op);
-       if (i) return i;
+       vc = ((struct tty_struct *)file->private_data)->driver_data;
+       i = con_font_op(vc, &op);
+       if (i)
+               return i;
        ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
        if (copy_to_user(fontop, &op, sizeof(struct console_font_op32)))
                return -EFAULT;
@@ -1694,9 +1443,9 @@ static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
        switch (cmd) {
        case PIO_UNIMAP:
                if (!perm) return -EPERM;
-               return con_set_unimap(fg_console, tmp.entry_ct, compat_ptr(tmp.entries));
+               return con_set_unimap(vc_cons[fg_console].d, tmp.entry_ct, compat_ptr(tmp.entries));
        case GIO_UNIMAP:
-               return con_get_unimap(fg_console, tmp.entry_ct, &(user_ud->entry_ct), compat_ptr(tmp.entries));
+               return con_get_unimap(vc_cons[fg_console].d, tmp.entry_ct, &(user_ud->entry_ct), compat_ptr(tmp.entries));
        }
        return 0;
 }
@@ -1773,8 +1522,7 @@ static struct {
        { ATM_QUERYLOOP32,   ATM_QUERYLOOP }
 };
 
-#define NR_ATM_IOCTL (sizeof(atm_ioctl_map)/sizeof(atm_ioctl_map[0]))
-
+#define NR_ATM_IOCTL ARRAY_SIZE(atm_ioctl_map)
 
 static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
@@ -2075,7 +1823,7 @@ static struct {
        { FDWERRORGET32, FDWERRORGET }
 };
 
-#define NR_FD_IOCTL_TRANS (sizeof(fd_ioctl_trans_table)/sizeof(fd_ioctl_trans_table[0]))
+#define NR_FD_IOCTL_TRANS ARRAY_SIZE(fd_ioctl_trans_table)
 
 static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
@@ -2292,7 +2040,8 @@ static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
        if (err)
                err = -EFAULT;
 
-out:   if (karg) kfree(karg);
+out:
+       kfree(karg);
        return err;
 }
 
@@ -2342,11 +2091,8 @@ static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg)
 static long
 put_dirent32 (struct dirent *d, struct compat_dirent __user *d32)
 {
-        int ret;
-
-        if ((ret = verify_area(VERIFY_WRITE, d32,
-                               sizeof(struct compat_dirent))))
-                return ret;
+        if (!access_ok(VERIFY_WRITE, d32, sizeof(struct compat_dirent)))
+                return -EFAULT;
 
         __put_user(d->d_ino, &d32->d_ino);
         __put_user(d->d_off, &d32->d_off);
@@ -2354,7 +2100,7 @@ put_dirent32 (struct dirent *d, struct compat_dirent __user *d32)
         if (__copy_to_user(d32->d_name, d->d_name, d->d_reclen))
                return -EFAULT;
 
-        return ret;
+        return 0;
 }
 
 static int vfat_ioctl32(unsigned fd, unsigned cmd, unsigned long arg)
@@ -2405,9 +2151,8 @@ static int get_raw32_request(struct raw_config_request *req, struct raw32_config
 {
         int ret;
 
-        if ((ret = verify_area(VERIFY_READ, user_req,
-                               sizeof(struct raw32_config_request))))
-                return ret;
+        if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request)))
+                return -EFAULT;
 
         ret = __get_user(req->raw_minor, &user_req->raw_minor);
         ret |= __get_user(req->block_major, &user_req->block_major);
@@ -2420,9 +2165,8 @@ static int set_raw32_request(struct raw_config_request *req, struct raw32_config
 {
        int ret;
 
-        if ((ret = verify_area(VERIFY_WRITE, user_req,
-                               sizeof(struct raw32_config_request))))
-                return ret;
+        if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request)))
+                return -EFAULT;
 
         ret = __put_user(req->raw_minor, &user_req->raw_minor);
         ret |= __put_user(req->block_major, &user_req->block_major);
@@ -2494,7 +2238,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
         __u32 udata;
 
         if (cmd == TIOCSSERIAL) {
-                if (verify_area(VERIFY_READ, ss32, sizeof(SS32)))
+                if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
                         return -EFAULT;
                 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
                        return -EFAULT;
@@ -2508,7 +2252,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
                 err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
         set_fs(oldseg);
         if (cmd == TIOCGSERIAL && err >= 0) {
-                if (verify_area(VERIFY_WRITE, ss32, sizeof(SS32)))
+                if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32)))
                         return -EFAULT;
                 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
                        return -EFAULT;
@@ -2575,229 +2319,11 @@ static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg
         return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p);
 }
 
-/* This needs more work before we can enable it.  Unfortunately
- * because of the fancy asynchronous way URB status/error is written
- * back to userspace, we'll need to fiddle with USB devio internals
- * and/or reimplement entirely the frontend of it ourselves. -DaveM
- *
- * The issue is:
- *
- *     When an URB is submitted via usbdevicefs it is put onto an
- *     asynchronous queue.  When the URB completes, it may be reaped
- *     via another ioctl.  During this reaping the status is written
- *     back to userspace along with the length of the transfer.
- *
- *     We must translate into 64-bit kernel types so we pass in a kernel
- *     space copy of the usbdevfs_urb structure.  This would mean that we
- *     must do something to deal with the async entry reaping.  First we
- *     have to deal somehow with this transitory memory we've allocated.
- *     This is problematic since there are many call sites from which the
- *     async entries can be destroyed (and thus when we'd need to free up
- *     this kernel memory).  One of which is the close() op of usbdevicefs.
- *     To handle that we'd need to make our own file_operations struct which
- *     overrides usbdevicefs's release op with our own which runs usbdevicefs's
- *     real release op then frees up the kernel memory.
- *
- *     But how to keep track of these kernel buffers?  We'd need to either
- *     keep track of them in some table _or_ know about usbdevicefs internals
- *     (ie. the exact layout of its file private, which is actually defined
- *     in linux/usbdevice_fs.h, the layout of the async queues are private to
- *     devio.c)
- *
- * There is one possible other solution I considered, also involving knowledge
- * of usbdevicefs internals:
- *
- *     After an URB is submitted, we "fix up" the address back to the user
- *     space one.  This would work if the status/length fields written back
- *     by the async URB completion lines up perfectly in the 32-bit type with
- *     the 64-bit kernel type.  Unfortunately, it does not because the iso
- *     frame descriptors, at the end of the struct, can be written back.
- *
- * I think we'll just need to simply duplicate the devio URB engine here.
- */
-#if 0
-struct usbdevfs_urb32 {
-       unsigned char type;
-       unsigned char endpoint;
-       compat_int_t status;
-       compat_uint_t flags;
-       compat_caddr_t buffer;
-       compat_int_t buffer_length;
-       compat_int_t actual_length;
-       compat_int_t start_frame;
-       compat_int_t number_of_packets;
-       compat_int_t error_count;
-       compat_uint_t signr;
-       compat_caddr_t usercontext; /* unused */
-       struct usbdevfs_iso_packet_desc iso_frame_desc[0];
-};
-
-#define USBDEVFS_SUBMITURB32       _IOR('U', 10, struct usbdevfs_urb32)
-
-static int get_urb32(struct usbdevfs_urb *kurb,
-                    struct usbdevfs_urb32 *uurb)
-{
-       if (get_user(kurb->type, &uurb->type) ||
-           __get_user(kurb->endpoint, &uurb->endpoint) ||
-           __get_user(kurb->status, &uurb->status) ||
-           __get_user(kurb->flags, &uurb->flags) ||
-           __get_user(kurb->buffer_length, &uurb->buffer_length) ||
-           __get_user(kurb->actual_length, &uurb->actual_length) ||
-           __get_user(kurb->start_frame, &uurb->start_frame) ||
-           __get_user(kurb->number_of_packets, &uurb->number_of_packets) ||
-           __get_user(kurb->error_count, &uurb->error_count) ||
-           __get_user(kurb->signr, &uurb->signr))
-               return -EFAULT;
-
-       kurb->usercontext = 0; /* unused currently */
-
-       return 0;
-}
-
-/* Just put back the values which usbdevfs actually changes. */
-static int put_urb32(struct usbdevfs_urb *kurb,
-                    struct usbdevfs_urb32 *uurb)
-{
-       if (put_user(kurb->status, &uurb->status) ||
-           __put_user(kurb->actual_length, &uurb->actual_length) ||
-           __put_user(kurb->error_count, &uurb->error_count))
-               return -EFAULT;
-
-       if (kurb->number_of_packets != 0) {
-               int i;
-
-               for (i = 0; i < kurb->number_of_packets; i++) {
-                       if (__put_user(kurb->iso_frame_desc[i].actual_length,
-                                      &uurb->iso_frame_desc[i].actual_length) ||
-                           __put_user(kurb->iso_frame_desc[i].status,
-                                      &uurb->iso_frame_desc[i].status))
-                               return -EFAULT;
-               }
-       }
-
-       return 0;
-}
-
-static int get_urb32_isoframes(struct usbdevfs_urb *kurb,
-                              struct usbdevfs_urb32 *uurb)
-{
-       unsigned int totlen;
-       int i;
-
-       if (kurb->type != USBDEVFS_URB_TYPE_ISO) {
-               kurb->number_of_packets = 0;
-               return 0;
-       }
-
-       if (kurb->number_of_packets < 1 ||
-           kurb->number_of_packets > 128)
-               return -EINVAL;
-
-       if (copy_from_user(&kurb->iso_frame_desc[0],
-                          &uurb->iso_frame_desc[0],
-                          sizeof(struct usbdevfs_iso_packet_desc) *
-                          kurb->number_of_packets))
-               return -EFAULT;
-
-       totlen = 0;
-       for (i = 0; i < kurb->number_of_packets; i++) {
-               unsigned int this_len;
-
-               this_len = kurb->iso_frame_desc[i].length;
-               if (this_len > 1023)
-                       return -EINVAL;
-
-               totlen += this_len;
-       }
-
-       if (totlen > 32768)
-               return -EINVAL;
-
-       kurb->buffer_length = totlen;
-
-       return 0;
-}
-
-static int do_usbdevfs_urb(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-       struct usbdevfs_urb *kurb;
-       struct usbdevfs_urb32 *uurb;
-       mm_segment_t old_fs;
-       __u32 udata;
-       void *uptr, *kptr;
-       unsigned int buflen;
-       int err;
-
-       uurb = compat_ptr(arg);
-
-       err = -ENOMEM;
-       kurb = kmalloc(sizeof(struct usbdevfs_urb) +
-                      (sizeof(struct usbdevfs_iso_packet_desc) * 128),
-                      GFP_KERNEL);
-       if (!kurb)
-               goto out;
-
-       err = -EFAULT;
-       if (get_urb32(kurb, uurb))
-               goto out;
-
-       err = get_urb32_isoframes(kurb, uurb);
-       if (err)
-               goto out;
-
-       err = -EFAULT;
-       if (__get_user(udata, &uurb->buffer))
-               goto out;
-       uptr = compat_ptr(udata);
-
-       buflen = kurb->buffer_length;
-       err = verify_area(VERIFY_WRITE, uptr, buflen);
-       if (err)
-               goto out;
-
-
-       old_fs = get_fs();
-       set_fs(KERNEL_DS);
-       err = sys_ioctl(fd, USBDEVFS_SUBMITURB, (unsigned long) kurb);
-       set_fs(old_fs);
-
-       if (err >= 0) {
-               /* RED-PEN Shit, this doesn't work for async URBs :-( XXX */
-               if (put_urb32(kurb, uurb)) {
-                       err = -EFAULT;
-               }
-       }
-
-out:
-       kfree(kurb);
-       return err;
-}
-#endif
-
-#define USBDEVFS_REAPURB32         _IOW('U', 12, u32)
-#define USBDEVFS_REAPURBNDELAY32   _IOW('U', 13, u32)
 
-static int do_usbdevfs_reapurb(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-        mm_segment_t old_fs;
-        void *kptr;
-        int err;
-
-        old_fs = get_fs();
-        set_fs(KERNEL_DS);
-        err = sys_ioctl(fd,
-                        (cmd == USBDEVFS_REAPURB32 ?
-                         USBDEVFS_REAPURB :
-                         USBDEVFS_REAPURBNDELAY),
-                        (unsigned long) &kptr);
-        set_fs(old_fs);
-
-        if (err >= 0 &&
-            put_user((u32)(u64)kptr, (u32 __user *)compat_ptr(arg)))
-                err = -EFAULT;
-
-        return err;
-}
+/*
+ *  USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY
+ *  are handled in usbdevfs core.                      -Christopher Li
+ */
 
 struct usbdevfs_disconnectsignal32 {
         compat_int_t signr;
@@ -2903,11 +2429,11 @@ static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long a
        tdata = compat_alloc_user_space(sizeof(*tdata));
        if (tdata == NULL)
                return -ENOMEM;
-       if (verify_area(VERIFY_WRITE, tdata, sizeof(*tdata)))
+       if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
                return -EFAULT;
 
        udata = compat_ptr(arg);
-       if (verify_area(VERIFY_READ, udata, sizeof(*udata)))
+       if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
                return -EFAULT;
 
        if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
@@ -2944,7 +2470,7 @@ static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long ar
 
        iwp = &iwr->u.data;
 
-       if (verify_area(VERIFY_WRITE, iwr, sizeof(*iwr)))
+       if (!access_ok(VERIFY_WRITE, iwr, sizeof(*iwr)))
                return -EFAULT;
 
        if (__copy_in_user(&iwr->ifr_ifrn.ifrn_name[0],
@@ -2980,6 +2506,40 @@ static int old_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg
        return -EINVAL;
 }
 
+#define RTC_IRQP_READ32                _IOR('p', 0x0b, compat_ulong_t)
+#define RTC_IRQP_SET32         _IOW('p', 0x0c, compat_ulong_t)
+#define RTC_EPOCH_READ32       _IOR('p', 0x0d, compat_ulong_t)
+#define RTC_EPOCH_SET32                _IOW('p', 0x0e, compat_ulong_t)
+
+static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
+{
+       mm_segment_t oldfs = get_fs();
+       compat_ulong_t val32;
+       unsigned long kval;
+       int ret;
+
+       switch (cmd) {
+       case RTC_IRQP_READ32:
+       case RTC_EPOCH_READ32:
+               set_fs(KERNEL_DS);
+               ret = sys_ioctl(fd, (cmd == RTC_IRQP_READ32) ?
+                                       RTC_IRQP_READ : RTC_EPOCH_READ,
+                                       (unsigned long)&kval);
+               set_fs(oldfs);
+               if (ret)
+                       return ret;
+               val32 = kval;
+               return put_user(val32, (unsigned int __user *)arg);
+       case RTC_IRQP_SET32:
+               return sys_ioctl(fd, RTC_IRQP_SET, arg); 
+       case RTC_EPOCH_SET32:
+               return sys_ioctl(fd, RTC_EPOCH_SET, arg);
+       default:
+               /* unreached */
+               return -ENOIOCTLCMD;
+       }
+}
+
 #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
 struct ncp_ioctl_request_32 {
        u32 function;
@@ -3167,10 +2727,34 @@ static int do_ncp_setprivatedata(unsigned int fd, unsigned int cmd, unsigned lon
 }
 #endif
 
-#undef CODE
-#endif
+static int
+lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
+{
+       struct compat_timeval __user *tc = (struct compat_timeval __user *)arg;
+       struct timeval __user *tn = compat_alloc_user_space(sizeof(struct timeval));
+       struct timeval ts;
+       if (get_user(ts.tv_sec, &tc->tv_sec) ||
+           get_user(ts.tv_usec, &tc->tv_usec) ||
+           put_user(ts.tv_sec, &tn->tv_sec) ||
+           put_user(ts.tv_usec, &tn->tv_usec))
+               return -EFAULT;
+       return sys_ioctl(fd, cmd, (unsigned long)tn);
+}
+
+#define HANDLE_IOCTL(cmd,handler) \
+       { (cmd), (ioctl_trans_handler_t)(handler) },
+
+/* pointer to compatible structure or no argument */
+#define COMPATIBLE_IOCTL(cmd) \
+       { (cmd), do_ioctl32_pointer },
 
-#ifdef DECLARES
+/* argument is an unsigned long integer, not a pointer */
+#define ULONG_IOCTL(cmd) \
+       { (cmd), (ioctl_trans_handler_t)sys_ioctl },
+
+
+struct ioctl_trans ioctl_start[] = {
+#include <linux/compat_ioctl.h>
 HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob)
 HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob)
 #ifdef CONFIG_NET
@@ -3232,10 +2816,7 @@ HANDLE_IOCTL(BLKGETSIZE, w_long)
 HANDLE_IOCTL(0x1260, broken_blkgetsize)
 HANDLE_IOCTL(BLKFRAGET, w_long)
 HANDLE_IOCTL(BLKSECTGET, w_long)
-HANDLE_IOCTL(FBIOGET_FSCREENINFO, fb_ioctl_trans)
 HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
-HANDLE_IOCTL(FBIOGETCMAP, fb_ioctl_trans)
-HANDLE_IOCTL(FBIOPUTCMAP, fb_ioctl_trans)
 HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans)
 HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans)
 HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans)
@@ -3253,14 +2834,13 @@ HANDLE_IOCTL(FDPOLLDRVSTAT32, fd_ioctl_trans)
 HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans)
 HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans)
 HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
+HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans)
 HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans)
 HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans)
 HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans)
 HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans)
 HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans)
 HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans)
-HANDLE_IOCTL(MTIOCGETCONFIG32, mt_ioctl_trans)
-HANDLE_IOCTL(MTIOCSETCONFIG32, mt_ioctl_trans)
 HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans)
 HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans)
 HANDLE_IOCTL(LOOP_SET_STATUS, loop_status)
@@ -3278,14 +2858,15 @@ HANDLE_IOCTL(EXT2_IOC32_GETFLAGS, do_ext2_ioctl)
 HANDLE_IOCTL(EXT2_IOC32_SETFLAGS, do_ext2_ioctl)
 HANDLE_IOCTL(EXT2_IOC32_GETVERSION, do_ext2_ioctl)
 HANDLE_IOCTL(EXT2_IOC32_SETVERSION, do_ext2_ioctl)
-HANDLE_IOCTL(VIDIOCGTUNER32, do_video_ioctl)
-HANDLE_IOCTL(VIDIOCSTUNER32, do_video_ioctl)
-HANDLE_IOCTL(VIDIOCGWIN32, do_video_ioctl)
-HANDLE_IOCTL(VIDIOCSWIN32, do_set_window)
-HANDLE_IOCTL(VIDIOCGFBUF32, do_video_ioctl)
-HANDLE_IOCTL(VIDIOCSFBUF32, do_video_ioctl)
-HANDLE_IOCTL(VIDIOCGFREQ32, do_video_ioctl)
-HANDLE_IOCTL(VIDIOCSFREQ32, do_video_ioctl)
+HANDLE_IOCTL(EXT3_IOC32_GETVERSION, do_ext3_ioctl)
+HANDLE_IOCTL(EXT3_IOC32_SETVERSION, do_ext3_ioctl)
+HANDLE_IOCTL(EXT3_IOC32_GETRSVSZ, do_ext3_ioctl)
+HANDLE_IOCTL(EXT3_IOC32_SETRSVSZ, do_ext3_ioctl)
+HANDLE_IOCTL(EXT3_IOC32_GROUP_EXTEND, do_ext3_ioctl)
+COMPATIBLE_IOCTL(EXT3_IOC_GROUP_ADD)
+#ifdef CONFIG_JBD_DEBUG
+HANDLE_IOCTL(EXT3_IOC32_WAIT_FOR_READONLY, do_ext3_ioctl)
+#endif
 /* One SMB ioctl needs translations. */
 #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
 HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
@@ -3328,13 +2909,25 @@ HANDLE_IOCTL(RAW_GETBIND, raw_ioctl)
 /* Serial */
 HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl)
 HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl)
+#ifdef TIOCGLTC
+COMPATIBLE_IOCTL(TIOCGLTC)
+COMPATIBLE_IOCTL(TIOCSLTC)
+#endif
+#ifdef TIOCSTART
+/*
+ * For these two we have defintions in ioctls.h and/or termios.h on
+ * some architectures but no actual implemention.  Some applications
+ * like bash call them if they are defined in the headers, so we provide
+ * entries here to avoid syslog message spew.
+ */
+COMPATIBLE_IOCTL(TIOCSTART)
+COMPATIBLE_IOCTL(TIOCSTOP)
+#endif
 /* Usbdevfs */
 HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
 HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
-/*HANDLE_IOCTL(USBDEVFS_SUBMITURB32, do_usbdevfs_urb)*/
-HANDLE_IOCTL(USBDEVFS_REAPURB32, do_usbdevfs_reapurb)
-HANDLE_IOCTL(USBDEVFS_REAPURBNDELAY32, do_usbdevfs_reapurb)
 HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
+COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
 /* i2c */
 HANDLE_IOCTL(I2C_FUNCS, w_long)
 HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
@@ -3355,6 +2948,10 @@ HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl)
 HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl)
 HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl)
 HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl)
+HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl)
+HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl)
+HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl)
+HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl)
 
 #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
 HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest)
@@ -3366,5 +2963,25 @@ HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata)
 HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata)
 #endif
 
-#undef DECLARES
-#endif
+/* dvb */
+HANDLE_IOCTL(DMX_GET_EVENT, do_dmx_get_event)
+HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event)
+HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture)
+HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette)
+
+/* parport */
+COMPATIBLE_IOCTL(LPTIME)
+COMPATIBLE_IOCTL(LPCHAR)
+COMPATIBLE_IOCTL(LPABORTOPEN)
+COMPATIBLE_IOCTL(LPCAREFUL)
+COMPATIBLE_IOCTL(LPWAIT)
+COMPATIBLE_IOCTL(LPSETIRQ)
+COMPATIBLE_IOCTL(LPGETSTATUS)
+COMPATIBLE_IOCTL(LPGETSTATUS)
+COMPATIBLE_IOCTL(LPRESET)
+/*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/
+COMPATIBLE_IOCTL(LPGETFLAGS)
+HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans)
+};
+
+int ioctl_table_size = ARRAY_SIZE(ioctl_start);