diff options
author | Andreas Kling <kling@serenityos.org> | 2021-08-14 13:32:35 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-14 13:34:59 +0200 |
commit | ef2720bcad5840a6e174492eb55046e9edacc782 (patch) | |
tree | 81b8bdaf03b1ec32fae5b648f864d4f703077eed /Kernel/FileSystem/DevPtsFS.cpp | |
parent | 459115a59c05ef478b2f99f4089343ef64d65a1c (diff) | |
download | serenity-ef2720bcad5840a6e174492eb55046e9edacc782.zip |
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.
Diffstat (limited to 'Kernel/FileSystem/DevPtsFS.cpp')
-rw-r--r-- | Kernel/FileSystem/DevPtsFS.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp index 80fc243211..ee5c2a4b46 100644 --- a/Kernel/FileSystem/DevPtsFS.cpp +++ b/Kernel/FileSystem/DevPtsFS.cpp @@ -136,21 +136,24 @@ KResult DevPtsFSInode::traverse_as_directory(Function<bool(FileSystem::Directory return KSuccess; } -RefPtr<Inode> DevPtsFSInode::lookup(StringView name) +KResultOr<NonnullRefPtr<Inode>> DevPtsFSInode::lookup(StringView name) { VERIFY(identifier().index() == 1); if (name == "." || name == "..") - return this; + return *this; auto& fs = static_cast<DevPtsFS&>(this->fs()); auto pty_index = name.to_uint(); if (pty_index.has_value() && s_ptys->contains(pty_index.value())) { - return fs.get_inode({ fsid(), pty_index_to_inode_index(pty_index.value()) }); + auto inode = fs.get_inode({ fsid(), pty_index_to_inode_index(pty_index.value()) }); + if (!inode) + return ENOENT; + return inode.release_nonnull(); } - return {}; + return ENOENT; } void DevPtsFSInode::flush_metadata() |