1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:08:12 +00:00

Kernel: Make FileSystem::get_inode() return KResultOr<NRP<Inode>>

This allows for natural error propagation in a bunch of new places.
This commit is contained in:
Andreas Kling 2021-09-05 18:55:55 +02:00
parent 12d9a6c1fa
commit caaeae9607
8 changed files with 33 additions and 49 deletions

View file

@ -61,14 +61,14 @@ unsigned TmpFS::next_inode_index()
return m_next_inode_index++;
}
RefPtr<Inode> TmpFS::get_inode(InodeIdentifier identifier) const
KResultOr<NonnullRefPtr<Inode>> TmpFS::get_inode(InodeIdentifier identifier) const
{
MutexLocker locker(m_lock, Mutex::Mode::Shared);
VERIFY(identifier.fsid() == fsid());
auto it = m_inodes.find(identifier.index());
if (it == m_inodes.end())
return nullptr;
return ENOENT;
return it->value;
}
@ -201,13 +201,8 @@ KResultOr<NonnullRefPtr<Inode>> TmpFSInode::lookup(StringView name)
if (name == ".")
return *this;
if (name == "..") {
auto inode = fs().get_inode(m_parent);
// FIXME: If this cannot fail, we should probably VERIFY here instead.
if (!inode)
return ENOENT;
return inode.release_nonnull();
}
if (name == "..")
return fs().get_inode(m_parent);
auto* child = find_child_by_name(name);
if (!child)