Expand description
Filesystem allocation-map scanning.
Answers one question — “which byte ranges of this file are actually allocated?” — with the same (offset, length) shape on every supported platform: SEEK_DATA/SEEK_HOLE on
unix, FSCTL_QUERY_ALLOCATED_RANGES on Windows. Consumers (sparse snapshot export, integrity verification, capture) never branch on OS; only the scan backend does.
Also home to the hole-restoration primitives that the scan’s consumers need on platforms where “just don’t write the hole” is not enough: NTFS only keeps unwritten ranges
unallocated on files flagged sparse (mark_sparse), and APFS densifies files on any write, so holes must be punched explicitly (punch_hole_aligned).
Structs§
- Extent
Map - Allocation map of a file: logical length plus sorted, non-overlapping, byte-granular data extents.
Functions§
- mark_
sparse - Unix files are hole-capable without any flag; kept so callers can mark destinations unconditionally.
- punch_
hole_ aligned - Hole punching is unnecessary outside macOS: on ext4/XFS/btrfs (and on NTFS files flagged via
mark_sparse) ranges that are never written stay unallocated.