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), asdata/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§
- Android
Image - An Android system image by content:
source.properties’s API level, tag, ABI and revision, the BLAKE3 of the files that boot it, andbuild.prop’s fingerprint. - Base
- The disk a delta is against, checked by its hash before use (#171).
- Captures
- Chunk
Store - 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
sizebytes. - Entry
- One directory, file or symlink of a file tree, at its path in the bundle.
- Extent
lenbytes of a disk atoffset: 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::extractwrote. - File
- A small file (
config.ini): its chunks, eachManifest::chunk_sizebut the last. - Guest
Identity - 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
maxbytes: 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§
- Entry
Kind - 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
resumemeans 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:
symlinkrefuses 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
dataas one LZ4 block (no size header: the manifest gives each chunk’s length).- decompress_
verified - Decompresses chunk
hashinto at mostmaxbytes (a block that would decompress past it is refused) and checks it is what its name says. - export
- Writes
contentsas a bundle atto(a.tararchive, else a new directory), withmanifest’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
cis 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
tonames the single-file form (.tar); anything else is a directory. - is_hash
- Whether
his a BLAKE3 hash as the manifest writes it: 64 lowercase hex digits. - max_
compressed - The most a chunk of
lenbytes takes compressed (LZ4’s bound for data that doesn’t compress). - parse_
chunk_ name - The hash a bundle entry named like
chunk_nameholds, if it is named so. - read_
regular - Reads bundle file
pathwhole: a regular file (not a symlink, a device or a FIFO) of at mostlimitbytes, so a directory bundle can’t make a reader follow a link to/dev/zero. - safe_
path - Whether
pathis safe to join to a destination directory: at mostMAX_TARGETbytes, relative,/-separated, with no empty,.or..component, no backslash, no NUL and noignorablecode point. - safe_
target - Whether
targetis a symlink target a bundle may hold: not empty, at mostMAX_TARGETbytes, with no NUL and noignorablecode point.