diff --git a/src/fs/ext2/block.rs b/src/fs/ext2/block.rs index a40b26244bf0ac9ec7964d03a70527f344dd1fc5..aec0dbfaa2297b3e6ce9d69fbd956a67b5791323 100644 --- a/src/fs/ext2/block.rs +++ b/src/fs/ext2/block.rs @@ -2,8 +2,6 @@ //! //! See the [OSdev wiki](https://wiki.osdev.org/Ext2) for more informations -use core::mem; - use anyhow::{anyhow, Result}; use bitflags::bitflags; use log::error; @@ -19,6 +17,9 @@ const BLOCK_GROUP_DESCRIPTOR_TABLE_START_BYTE: usize = 2048; /// Ext2 signature, used to help confirm the presence of an Ext2 volume const EXT2_SIGNATURE: u16 = 0xef53; +/// Size in bytes of a group block descriptor +const GROUP_BLOCK_DESCRIPTOR_SIZE: usize = 32; + /// Superblock of the Ext2 filesystem /// /// This implementation contains also the extended fields described [here](https://wiki.osdev.org/Ext2#Extended_Superblock_Fields) @@ -344,6 +345,6 @@ impl BlockGroupDescriptor { /// Returns the `n`th block group descriptor pub fn new(n: usize) -> Result<Self> { // SAFETY: the given offset is coherent with the documentation - unsafe { read::<Self>(BLOCK_GROUP_DESCRIPTOR_TABLE_START_BYTE + n * mem::size_of::<Self>()) } + unsafe { read::<Self>(BLOCK_GROUP_DESCRIPTOR_TABLE_START_BYTE + n * GROUP_BLOCK_DESCRIPTOR_SIZE) } } } diff --git a/src/fs/ext2/inode.rs b/src/fs/ext2/inode.rs index 1573a7ba99ee07f91c5ef9cbad66c026bcedd624..78bb973d59bd75ec33bb435f9720bc3637c33d50 100644 --- a/src/fs/ext2/inode.rs +++ b/src/fs/ext2/inode.rs @@ -7,7 +7,6 @@ use bitflags::bitflags; use super::block::{BlockGroupDescriptor, Superblock}; use super::{read, SUPERBLOCK}; -use crate::println; /// Inode index of the root /// diff --git a/src/fs/ext2/mod.rs b/src/fs/ext2/mod.rs index e17112ec0013baf6f1f7f54dd8517a9c5621ecab..a2de47a8568584154c96d923330b269659ce670e 100644 --- a/src/fs/ext2/mod.rs +++ b/src/fs/ext2/mod.rs @@ -14,7 +14,6 @@ use self::block::Superblock; use self::inode::{Inode, ROOT_INODE_INDEX}; use crate::fs::ext2::entry::Directory; use crate::kernel::device::storage::Device; -use crate::println; #[allow(clippy::same_name_method)] mod block; @@ -72,8 +71,6 @@ pub fn search(device: &Arc<Mutex<dyn Device + Send>>) -> Result<Arc<Mutex<dyn su let root = Directory::root(&root_inode)?; - // println!("{root:?}"); - info!("Found the root of the filesystem : {:?}", root); Ok(Arc::new(Mutex::new(root))) diff --git a/src/main.rs b/src/main.rs index e0bbeb41b74a99a0da643dfda490151ccd639fd2..4cdd3b9e145e9f47c7a4ba132d788d373736f172 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,6 +60,7 @@ #![feature(error_in_core)] #![feature(extend_one)] #![feature(int_roundings)] +#![feature(iter_advance_by)] #![feature(new_uninit)] #![feature(no_coverage)] #![feature(strict_provenance)] @@ -98,12 +99,9 @@ use test::exit; use user::tty::print_key; #[cfg(not(test))] use x86_64::instructions; -use x86_64::structures::paging::PageTableFlags; use self::syslog::SYS_LOGGER; use crate::kernel::interrupt::cmos::CMOS; -use crate::kernel::interrupt::pit::sleep; -use crate::kernel::memory::vmm::VIRTUAL_MEMORY_MANAGER; /// Configuration of the bootloader /// @@ -149,19 +147,6 @@ fn kernel_main(boot_info: &'static mut BootInfo) -> ! { let rtc = CMOS.rtc(); println!("It is currently : {:0>2}:{:0>2}:{:0>2} (UTC+0)", rtc.hour, rtc.minute, rtc.second); - // let page = VIRTUAL_MEMORY_MANAGER - // .lock() - // .as_mut() - // .unwrap() - // .new_page(PageTableFlags::PRESENT | PageTableFlags::WRITABLE); - // println!("{:?}", page); - - // loop { - // sleep(1000); - // let rtc = CMOS.rtc(); - // println!("It is currently : {:0>2}:{:0>2}:{:0>2} (UTC+0)", rtc.hour, rtc.minute, rtc.second); - // } - let mut executor = Executor::new(); executor.spawn(Task::new(print_key())); executor.run();