Expand description
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.24.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
// 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
v3— Enables squashfs v3v3_lzma— Enables squashfs v3 with LZMA compressionxz(enabled by default) — Enables xz compression inside library and binariesxz-static— Enables xz compression and forces static build inside library and binariesgzip(enabled by default) — Enables gzip compression inside library and binaries using flate2 library with zlib-rslzo— This library is licensed GPL and thus disabled by defaultzstd(enabled by default) — Enables zstd compression inside library and binarieslz4(enabled by default) — Enables Lz4 compressionany-gzip(enabled by default) — Internal onlyparallel(enabled by default) — Enable parallel decompression
Re-exports§
pub use crate::v3::V3;v3pub use crate::v4::V4;pub use crate::v4::data::DataSize;pub use crate::v4::export::Export;pub use crate::v4::filesystem::node::InnerNode;pub use crate::v4::filesystem::node::Node;pub use crate::v4::filesystem::node::NodeHeader;pub use crate::v4::filesystem::node::SquashfsBlockDevice;pub use crate::v4::filesystem::node::SquashfsCharacterDevice;pub use crate::v4::filesystem::node::SquashfsDir;pub use crate::v4::filesystem::node::SquashfsFileReader;pub use crate::v4::filesystem::node::SquashfsFileWriter;pub use crate::v4::filesystem::node::SquashfsSymlink;pub use crate::v4::filesystem::reader::FilesystemReader;pub use crate::v4::filesystem::reader::FilesystemReaderFile;pub use crate::v4::filesystem::reader_parallel::SquashfsReadFile;parallelpub use crate::v4::filesystem::writer::CompressionExtra;pub use crate::v4::filesystem::writer::ExtraXz;pub use crate::v4::filesystem::writer::FilesystemCompressor;pub use crate::v4::filesystem::writer::FilesystemWriter;pub use crate::v4::fragment::Fragment;pub use crate::v4::id::Id;pub use crate::v4::inode::BasicFile;pub use crate::v4::inode::Inode;pub use crate::v4::reader::BufReadSeek;pub use crate::v4::squashfs::DEFAULT_BLOCK_SIZE;pub use crate::v4::squashfs::DEFAULT_PAD_LEN;pub use crate::v4::squashfs::Flags;pub use crate::v4::squashfs::MAX_BLOCK_SIZE;pub use crate::v4::squashfs::MIN_BLOCK_SIZE;pub use crate::v4::squashfs::Squashfs;pub use crate::v4::squashfs::SuperBlock;pub use crate::error::BackhandError;pub use crate::traits::squashfs::create_squashfs_from_kind;pub use crate::traits::FilesystemReaderTrait;pub use crate::traits::GenericSquashfs;pub use crate::traits::SquashfsVersion;