Trying to implement FileSystem trait
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
1 parent
e5eb05eb3d
commit
b9e49dd946
5 files changed
+42
-21
No files matched your search
+26
-16
@@ -6,9 +6,35 @@ 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;
|
||||
|
||||
struct IsoFS {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl FileSystem for IsoFS {
|
||||
async fn open(&mut self, 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()
|
||||
@@ -18,20 +44,4 @@ pub async fn get_prim_vol_desc() -> IsoPrimVolDesc {
|
||||
.read_block(iso9660::ISO_PRIM_VOLDESC_BLOCK)
|
||||
.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)
|
||||
}
|
||||