Minor device number (source code)

= Minor device number

A \b[minor device number] is the second component of a <device number>. In the Linux interface, `minor(d)` extracts it from a value of type `dev_t`; the matching <major device number> supplies its device-class context.<Device-number conversion in the Linux man-pages project>[makedev(3), DESCRIPTION]{ref}

A concrete Linux allocation distinguishes two character-special interfaces sharing major1: `/dev/null` has minor3, while `/dev/zero` has minor5.<Linux allocated devices in the Linux kernel documentation>[Entry1, character memory devices]{ref} The former supplies end-of-file when read, while the latter supplies zero-valued bytes. Their different minor values select different interface behavior within the same major allocation.<Null and zero devices in the Linux man-pages project>[null(4), DESCRIPTION]{ref}

For an original pair comparison, let two registered character-device interfaces have numbers $(240,7)$ and $(241,7)$. Both have minor7, but their complete <device numbers> differ. Conversely, $(240,7)$ and $(240,8)$ share a major while selecting different minor values within it. A minor value alone is therefore insufficient to identify the interface.

Minor numbers are interpreted in the relevant device allocation; there is no universal rule that every minor counts disks, partitions or physical pieces of hardware. The device may also be a purely virtual interface. The conversion functions preserve the structured components:
$$
\operatorname{minor}(\operatorname{makedev}(a,b))=b
$$
for supported component values. Extracting the component with the documented interface avoids assuming an implementation-specific bit packing.