Format
This commit is contained in:
parent
511b948482
commit
8340113164
49
src/main.rs
49
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
|
||||
let proc = initrd
|
||||
.entries()
|
||||
.find(|entry| entry.filename().as_str().unwrap() == path)
|
||||
.expect(&format!("{} not found", path))
|
||||
.unwrap_or_else(|| panic!("{} not found", path))
|
||||
.data();
|
||||
let (space, entry) = Loader::load(&proc);
|
||||
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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user