basic FileSystem trait
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
parent
b9e49dd946
commit
8518982932
@ -6,7 +6,7 @@ use async_trait::async_trait;
|
||||
use core::cell::RefCell;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
pub type FDt = Arc<AsyncMutex<dyn FileDescriptor>>;
|
||||
pub type FDt = Arc<RefCell<dyn FileDescriptor>>;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref FD_TABLE: AsyncMutex<FDTable> = {
|
||||
|
@ -12,7 +12,7 @@ pub struct IsoFD {
|
||||
|
||||
impl IsoFD {
|
||||
pub fn new() -> FDt {
|
||||
Arc::new(AsyncMutex::new(IsoFD {
|
||||
Arc::new(RefCell::new(IsoFD {
|
||||
fd: FDId::new(),
|
||||
}))
|
||||
}
|
||||
|
@ -13,12 +13,12 @@ use fd::IsoFD;
|
||||
use alloc::{sync::Arc, boxed::Box};
|
||||
use async_trait::async_trait;
|
||||
|
||||
struct IsoFS {
|
||||
pub struct IsoFS {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
#[async_trait(?Send)]
|
||||
impl FileSystem for IsoFS {
|
||||
async fn open(&mut self, path: &str, flags: u32) -> Option<FDt> {
|
||||
async fn open(path: &str, flags: u32) -> Option<FDt> {
|
||||
if flags != crate::syscalls::io::O_RDONLY {
|
||||
return None;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use crate::fd::FDt;
|
||||
use alloc::{sync::Arc, boxed::Box};
|
||||
use async_trait::async_trait;
|
||||
|
||||
#[async_trait]
|
||||
#[async_trait(?Send)]
|
||||
pub trait FileSystem {
|
||||
async fn open(&mut self, path: &str, flags: u32) -> Option<FDt>;
|
||||
async fn open(path: &str, flags: u32) -> Option<FDt>;
|
||||
}
|
@ -20,6 +20,7 @@ use core::panic::PanicInfo;
|
||||
use drivers::vga::{self, Color, ColorCode};
|
||||
use multiboot2::BootInformation;
|
||||
use task::{executor::Executor, keyboard, Task};
|
||||
use crate::fs::FileSystem;
|
||||
|
||||
#[alloc_error_handler]
|
||||
fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
|
||||
@ -65,6 +66,6 @@ pub extern "C" fn julios_main(multiboot_info_addr: usize) -> ! {
|
||||
|
||||
|
||||
async fn get_file() {
|
||||
let fd = fs::iso::open("test", syscalls::io::O_RDONLY).await.unwrap();
|
||||
let fd = fs::iso::IsoFS::open("test", syscalls::io::O_RDONLY).await.unwrap();
|
||||
fd.borrow_mut().read(&[], 0).await;
|
||||
}
|
Loading…
Reference in New Issue
Block a user