I am trying to understand how a FAT file system works. From the attached first sector of FAT 16 partition I could understand,
- Bytes per sector = 512.
- Sectors per cluster = 4.
- FAT 16 file system.
- reserved sectors = 4.
- FAT table count = 2.
- Number of entries in root directory = 512.
- Total sectors = 204800.
- Root dir sector = 32.
- Size of FAT table = 200.
- First data sector = 436 (4 + 2 * 200 + 32).
- Cluster count = 51091.
Root directory is at 404th sector (0x32800th byte)
Root directory at address 0x32800 is attached. The root directory has two folders named a, b and one file named file.txt. In the given image above how to distinguish between file and folder.
Doubts listed below: 1. A folder entry should start with a 0x2E but there is no such value. So how to find out whether a given entry is a file or folder? 2. As you can see each entry in the root directory occupies 64 bytes (instead of 32 bytes). There seems to be 2 32byte entries for each file and folder. For example, folder 'a' has entries at 0x32800 and 0x32820 (totally 64bytes). 3. What does the value 0x41 denote in this context? The value 0x41 appears at 0x32800, 0x32820, 0x32840, 0x32880. The values at 0x32860 and 0x328A0 are different from 0x41. 4. The offset 0x1A from address 0x32800 (0x32800 + 0x1a = 0x3281a) has value 0, offset 0x1A from address 0x32820 (0x32820 + 0x1a = 0x3283a) has value 3. Which is the correct cluster number corresponding to folder 'a'?