This commit is contained in:
pjht 2024-08-06 19:38:09 -05:00
parent 511b948482
commit 8340113164
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -15,17 +15,29 @@ fn main() {
let syslog_client = syslog_rpc::Client::new(syslog_pid); 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("devfs".to_string(), vec![0, 1]);
syslog_client.subscribe_to_binary("tarfs".to_string(), vec![0]); 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"); 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"); 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(); syslog_msg_ipc::get_syslog_msg();
let vfs_client = vfs_rpc::Client::new(vfs_pid); let vfs_client = vfs_rpc::Client::new(vfs_pid);
vfs_client.mount(Path::new("/dummy"), "devfs", Path::new("/dev")).unwrap(); vfs_client
syslog_client.send_text_message("init", "Mounted /dev").unwrap(); .mount(Path::new("/dummy"), "devfs", Path::new("/dev"))
.unwrap();
syslog_client
.send_text_message("init", "Mounted /dev")
.unwrap();
run_initrd_proc(&initrd, "bin/tarfs"); 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 { loop {
let msg = syslog_msg_ipc::get_syslog_msg(); let msg = syslog_msg_ipc::get_syslog_msg();
if msg.from == "tarfs" { if msg.from == "tarfs" {
@ -33,30 +45,37 @@ fn main() {
} }
} }
run_initrd_proc(&initrd, "bin/initrd_driver"); 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 { loop {
let msg = syslog_msg_ipc::get_syslog_msg(); let msg = syslog_msg_ipc::get_syslog_msg();
if msg.from == "devfs" { if msg.from == "devfs" {
if let Some(binary) = msg.binary { 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; break;
} }
} }
} }
} }
vfs_client.mount(Path::new("/dev/initrd"), "tarfs", Path::new("/")).unwrap(); vfs_client
syslog_client.send_text_message("init", "Mounted the initrd as the root FS").unwrap(); .mount(Path::new("/dev/initrd"), "tarfs", Path::new("/"))
Command::new("/bin/load_test").spawn().unwrap(); .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 { fn run_initrd_proc(initrd: &TarArchiveRef, path: &str) -> u64 {
let proc = let proc = initrd
initrd .entries()
.entries() .find(|entry| entry.filename().as_str().unwrap() == path)
.find(|entry| entry.filename().as_str().unwrap() == path) .unwrap_or_else(|| panic!("{} not found", path))
.expect(&format!("{} not found", path)) .data();
.data(); let (space, entry) = Loader::load(proc);
let (space, entry) = Loader::load(&proc);
let path_arg = CString::new(path).unwrap(); let path_arg = CString::new(path).unwrap();
new_process(entry as _, space, &[path_arg.as_bytes_with_nul()]).unwrap() new_process(entry as _, space, &[path_arg.as_bytes_with_nul()]).unwrap()
} }