https://github.com/suhteevah/ext4-rw
no_std ext4 filesystem with read/write support in Rust
https://github.com/suhteevah/ext4-rw
bare-metal embedded ext4 filesystem no-std operating-system osdev rust
Last synced: 3 days ago
JSON representation
no_std ext4 filesystem with read/write support in Rust
- Host: GitHub
- URL: https://github.com/suhteevah/ext4-rw
- Owner: suhteevah
- License: apache-2.0
- Created: 2026-04-02T16:49:04.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-06-08T08:05:32.000Z (9 days ago)
- Last Synced: 2026-06-08T10:06:50.751Z (9 days ago)
- Topics: bare-metal, embedded, ext4, filesystem, no-std, operating-system, osdev, rust
- Language: Rust
- Size: 62.5 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# ext4-rw
[](https://rust-embedded.github.io/book/)
[](https://crates.io/crates/ext4-rw)
[](LICENSE-MIT)
A `no_std` ext4 filesystem implementation in Rust with full read and write support.
Designed for bare-metal, embedded, and OS development environments where the standard
library is not available. Requires only `alloc`.
## Features
- **Superblock** parsing and serialization with full ext4 field support
- **Block group descriptor** table management (32-bit and 64-bit modes)
- **Inode** reading and writing with extent tree support
- **Extent tree** traversal (leaf and multi-level index nodes)
- **Directory** entry parsing, creation, lookup, and linear iteration
- **Bitmap** allocation for blocks and inodes (single, contiguous runs, free ranges)
- **High-level API**: mount, read files, write files, create directories, list directories
- **`BlockDevice` trait** for pluggable storage backends (NVMe, virtio-blk, RAM disk, etc.)
- **`no_std`** compatible -- only depends on `alloc` and `log`
- **64-bit** block number support (INCOMPAT_64BIT)
## Usage
Add to your `Cargo.toml`:
```toml
[dependencies]
ext4-rw = "0.1"
```
Implement the `BlockDevice` trait for your storage backend:
```rust
use ext4_rw::{Ext4Fs, BlockDevice, Ext4Error};
struct RamDisk {
data: Vec,
}
impl BlockDevice for RamDisk {
fn read_bytes(&self, offset: u64, buf: &mut [u8]) -> Result<(), Ext4Error> {
let start = offset as usize;
let end = start + buf.len();
buf.copy_from_slice(&self.data[start..end]);
Ok(())
}
fn write_bytes(&self, offset: u64, buf: &[u8]) -> Result<(), Ext4Error> {
// For a real implementation, write to your backing store
Ok(())
}
}
// Mount and use the filesystem
let disk = RamDisk { data: load_disk_image() };
let mut fs = Ext4Fs::mount(disk).expect("failed to mount ext4");
// Read a file
let data = fs.read_file(b"/etc/hostname").expect("read failed");
// Write a file
fs.write_file(b"/output.txt", b"Hello from ext4-rw!").expect("write failed");
// Create a directory
fs.mkdir(b"/mydir").expect("mkdir failed");
// List directory contents
let entries = fs.list_dir(b"/").expect("list failed");
for entry in &entries {
println!("{} (inode {})", entry.name_str(), entry.inode);
}
// Persist metadata changes
fs.sync_metadata().expect("sync failed");
```
## Limitations
- **No journaling**: journal replay is not implemented. Mount only clean filesystems.
- **No HTree**: directory lookup is linear scan (fine for small/medium directories).
- **No legacy block map**: only extent-based files are supported (standard for ext4).
- **No checksums**: metadata checksums are not verified or computed.
- **No encryption**: encrypted inodes are not supported.
- **Extent tree splitting**: files larger than 4 extents in the root node are not yet supported for writes.
These are planned for future releases.
## Minimum Supported Rust Version
Rust 1.70 or later.
## License
Licensed under either of
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or )
- MIT License ([LICENSE-MIT](LICENSE-MIT) or )
at your option.
## Contributing
Contributions are welcome! Please open an issue or pull request on
[GitHub](https://github.com/suhteevah/ext4-rw).
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
## Support This Project
If you find this project useful, consider buying me a coffee! Your support helps me keep building and sharing open-source tools.
[](https://www.paypal.me/baal_hosting)
**PayPal:** [baal_hosting@live.com](https://paypal.me/baal_hosting)
Every donation, no matter how small, is greatly appreciated and motivates continued development. Thank you!