Messages in this thread Patch in this message | | | Date | Thu, 6 Jan 2005 15:41:44 +0200 | From | "Michael S. Tsirkin" <> | Subject | [PATCH] make standard conversions work with compat_ioctl. |
| |
Hello! Quoting r. Andrew Morton (akpm@osdl.org) "Re: [PATCH] deprecate (un)register_ioctl32_conversion": > "Michael S. Tsirkin" <mst@mellanox.co.il> wrote: > > Christoph, I know you want to remove the inode parameter :) > > > > Otherwise I think -mm1 has the final version of the replacement. > > I merged Christoph's verion of the patch into -mm.
Unfortunately, in -mm2 version, it seems that once a driver implements compat_ioctl, the standard ioctls like FIOQSIZE stop working for it, and so do standard commands implemented with COMPATIBLE_IOCTL.
The simplest solution is, I think, to do as Arnd Bergmann suggested, and go back to the hash lookup if compat_ioctl returns -ENOIOCTLCMD.
To make it easy to use the same function for unlocked_ioctl and for ioctl_compat, for unlocked_ioctl the code -ENOIOCTLCMD shall be translated to -EINVAL.
Attached patch is for -mm2, applies over 2.6.10 as well with ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.10/2.6.10-mm2/broken-out/ioctl-rework-2.patch
MST
Handle generic ioctl commands by falling back on static conversion functions in fs/compat_ioctl.c on -ENOIOCTLCMD code.
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
diff -rup linux-2.6.10/fs/compat.c linux-2.6.10-ioctls/fs/compat.c --- linux-2.6.10/fs/compat.c 2005-01-06 17:54:13.234156872 +0200 +++ linux-2.6.10-ioctls/fs/compat.c 2005-01-06 17:37:38.110438672 +0200 @@ -440,8 +440,10 @@ asmlinkage long compat_sys_ioctl(unsigne if (!filp->f_op->ioctl) goto do_ioctl; } else if (filp->f_op->compat_ioctl) { + /* compat_ioctl returns -ENOIOCTLCMD on unhandled command. */ error = filp->f_op->compat_ioctl(filp, cmd, arg); - goto out_fput; + if (error != -ENOIOCTLCMD) + goto out_fput; } down_read(&ioctl32_sem); diff -rup linux-2.6.10/fs/ioctl.c linux-2.6.10-ioctls/fs/ioctl.c --- linux-2.6.10/fs/ioctl.c 2005-01-06 17:54:13.235156720 +0200 +++ linux-2.6.10-ioctls/fs/ioctl.c 2005-01-06 18:00:10.463849704 +0200 @@ -26,6 +26,9 @@ static long do_ioctl(struct file *filp, if (filp->f_op->unlocked_ioctl) { error = filp->f_op->unlocked_ioctl(filp, cmd, arg); + if (error == -ENOIOCTLCMD) + error = -EINVAL; + goto out; } else if (filp->f_op->ioctl) { lock_kernel(); error = filp->f_op->ioctl(filp->f_dentry->d_inode, - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |