Open Source › LamBoot filesystem crates › lamxfs

lamxfs

Read-only XFS, v4 and v5, with in-memory log replay after an unclean shutdown.

Reads XFS | v0.1.3 | MIT OR Apache-2.0 | Rust 1.85+ | no_std, forbid(unsafe_code) | 1 required dependency
OVERVIEW

What lamxfs is for

lamxfs lets a bootloader read kernels, initrds and boot configuration straight from an XFS /boot or root partition, the default on RHEL 9, Rocky 9, AlmaLinux 9, Oracle Linux 9, CentOS Stream and Amazon Linux. It does that without a GPL UEFI filesystem driver, without std, and without the Linux kernel.

It's the XFS counterpart to ext4-view and lambutter, with a deliberately matching API, so a consumer's filesystem adapter is one-for-one across the family. Read-only by construction: There's no write path and no BlockWrite trait.

Basis: Clean-room implementation from the public XFS on-disk format.

INSTALL

Add it to your crate

# Cargo.toml
[dependencies]
lamxfs = "0.1"

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

Usage

use lamxfs::{Xfs, Path, BlockRead};

let mut fs = Xfs::open(reader, device_size_bytes)?;   // validates the superblock
let cfg = fs.read_file(Path::new(b"/boot/loader/entries/rocky.conf"))?;
let ino = fs.resolve(Path::new(b"/boot/vmlinuz-6.1.0"))?;
let mut buf = [0u8; 1 << 20];
let n = fs.read_file_at(&ino, 0, &mut buf)?;          // streaming read

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

CAPABILITIES

What it reads

FeatureStatus
XFS v5 (CRC, self-describing metadata)Read, CRC32C verified
XFS v4 (legacy, no CRC)Read
NREXT64 (64-bit extent counts)Read per inode, so a filesystem upgraded with xfs_repair -c nrext64=1 reads correctly
Parent pointers and exchange-range (mkfs.xfs defaults since xfsprogs 6.18)Read
Metadata directory tree (metadir)Read, without a realtime section
Block sizes to 64 KiB, sector sizes to 32 KiBRead
Sparse inodes, ftype entries, meta_uuid, bigtimeRead
ReflinksShared bytes read transparently
Shortform, block, leaf and node directories; inline and extent symlinksRead
A log left dirty by a power cut or crashReplayed in memory as Linux does at mount; nothing is written to the volume

What it refuses

  • A log that can't be replayed (a v4 log, an unfinished bmap or exchange-range change, an unknown log item or feature, a log corrupted before its last records)
  • A realtime device or realtime groups, including zoned
  • An external log, an in-progress mkfs, or an unknown incompat feature
  • ascii-ci filesystems (names hash case-insensitively there) and per-file encryption

Each is a typed error, never a misread. Mounting and unmounting such a filesystem once under Linux replays its log.

DEPENDENCIES

What it depends on, and what it doesn't

Avoids: The GPL XFS UEFI driver and the Linux kernel. Its one dependency is crc.

Always

  • crc 3.2: CRC32C for v5 metadata checksums

Only with a feature

None.

Cargo features

FeatureDefaultWhat it adds
stdNoAn std::error::Error impl for Error. The crate is no_std with alloc either way.
TESTING

How it's tested

Unit tests per parser; oracle tests against real mkfs.xfs images (v5 with and without NREXT64, v4, xfsprogs 7.1 defaults, metadir, 64 KiB blocks, 8 KiB sectors, an upgraded filesystem, a wrapped log), each file checked against its SHA-256; seven images shut down with a dirty log must read back as Linux shows them after replay; cargo-fuzz over open, walk and replay.

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