Use the new scheme format

This commit is contained in:
bjorn3
2024-07-11 21:02:40 +02:00
parent c39ee5a8b4
commit 88338f36f2
2 changed files with 12 additions and 7 deletions
+9 -4
View File
@@ -10,7 +10,9 @@ pub fn main() -> ! {
let envs = {
let mut env = [0_u8; 4096];
let fd = FdGuard::new(syscall::open("sys:env", O_RDONLY).expect("bootstrap: failed to open env"));
let fd = FdGuard::new(
syscall::open("/scheme/sys/env", O_RDONLY).expect("bootstrap: failed to open env"),
);
let bytes_read = syscall::read(*fd, &mut env).expect("bootstrap: failed to read env");
if bytes_read >= env.len() {
@@ -49,8 +51,11 @@ pub fn main() -> ! {
let total_args_envs_auxvpointee_size = path.len() + 1 + envs.len() + envs.iter().map(|v| v.len()).sum::<usize>() + CWD.len() + 1;
let image_file = FdGuard::new(syscall::open(path, O_RDONLY).expect("failed to open init"));
let open_via_dup = FdGuard::new(syscall::open("thisproc:current/open_via_dup", 0).expect("failed to open open_via_dup"));
let memory = FdGuard::new(syscall::open("memory:", 0).expect("failed to open memory"));
let open_via_dup = FdGuard::new(
syscall::open("/scheme/thisproc/current/open_via_dup", 0)
.expect("failed to open open_via_dup"),
);
let memory = FdGuard::new(syscall::open("/scheme/memory", 0).expect("failed to open memory"));
fexec_impl(image_file, open_via_dup, &memory, path.as_bytes(), [path], envs.iter(), total_args_envs_auxvpointee_size, &extrainfo, None).expect("failed to execute init");
@@ -58,7 +63,7 @@ pub fn main() -> ! {
}
unsafe fn spawn_initfs(initfs_start: *const u8, initfs_length: usize) {
let read = syscall::open("pipe:", O_CLOEXEC).expect("failed to open sync read pipe");
let read = syscall::open("/scheme/pipe", O_CLOEXEC).expect("failed to open sync read pipe");
// The write pipe will not inherit O_CLOEXEC, but is closed by the daemon later.
let write = syscall::dup(read, b"write").expect("failed to open sync write pipe");
+3 -3
View File
@@ -31,9 +31,9 @@ pub unsafe extern "C" fn start() -> ! {
let (rodata_start, rodata_end) = offsets::rodata();
let (data_start, data_end) = offsets::data_and_bss();
let _ = syscall::open("debug:", syscall::O_RDONLY); // stdin
let _ = syscall::open("debug:", syscall::O_WRONLY); // stdout
let _ = syscall::open("debug:", syscall::O_WRONLY); // stderr
let _ = syscall::open("/scheme/debug", syscall::O_RDONLY); // stdin
let _ = syscall::open("/scheme/debug", syscall::O_WRONLY); // stdout
let _ = syscall::open("/scheme/debug", syscall::O_WRONLY); // stderr
let _ = syscall::mprotect(4096, 4096, MapFlags::PROT_READ | MapFlags::MAP_PRIVATE).expect("mprotect failed for initfs header page");