diff options
| author | Marcel Braun <marcel.braun@ost.ch> | 2026-05-16 14:20:38 +0200 |
|---|---|---|
| committer | Marcel Braun <marcel.braun@ost.ch> | 2026-05-16 14:20:38 +0200 |
| commit | 106e9731aaf856f940592c02953e49a496555822 (patch) | |
| tree | f3916a9865d03ebb574bac7d5496f6ec85d638ed /kernel/src/filesystem/mount_table.cpp | |
| parent | d22812dbf54a9fd8ecd558a94bf4ee789caf8011 (diff) | |
| parent | 5b40e4a28307eed814adb46188c3f6783651d286 (diff) | |
| download | kernel-106e9731aaf856f940592c02953e49a496555822.tar.xz kernel-106e9731aaf856f940592c02953e49a496555822.zip | |
Merge branch 'mount-reference-count' into 'develop-BA-FS26'
Mount reference count
See merge request teachos/kernel!37
Diffstat (limited to 'kernel/src/filesystem/mount_table.cpp')
| -rw-r--r-- | kernel/src/filesystem/mount_table.cpp | 27 |
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 |
