From 83401131645e99f734b96cd3db3b891f38259d55 Mon Sep 17 00:00:00 2001 From: pjht Date: Tue, 6 Aug 2024 19:38:09 -0500 Subject: [PATCH] Format --- src/main.rs | 55 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index 49d5629..d07585a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,17 +15,29 @@ fn main() { let syslog_client = syslog_rpc::Client::new(syslog_pid); syslog_client.subscribe_to_binary("devfs".to_string(), vec![0, 1]); syslog_client.subscribe_to_binary("tarfs".to_string(), vec![0]); - syslog_client.send_text_message("init", "Started syslog").unwrap(); + syslog_client + .send_text_message("init", "Started syslog") + .unwrap(); let vfs_pid = run_initrd_proc(&initrd, "bin/vfs"); - syslog_client.send_text_message("init", "Started the VFS").unwrap(); + syslog_client + .send_text_message("init", "Started the VFS") + .unwrap(); run_initrd_proc(&initrd, "bin/devfs"); - syslog_client.send_text_message("init", "Started the devfs").unwrap(); + syslog_client + .send_text_message("init", "Started the devfs") + .unwrap(); syslog_msg_ipc::get_syslog_msg(); let vfs_client = vfs_rpc::Client::new(vfs_pid); - vfs_client.mount(Path::new("/dummy"), "devfs", Path::new("/dev")).unwrap(); - syslog_client.send_text_message("init", "Mounted /dev").unwrap(); + vfs_client + .mount(Path::new("/dummy"), "devfs", Path::new("/dev")) + .unwrap(); + syslog_client + .send_text_message("init", "Mounted /dev") + .unwrap(); run_initrd_proc(&initrd, "bin/tarfs"); - syslog_client.send_text_message("init", "Started the tar archive FS").unwrap(); + syslog_client + .send_text_message("init", "Started the tar archive FS") + .unwrap(); loop { let msg = syslog_msg_ipc::get_syslog_msg(); if msg.from == "tarfs" { @@ -33,30 +45,37 @@ fn main() { } } run_initrd_proc(&initrd, "bin/initrd_driver"); - syslog_client.send_text_message("init", "Started the initrd pseudodevice driver").unwrap(); + syslog_client + .send_text_message("init", "Started the initrd pseudodevice driver") + .unwrap(); loop { let msg = syslog_msg_ipc::get_syslog_msg(); if msg.from == "devfs" { if let Some(binary) = msg.binary { - if binary.kind == 1 && std::str::from_utf8(binary.data.as_slice()).unwrap() == "initrd" { + if binary.kind == 1 + && std::str::from_utf8(binary.data.as_slice()).unwrap() == "initrd" + { break; } } } } - vfs_client.mount(Path::new("/dev/initrd"), "tarfs", Path::new("/")).unwrap(); - syslog_client.send_text_message("init", "Mounted the initrd as the root FS").unwrap(); - Command::new("/bin/load_test").spawn().unwrap(); + vfs_client + .mount(Path::new("/dev/initrd"), "tarfs", Path::new("/")) + .unwrap(); + syslog_client + .send_text_message("init", "Mounted the initrd as the root FS") + .unwrap(); + Command::new("/bin/pci").spawn().unwrap(); } fn run_initrd_proc(initrd: &TarArchiveRef, path: &str) -> u64 { - let proc = - initrd - .entries() - .find(|entry| entry.filename().as_str().unwrap() == path) - .expect(&format!("{} not found", path)) - .data(); - let (space, entry) = Loader::load(&proc); + let proc = initrd + .entries() + .find(|entry| entry.filename().as_str().unwrap() == path) + .unwrap_or_else(|| panic!("{} not found", path)) + .data(); + let (space, entry) = Loader::load(proc); let path_arg = CString::new(path).unwrap(); new_process(entry as _, space, &[path_arg.as_bytes_with_nul()]).unwrap() }