diff --git a/Cargo.lock b/Cargo.lock index 309e91a..e3f3b8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,6 +64,7 @@ dependencies = [ "devfs_rpc", "fs_rpc", "parking_lot", + "syslog_rpc", "vfs_rpc", ] @@ -265,6 +266,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" diff --git a/Cargo.toml b/Cargo.toml index 2aada6f..23310c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ dev_driver_rpc = { version = "0.1.0", path = "../dev_driver_rpc" } devfs_rpc = { version = "0.1.0", path = "devfs_rpc" } 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/vfs_rpc" } [workspace] diff --git a/src/main.rs b/src/main.rs index f6309f1..53e5499 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ use parking_lot::RwLock; #[derive(Debug, Clone)] struct Serv { devices: Arc>>, + syslog_client: syslog_rpc::Client, } impl fs_rpc::Server for Serv { @@ -23,13 +24,28 @@ impl fs_rpc::Server for Serv { impl devfs_rpc::Server for Serv { fn register_dev(&self, from: u64, name: &str) -> Result<(), ()> { self.devices.write().insert(name.to_owned(), from); + self.syslog_client.send_text_binary_message( + "devfs", + format!("PID {} registered device {}", from, name), + 1, + name.as_bytes().to_vec() + ).unwrap(); Ok(()) } } fn main() { + let syslog_pid; + loop { + if let Some(pid) = syscalls::try_get_registered(2) { + syslog_pid = pid; + break; + } + } + let syslog_client = syslog_rpc::Client::new(syslog_pid); let serv = Serv { - devices: Arc::new(RwLock::new(HashMap::new())) + devices: Arc::new(RwLock::new(HashMap::new())), + syslog_client, }; fs_rpc::register_server(Box::new(serv.clone())); devfs_rpc::register_server(Box::new(serv)); @@ -42,6 +58,7 @@ fn main() { } vfs_rpc::Client::new(vfs_pid).register_fs("devfs").unwrap(); syscalls::register(1); + syslog_client.send_text_binary_message("devfs", "Devfs initialized", 0, &[]).unwrap(); loop { ipc::process_messages() }