mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
Kernel: Add DirectoryEntryView for VFS directory traversal
Unlike DirectoryEntry (which is used when constructing directories), DirectoryEntryView does not manage storage for file names. Names are just StringViews. This is much more suited to the directory traversal API and makes it easier to implement this in file system classes since they no longer need to create temporary name copies while traversing.
This commit is contained in:
parent
8abf5048b8
commit
eeaba41d13
Notes:
sideshowbarker
2024-07-19 03:26:18 +09:00
Author: https://github.com/awesomekling
Commit: eeaba41d13
16 changed files with 61 additions and 53 deletions
|
@ -191,9 +191,9 @@ bool VFS::is_vfs_root(InodeIdentifier inode) const
|
|||
return inode == root_inode_id();
|
||||
}
|
||||
|
||||
KResult VFS::traverse_directory_inode(Inode& dir_inode, Function<bool(const FS::DirectoryEntry&)> callback)
|
||||
KResult VFS::traverse_directory_inode(Inode& dir_inode, Function<bool(const FS::DirectoryEntryView&)> callback)
|
||||
{
|
||||
return dir_inode.traverse_as_directory([&](const FS::DirectoryEntry& entry) {
|
||||
return dir_inode.traverse_as_directory([&](auto& entry) {
|
||||
InodeIdentifier resolved_inode;
|
||||
if (auto mount = find_mount_for_host(entry.inode))
|
||||
resolved_inode = mount->guest().identifier();
|
||||
|
@ -202,13 +202,13 @@ KResult VFS::traverse_directory_inode(Inode& dir_inode, Function<bool(const FS::
|
|||
|
||||
// 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()) && !strcmp(entry.name, "..")) {
|
||||
if (is_root_inode && !is_vfs_root(dir_inode.identifier()) && entry.name == "..") {
|
||||
auto mount = find_mount_for_guest(dir_inode);
|
||||
ASSERT(mount);
|
||||
ASSERT(mount->host());
|
||||
resolved_inode = mount->host()->identifier();
|
||||
}
|
||||
callback(FS::DirectoryEntry(entry.name, entry.name_length, resolved_inode, entry.file_type));
|
||||
callback({ entry.name, resolved_inode, entry.file_type });
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue