Add mode to open operation
This commit is contained in:
parent
230adf0ee0
commit
bb2f570131
@ -1,6 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
os::mikros::{ipc, syscalls, Errno},
|
os::mikros::{ipc, syscalls, Errno, FileOpenMode},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ impl vfs_rpc::Server for Serv {
|
|||||||
Ok(())
|
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() {
|
if !path.is_absolute() {
|
||||||
return Err(Errno::EINVAL);
|
return Err(Errno::EINVAL);
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ impl vfs_rpc::Server for Serv {
|
|||||||
.map(|(a, b)| (a.clone(), *b))
|
.map(|(a, b)| (a.clone(), *b))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let (override_pid, fd) =
|
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 {
|
if let Some(override_pid) = override_pid {
|
||||||
Ok((override_pid, fd))
|
Ok((override_pid, fd))
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#![allow(clippy::result_unit_err)]
|
#![allow(clippy::result_unit_err)]
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
os::mikros::{ipc::rpc::{self, IncomingCall}, Errno},
|
os::mikros::{ipc::rpc::{self, IncomingCall}, Errno, FileOpenMode},
|
||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ const PROTO: u16 = 2;
|
|||||||
pub trait Server: Send + Sync {
|
pub trait Server: Send + Sync {
|
||||||
fn register_fs(&self, from: u64, kind: &str) -> Result<(), Errno>;
|
fn register_fs(&self, from: u64, kind: &str) -> Result<(), Errno>;
|
||||||
fn mount(&self, dev: &Path, kind: &str, path: &Path) -> 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 unmount(&self, path: &Path) -> Result<(), Errno>;
|
||||||
fn open_dir(&self, path: &Path) -> Result<(u64, u64), Errno>;
|
fn open_dir(&self, path: &Path) -> Result<(u64, u64), Errno>;
|
||||||
}
|
}
|
||||||
@ -47,9 +47,9 @@ impl Client {
|
|||||||
.unwrap()
|
.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(
|
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()
|
.unwrap()
|
||||||
}
|
}
|
||||||
@ -98,8 +98,8 @@ fn callback(call: IncomingCall) {
|
|||||||
let ret = postcard::to_stdvec(&server.mount(dev, kind, path)).unwrap();
|
let ret = postcard::to_stdvec(&server.mount(dev, kind, path)).unwrap();
|
||||||
call.send_return(&ret);
|
call.send_return(&ret);
|
||||||
} else if call.func == 2 {
|
} else if call.func == 2 {
|
||||||
let path = postcard::from_bytes(call.args()).unwrap();
|
let (path, mode) = postcard::from_bytes(call.args()).unwrap();
|
||||||
let ret = postcard::to_stdvec(&server.open(path)).unwrap();
|
let ret = postcard::to_stdvec(&server.open(path, mode)).unwrap();
|
||||||
call.send_return(&ret);
|
call.send_return(&ret);
|
||||||
} else if call.func == 3 {
|
} else if call.func == 3 {
|
||||||
let path = postcard::from_bytes(call.args()).unwrap();
|
let path = postcard::from_bytes(call.args()).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user