How come two devices share the same major-minor device number?
I am reading "Linux device drivers, 3rd edition", and found something i can't understand.
in Chapter 3.2, the author said:
Traditionally, the major number identifies the driver associated with the device. The minor number is used by the kernel to determine exactly which device is being referred to.
Then I tried "ls -l /dev" to have a look, I found some thing unusual:
brw-rw---- 1 root disk 1, 1 201开发者_JAVA技巧1-08-23 23:52 ram1
brw-rw---- 1 root disk 1, 2 2011-08-23 23:52 ram2
brw-rw---- 1 root disk 1, 3 2011-08-23 23:52 ram3
brw-rw---- 1 root disk 1, 4 2011-08-23 23:52 ram4
brw-rw---- 1 root disk 1, 5 2011-08-23 23:52 ram5
...
crw-r----- 1 root kmem 1, 1 2011-08-23 23:52 mem
crw-r----- 1 root kmem 1, 4 2011-08-23 23:52 port
crw-rw-rw- 1 root root 1, 3 2011-08-23 23:52 null
crw-rw-rw- 1 root root 1, 5 2011-08-23 23:52 zero
These devices (ram1-ram5) all have a clone, with the same major-minor, but different name and type. I thought the author was saying "major number means device class, and minor number means device index. So Major-Minor identifies a unique device."
Now I am confused. How come two devices could share the same major-minor? What exactly the device numbers are?
Correct me if I was wrong.. Thanks in advance.
mem
, port
, null
, and zero
are character devices (as evidenced by the c
the listing starts with). The ramN
devices are block devices (hence the b
). Major/minor numbers for block devices are independent from character devices, and vice versa.
精彩评论