Skip to content

File Format ​

A packed onelf file is up to five concatenated sections:

┌────────────────────────────────────┐  offset 0
│ Runtime (static musl ELF)          │
│  slim, or the larger update build  │
├────────────────────────────────────┤
│ Manifest (zstd-compressed)         │
│  - header (114 bytes)              │
│  - entrypoints                     │
│  - file/dir/symlink entries        │
│  - lib_dir_offsets                 │
│  - string_table                    │
├────────────────────────────────────┤
│ Payload                            │
│  blocks, zstd or raw               │
├────────────────────────────────────┤
│ Dictionary (optional, raw)         │
├────────────────────────────────────┤
│ Footer (76 bytes, fixed)           │  last 76 bytes of file
│  - magic, offsets, checksums       │
└────────────────────────────────────┘

When executed, the runtime reads its own tail to discover where the manifest, payload, and dictionary begin.

76 bytes at the end of the file. All integers little-endian.

OffsetSizeFieldDescription
08magic"ONELF\0\x01\x00"
82format_version2 (format 1 files have 1)
102flagsbit 0 HAS_DICT, bit 1 MEMFD_HINT, bit 2 reserved (never set), bit 3 STORED, bit 4 EXTERNAL_UPDATER, bit 5 NO_HOST_LIB_DIRS, bit 6 HOST_LIBS_ALWAYS, bit 7 CACHE_REQUESTED, bit 8 CACHE_PREFERRED, bit 9 STIPPLE_PAYLOAD; other bits reserved
128manifest_offsetAbsolute file offset of the compressed manifest
208manifest_compressedCompressed manifest size in bytes
288manifest_originalUncompressed manifest size
368payload_offsetAbsolute offset of payload start
448payload_sizePayload total size
528dict_offsetDictionary offset (0 if absent)
604dict_sizeDictionary size (0 if absent)
644manifest_checksumXXH32 of uncompressed manifest, see below
688end_magic"FLENONE\0"

Manifest ​

Compressed with zstd. After decompression:

┌────────────────┐
│ Header (114 B) │
├────────────────┤
│ Entrypoints    │  14 bytes each * entrypoint_count
├────────────────┤
│ Entries        │  variable-size records * entry_count
├────────────────┤
│ lib_dir_offsets│  4 bytes each * lib_dir_count
├────────────────┤
│ string_table   │  null-terminated strings
└────────────────┘

Header (114 bytes in version 3) ​

OffsetSizeField
02manifest_version (currently 3)
24entry_count
64string_table_size
102entrypoint_count
122default_entrypoint (index into entrypoints)
142lib_dir_count
162name_offset (into string_table)
1832package_id (BLAKE3 of the serialized manifest with this field and footer_hash zeroed)
5032prefix_hash (BLAKE3 over file bytes [0, manifest_offset); zeros in version 1/2)
8232footer_hash (BLAKE3 over the footer, see below; zeros in version 1/2)

Version 1 and 2 headers end at 50 bytes and carry no structure hashes.

Entrypoint (14 bytes each) ​

OffsetSizeField
04name (string_table offset)
44target_entry (index into entries)
84args (string_table offset, 0x1F-separated)
121working_dir (enum)
131flags (bit 0: MEMFD_ELIGIBLE)

Entry (variable) ​

Represents a file, directory, or symlink. Fields are serialized in this order (65-byte header, then the blocks):

text
kind:           u8        (0=dir, 1=file, 2=symlink)
parent:         u32       (index into entries, 0xFFFFFFFF for top-level)
name:           u32       (string_table offset)
mode:           u32       (unix mode bits)
mtime_secs:     u64
mtime_nsec:     u32
content_hash:   [u8; 32]  (BLAKE3 of concatenated block contents; zero for non-files)
num_blocks:     u32       (count of block refs that follow; derived from blocks.len())
symlink_target: u32       (string_table offset; 0 unless kind == symlink)
blocks:         [Block; num_blocks]  (file content block refs; empty for non-files)

Each Block is 56 bytes:

payload_offset:  u64
compressed_size: u64
original_size:   u64
content_hash:    [u8; 32]   (BLAKE3 of this block's decompressed bytes)

content_hash arrived with manifest version 2. It lets a reader verify a single block without reassembling the entry, which is what allows a large file to be served a byte at a time rather than buffered whole. In a version 1 manifest the field is absent and a Block is 24 bytes, leaving the whole-entry hash as the only check.

Payload ​

Contiguous sequence of blocks. Block boundaries are defined entirely by the blocks arrays in the manifest. Entries whose whole-file BLAKE3 matches share one set of blocks: the packer keeps a map from content hash to block list, and a repeated file points at the first copy rather than writing its own. Identical content therefore costs once per package, and pack reports the total under Dedup: when it saved anything. Two entries still get independent block lists in the manifest when their content differs, even if individual blocks were to match.

Block size defaults to 64 KiB uncompressed and can be set from 4 KiB to 32 MiB with --block-size or [compression] block-size. Each block is compressed independently, which lets the runtime decompress them lazily as the entrypoint reads files.

If a dictionary is present (dict_size > 0), each block is decompressed against that dictionary. The packer trains it only with --dict, at up to 1 MiB.

When the STORED footer flag is set (onelf pack --no-compress or [compression] store = true), blocks are written raw with no zstd: compressed_size == original_size for every block, and the runtime reads the bytes verbatim with zero decompression. STORED and HAS_DICT are mutually exclusive. The manifest stays zstd-compressed either way.

stipplefs payload ​

When the STIPPLE_PAYLOAD footer flag is set (onelf pack --payload stipple or [compression] payload = "stipple"), the payload region is a stipplefs image instead of separately compressed blocks. The image deduplicates content-defined chunks across files, compresses many files per block, and runs an x86 branch filter over executable code, so it comes out smaller than independently compressed blocks.

The manifest is unchanged in every other respect: every file is listed with its blocks and hashes. A block then describes a slice of its file rather than a region of the payload:

payload_offset:  u64        (where the slice starts within the file)
compressed_size: u64        (the file's inode in the stipplefs image)
original_size:   u64        (the slice's length, 64 KiB except the last)
content_hash:    [u8; 32]   (BLAKE3 of the slice)

A reader opens the image at payload_offset for payload_size bytes and reads each slice through it. The slice's BLAKE3 is checked exactly as a decompressed block's is, so the manifest remains what a package's integrity rests on, and the image's own XXH3 checksums are a second line. --block-size sets the image's block size, a power of two up to 64 MiB and 32 MiB unless chosen, while slices stay 64 KiB. A compressed image uses stipplefs variable blocks: each ends where the content says to and --block-size is the largest it may be, so unchanged content keeps its blocks across releases for delta updates. HAS_DICT is never set, and the image carries no dictionary of its own either. A onelf reader that predates the STIPPLE_PAYLOAD flag fails every hash check rather than serving wrong bytes, and a stipplefs reader that predates variable blocks refuses the image when it opens it.

Reading a packed file ​

In pseudocode:

file = open(path)
file.seek(SeekFrom::End(-76))
footer = read 76 bytes, validate magic
file.seek(footer.manifest_offset)
compressed = read footer.manifest_compressed bytes
manifest_bytes = zstd::decompress(compressed)
checksum = version >= 3 ? XXH32(manifest_bytes with footer_hash zeroed)
                         : XXH32(manifest_bytes)
assert checksum == footer.manifest_checksum
manifest = parse(manifest_bytes)

Then the manifest tells you how to read entrypoints, files, etc.

Integrity ​

  • XXH32 over the uncompressed manifest bytes catches accidental corruption of the manifest itself. From footer format 2 / manifest version 3 on, the footer_hash header field is zeroed for this checksum, because that field is pinned by the footer hash instead.
  • BLAKE3 over each file's concatenated content bytes is stored in the entry. onelf verify recomputes and compares.
  • BLAKE3 over each block's decompressed bytes is stored alongside the block from manifest version 2 onward. This is what a random-access reader checks, so a single byte can be served and verified without reassembling the file it came from.
  • BLAKE3 over the runtime prefix, prefix_hash in the manifest from version 3 on, covers the executable body in front of the manifest, which nothing else hashed before.
  • BLAKE3 over the footer, footer_hash in the manifest, covers the footer itself with four layout fields zeroed: manifest_compressed, manifest_original, payload_offset and dict_offset. Those four cannot take part in the chain, because the packer learns them only after compressing the manifest, and the manifest can only be compressed after the footer hash exists. Their honesty is enforced indirectly: a bogus region is caught by the bounds checks or by the hashes of what the region is supposed to hold.
  • The package_id (BLAKE3 of the manifest) uniquely identifies the package and drives cache-mode directory names.

The three hashes chain: the manifest checksum covers the manifest, and the manifest carries both prefix_hash and footer_hash, so replacing the executable body or rewriting the footer shows up in onelf verify. This is an integrity check, not authentication. No hash in the chain is keyed, so anyone who rewrites the file can recompute all of them and produce a consistent package. Only a detached signature over the file shows who produced it.

Runtime metadata records ​

Two package files carry validated records the runtime reads before it launches anything. Both ride in the payload as ordinary entries, so the container, the manifest, and the 14-byte entrypoint records are unchanged, and an older inspection tool can still read and extract a package carrying them; it just does not interpret them.

  • .onelf/entrypoint-sets, magic OSET: the canonical pin table of the recipe's declared dependency sets, each name with its full 32-byte BLAKE3, followed by one selection record per manifest entrypoint naming the sets that entrypoint selects. Absence is the legacy default: every declared set. Presence is exact: the launch fetches, mounts and extracts only what its entrypoint's record names, and a record that is truncated, of an unsupported version, inconsistent with the manifest's entrypoints or the carried pin table, or otherwise damaged, fails the launch before any acquisition or application execution instead of degrading to a default.
  • .onelf/runtime-rules, magic ORUL: the normalized framework rules a launch applies. Each record names a rule, an optional binding to one declared pin (set name and full BLAKE3), the rule's runtime path groups (kind, first, all or first-per-library-root selection, preserve or replace inheritance, package-root or library-root candidates and variable aliases) and its runtime hook IDs from the closed registry. Absence is the legacy default: the built-in catalog's mappings and every registered hook. Presence is exact: a launch evaluates only the carried groups and runs only the carried hooks. An unbound record applies to every launch. A bound record applies only while its pin is selected, and adds the pin's prepared subtree, .onelf-prepared/<set>/<pin hex>, to the same rule's groups, searched after the application and before the raw set roots. Every binding must name a pin the selection table, or without one the set table, declares. A build carries the record only when its rules differ from the built-ins (a project-local runtime rule or a disabled built-in mapping) or it prepared resources from a set.

Both formats share a bounded binary grammar: a 16-byte header (magic, little-endian u16 version 1, u16 reserved flags, u32 payload length, u32 aggregate record count), then length-prefixed strings and typed records with fixed-order fields, all little-endian. A file may be at most 1 MiB and may hold at most 4096 aggregate records; identifiers are at most 128 bytes and encoded paths at most 4096. Readers enforce every bound before allocating from an encoded length, and fail cleanly on a violation. Encodings are canonical: tables and references are sorted by name, and every accepted byte string re-encodes byte-for-byte.

Which records a runtime understands is advertised by a capability note in the runtime ELF's own prefix, in the ONELF note vendor namespace: a metadata schema version plus capability bits. Three bits are named. selection-view is the per-entrypoint selection table: a runtime without it cannot scope a launch's set acquisition to the invoked entrypoint. store-import is the HTTPS fetch of pinned GL builds and sets, which only the update-capable runtime carries; a package that pins builds over https:// needs it, while a file:// pin runs on the slim runtime. anchors is descriptor 77 on the package's anchor directory, which a package carrying .onelf/anchors needs. Packaging checks the note of the runtime it is about to embed and refuses the pack when the recipe's records or pins need support the runtime does not advertise, rather than emitting a package whose selections could be ignored. onelf info and --onelf-doctor print the carried records, the requirement, the advertisement and whether the two agree; see Inspecting Packages and Runtime Flags.

Anchor record ​

A library built to open an absolute directory can have that string rewritten in its bundled copy: the first 11 bytes of every string that is the directory's path, or starts with it followed by /, become /dev/fd/77/, and the rest is kept, unless another carried directory or a recipe pair sends the string somewhere else. The string keeps its length, and the key is the kept tail with any leading / removed, so /usr/share/alsa becomes /dev/fd/77/alsa with the key alsa. .onelf/anchors names the bundle directory each key stands for, one KEY<tab>RELATIVE line per anchor, separated by \n, with no trailing newline. The keys are listed in byte order, each once, and no key lies below another one, since a path below a key already resolves through that key's link. A key may span several components. Keys and directories follow the rules of .onelf/paths for a bundle path: relative, normalized, inside the package, and free of control characters. A record holds at most 1024 anchors in at most 256 KiB, and a reader refuses anything else as a whole. Packing also refuses an empty record, and one naming anything but a directory of the package reached without passing through one of its symlinks.

Before the entrypoint runs, the runtime makes a directory of its own in the private runtime directory, links each key in it to the bundle directory, creating the leading components of a multi-component key as plain directories, and leaves descriptor 77 open on it, without close-on-exec, in every mode that runs from a package tree. It also names that directory in ONELF_ANCHOR_DIR. /dev/fd/77 names the process's own descriptor, so another process or user cannot create or replace what an anchored path resolves to, and no namespace is needed. The application's children inherit the descriptor. A descriptor 77 the launch was started with is replaced. A bundled program started without the descriptor reopens it from ONELF_ANCHOR_DIR before its own code runs, while a host program started that way, or any process started with a cleared environment, finds nothing at the anchored paths. A package with anchors never runs from a memfd, which keeps no tree for them to name.

Format compatibility ​

The footer's format_version accepts 1 and 2; writers emit 2. Format 1 means manifest version 1 or 2: no prefix_hash, no footer_hash, and no hash covers the container structure. onelf verify refuses such a file with a clear message instead of printing OK, but it still runs, as it always did.

The manifest version has moved with the footer. Readers accept 1, 2 and 3 and reject anything higher with a clear error, so a package written by an older onelf still runs. Version 2 added the per-block content_hash (24-byte blocks in version 1, 56 bytes from version 2). Version 3 extended the header from 50 to 114 bytes with the two structure hashes. onelf writes a version 3 manifest only behind a format 2 footer.

Footer flags are decoded with from_bits_retain, so a bit a reader does not recognise is kept and ignored rather than treated as corruption. That is what lets a flag be added without invalidating existing packages, and why each newer one is set only for the new behaviour: a package written before they existed reads as "embedded updater, host drivers reachable through the resolver, no cache unless asked", which is what it was built expecting. The two host-library bits encode three policies: bit 5 set is never, bit 6 set is always, and neither is auto. Bit 5 wins when both are set.

Released under the MIT License.