linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] make standard conversions work with compat_ioctl.
@ 2005-01-06 13:41 Michael S. Tsirkin
  0 siblings, 0 replies; only message in thread
From: Michael S. Tsirkin @ 2005-01-06 13:41 UTC (permalink / raw)
  To: Andrew Morton
  Cc: hch, ak, mingo, rlrevell, tiwai, linux-kernel, pavel, discuss,
	gordon.jin, alsa-devel, greg

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,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-01-06 13:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-06 13:41 [PATCH] make standard conversions work with compat_ioctl Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).