4 releases
Uses new Rust 2024
| 0.1.3 | Aug 11, 2025 |
|---|---|
| 0.1.2 | May 11, 2025 |
| 0.1.1 | May 6, 2025 |
| 0.1.0 | May 3, 2025 |
#434 in Embedded development
1,515 downloads per month
37KB
841 lines
buf-fs
A buffer based, in-memory, no_std filesystem.
This crate mimics a file system, operating entirely within memory. By establishing a Fat (File Allocation Table) partition within a byte buffer, it exposes an API resembling that of a traditional filesystem to its users.
Example
use buf_fs::FileSystem;
let size = 4 * 1024 * 1024;
let mut fs = FileSystem::new(size).unwrap();
let data = b"foo";
fs.mkdir("/var/share/baz").unwrap();
fs.open("/var/share/data.bin")
.unwrap()
.update(|b| b.extend(data))
.save(&mut fs)
.unwrap();
fs.open("/var/share/bar.bin")
.unwrap()
.update(|b| b.extend(data))
.save(&mut fs)
.unwrap();
assert_eq!(fs.open("/var/share/data.bin").unwrap().contents, data);
let contents = fs.ls("/var/share").unwrap();
assert_eq!(contents.len(), 3);
// FAT-16 is always uppercase.
// It's a TODO to support ext4
assert_eq!(contents[0].path().as_str(), "BAZ");
assert_eq!(contents[1].path().as_str(), "BAR.BIN");
assert_eq!(contents[2].path().as_str(), "DATA.BIN");
Dependencies
~2MB
~34K SLoC