[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4 Files Reference

fd Special File

Purpose

Provides access to the diskette device driver.

Description

The fd special file provides block and character (raw) access to diskettes in the diskette drives. The special file name usually specifies both the drive number and the format of the diskette. The exceptions are /dev/fd0 and /dev/fd1, which specify diskette drives 0 and 1, respectively, without specifying their formats.

The generic special files /dev/fd0 and /dev/fd1 determine the diskette type automatically for both drive 0 and drive 1. First, the device-driver attempts to read the diskette using the characteristics of the default diskette for the drive type. If this fails, the device-driver changes its characteristics and attempts to read until it has read the diskette successfully or until it has tried all the possibilities supported for the drive type by the device driver.

An r prefix on a special file name means that the drive is accessed as a raw device rather than a block device. Performing raw I/O with a diskette requires that all data transfers be in multiples of the diskette sector length. Also, all lseek subroutine calls made to the raw diskette device driver must result in a file offset value that is a multiple of the sector size. For the diskette types supported, the sector length is always 512 bytes.

Note: The diskette device driver does not perform read verification of data that is written to a diskette.

Types of Diskettes Supported

The fd special file supports three diskette drives: the 1.2MB, 5.25-inch diskette drive, and the 1.44MB and 2.88MB, 3.5-inch diskette drives. All fd special file names (except the generic special files /dev/fd0, /dev/fd1, /dev/rfd0, and /dev/rfd1) contain suffixes that dictate how a diskette is to be treated. These special file names have a format of PrefixXY, where the Prefix, X, and Y variables have the following meanings:

Prefix Special file type. Possible values are fd and rfd, where the r indicates raw access to the special file.
X Drive number indicator. Possible values of 0 and 1 indicate drives 0 and 1, respectively.
Y Diskette format indicator. Possible values depend on the type of diskette being used. Either a single character or a decimal point followed by numeric characters is allowed. Possible values are:
h Highest density supported by the drive type
l Lowest density supported by the drive type
.9 9 sectors per track (all three drive types)
.15 15 sectors per track (1.2MB, 5.25-inch drive only)
.18 18 sectors per track (both 3.5-inch drive types)
.36 36 sectors per track (2.88MB, 3.5-inch drive only)
1.44MB, 3.5-inch Diskette Special Files

Ten different special files are available for use with the 1.44MB, 3.5-inch diskette drive. The default diskette type assumed for this drive type is a double-sided, 80-cylinder, 18 sectors-per-track diskette.

An h or .18 as the suffix of the special file name (for example, /dev/rfd0h or /dev/fd0.18 ) forces a diskette to be treated as a double-sided, 80-cylinder, 18 sectors-per-track diskette. An l or .9 as the suffix of the special file name (for example, /dev/fd1l or /dev/rfd0.9 ) forces a diskette to be treated as a double-sided, 80-cylinder, 9 sectors-per-track diskette.

2.88MB, 3.5-inch Diskette Special Files

Twelve different special files are available for use with the 2.88MB, 3.5-inch diskette drive. The default diskette type assumed for this drive type is a double-sided, 80-cylinder, 36 sectors-per-track diskette.

An h or .36 as the suffix of the special file name (for example, /dev/fd1h or /dev/fd0.36 ) forces a diskette to be treated as a double-sided, 80-cylinder, 36 sectors-per-track diskette. An l or .9 as the suffix of the special file name (for example, /dev/rfd0l or /dev/fd1.9 ) forces a diskette to be treated as a double-sided, 80-cylinder, 9 sectors-per-track diskette. A suffix of .18 (for example, /dev/fd1.18 ) forces a diskette to be treated as a double-sided, 80-cylinder, 18-sectors-per-track diskette.

1.2MB, 5.25-inch Diskette Special Files

Ten different special files are available for use with the 1.2MB, 5.25-inch diskette drive. The default diskette type assumed for this drive type is a double-sided, 80-cylinder, 15 sectors-per-track diskette.

An h or .15 as the suffix of the special file name (for example, /dev/rfd1h or /dev/fd0.15 ) forces a diskette to be treated as a double-sided, 80-cylinder, 15 sectors-per-track diskette. An l or .9 as the suffix of the special file name (for example, /dev/fd0l or /dev/rfd1.9 ) forces a diskette to be treated as a double-sided, 80-cylinder, 9 sectors-per-track diskette.

Note: Regardless of the diskette drive type, an h as the suffix of the special file name forces a diskette to be treated as the highest capacity diskette supported by the drive type. When an l is used as the suffix of the special file name, the diskette is treated as the lowest capacity diskette supported by the drive type.

Usage Considerations

When using subroutines with the fd special file, consider the following items:

open and close subroutines Only one process at a time can issue an open subroutine to gain access to a particular drive. However, all child processes created by a parent process that successfully opens a diskette drive inherit the open diskette drive.
read and write subroutines No special considerations.
ioctl subroutines The possible ioctl operations and their descriptions are:
IOCINFO Returns a devinfo structure (defined in the /usr/include/sys/devinfo.h file) that describes the device.
FDIOCSINFO Sets the characteristics of the device driver diskette to the values passed in the fdinfo structure, as defined in the /usr/include/sys/fd.h file.
FDIOCGINFO Gets the device-driver diskette characteristics and returns the values in the fdinfo structure, as defined in the /usr/include/sys/fd.h file.
FDIOCFORMAT Formats a diskette track. The diskette is formatted using data passed in an array of bytes. The length of this array is four times the number of sectors per track on the diskette. The reason for this is that 4 bytes of data must be passed in for every sector on the track. The 4 bytes contain, in this order, the cylinder number, the side number (0 or 1), the sector number, and the number of bytes per sector. This pattern must be repeated for every sector on the track.

The diskette characteristics used during formatting are whatever values are in the device driver when it receives the format command. These characteristics need to be set to the desired values prior to issuing the format command. There are three ways to do this:

  • Open the diskette driver using one of the format-specific special files. As a result, the diskette characteristics for the driver will be those of the diskette indicated by the special file.

  • Open the diskette driver using one of the generic special files. In this case, the diskette characteristics will be the default characteristics for that driver.

  • Set the characteristics explicitly using the FDIOCSINFO ioctl operation.

For formatting, the diskette driver should be opened only when the O_NDELAY flag is set. Otherwise, the driver will attempt to determine the type of diskette in the drive, causing the open to fail.

Implementation Specifics

The fd special file is part of Base Operating System (BOS) Runtime.

Special Files Overview.

Related Information

The close subroutine, ioctl subroutine, lseek subroutine, open subroutine, read subroutine, write subroutine.


[ Previous | Next | Contents | Glossary | Home | Search ]