mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 07:32:07 +00:00
Kernel: Make Inode::lookup() return a KResultOr<NonnullRefPtr<Inode>>
This allows file systems to return arbitrary error codes instead of just an Inode or not an Inode.
This commit is contained in:
parent
459115a59c
commit
ef2720bcad
18 changed files with 83 additions and 72 deletions
|
@ -1630,12 +1630,12 @@ KResult Ext2FSInode::populate_lookup_cache() const
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
RefPtr<Inode> Ext2FSInode::lookup(StringView name)
|
||||
KResultOr<NonnullRefPtr<Inode>> Ext2FSInode::lookup(StringView name)
|
||||
{
|
||||
VERIFY(is_directory());
|
||||
dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]:lookup(): Looking up '{}'", identifier(), name);
|
||||
if (populate_lookup_cache().is_error())
|
||||
return {};
|
||||
if (auto result = populate_lookup_cache(); result.is_error())
|
||||
return result;
|
||||
|
||||
InodeIndex inode_index;
|
||||
{
|
||||
|
@ -1643,11 +1643,15 @@ RefPtr<Inode> Ext2FSInode::lookup(StringView name)
|
|||
auto it = m_lookup_cache.find(name.hash(), [&](auto& entry) { return entry.key == name; });
|
||||
if (it == m_lookup_cache.end()) {
|
||||
dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]:lookup(): '{}' not found", identifier(), name);
|
||||
return {};
|
||||
return ENOENT;
|
||||
}
|
||||
inode_index = it->value;
|
||||
}
|
||||
return fs().get_inode({ fsid(), inode_index });
|
||||
|
||||
auto inode = fs().get_inode({ fsid(), inode_index });
|
||||
if (!inode)
|
||||
return ENOENT;
|
||||
return inode.release_nonnull();
|
||||
}
|
||||
|
||||
void Ext2FSInode::one_ref_left()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue