From 2df5db760e8ca5ccd4bc2b8590b1c42bb3514a32 Mon Sep 17 00:00:00 2001 From: pjht Date: Sat, 16 Nov 2024 11:53:37 -0600 Subject: [PATCH] Add mode to open operation --- src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 667230a..57959c0 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, }; @@ -13,7 +13,7 @@ const PROTO: u16 = 3; pub trait Server: Send + Sync { fn mount(&self, dev: &Path) -> Result; - fn open(&self, path: &Path, mount_id: u64) -> Result<(Option, u64), Errno>; + fn open(&self, path: &Path, mode: FileOpenMode, mount_id: u64) -> Result<(Option, u64), Errno>; fn open_dir(&self, path: &Path, mount_id: u64) -> Result<(Option, u64), Errno>; } @@ -33,13 +33,13 @@ impl Client { .unwrap() } - pub fn open(self, path: &Path, mount_id: u64) -> Result<(Option, u64), Errno> { + pub fn open(self, path: &Path, mode: FileOpenMode, mount_id: u64) -> Result<(Option, u64), Errno> { postcard::from_bytes( &rpc::send_call( self.0, PROTO, 1, - &postcard::to_stdvec(&(path, mount_id)).unwrap(), + &postcard::to_stdvec(&(path, mode, mount_id)).unwrap(), ) .get_return(), ) @@ -78,8 +78,8 @@ fn callback(call: IncomingCall) { let ret = postcard::to_stdvec(&server.mount(dev)).unwrap(); call.send_return(&ret); } else if call.func == 1 { - let (path, mount_id) = postcard::from_bytes(call.args()).unwrap(); - let ret = postcard::to_stdvec(&server.open(path, mount_id)).unwrap(); + let (path, mode, mount_id) = postcard::from_bytes(call.args()).unwrap(); + let ret = postcard::to_stdvec(&server.open(path, mode, mount_id)).unwrap(); call.send_return(&ret); } else if call.func == 2 { let (path, mount_id) = postcard::from_bytes(call.args()).unwrap();