mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00: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
Notes:
sideshowbarker
2024-07-17 10:54:57 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/80f400a150 Pull-request: https://github.com/SerenityOS/serenity/pull/20358 Reviewed-by: https://github.com/gmta ✅
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)
|
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> {
|
return dir_inode.traverse_as_directory([&](auto& entry) -> ErrorOr<void> {
|
||||||
InodeIdentifier resolved_inode;
|
TRY(callback({ entry.name, entry.inode, entry.file_type }));
|
||||||
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 }));
|
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue