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

46 lines
1.3 KiB
C++
Raw Normal View History

#include "fs/tmpfs/FileSystem.h"
#include <luna/Alloc.h>
2023-02-25 18:06:50 +00:00
#include <luna/Ignore.h>
namespace TmpFS
{
Result<SharedPtr<VFS::FileSystem>> FileSystem::create()
{
SharedPtr<FileSystem> fs = TRY(adopt_shared(new (std::nothrow) FileSystem()));
SharedPtr<VFS::Inode> root = TRY(fs->create_dir_inode());
fs->set_root(root);
return (SharedPtr<VFS::FileSystem>)fs;
}
Result<SharedPtr<VFS::Inode>> FileSystem::create_file_inode()
{
SharedPtr<FileInode> inode = TRY(make_shared<FileInode>());
inode->set_fs(*this, {});
inode->set_inode_number(m_next_inode_number, {});
TRY(m_inodes.try_append(inode));
m_next_inode_number++;
return (SharedPtr<VFS::Inode>)inode;
}
Result<SharedPtr<VFS::Inode>> FileSystem::create_dir_inode()
{
SharedPtr<DirInode> inode = TRY(make_shared<DirInode>());
inode->set_fs(*this, {});
inode->set_inode_number(m_next_inode_number, {});
TRY(m_inodes.try_append(inode));
m_next_inode_number++;
return (SharedPtr<VFS::Inode>)inode;
}
void FileSystem::set_root(SharedPtr<VFS::Inode> root)
{
m_root_inode = root;
}
2023-02-25 18:06:50 +00:00
Result<SharedPtr<VFS::Inode>> DirInode::find(const char* name) const
{
ignore(name);
todo();
}
}