Page 1 of 1

FAT questions

Posted: Sun Apr 27, 2003 1:29 pm
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?

Re:FAT questions

Posted: Sun Apr 27, 2003 1:44 pm
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.

Re:FAT questions

Posted: Sun Apr 27, 2003 2:02 pm
by eL JeDi
Thanks Tim, once again.

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

Re:FAT questions

Posted: Sun Apr 27, 2003 2:59 pm
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.

Re:FAT questions

Posted: Mon Apr 28, 2003 1:21 am
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?

Re:FAT questions

Posted: Mon Apr 28, 2003 1:56 pm
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.

Re:FAT questions

Posted: Mon Apr 28, 2003 3:12 pm
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.

Re:FAT questions

Posted: Tue Apr 29, 2003 2:44 am
by Balroj
Where in the boot entry is the number of entrys en the root dir?? can you post your boot str, please?

Re:FAT questions

Posted: Tue Apr 29, 2003 2:57 am
by Pype.Clicker
check out the bios parameter block (BPB) format in FAT documents at Operating System Resource Center (from .:QuickLinkz:.)

Re:FAT questions

Posted: Tue Apr 29, 2003 4:10 am
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 ).

Re:FAT questions

Posted: Tue Apr 29, 2003 5:43 am
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)

Re:FAT questions

Posted: Tue Apr 29, 2003 7:40 am
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