From d9c08ea98cbc68f046320ee374bc3ad2638612a0 Mon Sep 17 00:00:00 2001 From: DH Date: Mon, 26 Jun 2023 12:45:32 +0300 Subject: [PATCH] [rpcsx-os] implemented sys_read --- rpcsx-os/ops.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/rpcsx-os/ops.cpp b/rpcsx-os/ops.cpp index c725d98f4..001783109 100644 --- a/rpcsx-os/ops.cpp +++ b/rpcsx-os/ops.cpp @@ -275,7 +275,21 @@ orbis::SysResult write(orbis::Thread *thread, orbis::sint fd, } orbis::SysResult read(orbis::Thread *thread, orbis::sint fd, orbis::ptr data, orbis::ulong size) { - return ErrorCode::NOTSUP; + Ref handle = + static_cast(thread->tproc->fileDescriptors.get(fd)); + if (handle == nullptr) { + return ErrorCode::BADF; + } + + auto result = handle->read(handle.get(), data, size); + + if (result < 0) { + // TODO + return ErrorCode::IO; + } + + thread->retval[0] = result; + return {}; } orbis::SysResult pread(orbis::Thread *thread, orbis::sint fd, orbis::ptr data, orbis::ulong size,