CIS-24 Home http://www.c-jump.com/CIS24/CIS24syllabus.htm

The FAT File System


  1. FAT Overview
  2. Boot Sector, FAT, Root Directory, and Files
  3. FAT File System Layout
  4. FAT Clusters and Sectors
  5. FAT, Slack, and Unallocated Space
  6. Where is the First FAT Cluster?
  7. Boot Sector
  8. FAT Boot Sector, bytes 0-35 (FAT12/16 and FAT32)
  9. FAT Boot Sector (FAT12/16)
  10. FAT12 Boot Sector
  11. Boot Sector Interpretation
  12. Capacity of this Medium
  13. Sector Assignments
  14. Root Directory
  15. Root Directory Entries
  16. Root Directory Entry Format (SFN)
  17. Root Directory Example
  18. Sample Root Directory Entry
  19. Another Sample Root Directory Entry
  20. FATs Compared
  21. FAT12 File Allocation Table
  22. Interpreting FAT12
  23. FAT12 Contents
  24. Formatting a Floppy
  25. Formatted Floppy Data Structures
  26. Allocating A New File
  27. Deleting A File
  28. For More Information...

1. FAT Overview



2. Boot Sector, FAT, Root Directory, and Files


  • File tyui.jpg:

    • occupies clusters 2, 3, and 4.

    • The file size is 1,400 bytes, it occupies 1,536 bytes (3 clusters) on the disk, and cluster 4 includes 136 bytes of slack space.

  • File mes.doc:

    • occupies clusters 5 and 6.

    • The file size is 980 bytes, it occupies 1,024 bytes (2 clusters), and has 44 bytes of slack space in cluster 6.

  • Clusters 7, 8, and 9 are unallocated.

  •   Boot Sector, FAT, Root Directory, and Files


3. FAT File System Layout



4. FAT Clusters and Sectors



5. FAT, Slack, and Unallocated Space


  • Clusters 3, 6, and 8 are allocated; clusters 2, 4, 5, 7, and 9 are unallocated

  • Clusters 6 and 8 are only partially filled; the unused portion is slack space

  • File gary.txt:

    • logical size is 1,034 bytes

    • physical size is 2,048 bytes (slack = 1,014 B)

  • File hello.jpg:

    • logical size is 3,973 bytes

    • physical size is 4,096 bytes (slack = 123 B)

    FAT, Slack, and Unallocated Space

6. Where is the First FAT Cluster?


  • The first cluster is Cluster 2

  • Actual location of cluster 2 is different in FAT12/16 and FAT32

  • Assume cluster size = 2,048 B (4 sectors)

  • Assume that data area starts at sector 1224

  • First sectors of data area are reserved for the Root Directory

    • Size is established at boot time

  • Cluster 2 starts after Root Directory

  • Root directory is set at 32 sectors

    • Occupies sectors 1,224-1,255

  • FAT12/16 Cluster Example:

      FAT12/16 Cluster Example

  • Cluster 2 starts at sector 1,256

  • Cluster 3 starts at sector 1,260

  • Cluster 4 at 1,264...


7. Boot Sector



8. FAT Boot Sector, bytes 0-35 (FAT12/16 and FAT32)



9. FAT Boot Sector (FAT12/16)



10. FAT12 Boot Sector



11. Boot Sector Interpretation



12. Capacity of this Medium



13. Sector Assignments



14. Root Directory



15. Root Directory Entries



16. Root Directory Entry Format (SFN)



17. Root Directory Example



18. Sample Root Directory Entry



19. Another Sample Root Directory Entry



20. FATs Compared



21. FAT12 File Allocation Table


  • FAT table entries are packed so that two cluster entries occupy three bytes with the following general format:

        yz Zx XY
    

    where

    • xyz is the one pointer entry and

    • XYZ is the second pointer entry.

  • E.g., bytes 242-244:

        2d e0 02
    

    refer to clusters 0x02d (45) and 0x02e (46)

  • Primary FAT starts at sector 1, byte 0x200 (shown here)

  • The starting cluster in the directory is also a pointer into the FATs linking to the next cluster in the file

  • Primary FAT sector 1:

      FAT12 Primary FAT sector 1


22. Interpreting FAT12



23. FAT12 Contents



24. Formatting a Floppy



25. Formatted Floppy Data Structures


  • Floppy Data Structures before formatting, uninitialized:

      Floppy Data Structures before formatting

  • Floppy Data Structures after formatting, initialized root directory:

      Floppy Data Structures after formatting


26. Allocating A New File


  1. Find first free entry in directory and write file name

  2. Search FAT for unallocated cluster; set to EOF (0xFFF)

  3. Write that cluster's address into directory entry

  4. If another cluster is needed,

    Repeat this step as necessary

     


27. Deleting A File


  1. Find directory entry for file to delete

  2. Using starting cluster value in the root directory, set all FAT entries in file's cluster chain to zero

  3. Deallocate directory entry by overwriting first byte of the entry with 0xE5 (å)

     


28. For More Information...