[VFS] Skeleton for moving victoria falls to rust.
This commit is contained in:
parent
59efb1659a
commit
a806e41af0
11 changed files with 130 additions and 3 deletions
8
rust/lib/fs/ext2/Cargo.toml
Normal file
8
rust/lib/fs/ext2/Cargo.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "ext2"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
denali_client = { path = "../../client/denali_client" }
|
||||
mammoth = { path = "../../mammoth" }
|
||||
19
rust/lib/fs/ext2/src/ext2_driver.rs
Normal file
19
rust/lib/fs/ext2/src/ext2_driver.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
use denali_client::DiskReader;
|
||||
use mammoth::mem::MemoryRegion;
|
||||
|
||||
use crate::types::Superblock;
|
||||
|
||||
pub struct Ext2Driver {
|
||||
reader: DiskReader,
|
||||
}
|
||||
|
||||
impl Ext2Driver {
|
||||
pub fn new(mut reader: DiskReader) -> Self {
|
||||
let super_block_mem = MemoryRegion::from_cap(reader.read(2, 2).unwrap()).unwrap();
|
||||
let super_block: &Superblock = super_block_mem.as_ref();
|
||||
let inodes = super_block.inodes_count;
|
||||
let magic = super_block.magic;
|
||||
mammoth::debug!("Superblock ({:#x}): inodes: {:#x}", magic, inodes);
|
||||
Self { reader }
|
||||
}
|
||||
}
|
||||
8
rust/lib/fs/ext2/src/lib.rs
Normal file
8
rust/lib/fs/ext2/src/lib.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#![no_std]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
mod ext2_driver;
|
||||
mod types;
|
||||
|
||||
pub use ext2_driver::Ext2Driver;
|
||||
30
rust/lib/fs/ext2/src/types.rs
Normal file
30
rust/lib/fs/ext2/src/types.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#[repr(C, packed)]
|
||||
pub struct Superblock {
|
||||
pub inodes_count: u32,
|
||||
pub blocks_count: u32,
|
||||
pub reserved_blocks_count: u32,
|
||||
pub free_blocks_count: u32,
|
||||
pub free_inodes_count: u32,
|
||||
pub first_data_blok: u32,
|
||||
pub log_block_size: u32,
|
||||
pub log_frag_size: u32,
|
||||
pub blocks_per_group: u32,
|
||||
pub frags_per_group: u32,
|
||||
pub inodes_per_group: u32,
|
||||
pub mtime: u32,
|
||||
pub wtime: u32,
|
||||
pub mnt_count: u16,
|
||||
pub max_mnt_count: u16,
|
||||
pub magic: u16,
|
||||
pub state: u16,
|
||||
pub errors: u16,
|
||||
pub minor_rev_level: u16,
|
||||
pub lastcheck: u32,
|
||||
pub checkinterval: u32,
|
||||
pub creator_os: u32,
|
||||
pub rev_level: u32,
|
||||
pub def_resuid: u16,
|
||||
pub def_resgid: u16,
|
||||
pub first_ino: u32,
|
||||
pub inode_size: u16,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue