Update to latest file_rpc
This commit is contained in:
parent
a5639f879e
commit
6971161dba
52
Cargo.lock
generated
52
Cargo.lock
generated
@ -41,6 +41,26 @@ version = "0.2.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15"
|
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]]
|
[[package]]
|
||||||
name = "critical-section"
|
name = "critical-section"
|
||||||
version = "1.1.2"
|
version = "1.1.2"
|
||||||
@ -140,11 +160,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8"
|
checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cobs",
|
"cobs",
|
||||||
|
"const_format",
|
||||||
"embedded-io",
|
"embedded-io",
|
||||||
"heapless",
|
"heapless",
|
||||||
|
"postcard-derive",
|
||||||
"serde",
|
"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]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.85"
|
version = "1.0.85"
|
||||||
@ -210,7 +243,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.66",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -234,6 +267,17 @@ version = "1.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
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]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.66"
|
version = "2.0.66"
|
||||||
@ -286,6 +330,12 @@ version = "1.0.12"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vfs_rpc"
|
name = "vfs_rpc"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -10,3 +10,8 @@ parking_lot = "0.12.3"
|
|||||||
syslog_rpc = { version = "0.1.0", path = "../syslog/syslog_rpc" }
|
syslog_rpc = { version = "0.1.0", path = "../syslog/syslog_rpc" }
|
||||||
tar = { version = "0.4.41", default-features = false, path = "tar-0.4.41" }
|
tar = { version = "0.4.41", default-features = false, path = "tar-0.4.41" }
|
||||||
vfs_rpc = { version = "0.1.0", path = "../vfs/vfs_rpc" }
|
vfs_rpc = { version = "0.1.0", path = "../vfs/vfs_rpc" }
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
strip = true
|
||||||
|
lto = true
|
||||||
|
opt-level = "s"
|
||||||
|
12
src/main.rs
12
src/main.rs
@ -1,9 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
borrow::Cow, fs::File, io::{Read, Seek}, os::mikros::{ipc, syscalls}, path::PathBuf, sync::Arc
|
||||||
io::{Read, Seek},
|
|
||||||
os::mikros::{ipc, syscalls},
|
|
||||||
path::PathBuf,
|
|
||||||
sync::Arc,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
@ -50,11 +46,11 @@ impl fs_rpc::Server for Serv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl file_rpc::Server for Serv {
|
impl file_rpc::Server for Serv {
|
||||||
fn read(&self, fd: u64, pos: u64, len: usize) -> Result<Vec<u8>, ()> {
|
fn read(&self, fd: u64, pos: u64, len: usize) -> Result<Cow<'_, [u8]>, ()> {
|
||||||
let (mount_id, file_offset, size) = self.files.read()[fd as usize];
|
let (mount_id, file_offset, size) = self.files.read()[fd as usize];
|
||||||
let read_len = usize::min(len, size - (pos as usize));
|
let read_len = usize::min(len, size - (pos as usize));
|
||||||
if read_len == 0 {
|
if read_len == 0 {
|
||||||
return Ok(Vec::new());
|
return Ok(Vec::new().into());
|
||||||
};
|
};
|
||||||
let mounts = self.mounts.read();
|
let mounts = self.mounts.read();
|
||||||
let mount = &mounts[mount_id];
|
let mount = &mounts[mount_id];
|
||||||
@ -64,7 +60,7 @@ impl file_rpc::Server for Serv {
|
|||||||
let mut buf = vec![0; read_len];
|
let mut buf = vec![0; read_len];
|
||||||
let read_bytes = (&mount.0).read(&mut buf).map_err(|_| ())?;
|
let read_bytes = (&mount.0).read(&mut buf).map_err(|_| ())?;
|
||||||
buf.truncate(read_bytes);
|
buf.truncate(read_bytes);
|
||||||
Ok(buf)
|
Ok(buf.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write(&self, _fd: u64, _pos: u64, _data: &[u8]) -> Result<(), ()> {
|
fn write(&self, _fd: u64, _pos: u64, _data: &[u8]) -> Result<(), ()> {
|
||||||
|
Loading…
Reference in New Issue
Block a user