pub enum Fat {
Fat12(Fat12),
Fat16(Fat16),
Fat32(Fat32),
}Expand description
Allocation-table implementation selected for a mounted FAT volume.
Variants§
Fat12(Fat12)
FAT12 allocation table.
Fat16(Fat16)
FAT16 allocation table.
Fat32(Fat32)
FAT32 allocation table.
Implementations§
Source§impl Fat
impl Fat
Sourcepub fn next_cluster<T: Read + Seek>(
&self,
reader: &mut T,
cluster: usize,
) -> Result<Option<u32>>
pub fn next_cluster<T: Read + Seek>( &self, reader: &mut T, cluster: usize, ) -> Result<Option<u32>>
Returns the next cluster in a chain, or None at end-of-chain.
Sourcepub fn max_cluster(&self) -> u32
pub fn max_cluster(&self) -> u32
Highest valid cluster number on this volume (inclusive). Clusters 0 and 1
are reserved, so the chain-loop ceiling is max_cluster - 1 distinct
clusters; one extra step lets the walker observe the end-of-chain marker
before declaring a loop.
Sourcepub fn walk_chain<T, F>(
&self,
reader: &mut T,
start: u32,
max_steps: u32,
visit: F,
) -> Result<u32>
pub fn walk_chain<T, F>( &self, reader: &mut T, start: u32, max_steps: u32, visit: F, ) -> Result<u32>
Walk a cluster chain starting at start, calling visit for each
cluster (including start) until the chain ends. Returns the last
cluster visited.
Aborts with Error::ClusterLoop if more than max_steps
clusters are walked. The natural upper bound is
Self::max_cluster — any chain longer than that must repeat a
cluster and is therefore corrupt.
Sourcepub fn truncate_chain<T: Read + Write + Seek>(
&self,
rw: &mut T,
cluster: usize,
) -> Result<u32>
pub fn truncate_chain<T: Read + Write + Seek>( &self, rw: &mut T, cluster: usize, ) -> Result<u32>
Truncate a cluster chain after the specified cluster.
The specified cluster becomes the end of chain (marked with end-of-chain marker). All clusters following it are freed.
Returns the number of clusters freed.
Sourcepub fn free_chain<T: Read + Write + Seek>(
&self,
rw: &mut T,
cluster: usize,
) -> Result<u32>
pub fn free_chain<T: Read + Write + Seek>( &self, rw: &mut T, cluster: usize, ) -> Result<u32>
Free a cluster chain starting at start, returns count of freed clusters.
Sourcepub fn mark_bad<T: Read + Write + Seek>(
&self,
rw: &mut T,
cluster: usize,
) -> Result<()>
pub fn mark_bad<T: Read + Write + Seek>( &self, rw: &mut T, cluster: usize, ) -> Result<()>
Mark a cluster as bad in the FAT.
Writes the appropriate bad-cluster marker (0xFF7 / 0xFFF7 / 0x0FFFFFF7) to the FAT entry for the given cluster. This prevents the cluster from being allocated in the future.
Sourcepub fn read_status_flags<T: Read + Seek>(
&self,
reader: &mut T,
) -> Result<(bool, bool)>
pub fn read_status_flags<T: Read + Seek>( &self, reader: &mut T, ) -> Result<(bool, bool)>
Read the FAT-resident status bits from FAT[1].
The FAT spec stores two volume-level status bits in the high bits of the FAT entry for cluster 1:
- “clean shutdown” (set = clean, cleared = dirty)
- “no I/O errors” (set = ok, cleared = errors during last use)
FAT12 has no spare bits in its packed 12-bit entries, so it returns
(false, false)(treat as “clean, no errors”) — matches the spec’s “FAT12 has no status word” reading.
Returns (dirty, io_errors) — both true means trouble.
Sourcepub fn fat_copy_count(&self) -> usize
pub fn fat_copy_count(&self) -> usize
Returns the number of FAT copies on disk (typically 1 or 2).
Sourcepub fn compare_entry<T: Read + Seek>(
&self,
reader: &mut T,
cluster: usize,
) -> Result<bool>
pub fn compare_entry<T: Read + Seek>( &self, reader: &mut T, cluster: usize, ) -> Result<bool>
Compare a FAT entry between the primary (index 0) and backup (index 1) copies.
Returns Ok(true) if both copies match, Ok(false) if they differ.
Returns an error if there is only one FAT copy or on I/O failure.