From c0c002bfbc405bcd629fc51f32bb1cf7d27e21c6 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 7 Feb 2026 18:54:18 +0100 Subject: [PATCH] bootstrap: Remove Arc around KernelSchemeMap --- bootstrap/src/exec.rs | 19 ++++++------------- bootstrap/src/initnsmgr.rs | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/bootstrap/src/exec.rs b/bootstrap/src/exec.rs index 9cb2e15fcb..f005640af7 100644 --- a/bootstrap/src/exec.rs +++ b/bootstrap/src/exec.rs @@ -1,4 +1,3 @@ -use alloc::sync::Arc; use alloc::vec::Vec; use core::ffi::CStr; use core::str::FromStr; @@ -61,7 +60,6 @@ pub fn main() -> ! { let pipe_fd = *kernel_schemes .get(GlobalSchemes::Pipe) .expect("failed to get pipe fd"); - let infos_arc = Arc::new(kernel_schemes); let this_thr_fd = auth .dup(b"cur-context") @@ -74,7 +72,7 @@ pub fn main() -> ! { let mut envs = { let fd = FdGuard::new( syscall::openat( - *infos_arc + *kernel_schemes .get(GlobalSchemes::Sys) .expect("failed to get sys fd"), "env", @@ -124,13 +122,12 @@ pub fn main() -> ! { (*(core::ptr::addr_of!(__initfs_header) as *const redox_initfs::types::Header)).initfs_size }; - let infos_arc_clone = infos_arc.clone(); let initfs_fd = spawn( "initfs daemon", &auth, &this_thr_fd, pipe_fd, - move |write_fd| unsafe { + |write_fd| unsafe { // Creating a reference to NULL is UB. Mask the UB for now using black_box. // FIXME use a raw pointer and inline asm for reading instead for the initfs header. let initfs_start = core::ptr::addr_of!(__initfs_header); @@ -139,31 +136,29 @@ pub fn main() -> ! { crate::initfs::run( core::slice::from_raw_parts(initfs_start, initfs_length), write_fd, - &infos_arc_clone, + &kernel_schemes, scheme_creation_cap, ); }, ); - let infos_arc_clone = infos_arc.clone(); let proc_fd = spawn( "process manager", &auth, &this_thr_fd, pipe_fd, - |write_fd| crate::procmgr::run(write_fd, &auth, &infos_arc_clone, scheme_creation_cap), + |write_fd| crate::procmgr::run(write_fd, &auth, &kernel_schemes, scheme_creation_cap), ); - let infos_arc_clone = infos_arc.clone(); let initns_fd = spawn( "init namespace manager", &auth, &this_thr_fd, pipe_fd, - |write_fd| { + move |write_fd| { crate::initnsmgr::run( write_fd, - &infos_arc_clone, + kernel_schemes, initfs_fd, proc_fd, scheme_creation_cap, @@ -193,8 +188,6 @@ pub fn main() -> ! { .to_upper() .unwrap(); - drop(infos_arc); - let exe_path = alloc::format!("/scheme/initfs{}", path); let FexecResult::Interp { diff --git a/bootstrap/src/initnsmgr.rs b/bootstrap/src/initnsmgr.rs index 335ce111b2..3a5dfff3ba 100644 --- a/bootstrap/src/initnsmgr.rs +++ b/bootstrap/src/initnsmgr.rs @@ -489,7 +489,7 @@ where pub fn run( sync_pipe: usize, - kernel_schemes: &KernelSchemeMap, + kernel_schemes: KernelSchemeMap, initfs_cap: usize, proc_cap: usize, scheme_creation_cap: usize,