FreeClusterCount not updated properly
Brought to you by:
flecxie,
lennartyseboodt
The FreeClusterCount member in FileSystem does not get updated as cluster allocation/de-allocation operations occur. Consequently, this is not a good indication of free space. Each cluster allocation/de-allocation should update this variable.
Actually its not supposed to be updated automatically. You have to make a call to the fat_countFreeClusters() function.
I think there is also an environment variable somewhere you can set to have this updated. It's easier to call the aforementioned function once (and only once as its very computationally expensive) at the beggining of your system init (e.g. where you mount the drives).
Knowing the amount of free clusters on a FAT fs is actually always a bit tricky anyway, and updating the FreeClusterCount all the time would be a waste of time. You only need to know this out of interest to the user, if you try to write a file, and there aren't enough clusters available then the fwrite function will fail, and you can deal with the error approriately.
James