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.
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. - 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 - 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§
- Error
- Identity
- The system image (Android) a device needs. iOS’s runtime and device type come in its own variant.
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.
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). - 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: relative,/-separated, with no empty,.or..component, no backslash and no NUL.