Expand description
Sparse-aware fast copy with reflink fallback.
Two-tier strategy that preserves sparseness on every supported platform:
-
Reflink (zero-copy COW). Tries
clonefile(2)on macOS andioctl(FICLONE)on Linux viareflink-copy. Succeeds instantly on APFS, btrfs, XFS (withreflink=1), and bcachefs. ReturnsEOPNOTSUPP(or similar) on ext4 and other non-COW filesystems. -
Sparse-aware copy. Walks the source’s allocation map with POSIX
SEEK_DATA/SEEK_HOLEor WindowsFSCTL_QUERY_ALLOCATED_RANGES, then copies only allocated extents. The destination is extended to the source size up front so unallocated regions stay holes.
Never falls back to a naive byte-for-byte copy — that would densify a 4 GiB sparse file with a few MB of data into 4 GiB on disk, which is the exact failure mode this module exists to prevent.
See planning/microsandbox/implementation/snapshots.md for the
full design and tradeoffs.
Enums§
- Fast
Copy Strategy - Strategy that successfully created a destination in
fast_copy_with_strategy.
Functions§
- fast_
copy - Copy
srctodst, preserving sparseness. Returns the apparent size of the destination in bytes. - fast_
copy_ with_ strategy - Copy using the fastest safe strategy and report which strategy resolved.
- reflink
- Require a filesystem copy-on-write clone with no fallback.
- sparse_
copy - Sparse-aware copy via platform allocation metadata and per-extent copy.