fd(7) fd(7)NAME fd - provides an interface to 3.5-inch disk drives DESCRIPTION The fd device driver provides an interface to two types of Apple(Reg.) 3.5-inch disk drives. The standard drive supports a single-sided format providing 400 kilobytes (KB) of storage and a double-sided format providing 800 KB of storage. The Apple SuperDrive (formerly named the Apple FDHD drive) supports the 400 KB and 800 KB formats as well as industry-standard 720 KB and 1440 KB double-sided formats. The storage format, or density, is associated with individual floppy disks when they are formatted. Partitions and partition maps are not supported for floppy disks. Three main classes of floppy access are supported: fixed- density devices, autodensity devices, and special ioctl devices. Fixed-density Devices These devices require that the floppy disk match a specified density. If a fixed-density device encounters the wrong density disk, the driver immediately ejects the disk, prints an informational console message, and returns EINVAL. Autodensity Devices These devices automatically adjust to any valid floppy disk format as long as they can be supported by the drive. Special ioctl Devices These devices are used only for issuing special ioctl calls (FD_GETMETER, FD_SETMETER, FD_GETTUNE, and FD_SETTUNE). During an open system call, no check is made for the presence of a floppy disk or the current status of the device, that is, the disk drive. This allows these special ioctl calls to be used at any time without interfering with other users of the device. No other I/O operations are allowed to a special ioctl device. Both the AL_EJECT and GD_PARTSIZE calls are also allowed for special ioctl devices. The driver accepts a variety of the following ioctl functions. The first parameter for each of these functions is file-descriptor, which should be the raw device file corresponding to the drive, such as /dev/rdsk/c8d?s0. ioctl(file-descriptor, AL_EJECT, 0) Eject the disk. The file descriptor corresponds to the character device for the floppy device file. It may be January 1992 1
fd(7) fd(7)appropriate to unmount a file system before ejecting the disk. ioctl(file-descriptor, GD_PARTSIZE, 0) Return the format of the media. The value returned is the number of blocks on the disk, as follows: 800 400 KB 1600 800 KB 1440 720 KB 2880 1440 KB 0 unformatted EI0 empty drive ioctl(file-descriptor, UIOCFORMAT, fmt) ioctl(file-descriptor, FD_FMTONLY, fmt) ioctl(file-descriptor, FD_VFYONLY, fmt) Use UIOCFORMAT to format and verify the disk in one operation; use FD_FMTONLY or FD_VFYONLY to either format or verify the disk as a one operation. The third parameter to this function call contains the address of a diskformat structure that is defined in /usr/include/sys/diskformat.h. The d_lhead field of this structure determines the number of sides to be formatted. If it is set to 0, the disk is formatted in a one-sided, 400 KB format. If the same d_lhead field is nonzero, the d_dens field of the structure determines the density to which the disk is to be formatted. Values for d_dens are as follows: 400 400 KB 720 720 KB 800 800 KB 1440 1440 KB All other fields of the diskformat structure are ignored by most device drivers. However, d_fcyl and d_lcyl may sometimes be used. For example, the floppy device driver uses these two quantities as the first and last cylinders to be formatted. If both d_lhead and d_dens are set to their default values (DISK_DEFAULT), the density that is selected is based on the device class. Autodensity devices, such as /dev/rfd/d0, default to a double-sided 800 KB format for standard media or default to a double-sided 1440 KB format for high-density media. Fixed-density devices, such as /dev/rfd/d1m720, create a fixed-density format only. Conflicting density specifications, such as setting 2 January 1992
fd(7) fd(7)d_dens to 720 in an attempt to format the media in the drive referenced through /dev/rfd/d0m1440, causes EINVAL to be returned. Similarly, if the requested density is unavailable for the given device and current media, EINVAL is returned. Examples include referencing a non-SuperDrive drive with /dev/rfd/d0m1440 or attempting to format a low-density disk in a 1440 KB format. Before an ioctl function for formatting floppy disks is honored, the device must have been opened in exclusive-use mode with the O_EXCL flag. ioctl(file-descriptor, FD_GETMETER, meter) Return the current statistics counters for the file-descriptor device driver. The value of meter is the address of an fd_meter structure, as defined in /usr/include/sys/fdioctl.h. ioctl(file-descriptor, FD_SETMETER, meter) Copy the fd_meter structure at meter into the internal memory of the device driver. This is useful to clear the counters after doing a FD_GETMETER to gather statistics. ioctl(file-descriptor, FD_GETSTAT, int) Return the current status of the drive or media as a bit mask: STAT_FDHD (0x01) The drive is SuperDrive. STAT_2SIDED (0x02) The drive is a double-density drive. STAT_NODRIVE (0x04) No drive is present. STAT_NODISK (0x08) No 3.5-inch disk is in the drive. STAT_WRTENAB (0x10) The 3.5-inch disk in the drive is write-enabled. STAT_1MBMEDIA (0x20) The 3.5-inch disk in the drive is not a high- density disk. ioctl(file-descriptor, FD_GETTUNE, tune) Return the current settings of the tunable error thresholds in the fd device driver. The parameter tune is the address of a fd_tune structure as defined in the January 1992 3
fd(7) fd(7)header file /usr/include/sys/fdioctl.h. ioctl(file-descriptor, FD_SETTUNE, tune) Copy the fd_tune structure at tune into the internal memory of the device driver. WARNINGS Changing error thresholds with the tune parameter should not be necessary. Adjustments should be made with extreme care! NOTES Appending e to a device file causes the driver to eject the disk on close. Appending w causes open to block until a disk is inserted; the wait is interruptible, returning EINTR. Appending ew does both. High-density disks should only be formatted as 1440 KB while standard disks may only be formatted as 400 KB, 720 KB, or 800 KB. It is possible to format high-density disks as 400 KB or 800 KB on systems that do not support the SuperDrive drive. If an illegally formatted disk is encountered, the driver immediately ejects the disk, prints an informational console message, and returns EINVAL. Opening in O_EXCL mode prevents the driver from complaining about illegally formatted disks and also makes fixed-density devices behave in autodensity mode. While this behavior is implemented to allow reformatting, it may be deliberately exploited to extract data from an improperly formatted disk. Simultaneous access to a drive is limited to similar modes. This is enforced by only allowing users access to the drive through the same device file. This prevents incompatible combinations of density, wait-for-insert, and eject-on-close options. The 720 KB and 1440 KB formats are not interleaved. As a result, reading or writing in small block sizes can be quite slow. FILES /dev/fd/d[01]mdens Fixed density device file where dens is specified as 400, 720, 800, or 1440. /dev/rfd/d[01]mdens Fixed density device file where dens is specified as 400, 720, 800, or 1440. /dev/dsk/c8d[01]s0 Autodensity device file /dev/rdsk/c8d[01]s0 Autodensity device file /dev/floppy[01] 4 January 1992
fd(7) fd(7)Autodensity device file /dev/rfloppy[01] Autodensity device file /dev/fd/d[01] Autodensity device file /dev/rfd/d[01] Autodensity device file /dev/rfd/d0x Special ioctl device file /dev/rfd/d1x Special ioctl device file /usr/include/sys/ssioctl.h Header file /usr/include/sys/fdioctl.h Header file SEE ALSO ioctl(2), open(2) cpio(1), eject(1), tar(1) in A/UX Command Reference diskformat(1M), mkfs(1M), mount(1M) in A/UX System Administrator's Reference January 1992 5