starting to work on open(2)
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:
Julien CLEMENT 2022-12-22 22:03:06 +01:00
parent e2c2586a19
commit d66fb31c9a
4 changed files with 23 additions and 4 deletions

@ -6,7 +6,7 @@ use crate::drivers::atapi::{DRIVE};
use crate::fd::{FD_TABLE, FDt}; use crate::fd::{FD_TABLE, FDt};
use crate::utils::unserialize; use crate::utils::unserialize;
use iso9660::{IsoPrimVolDesc}; use iso9660::{IsoPrimVolDesc, IsoDir};
use fd::IsoFD; use fd::IsoFD;
pub async fn get_prim_vol_desc() -> IsoPrimVolDesc { pub async fn get_prim_vol_desc() -> IsoPrimVolDesc {
@ -20,8 +20,18 @@ pub async fn get_prim_vol_desc() -> IsoPrimVolDesc {
*unserialize::<IsoPrimVolDesc>(desc_block.as_ptr()) *unserialize::<IsoPrimVolDesc>(desc_block.as_ptr())
} }
pub async fn open() -> FDt { 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(); let fd = IsoFD::new();
FD_TABLE.lock().await.register_fd(fd.clone()); FD_TABLE.lock().await.register_fd(fd.clone());
fd Some(fd)
} }

@ -10,6 +10,7 @@ mod task;
mod fs; mod fs;
mod utils; mod utils;
mod fd; mod fd;
mod syscalls;
//#[macro_use] //#[macro_use]
extern crate alloc; extern crate alloc;
@ -64,6 +65,6 @@ pub extern "C" fn julios_main(multiboot_info_addr: usize) -> ! {
async fn get_file() { async fn get_file() {
let fd = fs::iso::open().await; let fd = fs::iso::open("test", syscalls::io::O_RDONLY).await.unwrap();
fd.borrow_mut().read(&[], 0).await; fd.borrow_mut().read(&[], 0).await;
} }

7
src/syscalls/io.rs Normal file

@ -0,0 +1,7 @@
// open flags
pub const O_RDONLY: u32 = 0;
// seek flags
pub const SEEK_SET: u32 = 0;
pub const SEEK_CUR: u32 = 1;
pub const SEEK_END: u32 = 2;

1
src/syscalls/mod.rs Normal file

@ -0,0 +1 @@
pub mod io;