fat32

Can cluster chains end with 0 or 1?


In the course of my research into making a formal model for FAT32, I've come across an implementation detail that's making my work really complicated: what values are allowed to occur at the end of a cluster chain?

According to Microsoft's specification, "The list of free clusters in the FAT is nothing more than the list of all clusters that contain the value 0 in their FAT cluster entry.", a corollary of which is that 0 cannot be the value at the end of a clusterchain, only EOC can be there. However, Wikipedia states "Otherwise, if this value occurs in cluster chains (e.g., in directory entries of zero length or deleted files), file system implementations should treat this like an end-of-chain marker." for 0, citing this claim to an obscure German-language book.

So I really wanted to ask folks who work with filesystems whether they consider 0 (and 1) to be valid end-of-clusterchain markers in implementations.

Update: I checked the Linux kernel implementation of FAT32 and the function for counting free clusters seems to count all zeros as free clusters, no more and no less.


Solution

  • A further examination of the Linux FAT32 code showed that clusterchains which end with 0 are considered invalid clusterchains and cause a return value of -EIO.