floppy(7) — SPECIAL FILES AND DEVICES
NAME
floppy − floppy support
DESCRIPTION
Slice number 15 selects the generic floppy interface. This interface provides BCS support for PC floppy emulation.
When you opens the generic floppy, the driver determines the geometry of the diskette in the drive and sets the drive geometry to match. If the device is a 5¼" drive, the diskette is assumed to be one of the following formats:
- 320KB PC/XT low-density format with 8 sectors per track
- 360KB PC/XT low-density format with 9 sectors per track
- 1.2MB PC/AT high-density format with 15 sectors per track
If the device is a 3½" drive, the diskette is assumed to be one of the following formats:
- 720KB PC/XT high density format with 9 sectors per track
- 1.44MB PS/2 high density format with 18 sectors per track
- 2.88MB super high density format with 36 sectors per track
If there is no diskette in the drive, the open still succeeds, but any attempt to read, write, or format the diskette fails, returning ENXIO. A diskette must be put in and the drive geometry set via the FL_SET_GEOMETRY or FL_GET_INFO ioctl for the open to succeed.
IOCTL COMMANDS
The floppy disks support several ioctl(2) functions on the character or raw devices. These functions permit control beyond the normal open(2), close(2), read(2), and write(2) system calls. Any attempt to utilize ioctl(2) functions not listed below causes an EINVAL error to be returned.
All FL_∗ commands are defined in sys/pcflio.h.
The operations supported by disks are listed below in alphabetical order.
DKFIXBADSPOT
Lock out a bad spot on the disk based on the information in the dkbadlst structure referenced by arg. The dkbadlst structure is defined in sys/dk.h.
DKFORMAT
Format a disk. The dkfmt structure is defined in sys/dk.h.
DKGETCFG
Get parameters associated with the disk and store them in the dkconfig structure referenced by arg. The dkconfig structure is defined in sys/dk.h. The disk is not accessed by this command.
DKGETINFO
Get parameters associated with the disk and store them in the dkblk0 structure referenced by arg. The dkblk0 structure is defined in sys/dk.h. The disk is not accessed by this command.
DKGETSLC
Get the Volume Table of Contents (VTOC) information for a disk and return the information in a structure of type struct motorola_vtoc (defined in sys/vtoc.h) referenced by arg. While the number of supported slices is determined by the number of slices defined in the ddefs file, all disks are expected to support 16 slices. The disk is not accessed by this command.
DKSETINFO
Set parameters associated with the disk based on the values in the dkblk0 structure referenced by arg. The disk is not accessed by this command.
DKSETSLC
Set the Volume Table of Contents (VTOC) information for a disk and return the information in a structure of type struct motorola_vtoc (defined in sys/vtoc.h) referenced by arg. The disk is not accessed by this command.
DKSETCFG
Get parameters associated with the disk and store them in the config structure referenced by arg. The disk is not accessed by this command.
DKINQUIRY
Return the SCSI INQUIRY data for the device; it is only valid for SCSI disks. This ioctl can be done on any device the calling process has open. The SCSI INQUIRY data for the device is copied into the struct inquiry structure pointed to by arg. The struct inquiry structure is defined in sys/dk.h.
DKREADCAP
Return the SCSI READ CAPACITY data for the device; it is only valid for SCSI disks. This ioctl can be done on any disk or CDROM device the calling process has open. The SCSI READ CAPACITY data for the device is copied into the struct readcap structure pointed to by arg. The struct readcap structure is defined in sys/dk.h. Note: the SCSI READ CAPACITY command returns the number of the last logical block on the media. This ioctl adds 1 to that number so it represents the actual capacity of the device. Logical block numbers start at zero.
FL_PC_LEVEL
Return the level of PC floppy emulation support as specified in the BCS PC floppy emulation support supplement. The level is returned to an integer pointed to by arg.
FL_SET_GEOMETRY
Set the geometry of the floppy drive, possibly overriding the current actual geometry of the diskette. The information is taken from the struct fl_geometry structure pointed to by arg. This function is only valid for the generic floppy device (slice 15). For any other device (slice number), this function fails, returning EINVAL. The geometry is selected by passing a structure containing the number of sectors per track and the number of cylinders. The driver then determines which of the supported geometries matches this geometry and sets the drive geometry accordingly.
The geometry is selected based on the following table for 5¼" drives.
| nsect | ncyl | geometry |
| 15 | 80 | 1.2MB PC/AT format |
| 9 | 40 | 360KB PC/XT format |
| 8 | 40 | 320KB PC/XT format |
The geometry is selected based on the following table for 3½" drives.
| nsect | ncyl | geometry |
| 36 | 80 | 2.88MB SHD format |
| 18 | 80 | 1.44MB PS/2 format |
| 9 | 80 | 720KB PC/XT format |
If no match is found, the ioctl fails, returning –1 and setting errno to EINVAL. A diskette does not have to be in the drive for this ioctl to succeed.
If the selected geometry does not match the actual geometry of the diskette in the drive, the results of reading or writing in this state are undetermined.
A subsequent format operation (FL_FORMAT_TRACK or DKFORMAT) uses the geometry selected by this operation.
FL_GET_INFO
Query the status of a floppy disk drive. The information is returned to the struct fl_info structure pointed to by arg. This command first determines if there is a diskette in the drive. If there is, it then determines if the drive door has been opened since the last open(2) or FL_GET_INFO operation. If the door has been opened, it determines the current diskette’s geometry and sets the drive geometry accordingly.
If the door has not been opened and closed since the last open(2) or FL_GET_INFO operation, the command returns the current drive geometry. Note: this may be different than the current diskette geometry as the result of a previous FL_SET_GEOMETRY operation.
The arg parameter points to a fl_diskinfo structure filled in by this command as follows:
fl_stat Give status information for the drive since the last time this drive was opened or the last time this ioctl was called. Most of these bits are set as a result of some error condition for a previous I/O operation.
FL_EMPTY
Set if there is no diskette in the drive.
FL_OFFLINE
Set if the drive is offline. If the drive was online during the open but has since been disconnected, then this bit is set and everything else is cleared.
FL_WRTLCK
Set if a previous write operation failed because the media is write-protected. It is cleared before each I/O or format operation.
FL_BLANK
Set if there is an unformatted diskette in the drive or if the diskette’s geometry is not listed as being supported.
FL_SOFTERR
Set if the previous I/O failed with a soft error (CRC or seek error). It is cleared before any I/O or format operation.
FL_HARDERR
Set if the previous I/O failed due to a media or drive error. It is cleared before any I/O or format operation.
FL_NOTDONE
Set whenever an I/O or format operation is sent to the drive and cleared when the operation completes successfully or with a soft error. It is not cleared if the operation completes with a hard error.
fl_type Indicate the type of floppy drive as follows:
| fl_type | drive type |
| 1 | 3½" low density |
| 2 | 3½" high density |
| 3 | 3½" low/high density |
| 4 | 5¼" low density |
| 5 | 5¼" high density |
| 6 | 5¼" low/high density |
fl_door Set to 1 if a previous operation failed because of a UNIT_ATTENTION condition. This means the drive door has been opened and closed. Note: this ioctl does a SCSI TEST_UNIT_READY before returning status, which gets the UNIT_ATTENTION condition if no other I/O has been attempted since the door was opened. After returning the current value to the user, this field is cleared. It can also be cleared by the open(2) system call.
fl_nsect If a diskette is in the drive and its geometry has been determined, this is the number of sectors per track on the diskette. Otherwise, it is zero.
fl_cyl If a diskette is in the drive and its geometry has been determined, this is the total number of cylinders on the diskette. Otherwise, it is zero.
fl_res This is cleared.
FL_FORMAT_TRACK
Format the specified track using the current drive geometry. The arg parameter points to an integer containing the track number to format. If the track number is invalid, the command fails, returning ERANGE.
FL_READ
Read buffered data after an error. This function is not currently supported. It always returns zero.
V_GETSSZ
Return the physical sector size of the CDROM. The arg parameter specifies a structure of type io_arg (defined in sys/vtoc.h). The sectst and datasz members of the io_arg structure are ignored. The memaddr member of the structure points to the address of an integer containing the sector size after a sucessful operation.
V_PDREAD
Read the Physical Description Area of the disk. The arg parameter specifies a structure of type io_arg (defined in sys/vtoc.h). The sectst and datasz members of the io_arg structure are ignored. The memaddr member of the io_arg structure points to the address of a structure of type pdsector (defined in sys/vtoc.h) which contain the requested data upon successful completion.
V_PDWRITE
Write the Physical Description Area of the disk. The arg parameter specifies a structure of type pdinfo (defined in sys/vtoc.h). The sectst and datasz members of the io_arg structure are ignored. The memaddr member of the io_arg structure points to the address of a structure of type pdsector (defined in sys/vtoc.h) which contain the requested data upon successful completion.
V_PREAD
Read physical sectors. This interface assumes sectors are 512 bytes in length so the driver is responsible from mapping the request block to the correct portion of the correct sector on the disk regardless of the actual physical sector size. The arg parameter specifies a structure of type io_arg (defined in sys/vtoc.h). The sectst member of the io_arg structure contains the starting sector number and the datasz member contains the number of sectors. The memaddr member of the io_arg structure points to the address of an sufficiently large area which contain the requested data upon successful completion.
V_PWRITE
Write physical sectors. This interface assumes sectors are 512 bytes in length so the driver is responsible from mapping the requested block(s) to the correct portion of the correct sector on the disk regardless of the actual physical sector size. The arg parameter specifies a structure of type io_arg (defined in sys/vtoc.h). The sectst member of the io_arg structure contains the starting sector number and the datasz member contains the number of sectors. The memaddr member of the io_arg structure points to the address of an sufficiently large area which contain the requested data upon successful completion.
V_RVTOC
Read the Volume Table of Contents (VTOC) from the disk. The arg parameter specifies a structure of type io_arg (defined in sys/vtoc.h). The sectst and datasz members of the io_arg structure are ignored. The memaddr member of the io_arg structure points to the address of a structure of type vtoc (defined in sys/vtoc.h) which contain the requested data upon successful completion.
V_WVTOC
Write the Volume Table of Contents (VTOC) to the disk. The arg parameter specifies a structure of type vtoc (defined in sys/vtoc.h). The sectst and datasz members of the io_arg structure are ignored. The memaddr member of the io_arg structure points to the address of a structure of type vtoc (defined in sys/vtoc.h) which contain the requested data upon successful completion.
DINIT CONSIDERATIONS
The utility dinit(1M) is used to format floppy disks.
DDEFS CONSIDERATIONS
The utility ddefs defines disk characteristics. The output of the ddefs utility is a file normally saved in the /etc/dskdefs directory. This file is used as input to the dinit(1M) utility when it initializes a disk.
There are no standards for floppy ddef files.