Major and Minor Device NumbersEach device has a major and minor device number assigned to it. 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 maps to a device driver such as sd, st, or hme. The minor device number indicates the specific member within that class of devices. 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/pci@1f,0/pci@1,1/ide@3 ls -l The system responds with this: total 4 drwxr-xr-x 2 root sys 512 Mar 24 13:25 dad@0,0 brw-r----- 1 root sys 136, 8 Aug 5 11:31 dad@0,0:a crw-r----- 1 root sys 136, 8 Aug 5 11:57 dad@0,0:a,raw brw-r----- 1 root sys 136, 9 Aug 5 11:32 dad@0,0:b crw-r----- 1 root sys 136, 9 Aug 5 11:57 dad@0,0:b,raw brw-r----- 1 root sys 136, 10 Aug 5 11:57 dad@0,0:c crw-r----- 1 root sys 136, 10 Aug 5 11:57 dad@0,0:c,raw brw-r----- 1 root sys 136, 11 Aug 5 11:55 dad@0,0:d crw-r----- 1 root sys 136, 11 Aug 5 11:57 dad@0,0:d,raw brw-r----- 1 root sys 136, 12 Aug 5 11:32 dad@0,0:e crw-r----- 1 root sys 136, 12 Aug 5 11:57 dad@0,0:e,raw brw-r----- 1 root sys 136, 13 Aug 5 11:32 dad@0,0:f crw-r----- 1 root sys 136, 13 Aug 5 11:57 dad@0,0:f,raw brw-r----- 1 root sys 136, 14 Aug 5 11:32 dad@0,0:g crw-r----- 1 root sys 136, 14 Aug 5 11:57 dad@0,0:g,raw brw-r----- 1 root sys 136, 15 Aug 5 11:32 dad@0,0:h crw-r----- 1 root sys 136, 15 Aug 5 11:57 dad@0,0:h,raw This long listing includes columns showing major and minor numbers for each device. The dad driver manages all the devices listed in the previous example, which have a major number of 136. Minor numbers are listed after the comma. During the process of building the /devices directory, major numbers are assigned based on the kernel module attached to the device. Each device is assigned 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. |