In the Programming Guide section of the FAT file system page of the Wiki, the formula shown to find the first data sector of an entry needs the value of fat_BS->DirectoryEntries, but the fat_BS struct, as shown earlier in the section, has no DirectoryEntries member (nor directory_entries, which would follow the coding style used). Also, the formula requires fat_BS->BytesPerSector, but the actual member found in the struct is bytes_per_sector.
What exactly does fat_BS->DirectoryEntries mean? Do I need to count the total number of directory entries in the entire disk?
fat_BS->DirectoryEntries (FAT page)
fat_BS->DirectoryEntries (FAT page)
Last edited by M374LX on Fri Aug 29, 2014 9:36 am, edited 1 time in total.
Re: fat_BS->DirectoryEntries (FAT page)
Looking through the wiki page, it's a bit confusing. To be honest, I'd suggest looking at the wikipedia article on the subject. Indeed, also reference fatgen103.
I've personally never been to the FAT page on the OSDev wiki and managed to implement a FAT32 driver.
To get the LBA (sector number) of a cluster, I use
where
This is for FAT32. So given a cluster number of a directory, use use the above formula to calculate which sector it starts at. TBH I don't know what the wiki article is trying to do, it might be FAT12/16 specific.
I've personally never been to the FAT page on the OSDev wiki and managed to implement a FAT32 driver.
To get the LBA (sector number) of a cluster, I use
Code: Select all
this->FirstUsableCluster + cluster * this->SectorsPerCluster - (2 * this->SectorsPerCluster)
Code: Select all
this->FirstUsableCluster = this->partition->GetStartLBA() + this->ReservedSectors + (this->NumberOfFATs * this->FATSectorSize);
[nx] kernel: http://github.com/zhiayang/nx