mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 18:32:28 -05:00
Kernel/VFS: Don't resolve root inode mounts when traversing a directory
This is not useful, as we have literally zero knowledge about where this inode is actually located at with respect to the entire global path tree so we could easily encounter a case where we do the following: ``` mkdir -p /tmp2 mount /dev/hda /tmp2 ``` and when traversing the /tmp2 directory entries, we will see the root inode of /dev/hda on "/tmp2/tmp2", even if it was not mounted. Therefore, we should just plainly give the raw directory entries as they are written "on the disk". Anything else that needs to exactly know if there's an underlying mounted filesystem, can just use the stat syscall instead.
This commit is contained in:
parent
debbfe07fb
commit
80f400a150
1 changed files with 1 additions and 15 deletions
|
@ -408,21 +408,7 @@ bool VirtualFileSystem::is_vfs_root(InodeIdentifier inode) const
|
|||
ErrorOr<void> VirtualFileSystem::traverse_directory_inode(Inode& dir_inode, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)> callback)
|
||||
{
|
||||
return dir_inode.traverse_as_directory([&](auto& entry) -> ErrorOr<void> {
|
||||
InodeIdentifier resolved_inode;
|
||||
if (auto mount = find_mount_for_host(entry.inode))
|
||||
resolved_inode = mount->guest().identifier();
|
||||
else
|
||||
resolved_inode = entry.inode;
|
||||
|
||||
// FIXME: This is now broken considering chroot and bind mounts.
|
||||
bool is_root_inode = dir_inode.identifier() == dir_inode.fs().root_inode().identifier();
|
||||
if (is_root_inode && !is_vfs_root(dir_inode.identifier()) && entry.name == "..") {
|
||||
auto mount = find_mount_for_guest(dir_inode.identifier());
|
||||
VERIFY(mount);
|
||||
VERIFY(mount->host());
|
||||
resolved_inode = mount->host()->identifier();
|
||||
}
|
||||
TRY(callback({ entry.name, resolved_inode, entry.file_type }));
|
||||
TRY(callback({ entry.name, entry.inode, entry.file_type }));
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue