Luna/kernel/src/fs/tmpfs/FileSystem.cpp

34 lines
722 B
C++
Raw Normal View History

#include "fs/tmpfs/FileSystem.h"
#include <luna/Alloc.h>
namespace TmpFS
{
Result<SharedPtr<VFS::FileSystem>> FileSystem::create()
{
SharedPtr<Inode> root = TRY(make_shared<Inode>());
SharedPtr<FileSystem> fs = TRY(adopt_shared(new (std::nothrow) FileSystem()));
root->set_fs(*fs, {});
TRY(fs->set_root(root));
return (SharedPtr<VFS::FileSystem>)fs;
}
FileSystem::FileSystem()
{
}
Result<void> FileSystem::set_root(SharedPtr<VFS::Inode> root)
{
m_root_inode = root;
return m_inodes.try_append(root);
}
Inode::Inode()
{
}
void Inode::set_fs(FileSystem& fs, Badge<FileSystem>)
{
m_fs = &fs;
}
}