Send messages to syslog on init and device registration
This commit is contained in:
parent
04cf7b8f6a
commit
9f3136724a
17
Cargo.lock
generated
17
Cargo.lock
generated
@ -64,6 +64,7 @@ dependencies = [
|
|||||||
"devfs_rpc",
|
"devfs_rpc",
|
||||||
"fs_rpc",
|
"fs_rpc",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
|
"syslog_rpc",
|
||||||
"vfs_rpc",
|
"vfs_rpc",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -265,6 +266,22 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"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]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.12"
|
version = "1.0.12"
|
||||||
|
@ -8,6 +8,7 @@ dev_driver_rpc = { version = "0.1.0", path = "../dev_driver_rpc" }
|
|||||||
devfs_rpc = { version = "0.1.0", path = "devfs_rpc" }
|
devfs_rpc = { version = "0.1.0", path = "devfs_rpc" }
|
||||||
fs_rpc = { version = "0.1.0", path = "../fs_rpc" }
|
fs_rpc = { version = "0.1.0", path = "../fs_rpc" }
|
||||||
parking_lot = "0.12.3"
|
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" }
|
vfs_rpc = { version = "0.1.0", path = "../vfs/vfs_rpc" }
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
|
19
src/main.rs
19
src/main.rs
@ -5,6 +5,7 @@ use parking_lot::RwLock;
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct Serv {
|
struct Serv {
|
||||||
devices: Arc<RwLock<HashMap<String, u64>>>,
|
devices: Arc<RwLock<HashMap<String, u64>>>,
|
||||||
|
syslog_client: syslog_rpc::Client,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fs_rpc::Server for Serv {
|
impl fs_rpc::Server for Serv {
|
||||||
@ -23,13 +24,28 @@ impl fs_rpc::Server for Serv {
|
|||||||
impl devfs_rpc::Server for Serv {
|
impl devfs_rpc::Server for Serv {
|
||||||
fn register_dev(&self, from: u64, name: &str) -> Result<(), ()> {
|
fn register_dev(&self, from: u64, name: &str) -> Result<(), ()> {
|
||||||
self.devices.write().insert(name.to_owned(), from);
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
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 {
|
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()));
|
fs_rpc::register_server(Box::new(serv.clone()));
|
||||||
devfs_rpc::register_server(Box::new(serv));
|
devfs_rpc::register_server(Box::new(serv));
|
||||||
@ -42,6 +58,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
vfs_rpc::Client::new(vfs_pid).register_fs("devfs").unwrap();
|
vfs_rpc::Client::new(vfs_pid).register_fs("devfs").unwrap();
|
||||||
syscalls::register(1);
|
syscalls::register(1);
|
||||||
|
syslog_client.send_text_binary_message("devfs", "Devfs initialized", 0, &[]).unwrap();
|
||||||
loop {
|
loop {
|
||||||
ipc::process_messages()
|
ipc::process_messages()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user