diff --git a/bootstrap/src/exec.rs b/bootstrap/src/exec.rs index 1120077cb4..d5100fe5bc 100644 --- a/bootstrap/src/exec.rs +++ b/bootstrap/src/exec.rs @@ -1,6 +1,9 @@ +use alloc::string::ToString; +use alloc::sync::Arc; use alloc::vec::Vec; use core::ffi::CStr; use core::str::FromStr; +use hashbrown::HashMap; use syscall::CallFlags; use syscall::data::{GlobalSchemes, KernelSchemeInfo}; @@ -156,13 +159,14 @@ pub fn main() -> ! { &this_thr_fd, pipe_fd, move |write_fd| { - crate::initnsmgr::run( - write_fd, - kernel_schemes, - initfs_fd, - proc_fd, - scheme_creation_cap, - ) + let mut schemes = HashMap::default(); + for (scheme, fd) in kernel_schemes.0.into_iter() { + schemes.insert(scheme.as_str().to_string(), Arc::new(FdGuard::new(fd))); + } + schemes.insert("proc".to_string(), Arc::new(FdGuard::new(proc_fd))); + schemes.insert("initfs".to_string(), Arc::new(FdGuard::new(initfs_fd))); + + crate::initnsmgr::run(write_fd, schemes, scheme_creation_cap) }, ); diff --git a/bootstrap/src/initnsmgr.rs b/bootstrap/src/initnsmgr.rs index e7de6f8d68..74bba3f50e 100644 --- a/bootstrap/src/initnsmgr.rs +++ b/bootstrap/src/initnsmgr.rs @@ -1,5 +1,3 @@ -use super::KernelSchemeMap; - use alloc::rc::Rc; use alloc::string::{String, ToString}; use alloc::sync::Arc; @@ -491,21 +489,12 @@ where pub fn run( sync_pipe: FdGuard, - kernel_schemes: KernelSchemeMap, - initfs_cap: usize, - proc_cap: usize, + schemes: HashMap>, scheme_creation_cap: usize, ) -> ! { let socket = Socket::create_inner(scheme_creation_cap, false) .expect("failed to open init namespace scheme socket"); - let mut schemes = HashMap::default(); - for (scheme, fd) in kernel_schemes.0.into_iter() { - schemes.insert(scheme.as_str().to_string(), Arc::new(FdGuard::new(fd))); - } - schemes.insert("proc".to_string(), Arc::new(FdGuard::new(proc_cap))); - schemes.insert("initfs".to_string(), Arc::new(FdGuard::new(initfs_cap))); - let mut scheme = NamespaceScheme::new(&socket, schemes, FdGuard::new(scheme_creation_cap)); // send namespace fd to bootstrap