[SOLVED] FAT12 and root directory

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
HugeCode
Member
Member
Posts: 112
Joined: Mon Dec 17, 2012 9:12 am

[SOLVED] FAT12 and root directory

Post by HugeCode »

Hi all. I have been looking on FAT12 filesystem and there are few things I don't understand. I have summarized them in few questions:
  1. Is the number of root directory entries (and logicaly size of root directory) changable by operating system, or it's only maximal limit of entries set by formatting program?
  2. Is the root directory also listed in FAT table (as it is for FAT32), or every calculation of cluster's sector must add the number of sectors reserved by root directory?
  3. Are the entries of clusters which don't physicaly exists (entries exist, because sectors of FAT table are 512-byte aligned as any other sectors, but there is no place on floppy for them) filled with some special value?
Thanks.
Last edited by HugeCode on Sat Jun 29, 2013 2:08 am, edited 1 time in total.
User avatar
Kazinsal
Member
Member
Posts: 559
Joined: Wed Jul 13, 2011 7:38 pm
Libera.chat IRC: Kazinsal
Location: Vancouver
Contact:

Re: FAT12 and root directory

Post by Kazinsal »

HugeCode wrote:Is the number of root directory entries (and logicaly size of root directory) changable by operating system, or it's only maximal limit of entries set by formatting program?
If the number of root directory entries is 224, you've got 224 entries to work with. No more. If it says 16, it's 16. The root directory is a fixed structure.

I suppose if you really wanted to you could do an OS-specific extension where a specifically-named directory in the root directory acts as an extension to the root directory if it exists, but there is no standard for such a thing.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: FAT12 and root directory

Post by egos »

HugeCode wrote:Is the number of root directory entries (and logicaly size of root directory) changable by operating system, or it's only maximal limit of entries set by formatting program?
The 2nd variant.
Is the root directory also listed in FAT table (as it is for FAT32), or every calculation of cluster's sector must add the number of sectors reserved by root directory?
The 2nd variant.
Are the entries of clusters which don't physicaly exists (entries exist, because sectors of FAT table are 512-byte aligned as any other sectors, but there is no place on floppy for them) filled with some special value?
Such entries are undefined. You shouldn't use them.
If you have seen bad English in my words, tell me what's wrong, please.
HugeCode
Member
Member
Posts: 112
Joined: Mon Dec 17, 2012 9:12 am

Re: FAT12 and root directory

Post by HugeCode »

Blacklight and egos, thanks.
egos: Can I predict that number of root entries will be (at least) multiply of 16? (512/32)
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: FAT12 and root directory

Post by egos »

Yes. Additionally in the FS driver you can check this field during FS detection.
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: FAT12 and root directory

Post by qw »

The [url=http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/fatgen103.doc]Microsoft Extensible Firmware Initiative FAT32 File System Specification[/url] wrote:BPB_BytsPerSec: Count of bytes per sector.

BPB_RootEntCnt: For FAT12 and FAT16 volumes, this field contains the count of 32-byte directory entries in the root directory. (...) For FAT12 and FAT16 volumes, this value should always specify a count that when multiplied by 32 results in an even multiple of BPB_BytsPerSec.
Casm
Member
Member
Posts: 221
Joined: Sun Oct 17, 2010 2:21 pm
Location: United Kingdom

Re: FAT12 and root directory

Post by Casm »

In the FAT12 and FAT16 file systems the root directory is allocated a fixed number of sectors following the file allocation tables, and it is not itself considered a file. Therefore it doesn't appear in the FAT.

If I remember rightly, 1.44mb floppies have a maximum of 224 root directory entries at 32 bytes per entry.
HugeCode
Member
Member
Posts: 112
Joined: Mon Dec 17, 2012 9:12 am

Re: FAT12 and root directory

Post by HugeCode »

casm: Is there some special reson for number 224?
User avatar
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

Re: FAT12 and root directory

Post by Yoda »

Casm, you may create floppy with any root dir entries number round to sector size.
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
Casm
Member
Member
Posts: 221
Joined: Sun Oct 17, 2010 2:21 pm
Location: United Kingdom

Re: FAT12 and root directory

Post by Casm »

HugeCode wrote:casm: Is there some special reson for number 224?
I was only quoting from memory, and a quick calculation suggests it might have been 288. That would give you two FAT12s, and a boot sector, on head 0 of track 0, with a 288 entry root directory occupying the whole of head 1 on track 0.

The above scheme would leave 96 out of 2880 sectors unaddressable. If that bothered you, you would have to have the second FAT overflowing onto head 1 of the floppy, leaving you with a slightly smaller root directory.
HugeCode
Member
Member
Posts: 112
Joined: Mon Dec 17, 2012 9:12 am

Re: FAT12 and root directory

Post by HugeCode »

Ok. Thank you.
Post Reply