1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 13:55:06 +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:
Andreas Kling 2021-08-14 13:32:35 +02:00
parent 459115a59c
commit ef2720bcad
18 changed files with 83 additions and 72 deletions

View file

@ -532,7 +532,7 @@ KResult ISO9660Inode::traverse_as_directory(Function<bool(FileSystem::DirectoryE
return KSuccess;
}
RefPtr<Inode> ISO9660Inode::lookup(StringView name)
KResultOr<NonnullRefPtr<Inode>> ISO9660Inode::lookup(StringView name)
{
auto& file_system = static_cast<ISO9660FS const&>(fs());
RefPtr<Inode> inode;
@ -558,11 +558,12 @@ RefPtr<Inode> ISO9660Inode::lookup(StringView name)
return RecursionDecision::Continue;
});
if (traversal_result.is_error()) {
return {};
}
if (traversal_result.is_error())
return traversal_result;
return inode;
if (!inode)
return ENOENT;
return inode.release_nonnull();
}
void ISO9660Inode::flush_metadata()