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.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/kernel/src/filesystem/mount_table.cpp b/kernel/src/filesystem/mount_table.cpp
index 5a49e7a..9951590 100644
--- a/kernel/src/filesystem/mount_table.cpp
+++ b/kernel/src/filesystem/mount_table.cpp
@@ -26,25 +26,21 @@ 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
{
- // TODO BA-FS26 check wheter something is open in this mount
- 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;
}
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;
@@ -55,11 +51,16 @@ namespace kernel::filesystem
return operation_result::removed;
}
- auto mount_table::find_exact_mount(std::string_view path) const -> kstd::shared_ptr<mount>
+ auto mount_table::find_mount(std::string_view path) const -> kstd::shared_ptr<mount>
{
- 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<kstd::shared_ptr<mount>>::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