From b0e7520fbf7b20a93ca9a9f33b9cd3fa440393c3 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 13 Aug 2020 13:46:07 +0100 Subject: [PATCH] [thin/superblock (rust)] Unpack flags --- src/thin/superblock.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/thin/superblock.rs b/src/thin/superblock.rs index 3bb2637..df69ff2 100644 --- a/src/thin/superblock.rs +++ b/src/thin/superblock.rs @@ -6,8 +6,14 @@ pub const SUPERBLOCK_LOCATION: u64 = 0; //const UUID_SIZE: usize = 16; const SPACE_MAP_ROOT_SIZE: usize = 128; +#[derive(Debug)] +pub struct SuperblockFlags { + pub needs_check: bool, +} + #[derive(Debug)] pub struct Superblock { + pub flags: SuperblockFlags, pub block: u64, //uuid: [u8; UUID_SIZE], pub version: u32, @@ -51,7 +57,7 @@ struct SuperblockError { fn unpack(data: &[u8]) -> IResult<&[u8], Superblock> { let (i, _csum) = le_u32(data)?; - let (i, _flags) = le_u32(i)?; + let (i, flags) = le_u32(i)?; let (i, block) = le_u64(i)?; let (i, _uuid) = take(16usize)(i)?; let (i, _magic) = le_u64(i)?; @@ -70,6 +76,7 @@ fn unpack(data: &[u8]) -> IResult<&[u8], Superblock> { Ok(( i, Superblock { + flags: SuperblockFlags {needs_check: (flags & 0x1) != 0}, block, //uuid: uuid[0..UUID_SIZE], version,