Re: [discuss] f_ops flag to speed up compatible ioctls in linux kernel

Michael S. Tsirkin
2004-09-07T18:24:36Z

Hello!
Quoting r. Andi Kleen (ak@suse.de) "Re: [discuss] f_ops flag to speed up compatible ioctls in linux kernel":
> On Tue, Sep 07, 2004 at 05:45:43PM +0300, Michael S. Tsirkin wrote:
> > > > > but I cannot think of a good alternative.
> > > > >
> > > >
> > > > Maybe one entry point with a flag?
> > >
> > > That would be IMHO far uglier than two.
> > >
> > > -Andi
> > >
> >
> > What would be a good name? ioctl32/ioctl64? ioctl_compat/ioctl_native?
>
> Later two sound ok to me.
>

Wait, I think that a properly coded ioctl can always
figure out this is a compat call by looking at the command
(see example below).
So maybe we can live with just one new entry point with these
semantics?

MST

Example:

my_ioctl.h

//This structure size is different on 32 and 64 bit systems
struct my_foo {
long foobar;
};

#define FOO _IOR(MY_MAGIC,0,struct my_foo)

//
my_ioctl.c

struct my_foo32 {
int foobar;
};
#define FOO32 _IOR(MY_MAGIC,0,struct my_foo32)

static int ioctl_native (struct inode *inode, struct file *file, unsigned int
opcode, unsigned long udata_l);
static int ioctl_compat (struct inode *inode, struct file *file, unsigned int
opcode, unsigned long udata_l);

static int ioctl (struct inode *inode, struct file *file, unsigned int
opcode, unsigned long udata_l)
{
switch (opcode)
{
case FOO32:
return ioctl_compat(inode,file,opcode,udata_l);
case FOO:
default:
return ioctl_native(inode,file,opcode,udata_l);
}
}