starting to work on open(2)
	
		
			
	
		
	
	
		
	
		
			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
							
								
									e2c2586a19
								
							
						
					
					
						commit
						d66fb31c9a
					
				@ -6,7 +6,7 @@ use crate::drivers::atapi::{DRIVE};
 | 
			
		||||
use crate::fd::{FD_TABLE, FDt};
 | 
			
		||||
use crate::utils::unserialize;
 | 
			
		||||
 | 
			
		||||
use iso9660::{IsoPrimVolDesc};
 | 
			
		||||
use iso9660::{IsoPrimVolDesc, IsoDir};
 | 
			
		||||
use fd::IsoFD;
 | 
			
		||||
 | 
			
		||||
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())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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();
 | 
			
		||||
    FD_TABLE.lock().await.register_fd(fd.clone());
 | 
			
		||||
    fd
 | 
			
		||||
    Some(fd)
 | 
			
		||||
}
 | 
			
		||||
@ -10,6 +10,7 @@ mod task;
 | 
			
		||||
mod fs;
 | 
			
		||||
mod utils;
 | 
			
		||||
mod fd;
 | 
			
		||||
mod syscalls;
 | 
			
		||||
 | 
			
		||||
//#[macro_use]
 | 
			
		||||
extern crate alloc;
 | 
			
		||||
@ -64,6 +65,6 @@ pub extern "C" fn julios_main(multiboot_info_addr: usize) -> ! {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										7
									
								
								src/syscalls/io.rs
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										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
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										1
									
								
								src/syscalls/mod.rs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
pub mod io;
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user