[PR #3360] [MERGED] Core: Simulate write-only file access with read-write access #3413

Closed
opened 2026-02-27 22:03:36 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/3360
Author: @StevenMiller123
Created: 8/1/2025
Status: Merged
Merged: 11/4/2025
Merged by: @georgemoralis

Base: mainHead: catherine-fix


📝 Commits (10+)

  • 5c9ba6c Swap write access mode for read write
  • 12dc103 Create mode
  • 038ad7d Update file_system.cpp
  • a538770 Check access mode in read functions
  • ad5c019 Separate appends into proper modes
  • b0f93af Move IsWriteOnly check after device/socket reads
  • bc7af55 Fix issues
  • f20636a Fix remaining uses of FileAccessMode write to create files
  • 2ce0433 Merge branch 'main' into catherine-fix
  • 7bc0ce0 Fix rebase

📊 Changes

16 files changed (+78 additions, -43 deletions)

View changed files

📝 src/common/io_file.cpp (+12 -8)
📝 src/common/io_file.h (+14 -4)
📝 src/common/logging/backend.cpp (+1 -1)
📝 src/core/devtools/widget/common.h (+1 -1)
📝 src/core/devtools/widget/frame_dump.cpp (+1 -1)
📝 src/core/file_format/psf.cpp (+1 -1)
📝 src/core/libraries/kernel/file_system.cpp (+34 -13)
📝 src/core/libraries/save_data/save_instance.cpp (+1 -1)
📝 src/core/libraries/save_data/save_memory.cpp (+2 -2)
📝 src/core/libraries/save_data/savedata.cpp (+1 -1)
📝 src/core/loader/elf.cpp (+4 -4)
📝 src/core/loader/symbols_resolver.cpp (+1 -1)
📝 src/shader_recompiler/frontend/translate/translate.cpp (+1 -1)
📝 src/shader_recompiler/ir/passes/flatten_extended_userdata_pass.cpp (+1 -1)
📝 src/shader_recompiler/ir/program.cpp (+2 -2)
📝 src/video_core/renderer_vulkan/vk_pipeline_cache.cpp (+1 -1)

📄 Description

The standard library functions we're using for opening files will erase files when opening with write access. This differs from real hardware behavior, where the file opens without getting erased.

To properly emulate this behavior, I've made write-only access identical to read-write access, and added checks in read, posix_preadv, and readv to ensure that reading from a file with write-only access fails in a hardware-accurate way. I've also created a separate create mode that uses write-access to create files to simplify the process of creating a file in open since read-write mode doesn't create files.

Handling this behavior properly fixes saving in Catherine: Full Body (CUSA15036)
image


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/3360 **Author:** [@StevenMiller123](https://github.com/StevenMiller123) **Created:** 8/1/2025 **Status:** ✅ Merged **Merged:** 11/4/2025 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `catherine-fix` --- ### 📝 Commits (10+) - [`5c9ba6c`](https://github.com/shadps4-emu/shadPS4/commit/5c9ba6ccbb8150cb89edf2d708e841c3d9816206) Swap write access mode for read write - [`12dc103`](https://github.com/shadps4-emu/shadPS4/commit/12dc10363548fec24092a640f9edff3ab30c5d22) Create mode - [`038ad7d`](https://github.com/shadps4-emu/shadPS4/commit/038ad7d782a0e99898aa44aef393a1c25b78c267) Update file_system.cpp - [`a538770`](https://github.com/shadps4-emu/shadPS4/commit/a53877062a4d838b729eef0a0d88dc73674bd1fc) Check access mode in read functions - [`ad5c019`](https://github.com/shadps4-emu/shadPS4/commit/ad5c019c6acb685cd984279481418ea3899468c6) Separate appends into proper modes - [`b0f93af`](https://github.com/shadps4-emu/shadPS4/commit/b0f93af18caac4e9c464da90aa11afb5de916fdf) Move IsWriteOnly check after device/socket reads - [`bc7af55`](https://github.com/shadps4-emu/shadPS4/commit/bc7af55a5f0a47e20213eaec49a506bf2d7b649c) Fix issues - [`f20636a`](https://github.com/shadps4-emu/shadPS4/commit/f20636aee569dfc843375d716e947b72f19eb56d) Fix remaining uses of FileAccessMode write to create files - [`2ce0433`](https://github.com/shadps4-emu/shadPS4/commit/2ce043327a7c4110121a5569d60f2b2f39d372e7) Merge branch 'main' into catherine-fix - [`7bc0ce0`](https://github.com/shadps4-emu/shadPS4/commit/7bc0ce0ebe583434836b970447180588ff77a6b7) Fix rebase ### 📊 Changes **16 files changed** (+78 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `src/common/io_file.cpp` (+12 -8) 📝 `src/common/io_file.h` (+14 -4) 📝 `src/common/logging/backend.cpp` (+1 -1) 📝 `src/core/devtools/widget/common.h` (+1 -1) 📝 `src/core/devtools/widget/frame_dump.cpp` (+1 -1) 📝 `src/core/file_format/psf.cpp` (+1 -1) 📝 `src/core/libraries/kernel/file_system.cpp` (+34 -13) 📝 `src/core/libraries/save_data/save_instance.cpp` (+1 -1) 📝 `src/core/libraries/save_data/save_memory.cpp` (+2 -2) 📝 `src/core/libraries/save_data/savedata.cpp` (+1 -1) 📝 `src/core/loader/elf.cpp` (+4 -4) 📝 `src/core/loader/symbols_resolver.cpp` (+1 -1) 📝 `src/shader_recompiler/frontend/translate/translate.cpp` (+1 -1) 📝 `src/shader_recompiler/ir/passes/flatten_extended_userdata_pass.cpp` (+1 -1) 📝 `src/shader_recompiler/ir/program.cpp` (+2 -2) 📝 `src/video_core/renderer_vulkan/vk_pipeline_cache.cpp` (+1 -1) </details> ### 📄 Description The standard library functions we're using for opening files will erase files when opening with write access. This differs from real hardware behavior, where the file opens without getting erased. To properly emulate this behavior, I've made write-only access identical to read-write access, and added checks in `read`, `posix_preadv`, and `readv` to ensure that reading from a file with write-only access fails in a hardware-accurate way. I've also created a separate create mode that uses write-access to create files to simplify the process of creating a file in `open` since read-write mode doesn't create files. Handling this behavior properly fixes saving in Catherine: Full Body (CUSA15036) <img width="1282" height="752" alt="image" src="https://github.com/user-attachments/assets/7629019d-89f7-4682-ba89-9a4f26b0a052" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:03:36 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shadPS4#3413
No description provided.