From 72680c7707d16baddf48001de750bfc3412d5917 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 18 Jun 2021 17:10:58 +0300 Subject: [PATCH] sys_fs: improve sys_fs_open accuracy for /dev_bdvd Based on software test. --- rpcs3/Emu/Cell/lv2/sys_fs.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index f592b3647b..a9a9feaa73 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -309,7 +309,7 @@ lv2_file::open_raw_result_t lv2_file::open_raw(const std::string& local_path, s3 if (mp->flags & lv2_mp_flag::read_only) { - if (flags & CELL_FS_O_ACCMODE || flags & (CELL_FS_O_CREAT | CELL_FS_O_TRUNC)) + if ((flags & CELL_FS_O_ACCMODE) != CELL_FS_O_RDONLY && fs::is_file(local_path)) { return {CELL_EPERM}; } @@ -400,9 +400,9 @@ lv2_file::open_raw_result_t lv2_file::open_raw(const std::string& local_path, s3 if (mp->flags & lv2_mp_flag::read_only) { // Failed to create file on read-only FS (file doesn't exist) - if (flags & CELL_FS_O_CREAT) + if (flags & CELL_FS_O_ACCMODE && flags & CELL_FS_O_CREAT) { - return {CELL_EROFS}; + return {CELL_EPERM}; } } @@ -420,21 +420,6 @@ lv2_file::open_raw_result_t lv2_file::open_raw(const std::string& local_path, s3 return {CELL_EIO}; } - if (mp->flags & lv2_mp_flag::read_only) - { - // Failed to create file on read-only FS (file exists) - if (flags & CELL_FS_O_CREAT && flags & CELL_FS_O_EXCL) - { - return {CELL_EEXIST}; - } - - // Failed to truncate file on read-only FS - if (flags & CELL_FS_O_TRUNC) - { - return {CELL_EROFS}; - } - } - if (flags & CELL_FS_O_MSELF && !verify_mself(file)) { return {CELL_ENOTMSELF};