Compare commits

..

No commits in common. "8518982932169ec9a9efb172557ed244cc115485" and "e5eb05eb3db4ad94dc292a94262c49a9df3985d1" have entirely different histories.

6 changed files with 20 additions and 42 deletions

@ -33,7 +33,7 @@ impl FDTable {
FDTable { table: BTreeMap::new() }
}
pub fn register_fd(&mut self, fd: FDt) {
pub async fn register_fd(&mut self, fd: FDt) {
// TODO
self.table.insert(fd.borrow().get_fd(), fd.clone());
println!("Registered fd: {:?}", self.table.get(&FDId(1)).unwrap().borrow().get_fd());

@ -1,6 +1,5 @@
use crate::println;
use crate::fd::{FDId, FileDescriptor, FDt};
use crate::utils::mutex::AsyncMutex;
use alloc::{sync::Arc, boxed::Box};
use async_trait::async_trait;

@ -6,35 +6,9 @@ use crate::drivers::atapi::{DRIVE};
use crate::fd::{FD_TABLE, FDt};
use crate::utils::unserialize;
use super::FileSystem;
use iso9660::{IsoPrimVolDesc, IsoDir};
use fd::IsoFD;
use alloc::{sync::Arc, boxed::Box};
use async_trait::async_trait;
pub struct IsoFS {
}
#[async_trait(?Send)]
impl FileSystem for IsoFS {
async fn open(path: &str, flags: u32) -> Option<FDt> {
if flags != crate::syscalls::io::O_RDONLY {
return None;
}
let voldesc = get_prim_vol_desc().await;
if voldesc.std_identifier != "CD001".as_bytes() {
return None;
}
let fd = IsoFD::new();
FD_TABLE.lock().await.register_fd(fd.clone());
Some(fd.clone())
}
}
pub async fn get_prim_vol_desc() -> IsoPrimVolDesc {
let desc_block = DRIVE
.lock()
@ -45,3 +19,19 @@ pub async fn get_prim_vol_desc() -> IsoPrimVolDesc {
.await;
*unserialize::<IsoPrimVolDesc>(desc_block.as_ptr())
}
pub async fn open(path: &str, flags: u32) -> Option<FDt> {
if flags != crate::syscalls::io::O_RDONLY {
return None;
}
let voldesc = get_prim_vol_desc().await;
if voldesc.std_identifier != "CD001".as_bytes() {
return None;
}
let fd = IsoFD::new();
FD_TABLE.lock().await.register_fd(fd.clone()).await;
Some(fd)
}

@ -1,11 +1 @@
pub mod iso;
use crate::fd::FDt;
use alloc::{sync::Arc, boxed::Box};
use async_trait::async_trait;
#[async_trait(?Send)]
pub trait FileSystem {
async fn open(path: &str, flags: u32) -> Option<FDt>;
}

@ -20,7 +20,6 @@ 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) -> ! {
@ -66,6 +65,6 @@ pub extern "C" fn julios_main(multiboot_info_addr: usize) -> ! {
async fn get_file() {
let fd = fs::iso::IsoFS::open("test", syscalls::io::O_RDONLY).await.unwrap();
let fd = fs::iso::open("test", syscalls::io::O_RDONLY).await.unwrap();
fd.borrow_mut().read(&[], 0).await;
}

@ -14,7 +14,7 @@ struct Lock {
waker: Arc<AtomicWaker>,
}
pub struct AsyncMutex<T: ?Sized> {
pub struct AsyncMutex<T> {
lock: Lock,
inner: UnsafeCell<T>,
}