|
5 | 5 | //! What is an `ioctl`?
|
6 | 6 | //! ===================
|
7 | 7 | //!
|
8 |
| -//! The `ioctl` syscall is the grab-bag syscall on POSIX systems. Don't want |
9 |
| -//! to add a new syscall? Make it an `ioctl`! `ioctl` refers to both the syscall, |
10 |
| -//! and the commands that can be send with it. `ioctl` stands for "IO control", |
11 |
| -//! and the commands are always sent to a file descriptor. |
| 8 | +//! The `ioctl` syscall is the grab-bag syscall on POSIX systems. Don't want to add a new |
| 9 | +//! syscall? Make it an `ioctl`! `ioctl` refers to both the syscall, and the commands that can be |
| 10 | +//! sent with it. `ioctl` stands for "IO control", and the commands are always sent to a file |
| 11 | +//! descriptor. |
12 | 12 | //!
|
13 | 13 | //! It is common to see `ioctl`s used for the following purposes:
|
14 | 14 | //!
|
15 |
| -//! * Provide read/write access to out-of-band data related |
16 |
| -//! to a device such as configuration (for instance, setting |
17 |
| -//! serial port options) |
18 |
| -//! * Provide a mechanism for performing full-duplex data |
19 |
| -//! transfers (for instance, xfer on SPI devices). |
20 |
| -//! * Provide access to control functions on a device (for example, |
21 |
| -//! on Linux you can send commands like pause, resume, and eject |
22 |
| -//! to the CDROM device. |
23 |
| -//! * Do whatever else the device driver creator thought made most sense. |
| 15 | +//! * Provide read/write access to out-of-band data related to a device such as configuration |
| 16 | +//! (for instance, setting serial port options) |
| 17 | +//! * Provide a mechanism for performing full-duplex data transfers (for instance, xfer on SPI |
| 18 | +//! devices). |
| 19 | +//! * Provide access to control functions on a device (for example, on Linux you can send |
| 20 | +//! commands like pause, resume, and eject to the CDROM device. |
| 21 | +//! * Do whatever else the device driver creator thought made most sense. |
24 | 22 | //!
|
25 | 23 | //! `ioctl`s are synchronous system calls and are similar to read and write calls in that regard.
|
26 | 24 | //! They operate on file descriptors and have an identifier that specifies what the ioctl is.
|
|
30 | 28 | //!
|
31 | 29 | //! Historically `ioctl` numbers were arbitrary hard-coded values. This changed to a more-ordered
|
32 | 30 | //! system where the ioctl numbers had various subcomponents:
|
| 31 | +//! |
33 | 32 | //! * Number: The actual ioctl ID
|
34 | 33 | //! * Type: A grouping of ioctls for a common purpose or driver
|
35 | 34 | //! * Size: The size in bytes of the data that will be transferred
|
|
0 commit comments