Chapter
4
I
MS-DOS
Disk
Allocation
The File Allocation Table contains
a
12-bit entry (1.5 bytes)
for
each cluster on the disk. The first
two
FAT entries map
a
portion
of
the directory; these FAT entries indicate the size and format
of
the disk.
The second and third bytes always contain FFH.
The third FAT entry, which starts at offset
04H,
begins the
mapping
of
the data area (cluster
002).
Files in the data area
are not always written sequentially on the disk. The data area is
allocated one cluster
at
a
time, skipping over clusters already al-
located. The first free cluster found will be the next cluster allo-
cated, regardless
of
its physical location on the disk. This
permits the most efficient utilization
of
disk space because clus-
ters made available by the erasing
of
files can be allocated
for
new files.
Each FAT entry contains three hexadecimal characters. Any
of
the following combinations is possible:
000
FF7
The cluster is unused and available.
The cluster has
a
bad sector in it. MS-DOS will not
allocate such
a
cluster. CHKDSK counts the num-
ber
of
bad clusters
for
its report. These bad clusters
are not
part
of
any allocation chain.
Indicates the last cluster
of
a
file.
Any other characters that are the cluster number
of
the next cluster in the file. The cluster number
of
the first cluster in the file is kept in the file’s direc-
tory
entry.
The File Allocation Table always begins on the first sector after
the reserved sectors.
If
the FAT is larger than one sector, the
sectors are contiguous. Two copies
of
the FAT are usually written
for
data integrity. The FAT is read into one
of
the MS-DOS buff-
ers
whenever needed (open, read, write, etc.). For performance
reasons, this buffer is given a high priority
to
keep it in memory
as long
as
possible.
FF8-FFF
xxx
169