From db19ea1622e9972611d3a2c95ca6f6ceb8cb08a4 Mon Sep 17 00:00:00 2001 From: Stephen Miller Date: Sun, 15 Jun 2025 13:21:33 -0500 Subject: [PATCH] A real fix for the sceKernelWrite issue Turns out, some data was just buffered. Running Flush fixes that problem. --- src/core/libraries/kernel/file_system.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index 5e6fd0852..afc7fe39a 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -294,18 +294,9 @@ s64 PS4_SYSV_ABI write(s32 fd, const void* buf, size_t nbytes) { return result; } - // Due to a quirk with std::fwrite - // we need to validate the returned bytes, and make sure the file size is correct. - auto expected_file_size = file->f.GetSize(); auto bytes_written = file->f.WriteRaw(buf, nbytes); - expected_file_size += bytes_written; - auto actual_file_size = file->f.GetSize(); - if (expected_file_size != actual_file_size) { - LOG_WARNING(Kernel_Fs, - "Unexpected behavior from fwrite. Expected size {:#x}, actual size {:#x}", - expected_file_size, actual_file_size); - file->f.SetSize(expected_file_size); - } + // Some written data might be buffered, run Flush to make sure all data is written properly. + file->f.Flush(); return bytes_written; }