Skip to main content

Crate simee_bundle

Crate simee_bundle 

Source
Expand description

Portable device bundles (#170).

A bundle describes a device with no host path in it: a Manifest (manifest.json) and content-addressed chunks (chunks/<aa>/<blake3>, each compressed alone with LZ4). Disk images are cut at fixed CHUNK_SIZE boundaries; all-zero chunks and holes are recorded as extents and never stored. It is a directory, or the same as one plain uncompressed tar with the manifest first, so an import streams it and checks each chunk as it arrives.

Platforms fill in the manifest’s identity and say what goes where (emu-avd for AVDs); this crate packs, unpacks and verifies: every chunk against its hash, every disk and file against its whole hash, every path (relative, no ..), and the format’s major version.

Modules§

ios
iOS simulators as portable bundles (#421): a shut-down simulator’s data directory (its settings, its installed apps and their containers) less what the system regenerates (left_out), as data/ in the bundle with its directories, symlinks and modes in the manifest’s tree; and its device type and runtime by identifier and build, which an import finds on the receiving host or refuses.

Structs§

AndroidImage
An Android system image by content: source.properties’s API level, tag, ABI and revision, the BLAKE3 of the files that boot it, and build.prop’s fingerprint.
Base
The disk a delta is against, checked by its hash before use (#171).
Captures
ChunkStore
A bundle directory’s chunks.
Contents
What goes into a bundle: disk images read from host files, and small files given whole, each at its path in the bundle.
Device
Disk
A disk image: its chunks, in order, covering size bytes.
Entry
One directory, file or symlink of a file tree, at its path in the bundle.
Extent
len bytes of a disk at offset: one stored chunk (hash), zeros (all-zero data and holes, never stored; an import leaves a hole), or the same range of the base (from_base, #171).
Extracted
What Reader::extract wrote.
File
A small file (config.ini): its chunks, each Manifest::chunk_size but the last.
GuestIdentity
IosSimulator
An iOS simulator’s device type and runtime, by the service’s identifiers. An import needs the same runtime build; the version and name only say what to install when it is missing.
Manifest
Options
How to write a bundle.
Reader
An opened bundle: its manifest, read and validated, and the chunks still to read.
Secret
Summary
What an export wrote, in the terms #169 measures: the disks’ logical and allocated sizes against the bundle’s.
TarReader
Reads an archive’s regular files in order, each into memory (at most max bytes: a bundle’s entries are the manifest and chunks). Directory entries are skipped; any other kind (links, devices, extended headers) is refused.
TarWriter
Writes regular-file entries, then the two zero blocks that end an archive.

Enums§

EntryKind
What a tree entry is.
Error
Identity
What a device needs on the receiving host: the system image (Android), or the runtime and device type (iOS).

Constants§

CHUNK_SIZE
Disk images are cut into chunks of this size (the last one shorter). Fixed boundaries suit disks, written in place: an offset never shifts, so content-defined chunking would find the same boundaries, and a small chunk limits what one dirty block drags into a bundle.
COLD_BOOT
What resume means in format 1: the receiver boots the disks cold (no RAM state).
COMPRESSION
The only chunk compression in format 1: each chunk is one LZ4 block (no frame or size header; the manifest gives each chunk’s length).
FORMAT
The format’s major version. A reader refuses any other: a new major may change what an existing field means. Additions that old readers can ignore keep the major.
MANIFEST
A bundle directory’s manifest file, and a bundle archive’s first entry.
MAX_MANIFEST
The largest manifest a reader accepts: a 64 GiB disk in 1 MiB chunks is ~7 MB of JSON.
MAX_SIZE
The most bytes (logical, holes included) a bundle’s disks and files may add up to: an import reads every byte back to check its hash, so a sparse disk of a petabyte would take days.
MAX_TARGET
The longest symlink target macOS makes: symlink refuses a longer one (ENAMETOOLONG).
OPEN_FILES
The most of an extract’s files open at once. An iOS data directory is thousands of files, and a process launchd starts may have 256 descriptors.

Functions§

chunk_name
The name a chunk has in a bundle: chunks/<first two hex digits>/<hash>.
compress
data as one LZ4 block (no size header: the manifest gives each chunk’s length).
decompress_verified
Decompresses chunk hash into at most max bytes (a block that would decompress past it is refused) and checks it is what its name says.
export
Writes contents as a bundle at to (a .tar archive, else a new directory), with manifest’s description and identity; its chunk fields, disks and files are filled in here. Reads every disk twice: once to cut and hash it, once to compress the distinct chunks (each checked against the first pass, so a disk that changes in between fails the export).
hash
The BLAKE3 of data, as the manifest writes it.
hash_file
The BLAKE3 of the file at path, read in 1 MiB pieces (a 4.4 GB system image: ~3 s).
ignorable
Whether c is a format code point (Unicode category Cf) or a default-ignorable one: what a volume may skip when it compares names (HFS+ skips some, APFS none) and a renderer draws as nothing. A simulator’s data has no use for one in a name, and a name that holds one can fold like another that the volume keeps apart, so a bundle path or link target with one is refused.
is_archive
Whether to names the single-file form (.tar); anything else is a directory.
is_hash
Whether h is a BLAKE3 hash as the manifest writes it: 64 lowercase hex digits.
max_compressed
The most a chunk of len bytes takes compressed (LZ4’s bound for data that doesn’t compress).
parse_chunk_name
The hash a bundle entry named like chunk_name holds, if it is named so.
read_regular
Reads bundle file path whole: a regular file (not a symlink, a device or a FIFO) of at most limit bytes, so a directory bundle can’t make a reader follow a link to /dev/zero.
safe_path
Whether path is safe to join to a destination directory: at most MAX_TARGET bytes, relative, /-separated, with no empty, . or .. component, no backslash, no NUL and no ignorable code point.
safe_target
Whether target is a symlink target a bundle may hold: not empty, at most MAX_TARGET bytes, with no NUL and no ignorable code point.

Type Aliases§

Result