#squashfs #linux #deku #system

app librarium-cli

Library for the reading, creating, and modification of CPIO file systems

1 unstable release

0.2.0 Sep 27, 2024

#948 in Filesystem

Download history 142/week @ 2024-09-23 25/week @ 2024-09-30 4/week @ 2024-10-07 7/week @ 2024-10-14

178 downloads per month

MIT/Apache

24KB
372 lines

Librarium

github crates.io docs.rs build status Codecov

Library and binaries for the reading, creating, and modification of CPIO archives.

Library

Compiler support: requires rustc 1.72.1+

Add the following to your Cargo.toml file:

[dependencies]
librarium = "0.2.0"

Read

let mut file = File::open("archive.cpio").unwrap();
let mut archive = ArchiveReader::from_reader(&mut file).unwrap();

// extract bytes from all in archive
for object in &archive.objects.inner {
    let mut out = OpenOptions::new().write(true).create(true).open(object.name).unwrap();
    archive.reader.extract_data(object, &mut out).unwrap();
}

Write

let file = File::create(&new_path).unwrap();
let mut writer = ArchiveWriter::new(Box::new(file));

// A
let a_data = "a\n".as_bytes();
let a_header = Header {
    ino: 9119860,
    mode: 33188,
    uid: 1000,
    gid: 1000,
    nlink: 1,
    mtime: 1703901104,
    devmajor: 0,
    devminor: 38,
    rdevmajor: 0,
    rdevminor: 0,
};
writer.push_file(Cursor::new(a_data), CString::new("cpio-in/a").unwrap(), a_header).unwrap();

// write to archive
writer.write().unwrap();

Binaries

Compiler support: requires rustc 1.77+

These are currently under development and are missing features, MR's welcome!

To install, run cargo install librarium-cli --locked, or download from the latest github release.

See --help for more information.

uncpio-librarium

tool to extract and list cpio filesystems

Usage: uncpio [OPTIONS] [ARCHIVE]

Arguments:
  [ARCHIVE]  CPIO path

Options:
  -o, --offset <BYTES>   Skip BYTES at the start of FILESYSTEM [default: 0]
  -d, --dest <PATHNAME>  Extract to [PATHNAME] [default: out]
  -h, --help             Print help
  -V, --version          Print version

Dependencies

~5MB
~95K SLoC