From 6a10af6f773ef785048883e266ea193884e80dd9 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 7 Mar 2026 21:42:46 +0100 Subject: [PATCH] Fully remove the broken support for unmounting schemes It has been broken since we moved namespaces into userspace. Fixing it can be done entirely inside userspace. Either by introducing a SYS_CALL for the root capability or by treating closing the last fd as unmount. --- src/scheme/user.rs | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/src/scheme/user.rs b/src/scheme/user.rs index c3c3b6ba86..6085d17afe 100644 --- a/src/scheme/user.rs +++ b/src/scheme/user.rs @@ -2,12 +2,7 @@ use alloc::{ sync::{Arc, Weak}, vec::Vec, }; -use core::{ - mem, - mem::size_of, - num::NonZeroUsize, - sync::atomic::{AtomicBool, Ordering}, -}; +use core::{mem, mem::size_of, num::NonZeroUsize}; use slab::Slab; use spin::{Mutex, RwLock}; use syscall::{ @@ -50,8 +45,6 @@ pub struct UserInner { // TODO: custom packed radix tree data structure states: Mutex>, - - unmounting: AtomicBool, } enum State { @@ -166,25 +159,10 @@ impl UserInner { scheme_id, context, todo: WaitQueue::new(), - unmounting: AtomicBool::new(false), states: Mutex::new(Slab::with_capacity(32)), } } - pub fn unmount(&self, token: &mut CleanLockToken) -> Result<()> { - // First, block new requests and prepare to return EOF - self.unmounting.store(true, Ordering::SeqCst); - - // Wake up any blocked scheme handler - unsafe { self.todo.condition.notify_signal(token) }; - - // Tell the scheme handler to read - event::trigger(self.root_id, self.scheme_id.get(), EVENT_READ, token); - - //TODO: wait for all todo and done to be processed? - Ok(()) - } - fn next_id(&self) -> Result { let idx = { let mut states = self.states.lock(); @@ -230,10 +208,6 @@ impl UserInner { caller_responsible: &mut PageSpan, token: &mut CleanLockToken, ) -> Result { - if self.unmounting.load(Ordering::SeqCst) { - return Err(Error::new(ENODEV)); - } - { // Disable preemption to avoid context switches between setting the // process state and sending the scheme request. The process is made @@ -704,17 +678,12 @@ impl UserInner { // If O_NONBLOCK is used, do not block let nonblock = flags & O_NONBLOCK as u32 != 0; - // If unmounting, do not block so that EOF can be returned immediately - let block = !(nonblock || self.unmounting.load(Ordering::SeqCst)); - match self .todo - .receive_into_user(buf, block, "UserInner::read (v2)", token) + .receive_into_user(buf, !nonblock, "UserInner::read (v2)", token) { // If we received requests, return them to the scheme handler Ok(byte_count) => Ok(byte_count), - // If there were no requests and we were unmounting, return EOF - Err(Error { errno: EAGAIN }) if self.unmounting.load(Ordering::SeqCst) => Ok(0), // If there were no requests and O_NONBLOCK was used (EAGAIN), or some other error // occurred, return that. Err(error) => Err(error),