From 14951d87130966d8eb242d83b9e6cecd7730dafb Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Mon, 24 Jan 2022 01:18:07 +0300 Subject: [PATCH] Fix abuse of fs::pending_file Debug dumps don't fall into category which needs atomic rewrite. --- rpcs3/Emu/Cell/PPUModule.cpp | 4 ++-- rpcs3/Emu/Cell/SPUThread.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index de6d24455e..3c99004229 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -859,9 +859,9 @@ static void ppu_check_patch_spu_images(const ppu_segment& seg) if (g_cfg.core.spu_debug) { - fs::pending_file temp(fs::get_cache_dir() + "/spu_progs/" + vfs::escape(name.substr(name.find_last_of('/') + 1)) + '_' + hash.substr(4) + ".elf"); + fs::file temp(fs::get_cache_dir() + "/spu_progs/" + vfs::escape(name.substr(name.find_last_of('/') + 1)) + '_' + hash.substr(4) + ".elf", fs::rewrite); - if (!temp.file || !(temp.file.write(obj.save()), temp.commit())) + if (!temp || !temp.write(obj.save())) { ppu_loader.error("Failed to dump SPU program from PPU executable: name='%s', hash=%s", name, hash); } diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index d112862f90..f8ba9afb92 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -4889,19 +4889,19 @@ bool spu_thread::capture_local_storage() const } } - fs::pending_file temp(elf_path); + fs::file temp(elf_path, fs::rewrite); - if (!temp.file) + if (!temp) { - spu_log.error("Failed to create temporary file for '%s' (error=%s)", elf_path, fs::g_tls_error); + spu_log.error("Failed to create file '%s' (error=%s)", elf_path, fs::g_tls_error); return false; } - temp.file.write(spu_exec.save()); + auto data = spu_exec.save(); - if (!temp.commit(false)) + if (temp.write(data.data(), data.size()) != data.size()) { - spu_log.error("Failed to create rename temporary file to '%s' (error=%s)", elf_path, fs::g_tls_error); + spu_log.error("Failed to write file '%s' (error=%s)", elf_path, fs::g_tls_error); return false; }