Every device in HP-UX has a corresponding device file in the /dev directory. This file describes the hardware path of the device and is used to communicate with the device. As you have seen in the ioscan listing, all devices (keyboard, mouse, disks, etc.) have device drivers associated with them.
The device files don't contain any data; instead, these are special files used for input or output purposes related to that device. These device files are created by HP-UX; however, you need to know which device file represents a particular device. You can use the ioscan command to list devices and device files simultaneously . For example, if you want to list devices and device files of category disk , use the following command.
# ioscan -funC disk Class I H/W Path Driver S/W State H/W Type Description =========================================================== disk 16 10/0.1.0 sdisk CLAIMED DEVICE SEAGATE ST34371W /dev/dsk/c2t1d0 /dev/rdsk/c2t1d0 disk 17 10/0.2.0 sdisk CLAIMED DEVICE SEAGATE ST34572WC /dev/dsk/c2t2d0 /dev/rdsk/c2t2d0 disk 18 10/0.3.0 sdisk CLAIMED DEVICE SEAGATE ST34371W /dev/dsk/c2t3d0 /dev/rdsk/c2t3d0 disk 19 10/0.4.0 sdisk CLAIMED DEVICE SEAGATE ST34371W /dev/dsk/c2t4d0 /dev/rdsk/c2t4d0 disk 20 10/0.5.0 sdisk CLAIMED DEVICE SEAGATE ST15150W /dev/dsk/c2t5d0 /dev/rdsk/c2t5d0 disk 21 10/0.6.0 sdisk CLAIMED DEVICE SEAGATE ST15150W /dev/dsk/c2t6d0 /dev/rdsk/c2t6d0 disk 22 10/5.2.0 sdisk CLAIMED DEVICE TOSHIBA CD- ROM XM-5401TA /dev/dsk/c3t2d0 /dev/rdsk/c3t2d0
Here you can see that device files related to all disk type devices are listed. Each disk has two device files, one that represents a character-type device and the other that represents a block-type device. To list an individual device file, you can use the ll command with a result as shown.
brw-r----- 1 root sys 31 0x010500 Jun 10 1996 c2t5d0
Output of the ll command for a device file is different from a normal file and it contains additional fields such as major and minor numbers . These fields will be explained shortly.
Usually the device files are present in the /dev directory. However, some device files are also grouped in a subdirectory under the /dev directory. For example, all block-type device files for disk drives are located in the /dev/dsk directory. Table 17-1 lists some other directories used for grouping device files.
Directory | Type of Files Present |
---|---|
/dev/dsk | Block device files for disk drives and CD-ROM |
/dev/rdsk | Raw or character device files for disk drives and CD-ROM |
/dev/vg00 | Device for volume group vg00; every volume group has its own directory |
/dev/rmt | Device files for tape drives |
/dev/pts | Stream-based pseudoterminal device files |
/dev/pty | Pseudoterminal slave device files |
/dev/ptym | Pseudoterminal master device files |
Let's look at a list of files. This list is an output of the ll command, and it does not show file sizes. Instead, there is some other information in fields 5 and 6. Field 5 shows the major device number and field 6 shows the minor device number.
brw-r----- 1 root sys 31 0x010500 Jun 10 1996 c1t0d5 brw-r----- 1 root sys 31 0x010600 Jun 10 1996 c1t0d6 brw-r----- 1 root sys 31 0x010700 Jun 10 1996 c1t0d7 brw-r----- 1 root sys 31 0x011000 Jun 10 1996 c1t1d0 brw-r----- 1 root sys 31 0x011100 Jun 10 1996 c1t1d1
Major device numbers represent the kernel driver used for the device. The kernel driver is a software component that is invoked when an I/O request is made for the device. All devices of the same type have the same major number, because the same driver is used for all of them. For example, the list shown is for disk drives of the same type, so these have the same major device number of 31.
Minor device numbers show the physical location of a device. It is a six-digit hexadecimal number. It may also be considered to distinguish among devices that have the same major number. The minor number is also used for device specific options. Consider this list of tape devices.
$ ll /dev/rmt/0m* crw-rw-rw- 2 bin bin 212 0x030000 Oct 28 1997 /dev/rmt/0m crw-rw-rw- 2 bin bin 212 0x030080 Sep 29 1997 /dev/rmt/0mb crw-rw-rw- 2 bin bin 212 0x030040 Sep 29 1997 /dev/rmt/0mn crw-rw-rw- 2 bin bin 212 0x0300c0 Sep 29 1997 /dev/rmt/0mnb $
All of these device files represent the same tape drive but they have different minor numbers. These numbers represent a specific type of tape cartridge or format used when accessing the drive.
Character devices are also called raw devices. I/O to these devices is performed one character at one time. These devices are used for serial data transfer. The types of character devices are terminals, modems, serial printers, and tape drives. Disk drives also have character devices that are used for low-level functions on a disk.
When you use the ll command to list device files, the first character of every line in the output is " c " for these device files.
Block devices are used for transferring a block of data to and from a device. The data are exchanged through a buffer space in memory. An actual write to the device is performed only when the buffer is full. Similarly, when a read operation is performed, a block of data is read and put into the buffer. All disk drives and CD-ROM drives are examples of block-type devices.
When you use the ll command to list device files, the first character of every output line is " b " in block-type device files.
Study BreakDevice Files and Hardware Paths
|
Top |