bux-e2fs
Ext4 filesystem image creation via libext2fs — static FFI bindings and safe Rust API.
Note: This crate statically links
libext2fsfrom e2fsprogs. For most use cases, prefer the high-levelbuxcrate.
How it works
Pre-generated bindgen bindings are committed in src/bindings.rs so end
users do not need libclang installed. At build time the build script:
- Downloads pre-built static libraries from GitHub Releases (or uses
BUX_E2FS_DIR). - Statically links
libext2fs,libcom_err,libe2p,libuuid, andlibcreate_inode.
Regenerating bindings
To update bindings from the pinned e2fsprogs headers (requires libclang, Linux/macOS only):
BUX_UPDATE_BINDINGS=1
Safe API
use Ext4Builder;
use Path;
// Create an ext4 image from a directory (like mke2fs -d)
new
.block_size
.reserved_ratio
.create_from_dir?;
// Inject a file into an existing image (like debugfs write)
inject_file?;
Environment variables
| Variable | Description |
|---|---|
BUX_E2FS_DIR |
Path to a local directory containing pre-built static libraries. Skips downloading. |
BUX_E2FS_VERSION |
Override the e2fsprogs release version (default: crate version). |
BUX_UPDATE_BINDINGS |
Copy generated bindings back to src/bindings.rs (with regenerate feature). |
Supported platforms
| Target | Status |
|---|---|
aarch64-apple-darwin |
✅ |
x86_64-unknown-linux-gnu |
✅ |
aarch64-unknown-linux-gnu |
✅ |
License
Licensed under either of Apache License, Version 2.0 or MIT License at your option.