From d3125dee241cd68ace6069537d36d32fc709b945 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 28 Aug 2026 16:40:11 +0200 Subject: kernel/vfs: add identity based mount removal --- kernel/kernel/vfs/mount_table.cpp | 12 +++++++++++- kernel/kernel/vfs/mount_table.hpp | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'kernel') diff --git a/kernel/kernel/vfs/mount_table.cpp b/kernel/kernel/vfs/mount_table.cpp index 1609bc36..01127697 100644 --- a/kernel/kernel/vfs/mount_table.cpp +++ b/kernel/kernel/vfs/mount_table.cpp @@ -44,6 +44,16 @@ namespace kernel::vfs } auto const & mount = *mount_it; + return remove_mount(mount); + } + + auto mount_table::remove_mount(kstd::shared_ptr const & mount) -> kstd::result + { + if (!mount) + { + return kstd::failure(errc::invalid_argument); + } + if (!mount->is_ready_to_unmount()) { return kstd::failure(errc::mount_busy); @@ -63,7 +73,7 @@ namespace kernel::vfs mount_dentry->unset_flag(dentry::dentry_flags::is_mount_point); } - m_mounts.erase(mount_it); + kstd::erase(m_mounts, mount); return kstd::success(); } diff --git a/kernel/kernel/vfs/mount_table.hpp b/kernel/kernel/vfs/mount_table.hpp index cb44c533..140aebac 100644 --- a/kernel/kernel/vfs/mount_table.hpp +++ b/kernel/kernel/vfs/mount_table.hpp @@ -25,6 +25,12 @@ namespace kernel::vfs //! @return Nothing on success, an error otherwise. [[nodiscard]] auto remove_mount(std::string_view path) -> kstd::result; + //! Remove the given mount. + //! + //! @param path The mount path to remove. + //! @return Nothing on success, an error otherwise. + [[nodiscard]] auto remove_mount(kstd::shared_ptr const & mount) -> kstd::result; + //! Find the mount with the exact mount path matching the given path. //! //! @param path The path to match against the mount paths in the table. -- cgit v1.2.3