3.3. Device Names in devfs
The device pseudo file system can be mounted as /dev in
which case it replaces the traditional Linux device subdirectory.
Alternatively it can be mounted elsewhere (e.g. /devfs)
and supplement the existing device structure.
Without devfs, devices names are typically maintained in the
dev directory
of the root partition. Hence the device names (and their associated
permissions) have file system persistence. The existence of a device name
does not necessarily imply such a device (or even its driver) is present. To
save users having to create device name entries (with the mknod
command) most Linux distributions come with thousands of device
names defined in the /dev directory. When applications
try to open() the device name then an errno value of ENODEV indicates there
is no corresponding device (or driver) currently available.
Devfs takes a different approach in which the existence of the device name
is directly related to the presence of the corresponding device (and its
driver).
Assuming devfs is mounted on /dev then SCSI devices
have primary device names that might look like this:
/dev/scsi/host0/bus0/target1/lun0/disc [whole disk]
/dev/scsi/host0/bus0/target1/lun0/part6 [partition 6]
/dev/scsi/host0/bus0/target1/lun0/generic [sg device for disk]
/dev/scsi/host1/bus0/target2/lun0/cd [CD reader or writer]
/dev/scsi/host1/bus0/target2/lun0/generic [sg device for cd]
/dev/scsi/host2/bus0/target0/lun0/mt [tape mode 0 rewind]
/dev/scsi/host2/bus0/target0/lun0/mtan [tape mode 3 no rewind]
/dev/scsi/host2/bus0/target0/lun0/generic [sg device for tape]
|
The sg device on the third line corresponds to the "whole disk" on the
first line since they have the same SCSI address (i.e.
host0/bus0/target1/lun0). If the sg driver is a module
and it has not yet been loaded (or it has been unloaded) then the
"generic" device names in the above list will not be present.
[Notice the spelling of "disc" as the devfs author favours English spelling
over the American variant.] It can be seen that devfs's naming scheme
closely matches the SCSI addressing discussed in
Section 3.1. It is worth noting that the IDE subsystem uses
a similar devfs device naming scheme with the word "scsi" replaced with
"ide". Devfs is discussed further in Chapter 12.