TFAT Implementation (Windows CE 5.0)

Send Feedback

The original FAT file system enabled file modification operations to be interrupted before completion. These interruptions resulted in possible data loss and file system corruption. TFAT stabilizes the file system and can handle such interruptions.

TFAT uses two copies of the FAT table to ensure that modifications are not committed until all elements in a transaction have completed successfully. If a transaction fails to complete properly, the disk is set in a consistent state as it was before the transaction began. All transactions in progress will take place synchronously, and operate on the FAT1 table. Upon successful completion of the transaction, the FAT1 table is copied to FAT0.

To modify existing files, TFAT allocates a new cluster for the modified bits and reroutes the FAT chain for a file to include the new cluster. This is to ensure that if the transaction fails to complete successfully, the original copy of the file is left untouched.

To provide transaction-safety mechanisms for data stored on a disk, TFAT maintains two file allocation tables. The following table shows the two file allocation tables.

Table name Table type
FAT0 This is the primary table on TFAT. This table is used to maintain the last known good FAT.
FAT1 This is the active table on TFAT. All write operations occur on this table.

The following sequence of steps summarizes the TFAT file modification process:

  1. An application calls the standard Win32 API.
  2. The write operation triggers TFAT to write a new sector to the disk using block drivers, preserving all of the old data.
  3. File and directory streams as well as used and unused cluster information are updated in the FAT1 table.
  4. TFAT invalidates the boot sector by marking the number of file allocation tables to zero.
  5. The FAT1 table is copied to FAT0.
  6. The boot sector is restored and the file allocation table uses FAT0 as its main table.

With this approach, you can maintain a backup of the most recent good version of the FAT, in case power is lost during either the sector writing process or the FAT updating process.

The TFAT file system is best suited for non-removable media such as NAND and NOR flash memory. Removable media can also use TFAT, but there are potential issues when attempting to use a TFAT removable card on a Microsoft® Windows® desktop OS. Because there is no implementation of TFAT on Windows desktop operating systems, Windows handles the removable media as a FAT file system. If the card is removed during a critical operation, the Windows desktop OS may not correctly recognize the volume. If a directory is created on the removable media using a Windows desktop OS and then used with TFAT in Microsoft Windows CE, operations on files inside that directory may not be transaction-safe. In addition, TFAT directories cannot be deleted using a Windows desktop OS.

See Also

Transaction-Safe FAT File System

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.