why maximum number of files is 4,077 in fat12?

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator:Moderators

Post Reply
brainbarshan
Posts:9
Joined:Fri Feb 19, 2010 12:58 pm
why maximum number of files is 4,077 in fat12?

Post by brainbarshan » Thu May 06, 2010 7:15 am

In chapter 6 : Bootloaders 4
under the topic File system theory
Because of the limited cluster size, The maximum number of files possible is 4,077
why is this so? can you explain?

Neutron
Posts:4
Joined:Tue May 19, 2009 2:20 pm
Location:Finland

Re: why maximum number of files is 4,077 in fat12?

Post by Neutron » Thu May 06, 2010 11:53 am

It actually has nothing to do with cluster sizes but the maximum number of clusters. Microsoft has specified that any FAT12 filesystem must have less than 4085 clusters. Similarly the FAT16 system must have less than 65525 clusters (the FAT filesystem type is actually detected by these numbers and not by any other field present in the Bios Parameter Block or extended FAT infofields in the boot sector)

The maximum number of files on FAT12 is less than 4085 because every file whose size > 0 will require at least one cluster. If your files are bigger than one cluster (typically 512 B in floppies), the maximum number of files is (naturally) even less. Also, every directory requires at least one cluster too.

As a historical side note, when the original FAT12 didn't have directory support, maximum number of files was 224 (field 'root entry count' in bios parameter block) and still is for the root directory.

Andyhhp
Moderator
Posts:387
Joined:Tue Oct 23, 2007 10:05 am
Location:127.0.0.1
Contact:

Re: why maximum number of files is 4,077 in fat12?

Post by Andyhhp » Thu May 06, 2010 2:14 pm

The reason that the total number of files is 4077 is that you have 12 bits to index clusters.

2^12 is 4096 but certain values are reserved (for example, 0xFFF means last cluster in file, 0xFF0 means bad cluster), leaving 4077 usable indicies.
As a historical side note, when the original FAT12 didn't have directory support, maximum number of files was 224 (field 'root entry count' in bios parameter block) and still is for the root directory.
Not quite. 224 is the default size for the root directory but it can be exanded if you need to fit more entries in. The only requirement is that:

root_dir_size*32 % bytes_per_sector = 0

or in other words, the total size of the root directory is an integer multiple of sectors

~Andrew
Image

brainbarshan
Posts:9
Joined:Fri Feb 19, 2010 12:58 pm

Re: why maximum number of files is 4,077 in fat12?

Post by brainbarshan » Thu May 06, 2010 9:05 pm

thank you.

BoydBun
Posts:2
Joined:Wed Aug 16, 2017 12:55 pm

Re: why maximum number of files is 4,077 in fat12?

Post by BoydBun » Wed Aug 23, 2017 7:34 am

How do we increase the max number of files?

Post Reply