How MS-DOS 6.22 Handles Write-Protected Floppy Disks

This article examines the mechanisms MS-DOS 6.22 uses to process file system operations on write-protected floppy media. It covers physical detection by the drive hardware, interaction with the ROM BIOS disk services, internal DOS kernel error processing, and the user-facing Critical Error Handler prompt.

Hardware Detection

Write protection relies primarily on physical detection mechanisms built into floppy disk drives:

  • 3.5-inch Media: The drive utilizes a mechanical switch or optical sensor to detect an open window in the bottom-left corner of the disk housing. When the slider is moved to uncover the hole, the sensor detects the absence of plastic.
  • 5.25-inch Media: The drive uses an optical sensor to detect a piece of opaque tape covering the notch on the disk's right edge. If light is blocked, writing is permitted; if light passes through the notch, writing is disabled.

When write protection is engaged, the Floppy Disk Controller (FDC) logic hardware disables the drive's write circuitry at the electrical level, preventing the drive head from altering magnetic media. The FDC reflects this state in its internal status registers.

BIOS-Level Processing (INT 13h)

When an application or the operating system attempts to write to the disk, the MS-DOS block device driver issues a low-level disk request via BIOS interrupt INT 13h. Functions that modify disk sectors include:

  • AH = 03h (Write Disk Sectors)
  • AH = 05h (Format Cylinder/Track)

Before sending write data, the BIOS queries the controller. If the write-protect sensor is triggered, the controller halts the write operation. The BIOS updates the CPU registers to signal failure:

  • Carry Flag (CF): Set to 1 (indicating an error).
  • AH Register: Loaded with error code 03h (Write-protect error).

DOS Kernel Interception (INT 21h)

MS-DOS 6.22 manages high-level file system tasks through INT 21h (creating files, updating the File Allocation Table, modifying directory entries, or appending clusters). The kernel translates these file-level requests into raw sector writes handled by the internal block device driver (IO.SYS).

When the driver receives the 03h error status from INT 13h, it recognizes the error as a write-protect violation. It halts any further operations in the current I/O queue to avoid corrupting internal cache buffers or the in-memory FAT.

The Critical Error Handler (INT 24h)

Once the DOS kernel registers the write-protect failure, it invokes the Critical Error Handler through software interrupt INT 24h. The kernel populates registers with context:

  • AH: Contains status flags indicating the drive number and error characteristics.
  • DI: Contains the specific driver error code, where 00h represents a write-protect error.
  • BP:SI: Points to the device driver header for the affected drive.

By default, the COMMAND.COM error handler outputs the classic prompt to standard output:

Write protect error writing drive A:
Abort, Retry, Fail?

The user or system processes this state via three standardized responses:

  • Abort (A): Immediately terminates the running application that initiated the write request. Any unsaved data held in the application's memory is lost.
  • Retry (R): Causes DOS to reissue the exact INT 13h write operation. This allows the user to remove the diskette, close the write-protect tab, reinsert the disk, and resume writing seamlessly.
  • Fail (F): Returns an error code back to the calling DOS system call (INT 21h). The operating system sets the carry flag and returns an extended error code (typically Error Code 19: ERROR_WRITE_PROTECT), permitting error-aware applications to handle the situation programmatically without crashing.

Read Operations and Integrity Protection

Read requests (AH = 02h via INT 13h) are entirely unaffected by the write-protect state. MS-DOS reads sectors, caches the Directory Table and FAT in RAM, and opens files in read-only mode normally.

Because write protection is enforced at the hardware and FDC level, the MS-DOS 6.22 kernel cannot bypass it, ensuring media integrity against accidental deletion, formatting, or file overwrites.