Skip to content

Commit

Permalink
Merge a2d947b into 341a89e
Browse files Browse the repository at this point in the history
  • Loading branch information
wcampbell0x2a authored Aug 30, 2024
2 parents 341a89e + a2d947b commit 87b6b9f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions backhand-cli/src/bin/unsquashfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ fn stat(args: Args, mut file: BufReader<File>, kind: Kind) {
println!("flag: fragments are always generated");
}

if superblock.data_has_been_duplicated() {
println!("flag: data has been duplicated");
if superblock.data_has_been_deduplicated() {
println!("flag: data has been deduplicated");
}

if superblock.nfs_export_table_exists() {
Expand Down
2 changes: 1 addition & 1 deletion backhand-test/tests/unsquashfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn test_unsquashfs_cli() {
export_table: 0x1308574,
}
Compression Options: None
flag: data has been duplicated
flag: data has been deduplicated
flag: nfs export table exists
"#,
);
Expand Down
6 changes: 4 additions & 2 deletions backhand/src/filesystem/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ pub struct FilesystemReader<'b> {
pub fragments: Option<Vec<Fragment>>,
/// All files and directories in filesystem
pub root: Nodes<SquashfsFileReader>,
// File reader
/// File reader
pub(crate) reader: Mutex<Box<dyn BufReadSeek + 'b>>,
// Cache used in the decompression
/// Cache used in the decompression
pub(crate) cache: RwLock<Cache>,
/// Superblock Flag to remove duplicate flags
pub(crate) no_duplicate_files: bool,
}

impl<'b> FilesystemReader<'b> {
Expand Down
3 changes: 2 additions & 1 deletion backhand/src/filesystem/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub struct FilesystemWriter<'a, 'b, 'c> {
/// The log2 of the block size. If the two fields do not agree, the archive is considered corrupted.
pub(crate) block_log: u16,
pub(crate) pad_len: u32,
/// Superblock Flag to remove duplicate flags
pub(crate) no_duplicate_files: bool,
}

Expand Down Expand Up @@ -235,7 +236,7 @@ impl<'a, 'b, 'c> FilesystemWriter<'a, 'b, 'c> {
id_table: reader.id_table.clone(),
root: Nodes { nodes: root },
pad_len: DEFAULT_PAD_LEN,
no_duplicate_files: true,
no_duplicate_files: reader.no_duplicate_files,
})
}

Expand Down
5 changes: 3 additions & 2 deletions backhand/src/squashfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl SuperBlock {
}

/// flag value
pub fn data_has_been_duplicated(&self) -> bool {
pub fn data_has_been_deduplicated(&self) -> bool {
self.flags & Flags::DataHasBeenDeduplicated as u16 != 0
}

Expand Down Expand Up @@ -429,7 +429,7 @@ impl<'b> Squashfs<'b> {
info!("flag: fragments are always generated");
}

if superblock.data_has_been_duplicated() {
if superblock.data_has_been_deduplicated() {
info!("flag: data has been duplicated");
}

Expand Down Expand Up @@ -646,6 +646,7 @@ impl<'b> Squashfs<'b> {
root,
reader: Mutex::new(Box::new(self.file)),
cache: RwLock::new(Cache::default()),
no_duplicate_files: self.superblock.data_has_been_deduplicated(),
};
Ok(filesystem)
}
Expand Down

0 comments on commit 87b6b9f

Please sign in to comment.