Re: ioctl's suck?

From: Mikael Pettersson
Date: Sat Aug 02 2008 - 21:18:58 EST


Brian Beattie writes:
> The other day Linus (I think) made the statement, that I don't disagree
> with, that I will parapharse as "ioctl's suck". If I recall correctly
> and understand he was saying that a device that uses ioctls is broken.
...
> I could add a control device and pass ascii strings for status and OOB
> messages, would that be an improvement?

The problem is that the classical unix I/O abstraction really only handles
two cases well, viz. "read next chunk of data" and "write this data and
advance position". Anything else is seen as something strange.

ioctls() are the equivalent of device-specific RPCs (remote procedure
calls): you present some arguments and a call code, and you get some
results. Nothing wrong with that.

In practice however there are some pitfalls. For instance, ioctls()
are often abused for quick hacks with little concern for backwards
compatibility. So when someone changes an ioctl, and breaks user-space,
who gets the blame? ioctls in general! I would argue that that is
why, and the main reason why, some people put ioctls() down.

There may be something wrong with people abusing ioctls, but that
is not a problem with ioctls per se. (I can easily design broken
ABIs around read()/write()/open()-only interfaces.)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/