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

Kernel: Make Inode::traverse_as_directory() callback return ErrorOr

This allows us to propagate errors from inside the callback with TRY().
This commit is contained in:
Andreas Kling 2021-11-10 15:42:39 +01:00
parent a15ed8743d
commit 5ce753b74d
31 changed files with 154 additions and 151 deletions

View file

@ -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)