Re: ioctl assignment strategy?

From: Greg KH
Date: Tue Dec 21 2004 - 12:31:46 EST

On Mon, Dec 20, 2004 at 11:37:54AM -0600, Chris Friesen wrote:
> Greg KH wrote:
> >Rethink the way you want to control your device. Seriously, a lot of
> >ioctls can be broken down into single device files, single sysfs files,
> >or other such things (a whole new fs as a last resort too.)
> Actually, my particular case is likely not a good example. We've got a
> misc char driver giving access to a lot of miscellaneous features we've
> added to the kernel,. We originally (a few years back) used new syscalls,
> but then we started supporting a bunch more arches, and having to patch all
> of them just to add syscall numbers sucked.
> Some of it could easily be moved to /proc or /sys, but if you do it that
> way, how do you handle returning unusual error values? Other stuff
> involves multiple stages of registration, then getting handles returned,
> and doing new calls with those handles. I don't see how this would tie
> nicely into the read/write paradigm.

Multiple files? One per type of action? Without a full description of
what you are doing I don't really have a good answer.

> What's the big problem with ioctls anyways? I mean, in a closed
> environment where I'm writing both the userspace and the kernelspace side
> of things.

ioctls are basically a simple way to add any kind of syscall to the
kernel. They also have nasty 32/64 bit issues. Because we want to have
well-defined syscalls that work on all platforms, and not any arbitrary
type of call, it is good to restrict ioctls.

See the other comments about this topic in the lkml archives.


greg k-h
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at