FAT questions

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
eL JeDi

FAT questions

Post by eL JeDi »

Hi,

Some questions about the fat12 implementation:

1) When i read a directory, is it better to load it on memory or reading directly from de FD?

2) How can I know how many entries are there on a directory?
Tim

Re:FAT questions

Post by Tim »

eL JeDi wrote:1) When i read a directory, is it better to load it on memory or reading directly from de FD?
It's better to cache it. Reserved a fixed-size buffer for directory entries. When you need an entry, check whether it's already in the cache. If it isn't, read it from disk into the cache.
2) How can I know how many entries are there on a directory?
The last entry will have empty entries after it (e.g. deleted or zero entries), unless that directory cluster is at the end of the chain.
eL JeDi

Re:FAT questions

Post by eL JeDi »

Thanks Tim, once again.

How it could be a good buffer size ( is for a floppy ) for the dir entry??
Tim

Re:FAT questions

Post by Tim »

You can only really determine that by experimentation, although the bigger the better. You might want a dynamic cache for floppy disks, where you read entries into memory and leave them there permanently.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:FAT questions

Post by distantvoices »

Isn't a directory a kind of file filled with entries telling about where to find other files (rights time and everything else not to mention here)?

Is it then good to have the directory entry be of a fixed size so that i can stuff line per line into a structure f. ex. to search for a certain file?
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
eL JeDi

Re:FAT questions

Post by eL JeDi »

Thanks Tim once again.

One last question, sorry 'cos i don't have understand it very well.

To know the last entry on a dir, i check the one after the last with information, is this?


Thanks for all.
Tim

Re:FAT questions

Post by Tim »

No.

It looks like either this:

Option 1:
<start of cluster>
[entry 1]
[entry 2]
[entry 3]
[deleted entry]
[entry 4]
[deleted entry]
[zero]
[zero]
[zero]
[zero]
<end of cluster>

Here entry 4 is the last entry. The ones afterwards are all deleted or zero.

Option 2:
<start of cluster>
[entry 1]
[entry 2]
[entry 3]
[deleted entry]
[entry 4]
[deleted entry]
[entry 5]
[entry 6]
[entry 7]
[entry 8]
<end of cluster>

You get to the end of that cluster and look for the next one. You see that this is the end of the cluster chain, so you know it's the end of the directory. Therefore entry 8 is the last one.

The root directory is a third alternative; there, you know the number of entries from the boot sector.
Balroj

Re:FAT questions

Post by Balroj »

Where in the boot entry is the number of entrys en the root dir?? can you post your boot str, please?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:FAT questions

Post by Pype.Clicker »

check out the bios parameter block (BPB) format in FAT documents at Operating System Resource Center (from .:QuickLinkz:.)
Balroj

Re:FAT questions

Post by Balroj »

Hi,

I search and don't find the field where is it. I have the str on the chris geise web, bue the only root_entry that there are the total entries: 224 ( I check some disks ).
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:FAT questions

Post by Pype.Clicker »

So you just have to read the directory entries as long as you find a null entry or that you reached the RootEntries count of the BPB.

(afaik)
eL JeDi

Re:FAT questions

Post by eL JeDi »

Thanks again Pype and Tim. :)

Balroj, here you have a good link for you question:
http://www.nondot.org/sabre/os/articles/FileSystems/ and http://www.nondot.org/sabre/os/files/FileSystems/FatFormat.pdf
Post Reply