#include #include #include #include #include #include #include namespace kernel::filesystem { mount::mount(kstd::shared_ptr const & mount_dentry, kstd::shared_ptr const & root_dentry, kstd::shared_ptr const & fs, kstd::shared_ptr const & parent_mount) : m_mount_dentry(mount_dentry) , m_root_dentry(root_dentry) , m_filesystem(fs) , m_parent_mount(parent_mount) , m_ref_count(0) { if (!m_filesystem) { kapi::system::panic("[FILESYSTEM] mount initialized with null filesystem."); } } auto mount::get_mount_dentry() const -> kstd::shared_ptr const & { return m_mount_dentry; } auto mount::get_filesystem() const -> kstd::shared_ptr const & { return m_filesystem; } auto mount::get_root_dentry() const -> kstd::shared_ptr const & { return m_root_dentry; } auto mount::get_mount_path() const -> kstd::string { if (m_mount_dentry) { return m_mount_dentry->get_absolute_path(); } return "/"; } auto mount::get_parent_mount() const -> kstd::shared_ptr const & { return m_parent_mount; } auto mount::increment_ref_count() -> void { m_ref_count += 1; } auto mount::decrement_ref_count() -> bool { if (m_ref_count == 0) { return false; } m_ref_count -= 1; return true; } auto mount::is_ready_to_unmount() const -> bool { return m_ref_count == 0; } } // namespace kernel::filesystem