OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 6:17 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: fat_BS->DirectoryEntries (FAT page)
PostPosted: Thu Aug 28, 2014 6:38 pm 
Offline

Joined: Sun Aug 24, 2014 9:07 am
Posts: 3
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.

Top
 Profile  
 
 Post subject: Re: fat_BS->DirectoryEntries (FAT page)
PostPosted: Fri Aug 29, 2014 9:08 am 
Offline
Member
Member
User avatar

Joined: Tue Dec 27, 2011 7:57 am
Posts: 368
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:
this->FirstUsableCluster + cluster * this->SectorsPerCluster - (2 * this->SectorsPerCluster)

where
Code:
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.

_________________
[nx] kernel: http://github.com/zhiayang/nx


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group