fd(HW)


fd -- floppy disk device driver

Description

The fd device driver provides an interface to floppy disk drives via a variety of special device files including /dev/fd*, /dev/dsk/*, /dev/rdsk/*, and /dev/install. Both a block-buffered and a raw interface are provided. Note that block transfers are always a multiple of the 1KB filesystem block size.

Commands such as tar(C), cpio(C), and dd(C) can be used to write to and read from floppy disks, taking the appropriate special device file as an argument. For instance, tar tvf /dev/fd0 tabulates (lists) the contents of the floppy disk in drive 0 (zero).

To increase the chance of being able to read from a damaged disk, the tunable parameter maxretry is provided in /etc/conf/pack.d/fd/space.c. The larger the value of maxretry, the more times the driver will reattempt a failed I/O operation. The default value of maxretry is 4. To change this value, edit space.c with a text editor and relink the kernel using link_unix(ADM) or idbuild(ADM).

XENIX floppy device names

XENIX floppy disk device file names use the following format:

/dev/[r]fd#format

See the table ``Floppy disk formats'' for the meaning of the various format strings. Device names determine the particular drive and media configuration. The character special or ``raw'' devices (/dev/rfd*) allow direct, unbuffered reading from or writing to a floppy disk.

UNIX system floppy device names

UNIX system floppy disk device file names use the following format:

/dev/[r]dsk/f#format[t]

where r indicates a raw (character) interface to the disk, rdsk selects the raw device interface and dsk selects the block device interface. The number # selects the drive; 0, 1 and so on.

The optional final parameter t allows the whole disk to be accessed (that is, from the first byte of sector 1, track 0, side 0). If t is not specified, the whole disk except cylinder 0 will be selected.

Note that XENIX device names always imply the presence of the t; that is, access the whole disk.

The following table describes the possible XENIX and UNIX system floppy disk formats:

Floppy disk formats

XENIX UNIX Description
135ds9 3d 3.5" double density (720KB)
135ds36 3e 3.5" extra density (2.88MB)
135ds21 - 3.5" higher density (1.6MB)
135ds18 3h 3.5" high density (1.44MB)
135ds15 3m 3.5" mid density (1.2MB)
48ss8 d8 5.25" single sided double density, 8 sectors per track (160KB)
48ss9 d9 5.25" single sided double density, 9 sectors per track (180KB)
48ds8 5d9 5.25" double sided double density, 8 sectors per track (320KB)
48ds9 5d16 5.25" double sided double density, 9 sectors per track (360KB)
96ds9 3d 5.25" double sided high density (720KB)
96ds15 5h 5.25" double sided high density (1.2MB)

 +--------+------+----------------------------------------------------------------+
 |XENIX   | UNIX | Description                                                    |
 +--------+------+----------------------------------------------------------------+
 |135ds9  | 3d   | 3.5" double density (720KB)                                    |
 +--------+------+----------------------------------------------------------------+
 |135ds36 | 3e   | 3.5" extra density (2.88MB)                                    |
 +--------+------+----------------------------------------------------------------+
 |135ds21 | -    | 3.5" higher density (1.6MB)                                    |
 +--------+------+----------------------------------------------------------------+
 |135ds18 | 3h   | 3.5" high density (1.44MB)                                     |
 +--------+------+----------------------------------------------------------------+
 |135ds15 | 3m   | 3.5" mid density (1.2MB)                                       |
 +--------+------+----------------------------------------------------------------+
 |48ss8   | d8   | 5.25" single sided double density, 8 sectors per track (160KB) |
 +--------+------+----------------------------------------------------------------+
 |48ss9   | d9   | 5.25" single sided double density, 9 sectors per track (180KB) |
 +--------+------+----------------------------------------------------------------+
 |48ds8   | 5d9  | 5.25" double sided double density, 8 sectors per track (320KB) |
 +--------+------+----------------------------------------------------------------+
 |48ds9   | 5d16 | 5.25" double sided double density, 9 sectors per track (360KB) |
 +--------+------+----------------------------------------------------------------+
 |96ds9   | 3d   | 5.25" double sided high density (720KB)                        |
 +--------+------+----------------------------------------------------------------+
 |96ds15  | 5h   | 5.25" double sided high density (1.2MB)                        |
 +--------+------+----------------------------------------------------------------+
Format specification is mandatory when opening the device for formatting unless the drive is capable of sensing the type of floppy installed. (The format(C) command is used to format floppies; a default format specification is provided in /etc/default/format.)

However, when accessing a floppy disk for other operations (read and write), the autosense nodes (/dev/[r]install, /dev/[r]install1, /dev/[r]dsk/finstall, and /dev/[r]dsk/finstall1) can be used. In this case, the floppy disk driver will automatically determine (autosense) the format previously established on the disk and then perform the requested operation. For example:

cpio -itv < /dev/rdsk/finstall

If you use the /dev/[r]dsk/f#[t] node (by default, linked to /dev/[r]dsk/f#5h[t]), the operation may fail if more than 1.2MB of data are transferred.

Besides the device file naming convention described above, some of the formats have alias names that correlate to previous releases. The following list describes the formats that have an alias:

Format Alias
3d q9d
3h q18d
5h q15d
5d8 d8d
5d9 d9d

 Format   Alias
 3d       q9d
 3h       q18d
 5h       q15d
 5d8      d8d
 5d9      d9d
For example, the device file /dev/rdsk/f0q15dt is equivalent to /dev/rdsk/f05ht.

Minor device numbers

The minor device number determines which physical device is accessed by each device file.

The minor device bit representation scheme for floppy disk drives is shown in the table below. Using this table, you can construct the minor device number of any allowable floppy disk configuration. For example, the minor device number would be 61 for a double sided, 135 tracks per inch, 18 sector floppy disk drive, connected as unit 1 (/dev/[r]dsk/f13ht). The corresponding bit representation would be ``00111101''.

The mknod command can be used to create special device files; see mknod(C) for more information.

Floppy disk drive minor device bit representation

Bits
7 6 5 4 3 2 1 0 Description
- - - - - - X X Disk drive number*
- - 0 0 0 0 - - 48tpi, 9 sector, ss
- - 0 0 0 1 - - 48tpi, 9 sector, ds
- - 0 0 1 0 - - 48tpi, 8 sector, ss
- - 0 0 1 1 - - 48tpi, 8 sector, ds
- - 1 0 0 1 - - 135tpi, 9 sector, ds
- - 1 0 0 1 - - 96tpi, 9 sector, ds
- - 1 0 1 1 - - 135tpi, 36 sector, ds
- - 1 1 0 0 - - 135tpi, 15 sector, ds
- - 1 1 0 1 - - 96tpi, 15 sector, ds
- - 1 1 1 1 - - 135tpi, 18 sector, ds
- - 0 1 0 0 - - 135tpi, 21 sector, ds
- 0 - - - - - - Autosense detection+
0 - - - - - - - Access whole disk (t)
1 - - - - - - - Skip first cylinder

 +-----------------------+-----------------------+
 |         Bits          |                       |
 +--+--+--+--+--+--+--+--+-----------------------+
 |7 |6 |5 |4 |3 |2 |1 |0 | Description           |
 +--+--+--+--+--+--+--+--+-----------------------+
 |- |- |- |- |- |- |X |X | Disk drive number*    |
 +--+--+--+--+--+--+--+--+-----------------------+
 |- |- |0 |0 |0 |0 |- |- | 48tpi, 9 sector, ss   |
 +--+--+--+--+--+--+--+--+-----------------------+
 |- |- |0 |0 |0 |1 |- |- | 48tpi, 9 sector, ds   |
 +--+--+--+--+--+--+--+--+-----------------------+
 |- |- |0 |0 |1 |0 |- |- | 48tpi, 8 sector, ss   |
 +--+--+--+--+--+--+--+--+-----------------------+
 |- |- |0 |0 |1 |1 |- |- | 48tpi, 8 sector, ds   |
 +--+--+--+--+--+--+--+--+-----------------------+
 |- |- |1 |0 |0 |1 |- |- | 135tpi, 9 sector, ds  |
 +--+--+--+--+--+--+--+--+-----------------------+
 |- |- |1 |0 |0 |1 |- |- | 96tpi, 9 sector, ds   |
 +--+--+--+--+--+--+--+--+-----------------------+
 |- |- |1 |0 |1 |1 |- |- | 135tpi, 36 sector, ds |
 +--+--+--+--+--+--+--+--+-----------------------+
 |- |- |1 |1 |0 |0 |- |- | 135tpi, 15 sector, ds |
 +--+--+--+--+--+--+--+--+-----------------------+
 |- |- |1 |1 |0 |1 |- |- | 96tpi, 15 sector, ds  |
 +--+--+--+--+--+--+--+--+-----------------------+
 |- |- |1 |1 |1 |1 |- |- | 135tpi, 18 sector, ds |
 +--+--+--+--+--+--+--+--+-----------------------+
 |- |- |0 |1 |0 |0 |- |- | 135tpi, 21 sector, ds |
 +--+--+--+--+--+--+--+--+-----------------------+
 |- |0 |- |- |- |- |- |- | Autosense detection   |
 +--+--+--+--+--+--+--+--+-----------------------+
 |0 |- |- |- |- |- |- |- | Access whole disk (t) |
 +--+--+--+--+--+--+--+--+-----------------------+
 |1 |- |- |- |- |- |- |- | Skip first cylinder   |
 +--+--+--+--+--+--+--+--+-----------------------+

*
Drive number 3 is reserved for special, non-floppy devices connected to the floppy controller as unit #3.

+
Automatic sensing of the floppy format is performed when this bit is set. When the autosense bit is on, the other format bits (2,3,4,5 and 7) are ignored.

Supported ioctls

The floppy driver supports the following ioctl(S) commands. Where the command requires an argument, this is passed by the argument arg to ioctl. Include <sys/floppy.h> when using these ioctls.


FLIOCFRTK
Formats a track. arg should point to a struct fmtfl, defined in <sys/floppy.h>. The following errno values are possible, in addition to those described on the ioctl(S) manual page:

[EBUSY]
The media type is still unknown (has not yet been sensed) on an autosense device, or the device is not a raw device, or the raw device has been opened more than once.

[EINVAL]
The device is not writable, or invalid values were specified for number of tracks or number of sides.

[EFAULT]
The driver could not successfully transfer the information from kernel to user space or vice-versa (copyout(D3oddi) or copyin(D3oddi) failed).

FLIOCSIZE
Returns the floppy size in the struct fmtfl pointed to by arg. If the driver cannot successfully transfer the information (that is, if copyout fails), [EFAULT] is returned in errno.

FLIOCPRT
Toggles the floppy driver's cmn_err(D3oddi) statements on or off. Set arg to 0 to have the floppy driver's error messages written to the console and system logs; or to 1 to turn them off. By default, this is set to 1 to turn off display of the floppy driver's error messages.

Diagnostics

The following error messages may be displayed on the console. See messages(M) for general information about kernel error messages, including a list of generic device driver errors.
NOTICE: floppy: Switch from disk dev major/minor1 to major/minor2
The system allows both root and boot floppies to be mounted at the same time (on /dev/root and /dev/install), although only one disk may be present in the drive at a time. This message is intended to serve as a reminder to swap the disks.
WARNING: floppy: 5.25 inch diskette Adapter/A not installed
This message is output by the driver for the PS/2 5.25-inch disk Adapter/A if the adapter is not found.
WARNING: floppy: CMOS indicates no diskette drives installed
WARNING: floppy: CMOS indicates diskette drive n not present
The configuration memory is invalid; run the DOS SETUP disk that came with your machine.
WARNING: floppy: Disk is write protected in fdn dev major/minor
Remove the write protect tag from the disk.
WARNING: floppy: fdn being formatted
The drive is presently formatting a disk.
WARNING: floppy: Handshake error for cmd 0xm on fdn dev major/minor
A handshaking error occurred while reading from or writing to the disk.
WARNING: floppy: I/O after close of fdn dev major/minor
An I/O request was detected after the drive was closed. The data transfer is not performed.
WARNING: floppy: Insert disk or close floppy n door
A disk has not been inserted in the drive or the drive door has not been closed. Also check for damage to the drive mechanism or the disk.
WARNING: floppy: Unknown fdn dev major/minor media format format
WARNING: floppy: Cannot determine fdn dev major/minor media format
The minor number of the special device file does not correspond to a known media format. Check that the device file minor number corresponds to the intended device according to the minor device bit representation described earlier on this page.
WARNING: floppy: Set Mid Density Failed
Driver was unable to set a 3-mode drive to mid-density mode. The device may not be a 15 sectors per track device, or it may not support mid-density mode.
WARNING: floppy: Set Normal Density Failed
Driver was unable to reset a 3-mode drive to normal mode. The device may have already been in normal, rather than middensity, mode; or, there may be a problem with the hardware.
WARNNG floppy: FDC command error
The floppy drive controller did not successfully receive an entire multibyte command, or an I/O operation on the drive controller did not complete cleanly. The driver resets the floppy drive controller.

This may occur when another program tries to directly access the FDC at the same time as the floppy driver.

WARNING: floppy: FDC result phase error
WARNING: floppy: FDC timeout error
WARNING: floppy: FDC couldn't read result
The driver cannot successfully determine the status of the floppy drive controller. As described above, this may occur when another program tries to directly access the FDC at the same time as the floppy driver. The driver resets the controller.

Limitations

It is not advisable to format a low density (48tpi) disk on a high density (96tpi or 135tpi) floppy drive. Low density disk written on a high density drive should be read on high density drives. They may or may not be readable on a low density drive.

It is not possible to format a 1.44MB high density disk as 720KB in a 3-mode drive (720KB, 1.2MB, and 1.44MB).

Support for 2.88MB and 1.2MB disks depends on drive and controller type. Almost all floppy disk controllers can write to a 2.88MB disk drive, but very few controllers can access a 3.5" 1.2MB disk even if they control a dual speed (3-mode) drive; this is due to incompatible controller chipsets.

Formatting a 1.2MB 3.5" disk in a 3-mode drive at the same time as a disk in a non-3-mode drive may take a long time and the density-select light on the latter drive will indicate an incorrect density. This is due to the way that the floppy driver selects density modes.

When accessing the character special floppy devices, the buffer must begin on a word boundary.

The count in a read(S), write(S), or lseek(S) call to a character special floppy device must be a multiple of 1KB.

Use error-free floppy disks for best results on reading and writing. Note that no bad blocking is performed on floppy disks. If a bad sector is found in the middle of a transfer, the transfer fails.

Files

XENIX devices:
/dev/[r]fd0
/dev/[r]fd048
/dev/[r]fd048ss8
/dev/[r]fd048ds8
/dev/[r]fd048ss9
/dev/[r]fd048ds9
/dev/[r]fd096
/dev/[r]fd096ds9
/dev/[r]fd096ds15
/dev/[r]fd0135ds9
/dev/[r]fd0135ds18
/dev/[r]fd0135ds21
/dev/[r]fd[0|1]135ds15
/dev/[r]fd[0|1]135ds36

UNIX system devices:
/dev/[r]dsk/f0
/dev/[r]dks/f0t
/dev/[r]dsk/f03d
/dev/[r]dsk/f03dt
/dev/[r]dsk/f03h
/dev/[r]dsk/f03ht
/dev/[r]dsk/f05d8
/dev/[r]dsk/f05d8t
/dev/[r]dsk/f05d9
/dev/[r]dsk/f05d9t
/dev/[r]dsk/f05d16
/dev/[r]dsk/f05d16t
/dev/[r]dsk/f05h
/dev/[r]dsk/f05ht
/dev/[r]dsk/f05q
/dev/[r]dsk/f05qt
/dev/[r]dsk/f03m
/dev/[r]dsk/f03e

Autosense devices:
/dev/[r]install
/dev/[r]install1
/dev/[r]dsk/finstall
/dev/[r]dsk/finstall1
/usr/include/sys/floppy.h   definitions of floppy structures and ioctls

See also

cpio(C), dd(C), format(C), copyin(D3oddi), mknod(C), Sflp(HW), tar(C)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005