3.3.1 Removable-Media Drives

Many programs use removable media, such as disks and tapes, to store data. A program can determine whether a drive supports removable media by using Does Device Use Removable Media (Interrupt 21h Function 4408h). If the specified drive supports removable media, the function clears the carry flag and returns zero in the AX register.

To help distinguish one removable disk or tape from another, the format command creates a unique identifier for each volume (for example, each disk or tape) as it formats the volume. Programs can also create their own unique identifiers by using Set Media ID (Interrupt 21h Function 440Dh Minor Code 46h) to set the volume label, volume serial number, and file-system type. A program can retrieve this information by using Get Media ID (Interrupt 21h Function 440Dh Minor Code 66h). (A volume label consists of up to 11 characters of the same type used in filenames.)

Since the user can change the volume in a removable-media drive at any time, programs that read from or write to removable media need ways to prevent inadvertently reading from or writing to the wrong volume. Some drives have change-line capability that helps MS-DOS automatically detect media changes and prompt the user to insert the proper volume so that read and write operations can be completed. A program can determine whether a drive has change-line capability by examining the dpDevAttr field in the DEVICEPARAMS structure returned by Get Device Parameters (Interrupt 21h Function 440Dh Minor Code 60h). This field also specifies whether the drive supports removable media. (For a full description of the DEVICEPARAMS structure, see Section 3.7, “Structures.”) If a drive does not have change-line capability, MS-DOS checks for the proper volume before read and write operations. To ensure that data is not lost when a disk is removed, a program may also need to direct MS-DOS to write all data immediately to the volume (that is, commit the file).