Francis M. Bacon
Francis M. Bacon

Reputation: 705

Is there any significance to Linux device major numbers besides being essentially an index into a table?

Confused by the significance of device major numbers. Could someone please confirm this for me?:

Linux device major numbers are simply indexes into some kernel list like data structure (~an array) and carry no real significance beyond that. Essentially some object implementing some set of interfaces (driver) lives at that offset. By convention certain major numbers point to such object with certain roles, but its only convention. For example, I had always assumed major numbers were somehow associated with specific hardware addresses / busses, but that is not the case - they are just indexes ...

Upvotes: 1

Views: 231

Answers (1)

skrrgwasme
skrrgwasme

Reputation: 9633

For the major device numbers, you're essentially correct: they index into the kernel's device driver table to identify driver routines for handling the device. The minor device numbers though, distinguish unique devices that use that driver from each other, as multiple devices could be present on the system that utilize a single driver.

You're also correct that some major numbers are statically (hard-coded) allocated to certain common devices like your hard disk or some TTY devices (for legacy reasons), but most are allocated dynamically. New drivers that are added to the Linux kernel are now expected to request device numbers dynamically.

Further Reading:

https://www.kernel.org/doc/Documentation/devices.txt - Shows which kinds of devices are hard-coded to which major numbers
http://www.linux-tutorial.info/modules.php?name=MContent&pageid=94 - More detailed explanation of major/minor numbers.

Upvotes: 2

Related Questions