Crates.io | ext4-view |
lib.rs | ext4-view |
version | 0.6.1 |
source | src |
created_at | 2024-06-27 15:40:21.495462 |
updated_at | 2024-11-14 16:14:11.459829 |
description | No-std compatible Rust library for reading ext2/ext4 filesystems |
homepage | |
repository | https://github.com/nicholasbishop/ext4-view-rs |
max_upload_size | |
id | 1285896 |
size | 216,105 |
This repository provides a Rust crate that allows read-only access to an
ext4 filesystem. It also works with ext2 filesystems. Write access
is an explicit non-goal. The crate is no_std
, so it can be used in
embedded contexts. However, it does require alloc
.
Add the dependency:
cargo add ext4-view
Basic example:
use ext4_view::{Ext4, Metadata};
// Load the filesystem. The data source can be be anything that
// implements the `Ext4Read` trait. The simplest source is a
// `Vec<u8>` containing the whole filesystem.
let fs_data: Vec<u8> = get_fs_data_from_somewhere();
let fs = Ext4::load(Box::new(fs_data))?;
// If the `std` feature is enabled, you can load a filesystem by path:
let fs = Ext4::load_from_path(std::path::Path::new("some-fs.bin"))?;
// The `Ext4` type has methods very similar to `std::fs`:
let path = "/some/file/path";
let file_data: Vec<u8> = fs.read(path)?;
let file_str: String = fs.read_to_string(path)?;
let exists: bool = fs.exists(path)?;
let metadata: Metadata = fs.metadata(path)?;
for entry in fs.read_dir("/some/dir")? {
let entry = entry?;
println!("{}", entry.path().display());
}
In order of importance:
unsafe
code in the main package (it is allowed in dependencies).std::fs
where possible.Non-goals:
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
See the code of conduct and contributing.md.
Bug reports and PRs are welcome!
This project is not an official Google project. It is not supported by Google and Google specifically disclaims all warranties as to its quality, merchantability, or fitness for a particular purpose.