fat_BS->DirectoryEntries (FAT page)

All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
Post Reply
M374LX
Posts: 3
Joined: Sun Aug 24, 2014 9:07 am
Contact:

fat_BS->DirectoryEntries (FAT page)

Post by M374LX »

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?
Last edited by M374LX on Fri Aug 29, 2014 9:36 am, edited 1 time in total.
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: fat_BS->DirectoryEntries (FAT page)

Post by zhiayang »

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

Code: Select all

this->FirstUsableCluster + cluster * this->SectorsPerCluster - (2 * this->SectorsPerCluster)
where

Code: Select all

this->FirstUsableCluster	= this->partition->GetStartLBA() + this->ReservedSectors + (this->NumberOfFATs * this->FATSectorSize);
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.
Post Reply