Root Directory Region

25 Mar

Root Directory Region
In a FAT16 volume, the sectors following the FATs contain the root directory. The root directory typically can store up to 512 entries of 32 bytes each. If the sector size is 512, the root directory requires 32 sectors. The root directory contains information about the files and subfolders in the device’s top-level directory. Note that the size of the root directory region limits the number of entries a FAT16 root directory can store. As Chapter 9 explains, files with long file names reduce the number of file entries the directory can store.

File and Directory Data Region
The sectors after the root directory are grouped into data clusters. A data cluster can consist of one or more sectors. Because the FAT has an entry for each cluster and reserves the first two entries for other purposes, the first data cluster is called cluster 2, with the rest following in sequence. Files and subdirectories are stored in the clusters.

Each subdirectory is a directory much like the root directory and can contain entries for files and additional subdirectories immediately below the subdirectory. An embedded-system host might support only the root directory, ignoring any entries for subdirectories.

Inside a FAT32 Volume
FAT32 is an option for larger media that can’t use FAT16. A FAT32 system has other advantages as well, such as no limit on root-directory size and the availability of additional information for use in repairing damaged media and finding free clusters quickly. Compared to FAT16, a FAT32 system requires more storage space for the FATs because the entries are twice as long.

Every FAT32 volume has these components:

• Reserved region, which contains the boot sector.
• FAT region, which contains two copies of the file allocation tables (FATs).
• File and directory data region, which can hold the root directory, files, and subdirectories. These components are stored in sequence in the volume.

The sections that follow focus on the differences between FAT32 and FAT16 and assume you’re familiar with the preceding information about FAT16.

Reserved Region
The first region in a FAT32 volume is the reserved region, which consists of the boot sector, an FSInfo structure containing information to help in finding free clusters, and a backup copy of the boot sector.

The Boot Sector
As with FAT16, the boot sector begins at the LBA value stored in the volume’s entry in the partition table. Table 3-4 shows the first 90 bytes in a FAT32 boot sector. Technically, the BIOS parameter block (BPB) consists of the data in bytes 11–63, while the remaining bytes are part of the boot sector but not in the BPB.

Compared to FAT16, a FAT32 BPB has these differences:
• The number of reserved sectors in byte 14 is typically 32 rather than 1.
• The maximum number of entries in the root directory in byte 17 is unused because FAT32 has no limit.

Table 8-3: A volume’s boot sector contains low-level information about the media’s formatting. These values are for a FAT32 volume (Sheet 1 of 2).

Table 8-3: A volume’s boot sector contains low-level information about the media’s formatting. These values are for a FAT32 volume (Sheet 2 of 2).

• The total number of sectors is always at offset 32 because a FAT32 volume is always at least 32 KB.
• The number of sectors per FAT is in bytes 24h–27h.
• The cluster number of the root directory is at offset 44 because FAT32 has no dedicated location for the root directory.
• Byte 48 holds the location of the FSInfo structure and byte 50 holds the location of the backup boot sector. FAT16 doesn’t have these components.
• A Flags field at byte 40 indicates whether the file system maintains identical FATs or whether only one FAT should be considered valid. If only one FAT is considered valid, the Flags specify which one. A FAT16 BPB has no Flags field.

• Some fields that have identical functions are stored in different locations in FAT16 and FAT32 BPBs.
• The boot code, if present, begins at byte 90.

For maximum compatibility with mass-storage host software, several items in a FAT32 boot sector have recommended values, as shown in Table 8-4. In theory all of the values shown can vary, but straying from the recommended values can cause problems with some hosts.

As in a FAT16 BPB, byte 13 stores the number of sectors per cluster.

A FAT32 boot sector can contain boot code in bytes 90–509 and the sector must have a boot signature of AA55h in bytes 510–511. The jump instruction at offset 00h is typically EBh 58h 90h, which means jump ahead 88 bytes to the beginning of the boot code at 5Ah.


Random Posts

No comments yet

Leave a Reply

You must be logged in to post a comment.