FAT Filesystem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
AvengerX

FAT Filesystem

Post by AvengerX »

Alright, I am reading a disk to get the FS info, i have the dir entry, a file finding function, but when it finds the file and calculates the sector it's on (cluster is begins at multiplied by number of sectors in a cluster), but i always get an incorrect value (i.e. it says 74 when it should be 105 (i used a hex editor and some math to figure out the right value), how could i tune this so it's correct?
Therx

Re:FAT Filesystem

Post by Therx »

You need to add on the number of FAT sectors, root dir sectors and reserved sectors(eg bootsect) Quick arithmitic tells me that this will turn 74 to 105
AvengerX

Re:FAT Filesystem

Post by AvengerX »

Ok, i've come up with the solution, thanks for your help.
for anyone who may have the same problem:

Code: Select all

filestart = (((rdir.start - 2) * clustersize) + (bs.reserved) + ((FAT_CVT_U16(bs.dir_entries) * 32) / 512) + (rootloc)) - 1;
where rdir is a structure containing the dir entry, rootloc is the location (sector-wise) of the root directory, clustersize is the # of sectors in a cluster, and bs is a structure containing the boot sector data
Post Reply