From ae4b3f3d4882c42805b8bbb92a120dd5bf30d6c3 Mon Sep 17 00:00:00 2001 From: pjht Date: Fri, 4 Oct 2024 12:37:11 -0500 Subject: [PATCH] Use Errno as RPC error type --- Cargo.lock | 97 ++++++++++++++++++++++++---------------------- Cargo.toml | 7 ++-- src/main.rs | 26 ++++++------- vfs_rpc/Cargo.lock | 97 ++++++++++++++++++++++++---------------------- vfs_rpc/Cargo.toml | 6 ++- vfs_rpc/src/lib.rs | 26 ++++++------- 6 files changed, 135 insertions(+), 124 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7896abc..a99d13d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,15 +13,15 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "byteorder" @@ -43,9 +43,9 @@ checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" [[package]] name = "critical-section" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" +checksum = "f64009896348fc5af4222e9cf7d7d82a95a256c634ebcf61c53e4ea461422242" [[package]] name = "embedded-io" @@ -53,6 +53,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + [[package]] name = "fs_rpc" version = "0.1.0" @@ -87,9 +93,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.155" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "lock_api" @@ -126,48 +132,49 @@ dependencies = [ [[package]] name = "postcard" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8" +checksum = "5f7f0a8d620d71c457dd1d47df76bb18960378da56af4527aaa10f515eee732e" dependencies = [ "cobs", - "embedded-io", + "embedded-io 0.4.0", + "embedded-io 0.6.1", "heapless", "serde", ] [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags", ] [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] @@ -186,18 +193,14 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +version = "1.0.210" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +version = "1.0.210" dependencies = [ "proc-macro2", "quote", @@ -227,9 +230,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "syn" -version = "2.0.66" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -254,9 +257,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "vfs" @@ -279,9 +282,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -295,48 +298,48 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/Cargo.toml b/Cargo.toml index a212faa..419698f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,10 +9,11 @@ parking_lot = "0.12.3" syslog_rpc = { version = "0.1.0", path = "../syslog/syslog_rpc" } vfs_rpc = { version = "0.1.0", path = "vfs_rpc" } -[workspace] -members = ["vfs_rpc"] - [profile.release] strip = true lto = true opt-level = "s" + +[patch.crates-io] +serde = { path = "../serde/serde" } +serde_derive = { path = "../serde/serde_derive" } diff --git a/src/main.rs b/src/main.rs index a689d7e..9052981 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use std::{ collections::HashMap, - os::mikros::{ipc, syscalls}, + os::mikros::{ipc, syscalls, Errno}, path::{Path, PathBuf}, }; @@ -15,20 +15,20 @@ struct Serv { } impl vfs_rpc::Server for Serv { - fn register_fs(&self, from: u64, kind: &str) -> Result<(), ()> { + fn register_fs(&self, from: u64, kind: &str) -> Result<(), Errno> { self.syslog_client.send_text_message("vfs", format!("PID {} registered FS type {}", from, kind)).unwrap(); self.fs_map.write().insert(kind.to_string(), from); Ok(()) } - fn mount(&self, dev: &Path, kind: &str, path: &Path) -> Result<(), ()> { + fn mount(&self, dev: &Path, kind: &str, path: &Path) -> Result<(), Errno> { if !dev.is_absolute() { - return Err(()); + return Err(Errno::EINVAL); } if !path.is_absolute() { - return Err(()); + return Err(Errno::EINVAL); } - let &fs_pid = self.fs_map.read().get(kind).ok_or(())?; + let &fs_pid = self.fs_map.read().get(kind).ok_or(Errno::EINVAL)?; let mount_id = fs_rpc::Client::new(fs_pid).mount(dev)?; self.mount_list .write() @@ -37,9 +37,9 @@ impl vfs_rpc::Server for Serv { Ok(()) } - fn open(&self, path: &Path) -> Result<(u64, u64), ()> { + fn open(&self, path: &Path) -> Result<(u64, u64), Errno> { if !path.is_absolute() { - return Err(()); + return Err(Errno::EINVAL); } let (mount_path, (fs_pid, mount_id)) = self .mount_list @@ -58,9 +58,9 @@ impl vfs_rpc::Server for Serv { } } - fn open_dir(&self, path: &Path) -> Result<(u64, u64), ()> { + fn open_dir(&self, path: &Path) -> Result<(u64, u64), Errno> { if !path.is_absolute() { - return Err(()); + return Err(Errno::EINVAL); } let (mount_path, (fs_pid, mount_id)) = self .mount_list @@ -79,16 +79,16 @@ impl vfs_rpc::Server for Serv { } } - fn unmount(&self, path: &Path) -> Result<(), ()> { + fn unmount(&self, path: &Path) -> Result<(), Errno> { if self.mount_list.write().remove(path).is_none() { - Err(()) + Err(Errno::EINVAL) } else { self.syslog_client.send_text_message("vfs", format!("Unmounted {}", path.display())).unwrap(); Ok(()) } } - fn set_stdio(&self, pid: u64, stdio: [Option<(u64, u64)>; 3]) -> Result<(), ()> { + fn set_stdio(&self, pid: u64, stdio: [Option<(u64, u64)>; 3]) -> Result<(), Errno> { self.process_stdio.write().insert(pid, stdio); Ok(()) } diff --git a/vfs_rpc/Cargo.lock b/vfs_rpc/Cargo.lock index 71d7b28..e96e58b 100644 --- a/vfs_rpc/Cargo.lock +++ b/vfs_rpc/Cargo.lock @@ -13,15 +13,15 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "byteorder" @@ -43,9 +43,9 @@ checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" [[package]] name = "critical-section" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" +checksum = "f64009896348fc5af4222e9cf7d7d82a95a256c634ebcf61c53e4ea461422242" [[package]] name = "embedded-io" @@ -53,6 +53,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + [[package]] name = "hash32" version = "0.2.1" @@ -78,9 +84,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.155" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "lock_api" @@ -117,48 +123,49 @@ dependencies = [ [[package]] name = "postcard" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8" +checksum = "5f7f0a8d620d71c457dd1d47df76bb18960378da56af4527aaa10f515eee732e" dependencies = [ "cobs", - "embedded-io", + "embedded-io 0.4.0", + "embedded-io 0.6.1", "heapless", "serde", ] [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags", ] [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] @@ -177,18 +184,14 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +version = "1.0.210" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +version = "1.0.210" dependencies = [ "proc-macro2", "quote", @@ -218,9 +221,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "syn" -version = "2.0.66" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -229,9 +232,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "vfs_rpc" @@ -244,9 +247,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -260,48 +263,48 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/vfs_rpc/Cargo.toml b/vfs_rpc/Cargo.toml index ae3db6b..2f6aee2 100644 --- a/vfs_rpc/Cargo.toml +++ b/vfs_rpc/Cargo.toml @@ -6,4 +6,8 @@ edition = "2021" [dependencies] parking_lot = "0.12.3" postcard = { version = "1.0.8", features = ["use-std"] } -serde = { version = "1.0.203" } +serde = { path = "../../serde/serde" } + +[patch.crates-io] +serde = { path = "../../serde/serde" } +serde_derive = { path = "../../serde/serde_derive" } diff --git a/vfs_rpc/src/lib.rs b/vfs_rpc/src/lib.rs index b44c0fa..1d1ffdb 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}, + os::mikros::{ipc::rpc::{self, IncomingCall}, Errno}, path::Path, }; @@ -12,13 +12,13 @@ static SERVER: RwLock>> = RwLock::new(None); const PROTO: u16 = 2; pub trait Server: Send + Sync { - fn register_fs(&self, from: u64, kind: &str) -> Result<(), ()>; - fn mount(&self, dev: &Path, kind: &str, path: &Path) -> Result<(), ()>; - fn open(&self, path: &Path) -> Result<(u64, u64), ()>; - fn unmount(&self, path: &Path) -> Result<(), ()>; - fn set_stdio(&self, pid: u64, stdio: [Option<(u64, u64)>; 3]) -> Result<(), ()>; + 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 unmount(&self, path: &Path) -> Result<(), Errno>; + fn set_stdio(&self, pid: u64, stdio: [Option<(u64, u64)>; 3]) -> Result<(), Errno>; fn get_stdio(&self, from: u64) -> [Option<(u64, u64)>; 3]; - fn open_dir(&self, path: &Path) -> Result<(u64, u64), ()>; + fn open_dir(&self, path: &Path) -> Result<(u64, u64), Errno>; } #[derive(Copy, Clone)] @@ -29,14 +29,14 @@ impl Client { Self(pid) } - pub fn register_fs(self, kind: &str) -> Result<(), ()> { + pub fn register_fs(self, kind: &str) -> Result<(), Errno> { postcard::from_bytes( &rpc::send_call(self.0, PROTO, 0, &postcard::to_stdvec(kind).unwrap()).get_return(), ) .unwrap() } - pub fn mount(self, dev: &Path, kind: &str, path: &Path) -> Result<(), ()> { + pub fn mount(self, dev: &Path, kind: &str, path: &Path) -> Result<(), Errno> { postcard::from_bytes( &rpc::send_call( self.0, @@ -49,14 +49,14 @@ impl Client { .unwrap() } - pub fn open(self, path: &Path) -> Result<(u64, u64), ()> { + pub fn open(self, path: &Path) -> Result<(u64, u64), Errno> { postcard::from_bytes( &rpc::send_call(self.0, PROTO, 2, &postcard::to_stdvec(path).unwrap()).get_return(), ) .unwrap() } - pub fn unmount(self, path: &Path) -> Result<(), ()> { + pub fn unmount(self, path: &Path) -> Result<(), Errno> { postcard::from_bytes( &rpc::send_call( self.0, @@ -69,7 +69,7 @@ impl Client { .unwrap() } - pub fn set_stdio(&self, pid: u64, stdio: [Option<(u64, u64)>; 3]) -> Result<(), ()> { + pub fn set_stdio(&self, pid: u64, stdio: [Option<(u64, u64)>; 3]) -> Result<(), Errno> { postcard::from_bytes( &rpc::send_call( self.0, @@ -95,7 +95,7 @@ impl Client { .unwrap() } - pub fn open_dir(self, path: &Path) -> Result<(u64, u64), ()> { + pub fn open_dir(self, path: &Path) -> Result<(u64, u64), Errno> { postcard::from_bytes( &rpc::send_call(self.0, PROTO, 6, &postcard::to_stdvec(path).unwrap()).get_return(), )