kernel: Make pivot_root() reset the parent entry of the new root directory
All checks were successful
continuous-integration/drone/pr Build is passing

Otherwise it would just be pointing to the old parent fs, and we don't want that.
This commit is contained in:
apio 2023-06-22 19:57:12 +02:00
parent 6ca131f8b9
commit d1ddf314d6
Signed by: apio
GPG Key ID: B8A7D06E42258954
6 changed files with 17 additions and 0 deletions

View File

@ -217,6 +217,7 @@ namespace VFS
g_root_inode = new_root_inode;
TRY(new_root_parent_inode->replace_entry(((MountInode*)g_root_inode.ptr())->source(), new_root_path.chars()));
((MountInode*)g_root_inode.ptr())->set_source({});
g_root_inode->fs()->reset_mount_dir();
return {};
}

View File

@ -36,6 +36,8 @@ namespace VFS
virtual Result<void> set_mount_dir(SharedPtr<Inode> parent) = 0;
virtual Result<void> reset_mount_dir() = 0;
virtual bool is_readonly() const
{
return false;

View File

@ -125,4 +125,9 @@ namespace Ext2
{
return m_root_inode->replace_entry(inode, "..");
}
Result<void> FileSystem::reset_mount_dir()
{
return m_root_inode->replace_entry(m_root_inode, "..");
}
}

View File

@ -149,6 +149,8 @@ namespace Ext2
Result<void> set_mount_dir(SharedPtr<VFS::Inode>) override;
Result<void> reset_mount_dir() override;
bool is_readonly() const override
{
return true;

View File

@ -72,6 +72,11 @@ namespace TmpFS
return m_root_inode->replace_entry(parent, "..");
}
Result<void> FileSystem::reset_mount_dir()
{
return m_root_inode->replace_entry(m_root_inode, "..");
}
void FileSystem::set_root(SharedPtr<VFS::Inode> root)
{
m_root_inode = root;

View File

@ -20,6 +20,8 @@ namespace TmpFS
Result<void> set_mount_dir(SharedPtr<VFS::Inode> parent) override;
Result<void> reset_mount_dir() override;
static Result<SharedPtr<VFS::FileSystem>> create();
dev_t host_device_id() const override