mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-14 08:12:16 +00:00
Only perform early read-write open when truncating is needed (#2874)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Should stop some fs error spam when games open files from /app0, as this open call would fail from reduced permissions.
This commit is contained in:
parent
eb09c4ccce
commit
0ba9ea6a3b
1 changed files with 8 additions and 7 deletions
|
@ -181,10 +181,6 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Start by opening as read-write so we can truncate regardless of flags.
|
|
||||||
// Since open starts by closing the file, this won't interfere with later open calls.
|
|
||||||
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite);
|
|
||||||
|
|
||||||
file->type = Core::FileSys::FileType::Regular;
|
file->type = Core::FileSys::FileType::Regular;
|
||||||
|
|
||||||
if (truncate && read_only) {
|
if (truncate && read_only) {
|
||||||
|
@ -192,9 +188,14 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
|
||||||
h->DeleteHandle(handle);
|
h->DeleteHandle(handle);
|
||||||
*__Error() = POSIX_EROFS;
|
*__Error() = POSIX_EROFS;
|
||||||
return -1;
|
return -1;
|
||||||
} else if (truncate && e == 0) {
|
} else if (truncate) {
|
||||||
// If the file was opened successfully and truncate was enabled, reduce size to 0
|
// Open the file as read-write so we can truncate regardless of flags.
|
||||||
file->f.SetSize(0);
|
// Since open starts by closing the file, this won't interfere with later open calls.
|
||||||
|
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite);
|
||||||
|
if (e == 0) {
|
||||||
|
// If the file was opened successfully, reduce size to 0
|
||||||
|
file->f.SetSize(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read) {
|
if (read) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue