Start working on a VFS implementation #22
@ -48,6 +48,8 @@ namespace VFS
|
||||
|
||||
virtual Result<SharedPtr<Inode>> create_file_inode() = 0;
|
||||
|
||||
virtual Result<SharedPtr<Inode>> create_dir_inode() = 0;
|
||||
|
||||
virtual ~FileSystem() = default;
|
||||
};
|
||||
|
||||
|
@ -7,7 +7,7 @@ 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_file_inode());
|
||||
SharedPtr<VFS::Inode> root = TRY(fs->create_dir_inode());
|
||||
fs->set_root(root);
|
||||
return (SharedPtr<VFS::FileSystem>)fs;
|
||||
}
|
||||
@ -22,6 +22,16 @@ namespace TmpFS
|
||||
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;
|
||||
|
@ -15,6 +15,7 @@ namespace TmpFS
|
||||
}
|
||||
|
||||
Result<SharedPtr<VFS::Inode>> create_file_inode() override;
|
||||
Result<SharedPtr<VFS::Inode>> create_dir_inode() override;
|
||||
|
||||
static Result<SharedPtr<VFS::FileSystem>> create();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user