34 lines
722 B
C++
34 lines
722 B
C++
#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;
|
|
}
|
|
}
|