Expand description
Library and binaries for the reading, creating, and modification of SquashFS file systems.
§Library
Add the library to your project:
$ cargo add backhand§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 a file on disk. The file is opened during write(), so an image
// can contain more files than the limit of open file descriptors of the process.
write_filesystem.push_file_from_path("dune", "/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 compressionv4_lzma— Enables squashfs v4 with adaptive 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 decompressiondescriptive-errors— Include deku descriptive parse-error strings.error-strings(enabled by default) — Include this library’s own error messages and log records. On by default. Turn it off to keep that text out of a compiled binary: errorDisplaythen prints nothing, and the log records are dropped.
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::LazyFile;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::SquashfsReadFile;pub use crate::v4::filesystem::reader::FilesystemReader;pub use crate::v4::filesystem::reader::FilesystemReaderFile;pub 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;
Modules§
- compression
- Compression Choice and Options
- error
- kind
- Support the wonderful world of vendor formats
- traits
- Shared traits for v3 and v4 SquashFS implementations
- v3
v3 - SquashFS v3 implementation
- v4
- SquashFS v4 implementation
- v3_lzma
v3_lzma - SquashFS v3 with LZMA compression support
- v4_lzma
v4_lzma - SquashFS v4 with LZMA compression support