From 1d647adb1ba20121eeb5c8e4470f48b2e972b3d4 Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Fri, 15 May 2026 16:50:55 +0200 Subject: Mount can only be unmounted if no references are present, increment references on open file and decrement on close file --- kernel/src/filesystem/mount.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'kernel/src/filesystem/mount.cpp') diff --git a/kernel/src/filesystem/mount.cpp b/kernel/src/filesystem/mount.cpp index 749c86a..3016509 100644 --- a/kernel/src/filesystem/mount.cpp +++ b/kernel/src/filesystem/mount.cpp @@ -18,6 +18,7 @@ namespace kernel::filesystem , m_root_dentry(root_dentry) , m_filesystem(fs) , m_parent_mount(parent_mount) + , m_ref_count(0) { if (!m_filesystem) { @@ -53,4 +54,25 @@ namespace kernel::filesystem { return m_parent_mount; } + + auto mount::increment_ref_count() -> void + { + m_ref_count += 1; + } + + auto mount::decrement_ref_count() -> bool + { + if (m_ref_count == 0) + { + return false; + } + + m_ref_count -= 1; + return true; + } + + auto mount::is_ready_to_unmount() const -> bool + { + return m_ref_count == 0; + } } // namespace kernel::filesystem \ No newline at end of file -- cgit v1.2.3