From 81e9a547ec1d182a06ab60f5b603ba5a1f848a62 Mon Sep 17 00:00:00 2001 From: Stephen Miller Date: Thu, 20 Feb 2025 18:50:04 -0600 Subject: [PATCH] Improve error checks on posix_unlink Just because a file isn't opened doesn't mean the file doesn't exist. Fixes the error returned if host_path.empty(), and removes the error return for when GetFile fails. --- src/core/libraries/kernel/file_system.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index e02adc9b4..02b833969 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -933,7 +933,7 @@ s32 PS4_SYSV_ABI posix_unlink(const char* path) { bool ro = false; const auto host_path = mnt->GetHostPath(path, &ro); if (host_path.empty()) { - *__Error() = POSIX_EACCES; + *__Error() = POSIX_ENOENT; return -1; } @@ -949,8 +949,8 @@ s32 PS4_SYSV_ABI posix_unlink(const char* path) { auto* file = h->GetFile(host_path); if (file == nullptr) { - *__Error() = POSIX_ENOENT; - return -1; + // Cannot unlink an unopened file + return ORBIS_OK; } file->f.Unlink();