kernel: Make pivot_root() reset the parent entry of the new root directory
All checks were successful
continuous-integration/drone/pr Build is passing
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:
parent
6ca131f8b9
commit
d1ddf314d6
@ -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 {};
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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, "..");
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user