diff --git a/rpcs3/Emu/Cell/Modules/cellSysCache.cpp b/rpcs3/Emu/Cell/Modules/cellSysCache.cpp index a12cfa25a6..b9f5cdaa1f 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysCache.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSysCache.cpp @@ -3,6 +3,7 @@ #include "Emu/IdManager.h" #include "Emu/Cell/PPUModule.h" +#include "Emu/Cell/lv2/sys_fs.h" #include "cellSysutil.h" #include "util/init_mutex.hpp" #include "Utilities/StrUtil.h" @@ -71,6 +72,18 @@ struct syscache_info { cellSysutil.fatal("cellSysCache: failed to clear cache directory '%s%s' (%s)", cache_root, cache_id, fs::g_tls_error); } + + // Poison opened files in /dev_hdd1 to return CELL_EIO on access + if (remove_root) + { + idm::select([](u32 id, lv2_file& file) + { + if (std::memcmp("/dev_hdd1", file.name.data(), 9) == 0) + { + file.lock = 2; + } + }); + } } }; diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index c1a40627be..b99bce08b8 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -399,6 +399,11 @@ error_code sys_fs_read(ppu_thread& ppu, u32 fd, vm::ptr buf, u64 nbytes, v std::lock_guard lock(file->mp->mutex); + if (file->lock == 2) + { + return CELL_EIO; + } + *nread = file->op_read(buf, nbytes); return CELL_OK; @@ -421,6 +426,11 @@ error_code sys_fs_write(ppu_thread& ppu, u32 fd, vm::cptr buf, u64 nbytes, if (file->lock) { + if (file->lock == 2) + { + return CELL_EIO; + } + return CELL_EBUSY; } @@ -437,7 +447,7 @@ error_code sys_fs_close(ppu_thread& ppu, u32 fd) const auto file = idm::withdraw(fd, [](lv2_file& file) -> CellError { - if (file.lock) + if (file.lock == 1) { return CELL_EBUSY; } @@ -706,6 +716,11 @@ error_code sys_fs_fstat(ppu_thread& ppu, u32 fd, vm::ptr sb) std::lock_guard lock(file->mp->mutex); + if (file->lock == 2) + { + return CELL_EIO; + } + const fs::stat_t& info = file->file.stat(); sb->mode = info.is_directory ? CELL_FS_S_IFDIR | 0777 : CELL_FS_S_IFREG | 0666; @@ -958,6 +973,11 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr _arg, u32 if (op == 0x8000000b && file->lock) { + if (file->lock == 2) + { + return CELL_EIO; + } + return CELL_EBUSY; } @@ -1448,6 +1468,11 @@ error_code sys_fs_ftruncate(ppu_thread& ppu, u32 fd, u64 size) std::lock_guard lock(file->mp->mutex); + if (file->lock == 2) + { + return CELL_EIO; + } + if (file->lock) { return CELL_EBUSY;