diff --git a/bootstrap/src/exec.rs b/bootstrap/src/exec.rs index 84931075e0..ab64c0be03 100644 --- a/bootstrap/src/exec.rs +++ b/bootstrap/src/exec.rs @@ -53,6 +53,8 @@ pub fn main() -> ! { FdGuard::new(*(base_ptr as *const usize)) }; + let cur_context_idx = scheme_creation_cap.as_raw_fd() + 1; + let mut kernel_schemes = KernelSchemeMap::new(kernel_scheme_infos); let auth = kernel_schemes @@ -60,8 +62,8 @@ pub fn main() -> ! { .remove(&GlobalSchemes::Proc) .expect("failed to get proc fd"); - let this_thr_fd = auth - .dup(b"cur-context") + let this_thr_fd = syscall::dup_into(auth.as_raw_fd(), cur_context_idx, b"cur-context") + .map(FdGuard::new) .expect("failed to open open_via_dup") .to_upper() .unwrap(); diff --git a/bootstrap/src/start.rs b/bootstrap/src/start.rs index e551071448..e51cc8d392 100644 --- a/bootstrap/src/start.rs +++ b/bootstrap/src/start.rs @@ -35,10 +35,6 @@ mod offsets { } } -fn dbg(msg: &[u8]) { - let _ = libredox::call::write(1, msg); -} - #[unsafe(no_mangle)] pub unsafe extern "C" fn start() -> ! { let (text_start, text_end) = offsets::text(); @@ -46,18 +42,14 @@ pub unsafe extern "C" fn start() -> ! { let (data_start, data_end) = offsets::data_and_bss(); let debug_fd = syscall::UPPER_FDTBL_TAG + syscall::data::GlobalSchemes::Debug as usize; - let _ = libredox::call::openat(debug_fd, "", syscall::O_RDONLY as i32, 0); - let _ = libredox::call::openat(debug_fd, "", syscall::O_WRONLY as i32, 0); - let _ = libredox::call::openat(debug_fd, "", syscall::O_WRONLY as i32, 0); - - dbg(b"BS:0\n"); + let _ = syscall::openat_into(debug_fd, 0, "", syscall::O_RDONLY, 0); + let _ = syscall::openat_into(debug_fd, 1, "", syscall::O_WRONLY, 0); + let _ = syscall::openat_into(debug_fd, 2, "", syscall::O_WRONLY, 0); unsafe { let _ = syscall::mprotect(4096, 4096, MapFlags::PROT_READ | MapFlags::MAP_PRIVATE) .expect("mprotect failed for initfs header page"); - dbg(b"BS:1\n"); - let _ = syscall::mprotect( text_start, text_end - text_start, @@ -65,8 +57,6 @@ pub unsafe extern "C" fn start() -> ! { ) .expect("mprotect failed for .text"); - dbg(b"BS:2\n"); - let _ = syscall::mprotect( rodata_start, rodata_end - rodata_start, @@ -74,8 +64,6 @@ pub unsafe extern "C" fn start() -> ! { ) .expect("mprotect failed for .rodata"); - dbg(b"BS:3\n"); - let _ = syscall::mprotect( data_start, data_end - data_start, @@ -83,8 +71,6 @@ pub unsafe extern "C" fn start() -> ! { ) .expect("mprotect failed for .data/.bss"); - dbg(b"BS:4\n"); - let _ = syscall::mprotect( data_end, crate::arch::STACK_START - data_end, @@ -93,6 +79,5 @@ pub unsafe extern "C" fn start() -> ! { .expect("mprotect failed for rest of memory"); } - dbg(b"BS:5\n"); crate::exec::main(); }