aboutsummaryrefslogtreecommitdiff
path: root/kernel/src/filesystem/mount_table.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/src/filesystem/mount_table.cpp')
-rw-r--r--kernel/src/filesystem/mount_table.cpp79
1 files changed, 0 insertions, 79 deletions
diff --git a/kernel/src/filesystem/mount_table.cpp b/kernel/src/filesystem/mount_table.cpp
deleted file mode 100644
index e4baac7a..00000000
--- a/kernel/src/filesystem/mount_table.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-#include <kernel/filesystem/mount_table.hpp>
-
-#include <kernel/filesystem/dentry.hpp>
-#include <kernel/filesystem/mount.hpp>
-
-#include <kstd/memory>
-#include <kstd/vector>
-
-#include <algorithm>
-#include <ranges>
-#include <string_view>
-
-namespace kernel::filesystem
-{
- auto mount_table::has_child_mounts(kstd::shared_ptr<mount> const & parent_mount) const -> bool
- {
- return std::ranges::any_of(m_mounts,
- [&parent_mount](auto const & mount) { return mount->parent_mount() == parent_mount; });
- }
-
- auto mount_table::add_mount(kstd::shared_ptr<mount> const & mount) -> void
- {
- m_mounts.push_back(mount);
-
- if (auto source_mount = mount->source_mount())
- {
- source_mount->increment_ref_count();
- }
-
- if (auto mount_dentry = mount->mount_dentry())
- {
- mount_dentry->set_flag(dentry::dentry_flags::is_mount_point);
- }
- }
-
- auto mount_table::remove_mount(std::string_view path) -> operation_result
- {
- auto mount_it = find_mount_iterator(path);
- if (mount_it == m_mounts.end())
- {
- return operation_result::mount_not_found;
- }
-
- 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;
- }
-
- if (auto source_mount = mount->source_mount())
- {
- source_mount->decrement_ref_count();
- }
-
- if (auto mount_dentry = mount->mount_dentry())
- {
- mount_dentry->unset_flag(dentry::dentry_flags::is_mount_point);
- }
-
- m_mounts.erase(mount_it);
- return operation_result::removed;
- }
-
- auto mount_table::find_mount(std::string_view path) const -> kstd::shared_ptr<mount>
- {
- 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<kstd::shared_ptr<mount>>::const_iterator
- {
- return std::ranges::find_last_if(m_mounts, [&](auto const & mount) { return mount->mount_path() == path; }).begin();
- }
-} // namespace kernel::filesystem \ No newline at end of file