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.21.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
xz
(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 onlyany-flate2
(enabled by default) — Internal only
Modules§
- compression
- Compression Choice and Options
- kind
- Support the wonderful world of vendor formats
Structs§
- Basic
File - Data
Size - Export
- NFS export support
- ExtraXz
- Xz compression option for
FilesystemWriter
- Filesystem
Compressor - All compression options for
FilesystemWriter
- Filesystem
Reader - Representation of SquashFS filesystem after read from image
- Filesystem
Reader File - Filesystem handle for file
- Filesystem
Writer - Representation of SquashFS filesystem to be written back to an image
- Fragment
- Id
- 32 bit user and group IDs
- Inode
- Node
- Filesystem Node
- Node
Header - File information for Node
- Squashfs
- Squashfs Image initial read information
- Squashfs
Block Device - Block Device for filesystem
- Squashfs
Character Device - Character Device for filesystem
- Squashfs
Dir - Directory for filesystem
- Squashfs
Read File - Squashfs
Symlink - Symlink for filesystem
- Super
Block - Contains important information about the archive, including the locations of other sections
Enums§
- Backhand
Error - Errors generated from library
- Compression
Extra - Compression options only for
FilesystemWriter
- Flags
- Inner
Node - Filesystem node
- Squashfs
File Reader - Unread file for filesystem
- Squashfs
File Writer - Read file from other SquashfsFile or an user file
Constants§
- DEFAULT_
BLOCK_ SIZE - 128KiB
- DEFAULT_
PAD_ LEN - 4KiB
- MAX_
BLOCK_ SIZE - 1MiB
- MIN_
BLOCK_ SIZE - 4KiB
Traits§
- BufRead
Seek - Pseudo-Trait for BufRead + Seek