add async trait to make FD methods async
continuous-integration/drone/push Build is passing

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
juju committed 2022-12-22 21:25:35 +01:00
1 parent ffe889a934
commit e2c2586a19
6 files changed
+25 -10

No files matched your search

+5 -3
View File
@@ -1,6 +1,7 @@
use crate::utils::AsyncMutex;
use alloc::{collections::BTreeMap, sync::Arc};
use alloc::{collections::BTreeMap, sync::Arc, boxed::Box};
use async_trait::async_trait;
use core::cell::RefCell;
use lazy_static::lazy_static;
@@ -35,7 +36,8 @@ impl FDTable {
}
}
#[async_trait]
pub trait FileDescriptor {
fn write(&mut self, buf: *const u8, count: usize) -> isize;
fn read(&mut self, buf: *mut u8, count: usize) -> isize;
async fn write(&mut self, buf: &[u8], count: usize) -> isize;
async fn read(&mut self, buf: &[u8], count: usize) -> isize;
}
+5 -3
View File
@@ -1,7 +1,8 @@
use crate::println;
use crate::fd::{FDId, FileDescriptor, FDt};
use alloc::sync::Arc;
use alloc::{sync::Arc, boxed::Box};
use async_trait::async_trait;
use core::cell::RefCell;
pub struct IsoFD {
@@ -16,12 +17,13 @@ impl IsoFD {
}
}
#[async_trait]
impl FileDescriptor for IsoFD {
fn write(&mut self, buf: *const u8, count: usize) -> isize {
async fn write(&mut self, buf: &[u8], count: usize) -> isize {
0
}
fn read(&mut self, buf: *mut u8, count: usize) -> isize {
async fn read(&mut self, buf: &[u8], count: usize) -> isize {
println!("Read from fd");
0
}
+1 -3
View File
@@ -3,14 +3,12 @@ mod fd;
use crate::println;
use crate::drivers::atapi::{DRIVE};
use crate::fd::{FDId, FD_TABLE, FDt};
use crate::fd::{FD_TABLE, FDt};
use crate::utils::unserialize;
use iso9660::{IsoPrimVolDesc};
use fd::IsoFD;
use alloc::sync::Arc;
pub async fn get_prim_vol_desc() -> IsoPrimVolDesc {
let desc_block = DRIVE
.lock()
+1 -1
View File
@@ -65,5 +65,5 @@ pub extern "C" fn julios_main(multiboot_info_addr: usize) -> ! {
async fn get_file() {
let fd = fs::iso::open().await;
fd.borrow_mut().read(0 as *mut u8, 0);
fd.borrow_mut().read(&[], 0).await;
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.