From 9decdce8ca22eb68a6bb70da3629657435b69921 Mon Sep 17 00:00:00 2001 From: Benjamin Lamowski Date: Fri, 19 Jul 2024 00:05:53 +0200 Subject: [PATCH] fixup: libc: implement read and write by async_read and async_write Issue #5302 --- repos/libports/src/lib/libc/vfs_plugin.cc | 40 +++++++++++------------ 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/repos/libports/src/lib/libc/vfs_plugin.cc b/repos/libports/src/lib/libc/vfs_plugin.cc index 66370be2156..5c4b41c8170 100644 --- a/repos/libports/src/lib/libc/vfs_plugin.cc +++ b/repos/libports/src/lib/libc/vfs_plugin.cc @@ -818,7 +818,7 @@ int Libc::Vfs_plugin::stat(char const *path, struct stat *buf) return Errno(EFAULT); } - typedef Vfs::Directory_service::Stat_result Result; + using Result = Vfs::Directory_service::Stat_result; Vfs::Directory_service::Stat stat; @@ -892,24 +892,24 @@ bool Libc::Vfs_plugin::async_read(File_descriptor *fd, } switch (out_result) { - case Result::READ_ERR_WOULD_BLOCK: - result_errno = EWOULDBLOCK; - result = -1; - break; - case Result::READ_ERR_INVALID: - result_errno = EINVAL; - result = -1; - break; - case Result::READ_ERR_IO: - result_errno = EIO; - result = -1; - case Result::READ_OK: - result_errno = 0; - result = out_count; - break; - case Result::READ_QUEUED: - /* handled above, so never reached */ - break; + case Result::READ_ERR_WOULD_BLOCK: + result_errno = EWOULDBLOCK; + result = -1; + break; + case Result::READ_ERR_INVALID: + result_errno = EINVAL; + result = -1; + break; + case Result::READ_ERR_IO: + result_errno = EIO; + result = -1; + case Result::READ_OK: + result_errno = 0; + result = out_count; + break; + case Result::READ_QUEUED: + /* handled above, so never reached */ + break; } return true; @@ -936,7 +936,6 @@ ssize_t Libc::Vfs_plugin::read(File_descriptor *fd, void *buf, Plugin::resume_all(); - /* XXX double getting the handle is a bit unfortunate */ Vfs::Vfs_handle *handle = vfs_handle(fd); handle->advance_seek(out_count); @@ -972,7 +971,6 @@ bool Libc::Vfs_plugin::async_write(File_descriptor *fd, if (fd->flags & O_NONBLOCK) { out_result = handle->fs().write(handle, src, write_state.bytes_written); - // XXX are we supposed to advance seek even with a fixed-offset async write? handle->advance_seek(write_state.bytes_written); } else { auto _fd_refers_to_continuous_file = [&]