aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-08-28 16:40:11 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-08-28 16:40:11 +0200
commitd3125dee241cd68ace6069537d36d32fc709b945 (patch)
treec0eaa73105af4264310654e87fe922b063145e32
parentb93a61ce7aca1831a2e81b7bd8d5870d86554f71 (diff)
downloadkernel-d3125dee241cd68ace6069537d36d32fc709b945.tar.xz
kernel-d3125dee241cd68ace6069537d36d32fc709b945.zip
kernel/vfs: add identity based mount removal
-rw-r--r--kernel/kernel/vfs/mount_table.cpp12
-rw-r--r--kernel/kernel/vfs/mount_table.hpp6
2 files changed, 17 insertions, 1 deletions
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<mount> const & mount) -> kstd::result<void>
+ {
+ 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<void>;
+ //! 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<mount> const & mount) -> kstd::result<void>;
+
//! 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.