OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 6:17 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: About FAT32 and mkfs.vfat
PostPosted: Wed Sep 13, 2017 1:47 pm 
Offline
Member
Member

Joined: Sun Aug 20, 2017 10:59 am
Posts: 43
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)


Top
 Profile  
 
 Post subject: Re: About FAT32 and mkfs.vfat
PostPosted: Sun Sep 17, 2017 7:35 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
valou3433 wrote:
The FAT says that the files are 1 clusters (= the first cluster of the file points to 0x0, not EOC but whatever...),

A value of 0 means an empty cluster. You're not reading the FAT correctly.

valou3433 wrote:
I was wondering : What does "a corrupt filesystem" means ?

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:
Could it be the source of my problems ?

Only if you're using it to create a FAT32 filesystem that's too small.

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) ?

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:
Finally, how should i format the partition without using mkfs.vfat -F 32 ?

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:
(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)

Same as with files, you're not reading the FAT correctly.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: SemrushBot [Bot] and 62 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group