Luna/kernel/src/fs/Mount.cpp
apio e79d4297ea
All checks were successful
continuous-integration/drone/push Build is passing
kernel: Make the root inode be a mountpoint as well + add pivot_root()
2023-06-17 17:27:22 +02:00

31 lines
664 B
C++

#include "fs/Mount.h"
LinkedList<MountInode> g_mounts;
Result<SharedPtr<VFS::Inode>> MountInode::create(SharedPtr<VFS::Inode> source, SharedPtr<VFS::FileSystem> fs)
{
auto inode = TRY(adopt_shared_if_nonnull(new (std::nothrow) MountInode()));
inode->m_mountee = fs;
inode->m_mount_root_inode = fs->root_inode();
if (source)
{
inode->m_source = source;
auto parent = TRY(source->find(".."));
TRY(fs->set_mount_dir(parent));
source->add_handle();
}
g_mounts.append(inode.ptr());
return (SharedPtr<VFS::Inode>)inode;
}
MountInode::~MountInode()
{
if (m_source) m_source->remove_handle();
}