diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-10 15:42:39 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-10 21:58:58 +0100 |
commit | 5ce753b74d669aa240cae310ed41984158205f21 (patch) | |
tree | fbe1297544534d9605d3f99d0066d8cf2451d04d /Kernel/FileSystem/DevPtsFS.cpp | |
parent | a15ed8743d03c6c683f19447be20ca7dac768485 (diff) | |
download | serenity-5ce753b74d669aa240cae310ed41984158205f21.zip |
Kernel: Make Inode::traverse_as_directory() callback return ErrorOr
This allows us to propagate errors from inside the callback with TRY().
Diffstat (limited to 'Kernel/FileSystem/DevPtsFS.cpp')
-rw-r--r-- | Kernel/FileSystem/DevPtsFS.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp index ef49e6b4c0..422430d126 100644 --- a/Kernel/FileSystem/DevPtsFS.cpp +++ b/Kernel/FileSystem/DevPtsFS.cpp @@ -105,23 +105,22 @@ InodeMetadata DevPtsFSInode::metadata() const return m_metadata; } -ErrorOr<void> DevPtsFSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const +ErrorOr<void> DevPtsFSInode::traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)> callback) const { if (identifier().index() > 1) return ENOTDIR; - callback({ ".", identifier(), 0 }); - callback({ "..", identifier(), 0 }); + TRY(callback({ ".", identifier(), 0 })); + TRY(callback({ "..", identifier(), 0 })); - SlavePTY::all_instances().with([&](auto& list) { + return SlavePTY::all_instances().with([&](auto& list) -> ErrorOr<void> { for (SlavePTY& slave_pty : list) { StringBuilder builder; builder.appendff("{}", slave_pty.index()); - callback({ builder.string_view(), { fsid(), pty_index_to_inode_index(slave_pty.index()) }, 0 }); + TRY(callback({ builder.string_view(), { fsid(), pty_index_to_inode_index(slave_pty.index()) }, 0 })); } + return {}; }); - - return {}; } ErrorOr<NonnullRefPtr<Inode>> DevPtsFSInode::lookup(StringView name) |