FAT filesystem

Albert Cahalan (albert@ccs.neu.edu)
Sat, 26 Oct 1996 23:00:31 -0400 (EDT)

Not counting the severe changes caused by OEM Windows 95,
it seems the FAT filesystem definition has changed a bit.
There is a dirty flag to maintain, just like ext2 has.
The dirty flag should be part of the Linux fat code because
this documentation is for Windows NT, which can operate with
long filenames disabled via a registry setting.

The following is from the Microsoft knowledge base, with some
of the stuff everybody knows trimmed out.


Detailed Explanation of FAT Boot Sector
Article ID: Q140418
Revision Date: 09-SEP-1996

Inside the FAT Boot Sector:

Field Offset Length

8086 jump 0 3
OEM ID 3 8

Bytes Per Sector 11 2
Sectors Per Cluster 13 1
Reserved Sectors 14 2
FATs 16 1
Root Entries 17 2
Small Sectors 19 2
Media Descriptor 21 1
Sectors Per FAT 22 2
Sectors Per Track 24 2
Heads 26 2
Hidden Sectors 28 4
Large Sectors 32 4

Physical Drive Number 36 1
Current Head 37 1 <--- now a dirty flag
Signature 38 1
ID 39 4
Volume Label 43 11
System ID 54 8

Sectors Per Track and Heads: These values are a part of the apparent
disk geometry in use when the disk was formatted.

Physical Drive Number: This is related to the BIOS physical drive number.
Floppy drives are numbered starting with 0x00 for the A: drive, while
physical hard disks are numbered starting with 0x80. Typically, you would
set this value prior to issuing an INT 13 BIOS call in order to specify the
device to access. The on-disk value stored in this field is typically
0x00 for floppies and 0x80 for hard disks, regardless of how many physical
disk drives exist, because the value is only relevant if the device is a
boot device.

Current Head: This is another field typically used when doing INT13 BIOS
calls. The value would originally have been used to store the track on
which the boot record was located, but the value stored on disk is not
currently used as such. Therefore, Windows NT uses this field to store
two flags:
- The low order bit is a dirty flag, used to indicate that autochk
should run chkdsk against the volume at boot time.
- The second lowest bit is a flag indicating that a surface scan should
also be run.

Signature: The extended boot record signature must be either 0x28 or 0x29
in order to be recognized by Windows NT.

Signature: The extended boot record signature must be either 0x28 or 0x29
in order to be recognized by Windows NT.

ID: The ID is a random serial number assigned at format time in order to
aid in distinguishing one disk from another.

Volume Label: This field was used to store the volume label, but the volume
label is now stored as a special file in the root directory.

System ID: This field is either FAT12 or FAT16 depending on the format
of the disk.