I'm building a file system that resembles FAT. It has the following setup:
| MBR | FAT Area | Data Area |
So if given the sector_size (the size of a sector in bytes), cluster_size(the size of the cluster in sectors), and disk_size (the size of the disk in clusters), how can I calculate the length of the FAT Area?
I know that MBR starts at cluster 0, and FAT Area starts at cluster 1. But I don't know what information I can use to calculate the length of the FAT Area.
Also, The root directory starts at the first cluster in the Data Area, so how can I calculate the length of the root directory as well?
This is how FAT12 (MSDOS 6.22) floppy image looks like:
Drive geometry
FAT
cluster=N*sector
whereN={1,2,3,4,...}
heads*tracks*sectors*sector_size
FAT size
floor(512*8/12)=341
entriesceil(4096/341)=12
sectorsFAT_entries=(drive_size-reserved)/cluster_size
cluster_size=(drive_size-reserved)/FAT_entries
16bit
(2Byte)2heads*1024tracks*64sectprs*512Byte=64MByte
cluster_size=4096Byte
FAT_entries=64*1024*1024/4096=16*1024