bootstrap: Move computation of schemes from initnsmgr to main

This commit is contained in:
bjorn3
2026-02-07 20:22:12 +01:00
parent a04626044e
commit 9ec0733951
2 changed files with 12 additions and 19 deletions
+11 -7
View File
@@ -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)
},
);
+1 -12
View File
@@ -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<String, Arc<FdGuard>>,
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