From 7a275e9d5f53c4dabd38429edf60109f9b2c3be4 Mon Sep 17 00:00:00 2001 From: ElBread3 <92335081+ElBread3@users.noreply.github.com> Date: Fri, 29 Nov 2024 11:33:06 -0600 Subject: [PATCH] fix not handling dents errors --- src/core/libraries/kernel/file_system.cpp | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index ab592872d..765c6311c 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -731,11 +731,33 @@ static int HandleSeparateUpdateDents(int fd, char* buf, int nbytes, s64* basep) } int PS4_SYSV_ABI sceKernelGetdents(int fd, char* buf, int nbytes) { - return GetDents(fd, buf, nbytes, nullptr) + HandleSeparateUpdateDents(fd, buf, nbytes, nullptr); + int a = GetDents(fd, buf, nbytes, nullptr); + int b = HandleSeparateUpdateDents(fd, buf, nbytes, nullptr); + if (a == ORBIS_OK && b == ORBIS_OK) { + return ORBIS_OK; + } + if (a < 0) { + return a; + } + if (b < 0) { + return b; + } + return a + b; } int PS4_SYSV_ABI sceKernelGetdirentries(int fd, char* buf, int nbytes, s64* basep) { - return GetDents(fd, buf, nbytes, basep) + HandleSeparateUpdateDents(fd, buf, nbytes, basep); + int a = GetDents(fd, buf, nbytes, basep); + int b = HandleSeparateUpdateDents(fd, buf, nbytes, basep); + if (a == ORBIS_OK && b == ORBIS_OK) { + return ORBIS_OK; + } + if (a < 0) { + return a; + } + if (b < 0) { + return b; + } + return a + b; } s64 PS4_SYSV_ABI sceKernelPwrite(int d, void* buf, size_t nbytes, s64 offset) {