FAT Filesystem Implementation

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
Ziddia
Member
Member
Posts: 38
Joined: Sat Nov 05, 2011 6:28 pm

FAT Filesystem Implementation

Post by Ziddia »

Hi,

I've been working on the theory and code found here and I've set everything up, but I'm confused on one point. How do I get the data that makes up fat_BS_t and either fat_extBS_16_t or fat_extBS_32_t? Do I need to read it from the BIOS during boot, or read it from the floppy I'm using somehow, or provide it myself?

Thanks!
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: FAT Filesystem Implementation

Post by Combuster »

fat_BS_t can be found at the first byte of the medium or partition. The bootloader also starts at the first byte of the medium or partition. The bootloader doesn't need any additional steps to read that structure because it's an integral part of itself.

If you need to read a filesystem at a later point, just read the first sector.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Ziddia
Member
Member
Posts: 38
Joined: Sat Nov 05, 2011 6:28 pm

Re: FAT Filesystem Implementation

Post by Ziddia »

Combuster wrote:fat_BS_t can be found at the first byte of the medium or partition. The bootloader also starts at the first byte of the medium or partition. The bootloader doesn't need any additional steps to read that structure because it's an integral part of itself.

If you need to read a filesystem at a later point, just read the first sector.
So all the information's located in the BPB, I assume. Assuming the first sector of the disk is loaded into ram at the position 0x0000:0x7c00, as the wiki page tells me, where would I read to find what I need? For example, the bytes per sector value is, according to the wiki, at an offset of 11 bytes. Is that relevant to where in memory the value is?

Questions are kind of silly and probably obvious, but I'm just kind of muddling through this at the moment.
User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Re: FAT Filesystem Implementation

Post by Nessphoro »

Well eh, yeah.
It will be located at (Where you loaded the first sector)+11
In this case 0x7C00+11
Ziddia
Member
Member
Posts: 38
Joined: Sat Nov 05, 2011 6:28 pm

Re: FAT Filesystem Implementation

Post by Ziddia »

Nessphoro wrote:Well eh, yeah.
It will be located at (Where you loaded the first sector)+11
In this case 0x7C00+11
Alright, seems simple enough. Thanks. I'll check back once I'm done with it.
Post Reply