backhand 0.14.0

Library for the reading, creating, and modification of SquashFS file systems
Documentation

Library and binaries for the reading, creating, and modification of SquashFS file systems.

Library

Add the following to your Cargo.toml file:

[dependencies]
backhand = "0.14.0"

Reading

For reading an image and extracting its details and contents, use [FilesystemReader::from_reader].

Writing

For creating a modified or new image, use [FilesystemWriter::from_fs_reader]. [FilesystemWriter] can also be created from scratch, without a previous image to base itself on.

Example

# use std::fs::File;
# use std::io::{Cursor, BufReader};
# use backhand::{FilesystemReader, FilesystemWriter, NodeHeader};
// read
let file = BufReader::new(File::open("file.squashfs").unwrap());
let read_filesystem = FilesystemReader::from_reader(file).unwrap();

// convert to writer
let mut write_filesystem = FilesystemWriter::from_fs_reader(&read_filesystem).unwrap();

// add file with data from slice
let d = NodeHeader::default();
let bytes = Cursor::new(b"Fear is the mind-killer.");
write_filesystem.push_file(bytes, "a/d/e/new_file", d);

// add file with data from file
let new_file = File::open("dune").unwrap();
write_filesystem.push_file(new_file, "/root/dune", d);

// replace a existing file
let bytes = Cursor::new(b"The sleeper must awaken.\n");
write_filesystem
.replace_file("/a/b/c/d/e/first_file", bytes)
.unwrap();

// write into a new file
let mut output = File::create("modified.squashfs").unwrap();
write_filesystem.write(&mut output).unwrap();

Features