Thursday 14 April 2016

File Allocation Table

A partition is divided up into identically sized clusters, small blocks of contiguous space.
Cluster sizes vary depending on the type of FAT file system being used and the size of the partition,
typically cluster sizes lie somewhere between 2 KB and 32 KB. Each file may occupy one or more
of these clusters depending on its size; thus, a file is represented by a chain of these clusters
(referred to as a singly linked list). However these chains are not necessarily stored adjacent to one
another on the disk's surface but are often instead fragmented throughout the Data Region.

The File Allocation Table (FAT) is a list of entries that map to each cluster on the partition.
Each entry records one of five things:

• the address of the next cluster in a chain
• a special end of file (EOF) character that indicates the end of a chain
• a special character to mark a bad cluster
• a special character to mark a reserved cluster
• a zero to note that that cluster is unused

Each version of the FAT file system uses a different size for FAT entries. The size is
indicated by the name, for example the FAT16 file system uses 16 bits for each entry while the
FAT32 file system uses 32 bits. This difference means that the File Allocation Table of a FAT32
system can map a greater number of clusters than FAT16, allowing for larger partition sizes with
FAT32. This also allows for more efficient use of space than FAT16, because on the same hard
drive a FAT32 table can address smaller clusters which means less wasted space.

FAT12 FAT16 FAT32 Description
0x000 0x0000 0x?0000000 Free Cluster
0x001 0x0001 0x?0000001 Reserved Cluster
0x002 -
0xFEF
0x0002 - 0xFFEF
0x?0000002
-
0x?FFFFFEF
Used cluster; value points to next cluster
0xFF0 -
0xFF6
0xFFF0 - 0xFFF6
0x?FFFFFF0
-
Reserved values

0x?FFFFFF6
0xFF7 0xFFF7 0x?FFFFFF7 Bad cluster
0xFF8 -
0xFFF
0xFFF8 - 0xFFFF
0x?FFFFFF8
-
0x?FFFFFFF
Last cluster in file

Note that FAT32 uses only 28 bits of the 32 possible bits. The upper 4 bits are usually zero
but are reserved and should be left untouched. In the table above these are denoted by a question
mark.

The first cluster of the data area is cluster #2. That leaves the first two entries of the FAT
unused. In the first byte of the first entry a copy of the media descriptor is stored. The remaining
bits of this entry are 1. In the second entry the end-of-file marker is stored. The high order two bits
of the second entry are sometimes, in the case of FAT16 and FAT32, used for dirty volume
management: high order bit 1: last shutdown was clean; next highest bit 1: during the previous
mount no disk I/O errors were detected.[6]

No comments:

Post a Comment

Popular Posts