Major and Minor Device Numbers
Each 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 OS 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 e1000g. 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@780/pci@0/pci@9/scsi@0<cr> # ls -l<cr>
The system responds with the following:
total 4 drwxr-xr-x 2 root sys 2 Jan 24 13:25 sd@0,0 brw-r----- 1 root sys 203, 16 Jan 24 12:32 sd@0,0:a crw-r----- 1 root sys 203, 16 Jan 24 12:32 sd@0,0:a,raw brw-r----- 1 root sys 203, 17 Jan 24 12:32 sd@0,0:b crw-r----- 1 root sys 203, 17 Jan 24 12:32 sd@0,0:b,raw brw-r----- 1 root sys 203, 18 Jan 24 12:32 sd@0,0:c crw-r----- 1 root sys 203, 18 Jan 24 12:32 sd@0,0:c,raw brw-r----- 1 root sys 203, 19 Jan 24 12:32 sd@0,0:d crw-r----- 1 root sys 203, 19 Jan 24 12:32 sd@0,0:d,raw brw-r----- 1 root sys 203, 20 Jan 24 12:32 sd@0,0:e crw-r----- 1 root sys 203, 20 Jan 24 12:32 sd@0,0:e,raw brw-r----- 1 root sys 203, 21 Jan 24 12:32 sd@0,0:f crw-r----- 1 root sys 203, 21 Jan 24 12:32 sd@0,0:f,raw brw-r----- 1 root sys 203, 22 Jan 24 12:32 sd@0,0:g crw-r----- 1 root sys 203, 22 Jan 24 12:32 sd@0,0:g,raw brw-r----- 1 root sys 203, 23 Jan 24 12:32 sd@0,0:h crw-r----- 1 root sys 203, 23 Jan 24 12:32 sd@0,0:h,raw ... <output has been truncated> ...
This long listing includes columns showing major and minor numbers for each device. The sd driver manages all of the devices listed in the previous example that have a major number of 203. 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<cr> ... <output has been truncated> ... sckmdrv 199 scsa1394 200 scsa2usb 201 scsi_vhci 202 sd 203 sdpib 204 sdt 205 seeprom 206 ses 207 ... <output has been truncated> ...
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.