Skip to content
Snippets Groups Projects
Verified Commit 40e14d56 authored by pigeonmoelleux's avatar pigeonmoelleux 💬
Browse files

fix(fs): ext2 block group descriptor read

parent d88e4550
No related branches found
No related tags found
1 merge request!5Draft: Resolve "Implement ext2 support"
Pipeline #12861 failed with stages
in 1 minute and 29 seconds
......@@ -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) }
}
}
......@@ -7,7 +7,6 @@ use bitflags::bitflags;
use super::block::{BlockGroupDescriptor, Superblock};
use super::{read, SUPERBLOCK};
use crate::println;
/// Inode index of the root
///
......
......@@ -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)))
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment