Skip to main content

Module repack

Module repack 

Source
Expand description

Repack — copy file trees from one source into a freshly-formatted destination filesystem.

Three kinds of sources, exposed as Source:

  • A host directory (Source::HostDir) — the original fstool create flow, walks a directory tree.
  • A tar archive on disk (Source::TarArchive), with optional compression codec. Compressed archives go through a two-pass stream-index → replay flow; plain .tar falls through to the Image path (the regular tar reader sits on top of a BlockDevice).
  • An existing image (Source::Image) — a raw or qcow2 file, optionally with a :N partition selector. Walks the source FS through AnyFs and copies entries straight through without host-filesystem intermediation.

The two main entry points — populate_ext_from_source and populate_fat32_from_source — take an already-formatted destination filesystem and stream the chosen source’s contents into it. Auto-sizing helpers (ext_build_plan_for_source, fat32_min_bytes_for_source) let callers right-size the destination geometry up-front.

Used by both the fstool repack CLI command and by the spec layer when a TOML source = "..." value points at a tar / image instead of a directory.

Enums§

Source
Where to draw a filesystem’s contents from when building or populating it. See module docs.

Functions§

build_ext_plan_through_trait
Public counterpart of build_ext_plan_inner for the binary crate’s build_ext_plan. Walks the source through the crate::fs::Filesystem trait, no AnyFs match.
ext_build_plan_for_source
Build a BuildPlan sized for the source. Walks the source once and feeds entry counts + byte totals into the plan; the resulting to_format_opts() is ready to drive Ext::format_with.
fat32_min_bytes_for_source
Compute the minimum FAT32 byte capacity needed to fit source. Bumps to the FAT32 cluster-count minimum + rounds up to a 512-byte sector boundary.
open_tar_stream_index
Open the tar source (optionally codec-wrapped) and build a random-access index over it. Shared entry point for the streaming-tar inspector commands.
populate_ext_from_source
Populate dst (a freshly formatted ext{2,3,4}) with the contents of source. The destination is assumed to already exist.
populate_fat32_from_source
Populate dst (a freshly formatted FAT32) with the contents of source. The destination is assumed to already exist.
populate_fs_from_source
Populate any crate::fs::Filesystem from source, dispatching through the trait for every entry create. Works for HFS+, NTFS, F2FS, SquashFS, XFS — whatever implements the trait — though ext/FAT32 callers should prefer populate_ext_from_source / populate_fat32_from_source which preserve xattrs and use the per-FS fast paths.
populate_fs_from_source_dyn
Trait-object form of populate_fs_from_source. Used by code paths (e.g. crate::inspect::AnyFs dispatch helpers) that have a &mut dyn Filesystem rather than a known concrete type.