From cf7852bb94c33a0eeaa595522e39961d84f45ea2 Mon Sep 17 00:00:00 2001 From: pjht Date: Mon, 23 Sep 2024 15:41:50 -0500 Subject: [PATCH] Log register_fs, mount, and unmount --- Cargo.lock | 17 +++++++++++++++++ Cargo.toml | 1 + src/main.rs | 12 ++++++++++++ 3 files changed, 30 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index a81666e..7896abc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -236,6 +236,22 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syslog_rpc" +version = "0.1.0" +dependencies = [ + "parking_lot", + "postcard", + "syslog_structs", +] + +[[package]] +name = "syslog_structs" +version = "0.1.0" +dependencies = [ + "serde", +] + [[package]] name = "unicode-ident" version = "1.0.12" @@ -248,6 +264,7 @@ version = "0.1.0" dependencies = [ "fs_rpc", "parking_lot", + "syslog_rpc", "vfs_rpc", ] diff --git a/Cargo.toml b/Cargo.toml index fa90694..a212faa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" [dependencies] fs_rpc = { version = "0.1.0", path = "../fs_rpc" } 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] diff --git a/src/main.rs b/src/main.rs index e4063e4..ee35cb8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,10 +11,12 @@ struct Serv { fs_map: RwLock>, mount_list: RwLock>, process_stdio: RwLock; 3]>>, + syslog_client: syslog_rpc::Client } impl vfs_rpc::Server for Serv { fn register_fs(&self, from: u64, kind: &str) -> Result<(), ()> { + 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(()) } @@ -31,6 +33,7 @@ impl vfs_rpc::Server for Serv { self.mount_list .write() .insert(path.to_owned(), (fs_pid, mount_id)); + self.syslog_client.send_text_message("vfs", format!("Mounted {} on {} type {}", dev.display(), path.display(), kind)).unwrap(); Ok(()) } @@ -59,6 +62,7 @@ impl vfs_rpc::Server for Serv { if self.mount_list.write().remove(path).is_none() { Err(()) } else { + self.syslog_client.send_text_message("vfs", format!("Unmounted {}", path.display())).unwrap(); Ok(()) } } @@ -75,12 +79,20 @@ impl vfs_rpc::Server for Serv { } fn main() { + let syslog_pid = loop { + if let Some(pid) = syscalls::try_get_registered(2) { + break pid; + } + }; + let syslog_client = syslog_rpc::Client::new(syslog_pid); vfs_rpc::register_server(Box::new(Serv { fs_map: RwLock::new(HashMap::new()), mount_list: RwLock::new(HashMap::new()), process_stdio: RwLock::new(HashMap::new()), + syslog_client, })); syscalls::register(0); + syslog_client.send_text_message("vfs", "VFS initialized").unwrap(); loop { ipc::process_messages() }