diff --git a/src/main.rs b/src/main.rs index 9f16c5c..1879934 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use std::{ collections::HashMap, - os::mikros::{ipc, syscalls, Errno}, + os::mikros::{ipc, syscalls, Errno, FileOpenMode}, path::{Path, PathBuf}, }; @@ -36,7 +36,7 @@ impl vfs_rpc::Server for Serv { Ok(()) } - fn open(&self, path: &Path) -> Result<(u64, u64), Errno> { + fn open(&self, path: &Path, mode: FileOpenMode) -> Result<(u64, u64), Errno> { if !path.is_absolute() { return Err(Errno::EINVAL); } @@ -49,7 +49,7 @@ impl vfs_rpc::Server for Serv { .map(|(a, b)| (a.clone(), *b)) .unwrap(); let (override_pid, fd) = - fs_rpc::Client::new(fs_pid).open(path.strip_prefix(mount_path).unwrap(), mount_id)?; + fs_rpc::Client::new(fs_pid).open(path.strip_prefix(mount_path).unwrap(), mode, mount_id)?; if let Some(override_pid) = override_pid { Ok((override_pid, fd)) } else { diff --git a/vfs_rpc/src/lib.rs b/vfs_rpc/src/lib.rs index f258f12..be0b897 100644 --- a/vfs_rpc/src/lib.rs +++ b/vfs_rpc/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, }; @@ -14,7 +14,7 @@ const PROTO: u16 = 2; pub trait Server: Send + Sync { fn register_fs(&self, from: u64, kind: &str) -> Result<(), Errno>; fn mount(&self, dev: &Path, kind: &str, path: &Path) -> Result<(), Errno>; - fn open(&self, path: &Path) -> Result<(u64, u64), Errno>; + fn open(&self, path: &Path, mode: FileOpenMode) -> Result<(u64, u64), Errno>; fn unmount(&self, path: &Path) -> Result<(), Errno>; fn open_dir(&self, path: &Path) -> Result<(u64, u64), Errno>; } @@ -47,9 +47,9 @@ impl Client { .unwrap() } - pub fn open(self, path: &Path) -> Result<(u64, u64), Errno> { + pub fn open(self, path: &Path, mode: FileOpenMode) -> Result<(u64, u64), Errno> { postcard::from_bytes( - &rpc::send_call(self.0, PROTO, 2, &postcard::to_stdvec(path).unwrap()).get_return(), + &rpc::send_call(self.0, PROTO, 2, &postcard::to_stdvec(&(path, mode)).unwrap()).get_return(), ) .unwrap() } @@ -98,8 +98,8 @@ fn callback(call: IncomingCall) { let ret = postcard::to_stdvec(&server.mount(dev, kind, path)).unwrap(); call.send_return(&ret); } else if call.func == 2 { - 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); } else if call.func == 3 { let path = postcard::from_bytes(call.args()).unwrap();