1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 23:04:59 +00:00

Add CoreInode::lookup() for directory lookups.

Also add a name-to-inode lookup cache to Ext2Inode. This seems like a great
speedup for filesystem traversal.
This commit is contained in:
Andreas Kling 2018-11-15 16:34:36 +01:00
parent 8fa2d7104a
commit 5f434bc00b
7 changed files with 48 additions and 18 deletions

View file

@ -320,3 +320,17 @@ bool SynthFSInode::traverse_as_directory(Function<bool(const FileSystem::Directo
callback({ child->m_name.characters(), child->m_name.length(), child->m_metadata.inode, child->m_metadata.isDirectory() ? (byte)2 : (byte)1 });
return true;
}
InodeIdentifier SynthFSInode::lookup(const String& name)
{
ASSERT(is_directory());
if (name == ".")
return identifier();
if (name == "..")
return m_parent;
for (auto& child : m_children) {
if (child->m_name == name)
return child->identifier();
}
return { };
}