Skip to content

Commit

Permalink
group flags bitmasks
Browse files Browse the repository at this point in the history
  • Loading branch information
BijanRegmi committed May 3, 2023
1 parent 4eb78d1 commit 4e1b039
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
34 changes: 25 additions & 9 deletions src/ext4_structs/block_group_descriptor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
use bitflags::bitflags;

use super::loadable::LoadAble;

bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct GroupFlags: u16 {
/// inode table and bitmap are not initialized
const INODE_UNINIT = 0x1;
/// block bitmap is not initialized
const BLOCK_UNINIT = 0x2;
/// inode table is zeroed
const INODE_ZEROED = 0x4;
}
}

#[allow(dead_code)]
#[derive(Debug)]
#[repr(C)]
Expand All @@ -22,6 +36,9 @@ pub struct Ext4GroupDesc {
/// Lower 16-bits of directory count.
pub bg_used_dirs_count_lo: u16,

/// Block group flags
pub bg_flags: GroupFlags,

/// Lower 32-bits of location of snapshot exclusion bitmap.
pub bg_exclude_bitmap_lo: u32,

Expand All @@ -31,10 +48,16 @@ pub struct Ext4GroupDesc {
/// Lower 16-bits of the inode bitmap checksum.
pub bg_inode_bitmap_csum_lo: u16,

/// Lower 16-bits of unused inode count. If set, we needn’t scan past the (sb.s_inodes_per_group - gdt.bg_itable_unused) th entry in the inode table for this group.
/// Lower 16-bits of unused inode count.
/// If set, we needn’t scan past the (sb.s_inodes_per_group - gdt.bg_itable_unused) th
/// entry in the inode table for this group.
pub bg_itable_unused_lo: u16,

/// Group descriptor checksum; crc16(sb_uuid+group_num+bg_desc) if the RO_COMPAT_GDT_CSUM feature is set, or crc32c(sb_uuid+group_num+bg_desc) & 0xFFFF if the RO_COMPAT_METADATA_CSUM feature is set. The bg_checksum field in bg_desc is skipped when calculating crc16 checksum, and set to zero if crc32c checksum is used.
/// Group descriptor checksum;
/// crc16(sb_uuid+group_num+bg_desc) if the RO_COMPAT_GDT_CSUM feature is set,
/// or crc32c(sb_uuid+group_num+bg_desc) & 0xFFFF if the RO_COMPAT_METADATA_CSUM feature is set.
/// The bg_checksum field in bg_desc is skipped when calculating crc16 checksum,
/// and set to zero if crc32c checksum is used.
pub bg_checksum: u16,

/// Upper 32-bits of location of block bitmap.
Expand Down Expand Up @@ -69,13 +92,6 @@ pub struct Ext4GroupDesc {

/// Padding to 64 bytes.
pub bg_reserved: u32,

/// Block group flags.
/// Value Description
/// 0x1 inode table and bitmap are not initialized (EXT4_BG_INODE_UNINIT).
/// 0x2 block bitmap is not initialized (EXT4_BG_BLOCK_UNINIT).
/// 0x3 inode table is zeroed (EXT4_BG_INODE_ZEROED).
pub bg_flags: u16,
}

impl LoadAble for Ext4GroupDesc {}
1 change: 1 addition & 0 deletions src/ext4_structs/inode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ bitflags! {
const Ext4NodumpFl = 0x00000040;
/// do not update atime
const Ext4NoatimeFl = 0x00000080;
///
const Ext4DirtyFl = 0x00000100;
/// One or more compressed clusters
const Ext4ComprblkFl = 0x00000200;
Expand Down

0 comments on commit 4e1b039

Please sign in to comment.