aboutsummaryrefslogtreecommitdiff
path: root/kernel/src/filesystem/mount.cpp
blob: f9e709c530439e865645fbfa8d7ce792d703815a (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "kernel/filesystem/mount.hpp"

#include "kapi/system.hpp"

#include "kernel/filesystem/dentry.hpp"
#include "kernel/filesystem/filesystem.hpp"

#include <kstd/memory>
#include <kstd/string>

#include <string_view>

namespace kernel::filesystem
{
  mount::mount(kstd::shared_ptr<dentry> const & mount_dentry, kstd::shared_ptr<dentry> const & root_dentry,
               kstd::shared_ptr<filesystem> const & fs, std::string_view mount_path)
      : m_mount_path(mount_path)
      , m_mount_dentry(mount_dentry)
      , m_root_dentry(root_dentry)
      , m_filesystem(fs)
  {
    if (!m_filesystem)
    {
      kapi::system::panic("[FILESYSTEM] mount initialized with null filesystem.");
    }
  }

  auto mount::get_mount_dentry() const -> kstd::shared_ptr<dentry>
  {
    return m_mount_dentry;
  }

  auto mount::get_filesystem() const -> kstd::shared_ptr<filesystem> const &
  {
    return m_filesystem;
  }

  auto mount::root_dentry() const -> kstd::shared_ptr<dentry> const &
  {
    return m_root_dentry;
  }

  auto mount::get_mount_path() const -> std::string_view
  {
    return m_mount_path.view();
  }
}  // namespace kernel::filesystem