Conceptual
Login

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?