Crates.io | ext2 |
lib.rs | ext2 |
version | 0.1.1 |
source | src |
created_at | 2023-06-20 14:32:33.697114 |
updated_at | 2023-07-04 12:20:38.808356 |
description | Read and write on Ext2 partitions without mount |
homepage | |
repository | https://gitlab.com/mordaklavache/ext2.git |
max_upload_size | |
id | 895189 |
size | 180,060 |
This crate was created with the purpose of being able to read and write on ext2 partitions, whether they are in block device or in the form of a simple disk image file.
It does not require any Unix kernel module to function. Originally, it was designed to open ext2 images from within a Docker container without the need for privileged mode.
This crate covers basic system calls:
Additionally, the crate also has its own implementation of OpenOptions.
You have full permissions on the files, and all specified paths must be absolute. Currently, this crate only works on Unix-like operating systems.
Disclaimer : This crate is still in its early stages and should be used with caution on existing system partitions.
this module contains a ext2 driver see osdev
FUTURE ROAD MAP
Add the following dependency to your Cargo manifest...
[dependencies]
ext2 = "0.1"
# or
ext2 = { version = "0.1" }
First, create a new ext2 disk image named 'disk.img':
dd if=/dev/zero of=disk.img bs=1024 count=1024
mkfs.ext2 disk.img
Open, the disk image, and write to the '/foo.raw' file :
use ext2;
let f = std::fs::OpenOptions::new() // OpenOptions from std
.read(true)
.write(true)
.open("disk.img")
.expect("open filesystem failed");
let ext2 = ext2::Ext2::new(f).unwrap();
let mut f = ext2::OpenOptions::new() // OpenOptions from ext2
.write(true)
.create(true)
.open("/foo.raw", ext2)
.unwrap();
let b: Box<[u8; 1024 * 128]> = Box::new([42; 1024 * 128]);
let size = f.write(&*b).unwrap(); // write the box content to file
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.