Advanced settings FAT modification: fix expanding directory

When no more directory entries are available in the existing
cluster(s) of a directory on FAT32, we allocate an
extra cluster.
Make sure to zero out that new cluster, as disk checking utilities
may not stop reading when reaching an end of directory marker but
read the rest of cluster as well.
So there must not be any garbage data from a previously deleted file
in the sector there.

Also add checks to prevent getting in an endless loop on
encoutering circular "next cluster" references.
This commit is contained in:
Floris Bos 2022-11-20 18:44:22 +01:00
parent 2694f3976a
commit a403df4385
3 changed files with 24 additions and 4 deletions

View file

@ -31,6 +31,7 @@ protected:
uint32_t _fat32_firstRootDirCluster, _fat32_currentRootDirCluster;
uint16_t _bytesPerSector, _fat32_fsinfoSector;
QList<uint32_t> _fatStartOffset;
QList<uint32_t> _currentDirClusters;
QList<uint32_t> getClusterChain(uint32_t firstCluster);
void setFAT16(uint16_t cluster, uint16_t value);