The FAT filesystem in DOSPLUS 1.2

DOSPLUS 1.2 (CP/M-86 4.1) allows CP/M programs to access DOS-formatted discs via conventional BDOS calls, emulating (as far as possible) the behaviour of a normal CP/M FS. The behaviour is probably a good starting point for anyone writing a CP/M emulator which uses a hierarchical or non-CP/M filesystem.

This document is a work in progress. It is not guaranteed to be accurate.

Test for DOS media

The standard test is to perform a Search First (BDOS function 11h) with the first 12 bytes of the FCB containing '?' marks. On a DOS disc, this will return a "disc label" directory entry, and byte 0Fh of this entry will be 80h. On a CP/M disc, it may or may not return the label, but if it does byte 0Fh of the label entry will be zero.

FCB functions in general

If bit 7 of the "drive" byte in the FCB is set, then the call is assumed to apply to directories rather than files. The following calls appear to support directories:

0Fh
Open. Changes to the specified subdirectory (can be ".."). The Extent byte should be 0 to set the current directory, or 1-3 to set a "floating" drive (N: O: or P:) to the specified directory.
10h
Close. Changes to the root directory.
11h
Search first. Will return directories and files.
12h
Search next.
13h
Delete. Will remove a subdirectory if it is empty.
16h
Create. Creates a new subdirectory.

FCB functions behave normally, but the allocation area (16 bytes at FCB+10h) contains the following data:

  fl fl of 00 cc cc ci ci dd dd cl cl le le le le  ................

  Where:

  fl = flags:
       d7 always set 
       d6 set if file is a directory 
       d5 set if file is hidden
       d4-d0 are high bits of file number
   of = file number, low 8 bits. Number is 0 for 1st dir entry, 1 for 2nd, etc.
   cc = current cluster, 0 if none
   ci = index of current cluster (0, 1, 2, ...) in file chain. Only meaningful
        if cc is nonzero.
   dd = DOS date
   cl = DOS cluster
   le = DOS length

Functions 11h and 12h

Functions 11h and 12h will return a fake directory record with:

The emulation goes to some pains to ensure that if a '?' is in byte 0Ch of the search FCB, a suitable list of "extents" is returned.

XIOS level

The DOSPLUS XIOS returns an Extended DPB (call it an EDPB) for DOS media:

DW   -1 or -2 ;Signals EDPB
              ;-1 for FAT12
              ;-2 for FAT16
DW   no of FATs
DW   Sectors/FAT
DW   no of clusters?
DW   bytes/cluster?
DW   no of reserved sectors
- then normal DPB

I believe that the BDOS returns the normal DPB rather than the EDPB to function 1Fh.


John Elliott 16-11-1998