diff --git a/Cargo.lock b/Cargo.lock index 31873e8..2ed28d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" @@ -50,6 +50,14 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f64009896348fc5af4222e9cf7d7d82a95a256c634ebcf61c53e4ea461422242" +[[package]] +name = "dir_rpc" +version = "0.1.0" +dependencies = [ + "parking_lot", + "postcard", +] + [[package]] name = "embedded-io" version = "0.4.0" @@ -302,6 +310,7 @@ dependencies = [ name = "tarfs" version = "0.1.0" dependencies = [ + "dir_rpc", "file_rpc", "fs_rpc", "parking_lot", diff --git a/Cargo.toml b/Cargo.toml index 23ce8e2..b3efa27 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] +dir_rpc = { version = "0.1.0", path = "../dir_rpc" } file_rpc = { version = "0.1.0", path = "../file_rpc" } fs_rpc = { version = "0.1.0", path = "../fs_rpc" } parking_lot = "0.12.3" diff --git a/src/main.rs b/src/main.rs index db2f490..68ded3b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,7 +57,10 @@ impl fs_rpc::Server for Serv { Ok((None, (self.files.read().len() - 1) as u64)) } - fn open_dir(&self, _path: &std::path::Path, _mount_id: u64) -> Result<(Option, u64), Errno> { + fn open_dir(&self, path: &std::path::Path, _mount_id: u64) -> Result<(Option, u64), Errno> { + if path.to_str() == Some("") { + return Ok((None, 0)); // needed so chdir succeeds + } // TODO Err(Errno::ENOSYS) } @@ -131,12 +134,24 @@ impl file_rpc::Server for Serv { } +impl dir_rpc::Server for Serv { + fn next_entry(&self, _fd: u64) -> Result, Errno> { + // TODO + Err(Errno::ENOSYS) + } + + fn close(&self, _fd: u64) -> Result<(), Errno> { + Ok(()) + } +} + fn main() { let serv = Serv { mounts: Arc::new(RwLock::new(Vec::new())), files: Arc::new(RwLock::new(Vec::new())), }; fs_rpc::register_server(Box::new(serv.clone())); + dir_rpc::register_server(Box::new(serv.clone())); file_rpc::register_server(Box::new(serv)); let vfs_pid; loop {