Skip to content

Commit

Permalink
Pull request FauxFaux#8: Ext4: получение fs uuid'а
Browse files Browse the repository at this point in the history
Merge in CRATES/ext4-rs from cases/PKM-1532 to without_state_verification

* commit '087bdf3ebafb64e988363fd2a18f08233922696e':
  [PKM-1532] store uuid
  • Loading branch information
Roman Pirogov committed Mar 2, 2023
2 parents e5b6260 + 087bdf3 commit a56e25b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ pub struct SuperBlock<R: ReadAt, C: Crypto, M: MetadataCrypto> {
load_xattrs: bool,
/// All* checksums are computed after concatenation with the UUID, so we keep that.
uuid_checksum: Option<u32>,
uuid: [u8; 16],
groups: block_groups::BlockGroups,
crypto: C,
}
Expand Down Expand Up @@ -304,6 +305,10 @@ impl<R: ReadAt, C: Crypto, M: MetadataCrypto> SuperBlock<R, C, M> {
Self::new_with_options_and_crypto(inner, &Options::default(), crypto, metadata_crypto)
}

pub fn get_uuid(&self) -> &[u8; 16] {
&self.uuid
}

pub fn get_crypto_mut(&mut self) -> &mut C {
&mut self.crypto
}
Expand Down
7 changes: 4 additions & 3 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ pub fn superblock<R: ReadAt, C: Crypto, M: MetadataCrypto>(
not_found("checksums are disabled, but required by options")
);

let mut s_uuid = [0; 16];
inner.read_exact(&mut s_uuid)?; /* 128-bit uuid for volume */
let mut uuid = [0; 16];
inner.read_exact(&mut uuid)?; /* 128-bit uuid for volume */
let mut s_volume_name = [0u8; 16];
inner.read_exact(&mut s_volume_name)?; /* volume name */
let mut s_last_mounted = [0u8; 64];
Expand Down Expand Up @@ -347,14 +347,15 @@ pub fn superblock<R: ReadAt, C: Crypto, M: MetadataCrypto>(

let uuid_checksum = if has_checksums {
// TODO: check s_checksum_seed
Some(ext4_style_crc32c_le(!0, &s_uuid))
Some(ext4_style_crc32c_le(!0, &uuid))
} else {
None
};

Ok(crate::SuperBlock {
inner: reader,
load_xattrs,
uuid,
uuid_checksum,
groups,
crypto,
Expand Down

0 comments on commit a56e25b

Please sign in to comment.