The minor number is used by the kernel to determine exactly which device is being referred to.
The above explanation is just two abstract, can someone illustrate?
The minor number is used by the kernel to determine exactly which device is being referred to.
The above explanation is just two abstract, can someone illustrate?
The major number identifies the device driver to use, the minor number indicates which device. If you have multiple partitions, for instance, each gets its own minor:
brw-rw---- 1 root disk 8, 0 Jun 3 20:48 /dev/sda
brw-rw---- 1 root disk 8, 1 Jun 3 20:48 /dev/sda1
brw-rw---- 1 root disk 8, 2 Jun 3 20:48 /dev/sda2
Minor 0 in this case is the raw drive, minor 1 is partition 1, minor 2 is partition 2, etc. Not all devices use 0 as a special case, however. The serial devices start their numbering at 0, where /dev/tty0
is just the first (virtual) terminal device on the system:
crw--w---- 1 root tty 4, 0 Jun 3 20:48 /dev/tty0
crw------- 1 root root 4, 1 Jun 3 20:50 /dev/tty1
crw------- 1 root root 4, 2 Jun 3 20:50 /dev/tty2
crw------- 1 root root 4, 3 Jun 3 20:50 /dev/tty3
In either event, when the device file is opened the kernel will use the major number to determine which module will handle the file and passes the minor to the open()
method of the struct file_operations
structure that was registered with register_chrdev()
.