Add mkdir call

This commit is contained in:
pjht 2025-02-28 13:48:15 -06:00
parent 2df5db760e
commit 9f6ddd024b
Signed by: pjht
GPG Key ID: CA239FC6934E6F3A
2 changed files with 23 additions and 5 deletions

10
Cargo.lock generated
View File

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4
[[package]]
name = "atomic-polyfill"
@ -193,14 +193,14 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
[[package]]
name = "serde"
version = "1.0.210"
version = "1.0.218"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.210"
version = "1.0.218"
dependencies = [
"proc-macro2",
"quote",
@ -230,9 +230,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "syn"
version = "2.0.79"
version = "2.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
dependencies = [
"proc-macro2",
"quote",

View File

@ -15,6 +15,7 @@ pub trait Server: Send + Sync {
fn mount(&self, dev: &Path) -> Result<u64, Errno>;
fn open(&self, path: &Path, mode: FileOpenMode, mount_id: u64) -> Result<(Option<u64>, u64), Errno>;
fn open_dir(&self, path: &Path, mount_id: u64) -> Result<(Option<u64>, u64), Errno>;
fn mkdir(&self, path: &Path, mount_id: u64) -> Result<(), Errno>;
}
#[derive(Copy, Clone)]
@ -58,6 +59,19 @@ impl Client {
)
.unwrap()
}
pub fn mkdir(self, path: &Path, mount_id: u64) -> Result<(), Errno> {
postcard::from_bytes(
&rpc::send_call(
self.0,
PROTO,
3,
&postcard::to_stdvec(&(path, mount_id)).unwrap(),
)
.get_return(),
)
.unwrap()
}
}
pub fn register_server(server: Box<dyn Server>) {
@ -85,5 +99,9 @@ fn callback(call: IncomingCall) {
let (path, mount_id) = postcard::from_bytes(call.args()).unwrap();
let ret = postcard::to_stdvec(&server.open_dir(path, mount_id)).unwrap();
call.send_return(&ret);
} else if call.func == 3 {
let (path, mount_id) = postcard::from_bytes(call.args()).unwrap();
let ret = postcard::to_stdvec(&server.mkdir(path, mount_id)).unwrap();
call.send_return(&ret);
}
}