From 6971161dbacc0c408c05909ed7c25dc463024110 Mon Sep 17 00:00:00 2001 From: pjht Date: Mon, 12 Aug 2024 15:42:17 -0500 Subject: [PATCH] Update to latest file_rpc --- Cargo.lock | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 5 +++++ src/main.rs | 12 ++++-------- 3 files changed, 60 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d818ada..48da1de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,6 +41,26 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" +[[package]] +name = "const_format" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "critical-section" version = "1.1.2" @@ -140,11 +160,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8" dependencies = [ "cobs", + "const_format", "embedded-io", "heapless", + "postcard-derive", "serde", ] +[[package]] +name = "postcard-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc4b01218787dd4420daf63875163a787a78294ad48a24e9f6fa8c6507759a79" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "proc-macro2" version = "1.0.85" @@ -210,7 +243,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.66", ] [[package]] @@ -234,6 +267,17 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.66" @@ -286,6 +330,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "vfs_rpc" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 8da3ca1..9f173c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,3 +10,8 @@ parking_lot = "0.12.3" syslog_rpc = { version = "0.1.0", path = "../syslog/syslog_rpc" } tar = { version = "0.4.41", default-features = false, path = "tar-0.4.41" } vfs_rpc = { version = "0.1.0", path = "../vfs/vfs_rpc" } + +[profile.release] +strip = true +lto = true +opt-level = "s" diff --git a/src/main.rs b/src/main.rs index cf783ad..b12bf9f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,5 @@ use std::{ - fs::File, - io::{Read, Seek}, - os::mikros::{ipc, syscalls}, - path::PathBuf, - sync::Arc, + borrow::Cow, fs::File, io::{Read, Seek}, os::mikros::{ipc, syscalls}, path::PathBuf, sync::Arc }; use parking_lot::RwLock; @@ -50,11 +46,11 @@ impl fs_rpc::Server for Serv { } impl file_rpc::Server for Serv { - fn read(&self, fd: u64, pos: u64, len: usize) -> Result, ()> { + fn read(&self, fd: u64, pos: u64, len: usize) -> Result, ()> { let (mount_id, file_offset, size) = self.files.read()[fd as usize]; let read_len = usize::min(len, size - (pos as usize)); if read_len == 0 { - return Ok(Vec::new()); + return Ok(Vec::new().into()); }; let mounts = self.mounts.read(); let mount = &mounts[mount_id]; @@ -64,7 +60,7 @@ impl file_rpc::Server for Serv { let mut buf = vec![0; read_len]; let read_bytes = (&mount.0).read(&mut buf).map_err(|_| ())?; buf.truncate(read_bytes); - Ok(buf) + Ok(buf.into()) } fn write(&self, _fd: u64, _pos: u64, _data: &[u8]) -> Result<(), ()> {