-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Core: Simulate write-only file access with read-write access #3360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Opening with access mode w will erase the opened file. We do not want this.
Opening with write access was previously the only way to create a file through open, so add a separate FileAccessMode that uses the write access mode to create files.
Remove a hack added to posix_rename to bypass the file clearing behaviors of FileAccessMode::Write
Write-only files cause the EBADF return on the various read functions. Now that we're opening files differently, properly handling this is necessary.
Fixes a potential regression from one of my prior PRs, and ensures the Write | Append flag combo also behaves properly in read-related functions.
file->f is only valid for files, so checking this before checking for sockets/devices will cause access violations.
Now that Write is identical to ReadWrite, internal uses of Write need to be swapped to my new Create mode
This PR should probably receive further testing before any merge, to ensure there aren't any other issues I've caused by messing with FileAccessMode::Write. |
Missed these before.
Anything blocking this other than need of more testing? |
I think the main holdup here comes from PR #3368. Once that's ready for merge, this PR becomes an unnecessary hack. |
ah nice |
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
, andreadv
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 inopen
since read-write mode doesn't create files.Handling this behavior properly fixes saving in Catherine: Full Body (CUSA15036)
