Log register_fs, mount, and unmount
This commit is contained in:
parent
35b8f3b441
commit
cf7852bb94
17
Cargo.lock
generated
17
Cargo.lock
generated
@ -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",
|
||||
]
|
||||
|
||||
|
@ -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]
|
||||
|
12
src/main.rs
12
src/main.rs
@ -11,10 +11,12 @@ struct Serv {
|
||||
fs_map: RwLock<HashMap<String, u64>>,
|
||||
mount_list: RwLock<HashMap<PathBuf, (u64, u64)>>,
|
||||
process_stdio: RwLock<HashMap<u64, [Option<(u64, u64)>; 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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user