Add Ext2 fs and basic bio layer

This commit is contained in:
LI Qing
2023-09-18 11:47:17 +08:00
committed by Tate, Hongliang Tian
parent 1616f2d32c
commit 9473889c6b
51 changed files with 5346 additions and 427 deletions

View File

@ -1,6 +1,7 @@
pub mod device;
pub mod devpts;
pub mod epoll;
pub mod ext2;
pub mod file_handle;
pub mod file_table;
pub mod fs_resolver;
@ -10,3 +11,28 @@ pub mod procfs;
pub mod ramfs;
pub mod rootfs;
pub mod utils;
use crate::fs::{ext2::Ext2, fs_resolver::FsPath};
use crate::prelude::*;
use crate::thread::kernel_thread::KernelThreadExt;
use aster_virtio::device::block::device::BlockDevice as VirtIoBlockDevice;
use aster_virtio::device::block::DEVICE_NAME as VIRTIO_BLOCK_NAME;
pub fn lazy_init() {
let block_device = aster_block::get_device(VIRTIO_BLOCK_NAME).unwrap();
let cloned_block_device = block_device.clone();
let task_fn = move || {
info!("spawn the virt-io-block thread");
let virtio_block_device = block_device.downcast_ref::<VirtIoBlockDevice>().unwrap();
loop {
virtio_block_device.handle_requests();
}
};
crate::Thread::spawn_kernel_thread(crate::ThreadOptions::new(task_fn));
let ext2_fs = Ext2::open(cloned_block_device).unwrap();
let target_path = FsPath::try_from("/ext2").unwrap();
println!("[kernel] Mount Ext2 fs at {:?} ", target_path);
self::rootfs::mount_fs_at(ext2_fs, &target_path).unwrap();
}