erofs-rs

Crates.ioerofs-rs
lib.rserofs-rs
version0.1.0
created_at2026-01-14 15:18:24.486079+00
updated_at2026-01-14 15:18:24.486079+00
descriptionA pure Rust library for reading EROFS (Enhanced Read-Only File System) images
homepage
repositoryhttps://github.com/Dreamacro/erofs-rs
max_upload_size
id2043013
size43,108
Dreamacro (Dreamacro)

documentation

README

erofs-rs

A pure Rust library for reading and building EROFS (Enhanced Read-Only File System) images.

Note: This library aims to provide essential parsing and building capabilities for common use cases, not a full reimplementation of erofs-utils.

Features

  • Zero-copy parsing via mmap
  • Directory traversal and file reading
  • Multiple data layouts: flat plain, flat inline, chunk-based

Usage

use std::fs::File;
use std::io::Read;
use memmap2::Mmap;
use erofs_rs::EroFS;

fn main() -> erofs_rs::Result<()> {
    let file = File::open("system.erofs")?;
    let mmap = unsafe { Mmap::map(&file) }?;
    let fs = EroFS::new(mmap)?;

    // Read file
    let mut file = fs.open("/etc/os-release")?;
    let mut buf = Vec::new();
    file.read_to_end(&mut buf)?;

    // List directory
    for entry in fs.read_dir("/usr/bin")? {
        println!("{}", entry?.dir_entry.file_name());
    }

    Ok(())
}

CLI

# Dump superblock info
erofs-cli dump image.erofs

# List directory
erofs-cli inspect -i image.erofs ls /

# Read file content
erofs-cli inspect -i image.erofs cat /etc/passwd

# Convert to tar
erofs-cli convert image.erofs -o out.tar

Status

Implemented

  • Superblock / inode / dirent parsing
  • Flat plain layout
  • Flat inline layout
  • Chunk-based layout (without chunk indexes)
  • Directory walk (walk_dir)
  • Convert to tar archive

TODO

  • Extended attributes
  • Compressed data (lz4, lzma, deflate)
  • Image building (mkfs.erofs equivalent)

License

MIT OR Apache-2.0

Commit count: 2

cargo fmt