Library and binaries for the reading, creating, and modification of SquashFS file systems.
| :warning: WARNING | |:-------------------------------------------------------------------------------------------| | The API for this library isn't complete. I will most likely break this for improvements |
Add the following to your Cargo.toml
file:
toml
[dependencies]
backhand = "0.9.1"
```rust,no_run use std::fs::File; use std::io::Cursor; use backhand::{FilesystemReader, FilesystemWriter, NodeHeader};
// read let file = File::open("file.squashfs").unwrap(); let readfilesystem = FilesystemReader::fromreader(file).unwrap();
// convert to writer let mut writefilesystem = FilesystemWriter::fromfsreader(&readfilesystem).unwrap();
// add file with data from slice let d = NodeHeader::default(); let bytes = Cursor::new(b"Fear is the mind-killer."); writefilesystem.pushfile(bytes, "a/d/e/new_file", d);
// add file with data from file let newfile = File::open("dune").unwrap(); writefilesystem.pushfile(newfile, "/root/dune", d);
// modify file let bytes = Cursor::new(b"The sleeper must awaken.\n"); writefilesystem.replacefile("/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(); ```
This library is tested with unpacking and packing SquashFS firmwares and testing that result with unsquashfs
.
openwrt
binaries are primarily being tested.
These are currently under development and are missing features, MR's welcome!
To install, run cargo install backhand
.
```console tool to uncompress, extract and list squashfs filesystems
Usage: unsquashfs [OPTIONS]
Arguments:
Options:
-o, --offset
```console tool to add files to squashfs filesystems
Usage: add
Arguments:
Options: -h, --help Print help information -V, --version Print version information ```