Messages in this thread | | | Date | Sun, 3 Aug 2008 03:18:28 +0200 | From | Mikael Pettersson <> | Subject | Re: ioctl's suck? |
| |
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.)
| |