The /proc file system also contains information about the disk drives present in the system and the file systems mounted from them.
The /proc/filesystems entry displays the file system types known to the kernel. Note that this list isn't very useful because it is not complete: File systems can be loaded and unloaded dynamically as kernel modules. The contents of /proc/filesystems list only file system types that either are statically linked into the kernel or are currently loaded. Other file system types may be available on the system as modules but might not be loaded yet.
The /proc file system includes information about devices connected to both IDE controllers and SCSI controllers (if the system includes them).
On typical systems, the /proc/ide subdirectory may contain either or both of two subdirectories, ide0 and ide1, corresponding to the primary and secondary IDE controllers on the system.  These contain further subdirectories corresponding to physical devices attached to the controllers. The controller or device directories may be absent if Linux has not recognized any connected devices. The full paths corresponding to the four possible IDE devices are listed in Table 7.1.
 If properly configured, the Linux kernel can support additional IDE controllers. These are numbered sequentially from ide2.
See Section 6.4, "Hardware Devices," for more information about IDE device names.
Each IDE device directory contains several entries providing access to identification and configuration information for the device. A few of the most useful are listed here:
· model contains the device's model identification string.
· media contains the device's media type. Possible values are disk, cdrom, tape, floppy, and UNKNOWN.
· capacity contains the device's capacity, in 512-byte blocks. Note that for CD-ROM devices, the value will be 231–1, not the capacity of the disk in the drive. Note that the value in capacity represents the capacity of the entire physical disk; the capacity of file systems contained in partitions of the disk will be smaller.
For example, these commands show how to determine the media type and device identification for the master device on the secondary IDE controller. In this case, it turns out to be a Toshiba CD-ROM drive.
% cat /proc/ide/ide1/hdc/media
% cat /proc/ide/ide1/hdc/model
TOSHIBA CD-ROM XM-6702B
If SCSI devices are present in the system, /proc/scsi/scsi contains a summary of their identification values. For example, the contents might look like this:
% cat /proc/scsi/scsi
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: QUANTUM Model: ATLAS_V__9_WLS Rev: 0230
Type: Direct-Access ANSI SCSI revision: 03
Host: scsi0 Channel: 00 Id: 04 Lun: 00
Vendor: QUANTUM Model: QM39100TD-SW Rev: N491
Type: Direct-Access ANSI SCSI revision: 02
This computer contains one single-channel SCSI controller (designated "scsi0"), to which two Quantum disk drives are connected, with SCSI device IDs 0 and 4.
The /proc/partitions entry displays the partitions of recognized disk devices. For each partition, the output includes the major and minor device number, the number of 1024-byte blocks, and the device name corresponding to that partition.
The /proc/sys/dev/cdrom/info entry displays miscellaneous information about the capabilities of CD-ROM drives. The fields are self-explanatory:
% cat /proc/sys/dev/cdrom/info
CD-ROM information, Id: cdrom.c 2.56 1999/09/09
drive name: hdc
drive speed: 48
drive # of slots: 0
Can close tray: 1
Can open tray: 1
Can lock tray: 1
Can change speed: 1
Can select disk: 0
Can read multisession: 1
Can read MCN: 1
Reports media changed: 1
Can play audio: 1
The /proc/mounts file provides a summary of mounted file systems. Each line corresponds to a single mount descriptor and lists the mounted device, the mount point, and other information. Note that /proc/mounts contains the same information as the ordinary file /etc/mtab, which is automatically updated by the mount command.
These are the elements of a mount descriptor:
· The first element on the line is the mounted device (see Chapter 6). For special file systems such as the /proc file system, this is none.
· The second element is the mount point, the place in the root file system at which the file system contents appear. For the root file system itself, the mount point is listed as /. For swap drives, the mount point is listed as swap.
· The third element is the file system type. Currently, most GNU/Linux systems use the ext2 file system for disk drives, but DOS or Windows drives may be mounted with other file system types, such as fat or vfat. Most CD-ROMs contain an iso9660 file system. See the man page for the mount command for a list of file system types.
· The fourth element lists mount flags. These are options that were specified when the mount was added. See the man page for the mount command for an explanation of flags for the various file system types.
In /proc/mounts, the last two elements are always 0 and have no meaning.
See the man page for fstab for details about the format of mount descriptors.  GNU/Linux includes functions to help you parse mount descriptors; see the man page for the getmntent function for information on using these.
 The /etc/fstab file lists the static mount configuration of the GNU/Linux system.
Section 8.3, "fcntl: Locks and Other File Operations," describes how to use the fcntl system call to manipulate read and write locks on files. The /proc/locks entry describes all the file locks currently outstanding in the system. Each row in the output corresponds to one lock.
For locks created with fcntl, the first two entries on the line are POSIX ADVISORY. The third is WRITE or READ, depending on the lock type. The next number is the process ID of the process holding the lock. The following three numbers, separated by colons, are the major and minor device numbers of the device on which the file resides and the inode number, which locates the file in the file system. The remainder of the line lists values internal to the kernel that are not of general utility.
Turning the contents of /proc/locks into useful information takes some detective work. You can watch /proc/locks in action, for instance, by running the program in Listing 8.2 to create a write lock on the file /tmp/test-file.
% touch /tmp/test-file
% ./lock-file /tmp/test-file
locked; hit enter to unlock. . .
In another window, look at the contents of /proc/locks.
% cat /proc/locks
1: POSIX ADVISORY WRITE 5467 08:05:181288 0 2147483647 d1b5f740 00000000
dfea7d40 00000000 00000000
There may be other lines of output, too, corresponding to locks held by other programs. In this case, 5467 is the process ID of the lock-file program. Use ps to figure out what this process is running.
% ps 5467
PID TTY STAT TIME COMMAND
5467 pts/28 S 0:00 ./lock-file /tmp/test-file
The locked file, /tmp/test-file, resides on the device that has major and minor device numbers 8 and 5, respectively. These numbers happen to correspond to /dev/sda5.
% df /tmp
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/sda5 8459764 5094292 2935736 63% /
% ls -l /dev/sda5
brw-rw---- 1 root disk 8, 5 May 5 1998 /dev/sda5
The file /tmp/test-file itself is at inode 181,288 on that device.
% ls --inode /tmp/test-file
See Section 6.2, "Device Numbers," for more information about device numbers.