[lkml]   [2003]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: ioctl cleanups: enable sg_io and serial stuff to be shared
On Wednesday 07 May 2003 18:04, David S. Miller wrote:
> You can define it as follows:
> 1) If entry exists in COMPAT or TRANSLATE table, invoke
> fops->ioctl(), else
> 2) If ->compat_ioctl() exists, invoke that, else
> 3) Fail.

Another solution could be to use the tables only if
->compat_ioctl() is undefined or returned -ENOTTY. That
would save the hash table lookup in many cases and makes
it possible for a driver to override a generic handler
with its more specialized version (e.g. CIODEVPRIVATE).

> The COMPAT tables are sort of valuable, in that it eliminates
> the need to duplicate code when all of a drivers ioctls need
> no translation.

Right. Of course you can just as well do

.ioctl = &foo_ioctl,
.compat_ioctl = &foo_ioctl,

in that case.

Btw: is there any bit in the ioctl number definition that can
be (ab)used for compat_ioctl? Maybe we don't even need another
callback if the compatibility mode can be encoded in the
number itself (simplified):

long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
unsigned long arg)
long err = sys_ioctl(fd, cmd | _IOC_COMPAT, arg);
if (err == -ENOTTY) /* use ioctl_trans table */
err = compat_do_ioctl(fd, cmd, arg);
return err;
long foo_ioctl(struct inode * inode, struct file * filp,
unsigned int cmd, unsigned long arg)
switch(cmd) {
return do_something(inode, arg);
return compat_do_something(inode, arg);
return do_something_else(inode, arg);
return -ENOTTY;

Arnd <><
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:35    [W:0.237 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site