Open Source › LamBoot filesystem crates › lambutter

lambutter

Read-only btrfs on SINGLE, DUP and RAID1 profiles, with subvolumes and zstd, zlib and LZO.

Reads btrfs | v0.5.0 | MIT OR Apache-2.0 | Rust 1.87+ | no_std | 2 required dependencies
OVERVIEW

What lambutter is for

lambutter is a pure-Rust, allocation-aware, read-only btrfs reader for code that can't link std: UEFI applications, microcontrollers, bare-metal kernels and recovery tools. It's the btrfs counterpart to ext4-view, and covers what /boot needs on stock openSUSE Tumbleweed and Leap, Fedora Workstation, CachyOS and Garuda under Secure Boot.

It's linked into LamBoot as its native btrfs backend and boots openSUSE Tumbleweed end to end under UEFI firmware. The crate can't change a btrfs volume.

Basis: Implemented from the btrfs on-disk format specification, independent of any other btrfs crate.

INSTALL

Add it to your crate

# Cargo.toml
[dependencies]
lambutter = { version = "0.5", features = ["zstd", "zlib", "lzo"] }

Or cargo add lambutter. On Debian unstable or testing, the packaged crate is librust-lambutter-dev (rust-lambutter).

Usage

use lambutter::{Btrfs, Path};

let mut fs = Btrfs::open(reader, device_size_bytes)?;
let kernel = fs.read_file(Path::new(b"/vmlinuz")?)?;      // whole file
let inode = fs.resolve(Path::new(b"/vmlinuz")?)?;          // or stream it
let n = fs.read_file_at(&inode, 0, &mut buf)?;

The full API, with every type and error, is on docs.rs.

CAPABILITIES

What it reads

FeatureStatus
Regular files, symlinks and directory listingsRead
SINGLE, DUP, RAID1, RAID1C3 and RAID1C4 profilesRead
SubvolumesThe default one, or one chosen by id or path (as subvolid= and subvol=); nested subvolumes crossed as a Linux mount does
A filesystem across several devicesRead from the device given; a chunk with no copy there is refused
zstd, zlib and LZO extentsDecoded, each behind a feature
Files and directories spanning B-tree leavesRead

What it refuses

  • RAID0, RAID10, RAID5 and RAID6
  • ZONED, RAID_STRIPE_TREE and REMAP_TREE
  • fscrypt markers and any unknown incompat feature

Each is a typed error. Data-block checksum verification and snapshot enumeration aren't implemented.

DEPENDENCIES

What it depends on, and what it doesn't

Avoids: The GPL btrfs UEFI driver, std and any async runtime. Codecs are opt-in, so a build without them depends on bitflags and crc alone.

Always

  • bitflags 2.6: On-disk flag sets
  • crc 3.2: Metadata checksums

Only with a feature

Cargo features

FeatureDefaultWhat it adds
zstdYeszstd extents through ruzstd (the Tumbleweed and Fedora default)
zlibNozlib extents through miniz_oxide (the legacy default)
lzoNoLZO extents through lzokay
stdNoAn std::error::Error impl for Error
TESTING

How it's tested

55 unit tests; 15 oracle tests on kernel-written images (each codec, DUP metadata, NO_HOLES, leaf-spanning extents and directories, subvolumes and snapshots, RAID1 across two devices); 5 cargo-fuzz harnesses; live reads of a Snapper-managed Tumbleweed partition, byte-identical to the kernel.

WHY IT EXISTS

No GPL drivers in the boot path

Until 2026 LamBoot read most Linux filesystems through about a dozen prebuilt UEFI filesystem driver binaries from the EfiFs (GPL-3.0) and rEFInd (GPL-2.0) projects. Three things ruled them out at once. Debian's free-software guidelines and Fedora's packaging rules reject a prebuilt .efi blob that isn't built from source in the archive. Microsoft doesn't sign GPLv3 code for Secure Boot, and loading a separate UEFI driver binary removes the ShimLock protocol that shim 15.8 relies on. And GPL binaries sit badly beside a permissively licensed loader. These crates replace those drivers with readers compiled into LamBoot itself. The whole family · LamBoot