MS-DOS 6.22 Directory Listing on Empty FAT Partitions

When MS-DOS 6.22 processes a directory listing request on an empty FAT12 or FAT16 partition, it queries the drive's Drive Parameter Block (DPB), reads the root directory table from a fixed disk sector, scans the initial 32-byte directory entries, and calculates remaining capacity from the File Allocation Table. Because an empty partition marks the very first file entry with an end-of-directory marker (0x00), the operating system aborts file traversal almost immediately, reporting zero files while computing total available disk space.

Command Execution and the Interrupt 21h Interface

When a user executes the DIR command, the internal command processor COMMAND.COM issues system calls to the MS-DOS kernel via INT 21h. To gather the entries, it utilizes:

  • AH = 4Eh (Find First File): Initiates a search matching the standard *.* wildcard mask.
  • AH = 4Fh (Find Next File): Continues the search until all entries are exhausted.
  • AH = 36h (Get Free Disk Space): Retrieves allocation unit geometry to report free bytes.

Locating the Root Directory via the Drive Parameter Block

Unlike subdirectories, which are dynamic cluster chains, the root directory on FAT12 and FAT16 partitions resides at a fixed physical location immediately following the File Allocation Tables.

MS-DOS 6.22 references the Drive Parameter Block (DPB) stored in low memory, which was initialized during system boot from the partition's BIOS Parameter Block (BPB). The DPB dictates:

  • The logical sector number where the root directory starts.
  • The fixed number of 32-byte directory entries allocated (typically 512 entries on standard FAT16 hard disks).

Sector Buffering and Entry Evaluation

MS-DOS reads the first sector of the root directory into one of its internal disk buffers (configured via BUFFERS= in CONFIG.SYS). It then reads the 32-byte structures sequentially:

  1. Volume Label Inspection: The operating system checks for an entry flagged with the Volume Label attribute (0x08). If the disk was formatted with a label, this entry occupies the first slot. MS-DOS extracts the string for the header output (Volume in drive X is ...) and advances to the next entry.
  2. End-of-Directory Evaluation: On an empty formatted partition, the first non-label entry begins with a null byte (0x00). In the FAT filesystem specification, a leading 0x00 indicates that the entry is unused and that no populated entries exist beyond it.
  3. Search Termination: Because the byte is 0x00, the MS-DOS kernel immediately terminates the search. It does not read any remaining sectors reserved for the root directory, saving I/O cycles. INT 21h, AH=4Eh returns an error code (typically Error 02h or 12h, "No more files").

Computing Free Space via the FAT

After COMMAND.COM determines that no file records match the query, it calculates free storage:

  1. The DOS kernel reads the File Allocation Table (FAT).
  2. It counts the number of clusters containing the value 0x000 (FAT12) or 0x0000 (FAT16), representing unallocated disk blocks.
  3. This cluster count is multiplied by the sectors per cluster and bytes per sector values retrieved from the DPB.

Final Screen Output Formatting

With the scan terminated and disk capacity verified, COMMAND.COM formats the output stream sent to standard output (CON):

  • Prints the volume label and volume serial number.
  • Prints the directory path string (Directory of X:\).
  • Depending on whether flags like /W or standard layout are used, it outputs File not found or lists 0 file(s) 0 bytes.
  • Appends the final summary footer indicating the total free byte count on the partition.