What is the File Allocation Table (FAT)?

File Allocation Table FAT

File Allocation Table (FAT)

The File Allocation Table (FAT) is a map of different clusters that are associated with different files. The FAT is located immediately after the DBR (Disk Buffer Register) and it always begins on DOS sector number 1. DOS keeps two copies of the FAT, the primary and the secondary (for the back up). They are placed next to each other.

Types of FAT

There are two kinds of FAT organizations. Fat with 12 bits can have up to 4 k entries. The 12 bit FAT needs a total area of 6 k on disk. The second type is 16 bit FAT which can have entries up to 64 k, which requires an area of 128 k for each copy.

The FAT is immediately followed by the root directory. The root directory is the basis of the tree-structured file system. There are 512 entries for a disk with 16 bit FAT and 128 entries for 12 bit FAT (which is directory information). Generally, the directory entries are 32 bytes long. The exact number of root entries is stored in the DBR.

The actual user data area immediately follows the root directory. The FAT helps DOS (Disk Operating System) in avoiding the use of unreliable and bad areas on the disk. It keeps the information of sectors that are unsuitable, sectors that are in use, and the sectors that are available. 

When any file is saved on a disk, it writes on the disk. But remember that DOS may not write a file of files to the consecutive clusters on the disk. It may not even write to the consecutive sectors, that follow each other logically by number. That means if a cluster is part of a file, the address in the FAT contains the address of the next cluster, which forms part of the file. In a chain like this, the address of the last cluster in the file contains a piece of information that tells that the cluster is the end of the file. 

As discussed earlier directory, a directory entry contains 32 bytes of information about a file. The information is as follows,

8 bytes for filename

3 bytes for file extension

1 byte for Attributes

2 bytes for the date of the last update

2 bytes for the time of the last update

2 bytes for starting cluster

4 bytes for file size

10 bytes left for future use

The one attribute byte is divided into eight attribute bits by DOS and out of which six are used. they are 

  1. Archive - When this is set it indicates that the file has no backup 
  2. Hidden - When set, the file is invisible
  3. Read-only - When set, file is only for read, no writing or changes are allowed.
  4. Label - When set, indicates that this directory entry is not a file entry but a disklabel. Hence using the file name and file extension bytes gives a maximum of 11 characters length of file name/label.
  5. Directory - When set it means that the directory entry does not pint to a normal file, but to a subdirectory.
  6. System - When set, file can't be moved

The starting cluster number gives the information to the DOS that where a file begins and, the  FAT tells where the rest of the file is located. As it was told earlier, the FAT is a table of numbers representing which cluster belongs to which file. Each cluster on the cluster can be any of the following.

"0" indicates that the cluster is not allocated

"EOF" (hex FFF8 to FFFF) indicates that it is the last cluster in a file

BAD (hex FFF7) indicates the cluster has bad sectors and not to be used

A (NON-ZERO) indicates the number, which is a pointer to the next cluster of the file. 

Post a Comment