tmpfs: make the root inode a DirInode instead of a FileInode
This commit is contained in:
parent
cca4743a51
commit
9248a5b3cc
@ -48,6 +48,8 @@ namespace VFS
|
|||||||
|
|
||||||
virtual Result<SharedPtr<Inode>> create_file_inode() = 0;
|
virtual Result<SharedPtr<Inode>> create_file_inode() = 0;
|
||||||
|
|
||||||
|
virtual Result<SharedPtr<Inode>> create_dir_inode() = 0;
|
||||||
|
|
||||||
virtual ~FileSystem() = default;
|
virtual ~FileSystem() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ namespace TmpFS
|
|||||||
Result<SharedPtr<VFS::FileSystem>> FileSystem::create()
|
Result<SharedPtr<VFS::FileSystem>> FileSystem::create()
|
||||||
{
|
{
|
||||||
SharedPtr<FileSystem> fs = TRY(adopt_shared(new (std::nothrow) FileSystem()));
|
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);
|
fs->set_root(root);
|
||||||
return (SharedPtr<VFS::FileSystem>)fs;
|
return (SharedPtr<VFS::FileSystem>)fs;
|
||||||
}
|
}
|
||||||
@ -22,6 +22,16 @@ namespace TmpFS
|
|||||||
return (SharedPtr<VFS::Inode>)inode;
|
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)
|
void FileSystem::set_root(SharedPtr<VFS::Inode> root)
|
||||||
{
|
{
|
||||||
m_root_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_file_inode() override;
|
||||||
|
Result<SharedPtr<VFS::Inode>> create_dir_inode() override;
|
||||||
|
|
||||||
static Result<SharedPtr<VFS::FileSystem>> create();
|
static Result<SharedPtr<VFS::FileSystem>> create();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user