blob: 681c2b9a1372f01efbb5b22faad93bb32a10845d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "kernel/filesystem/mount_table.hpp"
#include "kernel/filesystem/dentry.hpp"
#include "kernel/filesystem/mount.hpp"
#include <kstd/memory>
#include <algorithm>
namespace filesystem
{
void mount_table::add_mount(kstd::shared_ptr<mount> mount)
{
m_mounts.push_back(mount);
}
auto mount_table::get_root_mount() const -> kstd::shared_ptr<mount>
{
auto it = std::ranges::find_if(m_mounts, [](auto const & mount) { return mount->get_mount_dentry() == nullptr; });
return it != m_mounts.end() ? *it : nullptr;
}
auto mount_table::find_mount_by_dentry(kstd::shared_ptr<dentry> const & dentry) -> kstd::shared_ptr<mount>
{
auto it = std::ranges::find_if(m_mounts, [&](auto const & mnt) { return mnt->get_mount_dentry() == dentry; });
return it != m_mounts.end() ? *it : nullptr;
}
} // namespace filesystem
|