[En-Nut-Discussion] number of files in a directory (FAT32)

PragmaLab info at pragmalab.nl
Wed Oct 22 12:01:12 CEST 2008


Hello all,

Using FAT32, the number of files in the rootdirectory should not be
restricted, like it is when using FAT16. Still we were not able to store
more then 512 files in the rootdir of our SD-cards (FAT32 formatted). To
make a long (debug)story short: the variables 'pos' and 'npos' in the
function 'PhatDirEntryAlloc()' in 'phatdir.c' should be unsigned longs, not
ints. Using ints, the maximum position that can be reached is 32.768.
Knowing that each file takes at least 2 dir-entries (long filename support)
and 1 dir-entry takes up 32 bytes, you can store 512 files
(512x2x32=32.768), before your location pointer goes cyclic.

Now the limit to the number of files in one directory is:  #define
PHAT_MAXDIRENT   65536 (for FAT32 also for the root)

I'm also making modifications in the same routine, to avoid that every file
takes at least 2 entries, even if the filename is in the 8.3 format. A bit
waste of time and space and easy to avoid.

I'll send my files to Ole,together with the other modifications.

I wonder if any other developer run into this 512 limit issue with FAT32?

Best regards,

Rob
 




More information about the En-Nut-Discussion mailing list