[thin/superblock (rust)] Unpack flags
This commit is contained in:
parent
c254ebe384
commit
b0e7520fbf
@ -6,8 +6,14 @@ pub const SUPERBLOCK_LOCATION: u64 = 0;
|
|||||||
//const UUID_SIZE: usize = 16;
|
//const UUID_SIZE: usize = 16;
|
||||||
const SPACE_MAP_ROOT_SIZE: usize = 128;
|
const SPACE_MAP_ROOT_SIZE: usize = 128;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct SuperblockFlags {
|
||||||
|
pub needs_check: bool,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Superblock {
|
pub struct Superblock {
|
||||||
|
pub flags: SuperblockFlags,
|
||||||
pub block: u64,
|
pub block: u64,
|
||||||
//uuid: [u8; UUID_SIZE],
|
//uuid: [u8; UUID_SIZE],
|
||||||
pub version: u32,
|
pub version: u32,
|
||||||
@ -51,7 +57,7 @@ struct SuperblockError {
|
|||||||
|
|
||||||
fn unpack(data: &[u8]) -> IResult<&[u8], Superblock> {
|
fn unpack(data: &[u8]) -> IResult<&[u8], Superblock> {
|
||||||
let (i, _csum) = le_u32(data)?;
|
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, block) = le_u64(i)?;
|
||||||
let (i, _uuid) = take(16usize)(i)?;
|
let (i, _uuid) = take(16usize)(i)?;
|
||||||
let (i, _magic) = le_u64(i)?;
|
let (i, _magic) = le_u64(i)?;
|
||||||
@ -70,6 +76,7 @@ fn unpack(data: &[u8]) -> IResult<&[u8], Superblock> {
|
|||||||
Ok((
|
Ok((
|
||||||
i,
|
i,
|
||||||
Superblock {
|
Superblock {
|
||||||
|
flags: SuperblockFlags {needs_check: (flags & 0x1) != 0},
|
||||||
block,
|
block,
|
||||||
//uuid: uuid[0..UUID_SIZE],
|
//uuid: uuid[0..UUID_SIZE],
|
||||||
version,
|
version,
|
||||||
|
Loading…
Reference in New Issue
Block a user