Major and Minor Device Numbers

Each device has a major and minor device number assigned. These numbers identify the proper device location and device driver to the kernel. This number is used by the operating system to key into the proper device driver whenever a physical device file corresponding to one of the devices it manages is opened. The major device number indicates the general device class, such as disk, tape, or serial line. The minor device number indicates the specific member within that class. All devices managed by a given device driver contain a unique minor number. Some drivers of pseudo devices (software entities set up to look like devices) create new minor devices on demand. Together, the major and minor numbers uniquely define a device and its device driver.

Physical device files have a unique output when listed with the ls -l command, as shown in the following example:

cd /devices/iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000 
ls -l sd@0 

The system responds with this:

brw-r-----   1 root     sys       32,  0 Jul 21 07:44 sd@0,0:a 
crw-r-----   1 root     sys       32,  0 Jul 21 07:44 sd@0,0:a,raw 
brw-r-----   1 root     sys       32,  1 Jul 21 07:44 sd@0,0:b 
crw-r-----   1 root     sys       32,  1 Aug 16 06:15 sd@0,0:b,raw 
brw-r-----   1 root     sys       32,  2 Jul 21 07:44 sd@0,0:c 
crw-r-----   1 root     sys       32,  2 Jul 21 07:44 sd@0,0:c,raw 
brw-r-----   1 root     sys       32,  3 Jul 21 07:44 sd@0,0:d 
crw-r-----   1 root     sys       32,  3 Jul 21 07:44 sd@0,0:d,raw 
brw-r-----   1 root     sys       32,  4 Jul 21 07:44 sd@0,0:e 
crw-r-----   1 root     sys       32,  4 Jul 21 07:44 sd@0,0:e,raw 
brw-r-----   1 root     sys       32,  5 Jul 21 07:44 sd@0,0:f 
crw-r-----   1 root     sys       32,  5 Jul 21 07:44 sd@0,0:f,raw 
brw-r-----   1 root     sys       32,  6 Jul 21 07:44 sd@0,0:g 
crw-r-----   1 root     sys       32,  6 Aug 16 06:13 sd@0,0:g,raw 
brw-r-----   1 root     sys       32,  7 Jul 21 07:44 sd@0,0:h 
crw-r-----   1 root     sys       32,  7 Jul 21 07:44 sd@0,0:h,raw 

This long listing includes columns showing major and minor numbers for each device. The sd driver manages all the devices listed in the previous example, which have a major number of 32. Minor numbers are listed after the comma.

During the process of building the /devices directory, the devfsadmd daemon assigns each device a major device number by using the name-to-number mappings held in the /etc/name_to_major file. This file is maintained by the system and is undocumented. The following is a sample of the / etc/ name_to_major file:

more /etc/name_to_major 
cn 0 
rootnex 1 
pseudo 2 
ip 3 
logindmux 4 
icmp 5 
fas 6 
hme 7 
p9000 8 
p9100 9 
sp 10 
clone 11 
sad 12 
mm 13 
iwscn 14 
wc 15 
conskbd 16 
consms 17 
ipdcm 18 
dump 19 
se 20 
log 21 
sy 22 
ptm 23 
pts 24 
ptc 25 
ptsl 26 
bwtwo 27 
audio 28 
zs 29 
cgthree 30 
cgtwo 31 
sd 32 
st 33 
... 
... 

envctrl 131 
cvc 132 
cvcredir 133 
eide 134 
hd 135  
tadbat 136 
ts102 137 
simba 138 
uata 139 
dad 140 
atapicd 141 

To create the minor device entries, the devfsadmd daemon uses the information placed in the dev_info node by the device driver. Permissions and ownership information are kept in the / etc/minor_perm file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset