Hello again !
I finished implementing a read/write FAT32 driver, and it was working fine (did not do delete or mkdir but everything else was good) until i started to read files that are more than 512 bytes in size. The FAT says that the files are 1 clusters (= the first cluster of the file points to 0x0, not EOC but whatever...), and the BPB tells me that sectors_per_cluster = 1. I formatted the partition with mkfs.vfat -F 32, and after a lots of checks and considerations, i read that on the wiki :
"Several developers also make the error of passing -F to mkdosfs in an attempt to choose a FAT size, which often has the effect of creating a corrupt filesystem since the result doesn't follow the official rule for FAT sizes anymore." (http://wiki.osdev.org/FAT#Creating_a_fr ... filesystem)
I was wondering : What does "a corrupt filesystem" means ? Could it be the source of my problems ? And then how does linux to deal with this filesystem (because editing files, even files that are more than 512 bytes, is working fine on it) ? Finally, how should i format the partition without using mkfs.vfat -F 32 ?
Thanks for reading ! (and sorry if my english is bad, i'm french)
(EDIT: i also have problems to read directory that have lots of entries, and i think again that it could be because the dir is taking more than 1 sector or cluster, but the FAT tells me the opposite)
About FAT32 and mkfs.vfat
-
- Member
- Posts: 5586
- Joined: Mon Mar 25, 2013 7:01 pm
Re: About FAT32 and mkfs.vfat
A value of 0 means an empty cluster. You're not reading the FAT correctly.valou3433 wrote:The FAT says that the files are 1 clusters (= the first cluster of the file points to 0x0, not EOC but whatever...),
There's a minimum size for FAT32. Using the -F option may force mkfs.vfat to create a FAT32 filesystem that's too small, and it won't be usable.valou3433 wrote:I was wondering : What does "a corrupt filesystem" means ?
Only if you're using it to create a FAT32 filesystem that's too small.valou3433 wrote:Could it be the source of my problems ?
Linux might have a built-in workaround to detect an invalid filesystem and work with it anyway. Or, your partition might be big enough that FAT32 is valid.valou3433 wrote:And then how does linux to deal with this filesystem (because editing files, even files that are more than 512 bytes, is working fine on it) ?
Typically, you should let mkfs.vfat guess the correct type of filesystem (FAT12, FAT16, or FAT32). However, if your partition is bigger than approximately 32MB, you may use the -F option to override the default. You'll receive a warning from mkfs.vfat if the result is a corrupt filesystem.valou3433 wrote:Finally, how should i format the partition without using mkfs.vfat -F 32 ?
Same as with files, you're not reading the FAT correctly.valou3433 wrote:(EDIT: i also have problems to read directory that have lots of entries, and i think again that it could be because the dir is taking more than 1 sector or cluster, but the FAT tells me the opposite)