From 13f41e3816bd0be96c9bf728b534a58e6d4e5c28 Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Thu, 14 May 2026 15:41:54 +0200 Subject: add todo --- kernel/src/filesystem/mount_table.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'kernel/src/filesystem/mount_table.cpp') diff --git a/kernel/src/filesystem/mount_table.cpp b/kernel/src/filesystem/mount_table.cpp index 5a49e7a..e0cf140 100644 --- a/kernel/src/filesystem/mount_table.cpp +++ b/kernel/src/filesystem/mount_table.cpp @@ -35,6 +35,7 @@ namespace kernel::filesystem auto mount_table::remove_mount(std::string_view path) -> operation_result { // TODO BA-FS26 check wheter something is open in this mount + // TODO BA-FS26 nearly the same code is in find_exact_mount -> refactor to avoid code duplication auto mount_range = std::ranges::find_last_if(m_mounts, [&](auto const & mount) { return mount->get_mount_path() == path; }); auto mount_it = mount_range.begin(); -- cgit v1.2.3 From fe0b38db0f8848da8cf28bb883e01bbbb889dd0a Mon Sep 17 00:00:00 2001 From: Marcel Braun Date: Thu, 14 May 2026 21:02:25 +0200 Subject: Remove unneeded functionality part 2 --- kernel/src/filesystem/mount_table.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'kernel/src/filesystem/mount_table.cpp') diff --git a/kernel/src/filesystem/mount_table.cpp b/kernel/src/filesystem/mount_table.cpp index e0cf140..4b61fb0 100644 --- a/kernel/src/filesystem/mount_table.cpp +++ b/kernel/src/filesystem/mount_table.cpp @@ -26,10 +26,6 @@ namespace kernel::filesystem { mount_dentry->set_flag(dentry::dentry_flags::is_mount_point); } - if (auto root_dentry = mount->get_root_dentry()) - { - root_dentry->set_flag(dentry::dentry_flags::is_mount_root); - } } auto mount_table::remove_mount(std::string_view path) -> operation_result -- cgit v1.2.3 From 963c926c68aac4606d80743aca8e7b052eee7efe Mon Sep 17 00:00:00 2001 From: Marcel Braun Date: Fri, 15 May 2026 11:42:33 +0200 Subject: Rename mount_table method from find_exact_mount to find_mount --- kernel/src/filesystem/mount_table.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'kernel/src/filesystem/mount_table.cpp') diff --git a/kernel/src/filesystem/mount_table.cpp b/kernel/src/filesystem/mount_table.cpp index 4b61fb0..78ac727 100644 --- a/kernel/src/filesystem/mount_table.cpp +++ b/kernel/src/filesystem/mount_table.cpp @@ -31,7 +31,7 @@ namespace kernel::filesystem auto mount_table::remove_mount(std::string_view path) -> operation_result { // TODO BA-FS26 check wheter something is open in this mount - // TODO BA-FS26 nearly the same code is in find_exact_mount -> refactor to avoid code duplication + // TODO BA-FS26 nearly the same code is in find_mount -> refactor to avoid code duplication auto mount_range = std::ranges::find_last_if(m_mounts, [&](auto const & mount) { return mount->get_mount_path() == path; }); auto mount_it = mount_range.begin(); @@ -52,7 +52,7 @@ namespace kernel::filesystem return operation_result::removed; } - auto mount_table::find_exact_mount(std::string_view path) const -> kstd::shared_ptr + auto mount_table::find_mount(std::string_view path) const -> kstd::shared_ptr { auto mount_range = std::ranges::find_last_if(m_mounts, [&](auto const & mount) { return mount->get_mount_path() == path; }); -- cgit v1.2.3 From 95ff59017db74a6988f791ca9f122254dd743541 Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Fri, 15 May 2026 16:17:50 +0200 Subject: refactor find_mount_iterator to avoid code duplication --- kernel/src/filesystem/mount_table.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'kernel/src/filesystem/mount_table.cpp') diff --git a/kernel/src/filesystem/mount_table.cpp b/kernel/src/filesystem/mount_table.cpp index 78ac727..b582fd9 100644 --- a/kernel/src/filesystem/mount_table.cpp +++ b/kernel/src/filesystem/mount_table.cpp @@ -31,11 +31,7 @@ namespace kernel::filesystem auto mount_table::remove_mount(std::string_view path) -> operation_result { // TODO BA-FS26 check wheter something is open in this mount - // TODO BA-FS26 nearly the same code is in find_mount -> refactor to avoid code duplication - auto mount_range = - std::ranges::find_last_if(m_mounts, [&](auto const & mount) { return mount->get_mount_path() == path; }); - auto mount_it = mount_range.begin(); - + auto mount_it = find_mount_iterator(path); if (mount_it == m_mounts.end()) { return operation_result::mount_not_found; @@ -54,9 +50,14 @@ namespace kernel::filesystem auto mount_table::find_mount(std::string_view path) const -> kstd::shared_ptr { - auto mount_range = - std::ranges::find_last_if(m_mounts, [&](auto const & mount) { return mount->get_mount_path() == path; }); - auto mount_it = mount_range.begin(); + auto mount_it = find_mount_iterator(path); return (mount_it != m_mounts.end()) ? *mount_it : nullptr; } + + auto mount_table::find_mount_iterator(std::string_view path) const + -> kstd::vector>::const_iterator + { + return std::ranges::find_last_if(m_mounts, [&](auto const & mount) { return mount->get_mount_path() == path; }) + .begin(); + } } // namespace kernel::filesystem \ No newline at end of file -- cgit v1.2.3 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_table.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'kernel/src/filesystem/mount_table.cpp') diff --git a/kernel/src/filesystem/mount_table.cpp b/kernel/src/filesystem/mount_table.cpp index b582fd9..9951590 100644 --- a/kernel/src/filesystem/mount_table.cpp +++ b/kernel/src/filesystem/mount_table.cpp @@ -30,7 +30,6 @@ namespace kernel::filesystem auto mount_table::remove_mount(std::string_view path) -> operation_result { - // TODO BA-FS26 check wheter something is open in this mount auto mount_it = find_mount_iterator(path); if (mount_it == m_mounts.end()) { @@ -38,6 +37,10 @@ namespace kernel::filesystem } auto const & mount = *mount_it; + if (!mount->is_ready_to_unmount()) + { + return operation_result::cannot_be_unmounted; + } if (has_child_mounts(mount)) { return operation_result::has_child_mounts; -- cgit v1.2.3