diff --git a/src/lib.rs b/src/lib.rs index 10b0e9b..9fa2a29 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ #![allow(clippy::result_unit_err)] use std::{ - os::mikros::{ipc::rpc::{self, IncomingCall}, Errno}, + os::mikros::{ipc::rpc::{self, IncomingCall}, Errno, FileOpenMode}, path::Path, }; @@ -12,7 +12,7 @@ static SERVER: RwLock>> = RwLock::new(None); const PROTO: u16 = 0; pub trait Server: Send + Sync { - fn open(&self, path: &Path) -> Result; + fn open(&self, path: &Path, mode: FileOpenMode) -> Result; } #[derive(Copy, Clone)] @@ -23,9 +23,9 @@ impl Client { Self(pid) } - pub fn open(self, path: &Path) -> Result { + pub fn open(self, path: &Path, mode: FileOpenMode) -> Result { postcard::from_bytes( - &rpc::send_call(self.0, PROTO, 0, &postcard::to_stdvec(path).unwrap()).get_return(), + &rpc::send_call(self.0, PROTO, 0, &postcard::to_stdvec(&(path, mode)).unwrap()).get_return(), ) .unwrap() } @@ -45,8 +45,8 @@ fn callback(call: IncomingCall) { let server_lock = SERVER.read(); let server = server_lock.as_ref().unwrap(); if call.func == 0 { - let path = postcard::from_bytes(call.args()).unwrap(); - let ret = postcard::to_stdvec(&server.open(path)).unwrap(); + let (path, mode) = postcard::from_bytes(call.args()).unwrap(); + let ret = postcard::to_stdvec(&server.open(path, mode)).unwrap(); call.send_return(&ret); } }