From e94149340e151fce68bb42ec6603a433b93a76d7 Mon Sep 17 00:00:00 2001 From: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com> Date: Wed, 26 Jun 2024 18:09:58 +0300 Subject: [PATCH] kernel: Fix pread and pwrite --- src/core/libraries/kernel/file_system.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index 8ec8b167..27a6ccf3 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -277,9 +277,9 @@ s64 PS4_SYSV_ABI sceKernelPread(int d, void* buf, size_t nbytes, s64 offset) { } std::scoped_lock lk{file->m_mutex}; - if (file->f.Tell() != offset) { - file->f.Seek(offset); - } + const s64 pos = file->f.Tell(); + SCOPE_EXIT { file->f.Seek(pos); }; + file->f.Seek(offset); return file->f.ReadRaw(buf, nbytes); } @@ -371,7 +371,8 @@ s64 PS4_SYSV_ABI sceKernelPwrite(int d, void* buf, size_t nbytes, s64 offset) { std::scoped_lock lk{file->m_mutex}; const s64 pos = file->f.Tell(); SCOPE_EXIT { file->f.Seek(pos); }; - return file->f.Seek(offset) && file->f.WriteRaw(buf, nbytes); + file->f.Seek(offset); + return file->f.WriteRaw(buf, nbytes); } void fileSystemSymbolsRegister(Core::Loader::SymbolsResolver* sym) {