Open piranna opened 9 years ago
Interesting, thanks for the tip! I've created a cross-reference from the issue #5 (right now this library only every writes to the first table at all :crying_cat_face:) as transaction safety would be a great bonus feature for "doing the right thing" with the multiple tables.
To summarize/paraphrase the linked article: TFAT works by using the second FAT as the main "workspace" and then directly copying that to the first table at the end of a transaction.
So for this library, we'd basically do what we're doing now except point it at the second FAT instead. Add some logic for tracking "changed" blocks of that second FAT, and copying those to the first FAT at the right time.
So for this library, we'd basically do what we're doing now except point it at the second FAT instead. Add some logic for tracking "changed" blocks of that second FAT, and copying those to the first FAT at the right time.
Yes. Seems that there are some subtle indicators that could be the reason why desktop Windows doesn't implement support for TFAT, though:
If the number of FATs in the BPB is not set to 2, the second cluster entry in the first FAT (cluster 1) may also reflect the status of a TFAT volume for TFAT-aware operating systems. If the cluster 1 entry in that FAT holds the value 0, this may indicate that the second FAT represents the last known valid transaction state and should be copied over the first FAT, whereas the first FAT should be copied over the second FAT if all bits are set.
(Take a look at BIOS Parameter Block section, too.)
But seems mostly you can use your proposed algorythm. Only thing, if you need to modify the FAT tables I would do it in a copy-on-write fashion to not modify current data and be sure that the final copy of the second FAT to the first one is the only problematic operation, making it totally safe.
Transactional-safe FAT filesystem is a driver-level modification of FAT that implements transactions on a FAT filesystem, increasing stability and reliability of data. The API and the data structures are the same, only diference is the usage of the second FAT as a workbench while there are operations, and copy them on the main FAT when they have finished.