mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 20:59:16 +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
Notes:
sideshowbarker
2024-07-18 06:57:29 +09:00
Author: https://github.com/awesomekling
Commit: ef2720bcad
18 changed files with 83 additions and 72 deletions
|
@ -193,19 +193,24 @@ KResultOr<size_t> TmpFSInode::write_bytes(off_t offset, size_t size, const UserO
|
|||
return size;
|
||||
}
|
||||
|
||||
RefPtr<Inode> TmpFSInode::lookup(StringView name)
|
||||
KResultOr<NonnullRefPtr<Inode>> TmpFSInode::lookup(StringView name)
|
||||
{
|
||||
MutexLocker locker(m_inode_lock, Mutex::Mode::Shared);
|
||||
VERIFY(is_directory());
|
||||
|
||||
if (name == ".")
|
||||
return this;
|
||||
if (name == "..")
|
||||
return fs().get_inode(m_parent);
|
||||
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();
|
||||
}
|
||||
|
||||
auto* child = find_child_by_name(name);
|
||||
if (!child)
|
||||
return {};
|
||||
return ENOENT;
|
||||
return child->inode;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue