OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 8:52 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: FAT Page method of finding first sector of cluster wrong?
PostPosted: Sun Feb 15, 2015 7:44 pm 
Offline
Member
Member
User avatar

Joined: Sun Aug 25, 2013 5:47 pm
Posts: 86
Location: Nebraska, USA
Although I could edit the page, I am 99% certain I am wrong, so I am going to ask instead if I got a point. Anyways, I was reading up on FAT so I could figure out how to load a second stage bootloader from my current bootloader project. Now, the page says this is how the first sector of a cluster should be computed:

Quote:
first_sector_of_cluster = (cluster - 2) * fat_boot->reserved_sector_count + first_data_sector;


However, shouldn't it be:

Quote:
first_sector_of_cluster = ((cluster - 2) * fat_boot->sectors_per_cluster) + first_data_sector;


If I am wrong, please explain how it is so so I can move on to actually making a bootloader :D.

_________________
"Procrastination is the art of keeping up with yesterday."


Top
 Profile  
 
 Post subject: Re: FAT Page method of finding first sector of cluster wrong
PostPosted: Sun Feb 15, 2015 8:01 pm 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
Reserved sectors definitely aren't multiplied by cluster number. There's a constant number of them, all grouped in one location.
As usual, look up your copy of fatgen103.doc.


Top
 Profile  
 
 Post subject: Re: FAT Page method of finding first sector of cluster wrong
PostPosted: Sun Feb 15, 2015 8:16 pm 
Offline
Member
Member
User avatar

Joined: Sun Aug 25, 2013 5:47 pm
Posts: 86
Location: Nebraska, USA
Quote:
Reserved sectors definitely aren't multiplied by cluster number. There's a constant number of them, all grouped in one location.
As usual, look up your copy of fatgen103.doc.


I know; it is what drew my eye to the page's method of looking up a cluster's first sector and suggested the latter method in my post.

What is fatgen103.doc anyway? (EDIT: Found the pdf.)

Also, are you saying I am right (at least partly), or are you saying I am mistaken?

_________________
"Procrastination is the art of keeping up with yesterday."


Top
 Profile  
 
 Post subject: Re: FAT Page method of finding first sector of cluster wrong
PostPosted: Sun Feb 15, 2015 8:52 pm 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
I'm saying that the official document from MS is the ultimate reference and it is correct (I've been able to implement FAT12/16/32 code based on it) and if you have any doubts, you should see what it says.


Top
 Profile  
 
 Post subject: Re: FAT Page method of finding first sector of cluster wrong
PostPosted: Sun Feb 15, 2015 9:04 pm 
Offline
Member
Member
User avatar

Joined: Sun Aug 25, 2013 5:47 pm
Posts: 86
Location: Nebraska, USA
Turns out I was right. Here is what I found after some quick text-searching:

Quote:
Given any valid data cluster number N, the sector number of the first sector of that cluster (again relative to sector 0 of the FAT volume) is computed as follows:
FirstSectorofCluster = ((N – 2) * BPB_SecPerClus) + FirstDataSector;


I'll get the FAT page corrected in the next few minutes! (EDIT: Done.)

_________________
"Procrastination is the art of keeping up with yesterday."


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 40 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