-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d43cc0b
commit 4148aa7
Showing
5 changed files
with
392 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
mod block_group_descriptor; | ||
mod directories; | ||
mod extents; | ||
mod inode; | ||
mod loadable; | ||
mod superblock; | ||
pub use self::block_group_descriptor::Ext4GroupDesc; | ||
pub use self::inode::Ext4Inode; | ||
pub use self::loadable::LoadAble; | ||
pub use self::superblock::Ext4SuperBlock; | ||
|
||
pub use block_group_descriptor::Ext4GroupDesc; | ||
pub use directories::{Ext4DirEntry, Ext4DirEntry2, Ext4DirEntryHash}; | ||
pub use extents::{Ext4Extent, Ext4ExtentHeader, Ext4ExtentIdx, Ext4ExtentTail}; | ||
pub use inode::Ext4Inode; | ||
pub use loadable::LoadAble; | ||
pub use superblock::Ext4SuperBlock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
use super::loadable::LoadAble; | ||
|
||
#[allow(dead_code)] | ||
#[derive(Debug)] | ||
#[repr(C)] | ||
pub struct Ext4DirEntry { | ||
/// Number of the inode that this directory entry points to. | ||
pub inode: u32, | ||
|
||
/// Length of this directory entry. Must be a multiple of 4. | ||
pub rec_len: u16, | ||
|
||
/// Length of the file name. | ||
pub name_len: u16, | ||
|
||
/// File name. | ||
pub name: [char; 255], | ||
} | ||
impl LoadAble for Ext4DirEntry {} | ||
|
||
#[allow(dead_code)] | ||
#[derive(Debug)] | ||
#[repr(u8)] | ||
pub enum FileType { | ||
Ext4FtUnknown = 0, | ||
Ext4FtRegFile = 1, | ||
Ext4FtDir = 2, | ||
Ext4FtChrdev = 3, | ||
Ext4FtBlkdev = 4, | ||
Ext4FtFifo = 5, | ||
Ext4FtSock = 6, | ||
Ext4FtSymlink = 7, | ||
Ext4FtMax = 8, | ||
Ext4FtDirCsum = 0xDE, | ||
} | ||
|
||
#[allow(dead_code)] | ||
#[derive(Debug)] | ||
#[repr(C)] | ||
pub struct Ext4DirEntry2 { | ||
/// Number of the inode that this directory entry points to. | ||
pub inode: u32, | ||
|
||
/// Length of this directory entry. | ||
pub rec_len: u16, | ||
|
||
/// Length of the file name. | ||
pub name_len: u8, | ||
|
||
/// File type code | ||
pub file_type: FileType, | ||
|
||
/// File name. | ||
pub name: [char; 255], | ||
} | ||
impl LoadAble for Ext4DirEntry2 {} | ||
|
||
#[allow(dead_code)] | ||
#[derive(Debug)] | ||
#[repr(C)] | ||
pub struct Ext4DirEntryHash { | ||
/// The hash of the directory name | ||
pub hash: u32, | ||
|
||
/// The minor hash of the directory name | ||
pub minor_hash: u32, | ||
} | ||
impl LoadAble for Ext4DirEntryHash {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
use super::loadable::LoadAble; | ||
|
||
#[allow(dead_code)] | ||
#[derive(Debug)] | ||
#[repr(C)] | ||
pub struct Ext4ExtentHeader { | ||
/// Magic number, 0xF30A. | ||
pub eh_magic: u16, | ||
|
||
/// Number of valid entries following the header. | ||
pub eh_entries: u16, | ||
|
||
/// Maximum number of entries that could follow the header. | ||
pub eh_max: u16, | ||
|
||
/// Depth of this extent node in the extent tree. | ||
/// 0 = this extent node points to data blocks; | ||
/// otherwise, this extent node points to other extent nodes. | ||
/// The extent tree can be at most 5 levels deep: | ||
/// a logical block number can be at most 2^32, | ||
/// and the smallest n that satisfies 4*(((blocksize - 12)/12)^n) >= 2^32 is 5. | ||
pub eh_depth: u16, | ||
|
||
/// Generation of the tree. (Used by Lustre, but not standard ext4). | ||
pub eh_generation: u32, | ||
} | ||
impl LoadAble for Ext4ExtentHeader {} | ||
|
||
#[allow(dead_code)] | ||
#[derive(Debug)] | ||
#[repr(C)] | ||
pub struct Ext4ExtentIdx { | ||
/// This index node covers file blocks from ‘block’ onward. | ||
pub ei_block: u32, | ||
|
||
/// Lower 32-bits of the block number of the extent node that is | ||
/// the next level lower in the tree. The tree node pointed to | ||
/// can be either another internal node or a leaf node, described below. | ||
pub ei_leaf_lo: u32, | ||
|
||
/// Upper 16-bits of the previous field. | ||
pub ei_leaf_hi: u16, | ||
|
||
pub ei_unused: u16, | ||
} | ||
impl LoadAble for Ext4ExtentIdx {} | ||
|
||
// Leaf node | ||
#[allow(dead_code)] | ||
#[derive(Debug)] | ||
#[repr(C)] | ||
pub struct Ext4Extent { | ||
/// First file block number that this extent covers. | ||
pub ee_block: u32, | ||
|
||
/// Number of blocks covered by extent. | ||
/// If the value of this field is <= 32768, the extent is initialized. | ||
/// If the value of the field is > 32768, the extent is uninitialized | ||
/// and the actual extent length is ee_len - 32768. | ||
/// Therefore, the maximum length of a initialized extent is 32768 blocks, | ||
/// and the maximum length of an uninitialized extent is 32767. | ||
pub ee_len: u16, | ||
|
||
/// Upper 16-bits of the block number to which this extent points. | ||
pub ee_start_hi: u16, | ||
|
||
/// Lower 32-bits of the block number to which this extent points. | ||
pub ee_start_lo: u32, | ||
} | ||
impl LoadAble for Ext4Extent {} | ||
|
||
#[allow(dead_code)] | ||
#[derive(Debug)] | ||
#[repr(C)] | ||
pub struct Ext4ExtentTail { | ||
/// Checksum of the extent block, crc32c(uuid+inum+igeneration+extentblock) | ||
pub et_checksum: u32, | ||
} | ||
impl LoadAble for Ext4ExtentTail {} |
Oops, something went wrong.