The ioctl Call for Commands That Are Not Reads or Writes
Plenty of things you want to ask a device are not a stream of bytes: reset yourself, report your version, set a mode. Ioctl is the general-purpose side door for exactly those, taking a command number and an optional pointer to a small structure. It is powerful and easy to abuse, so each command number encodes its direction and size, and every pointer it carries must be treated as untrusted.
Questions this Concept answers
- Why does ioctl exist when `read` and `write` already move data between a program and a driver?
ioctl for Character Device Drivers in the Linux Kernel
ioctl (I/O control) is a generic mechanism in Unix-like operating systems that lets user-space programs invoke device-specific operations on an open file descriptor that go beyond the standard read/w…