TFAT Programming Considerations
The interfaces exposed by the transaction-safe FAT (TFAT) file system are equivalent to those associated with the FAT file system. The following enhancements are provided by TFAT to ensure transaction safety:
TFAT atomic sector writes
FAT volume operations
Operations from other components
TFAT is an extension of the FAT file system. TFAT requires a hardware-specific driver designed for the type of media on which the volume resides. The driver abstracts the media storage and provides atomic block operations.
For flash storage, the block driver must provide a verification of atomicity on the block level to provide transaction-safety for data on a disk.
TFAT requires the underlying block structure to support atomic sector writes. The flash driver and most CF card hardware provide atomic sector write operations. If the block driver is not atomic, TFAT cannot guarantee transaction-safety.
Use the following settings for hard drives and other media with non-atomic sector writes:
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\HDProfile\FATFS] "TfatMarkAlways"=dword:1 "NonatomicSector"=dword:1 "DisableAutoScan"=dword:1
Use the following settings for storage media with atomic sector writes:
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\<Profile Name>\FATFS] "DisableAutoScan"=dword:1
Most TFAT operations are triggered by the FILE_FLAG_WRITE_THROUGH file attribute, as follows:
When the file attribute FILE_FLAG_WRITE_THROUGH is set to TRUE for any file, each WriteFile function call is committed to the disk in an individual transaction. This means that TFAT has written data to both the volume and the FAT tables. If this attribute is not set, the data written by the WriteFile function is not committed until the CloseHandle or the FlushFileBuffers function is called.
When CreateFile creates a memory-mapped file, it automatically sets the FILE_FLAG_WRITE_THROUGH value to TRUE.
- All databases and memory-mapped files must commit every WriteFile operation to the FAT atomically and set the FILE_FLAG_WRITE_THROUGH value to TRUE.