Repository navigation
ps2client: open host: files read-write as O_RDWR - #34
Merged
Merged
Conversation
The PS2's open flags hold the access mode in the low two bits (1 read, 2 write, 3 both). fix_flags or-ed O_RDONLY and O_WRONLY for 3, which is O_WRONLY | O_TRUNC on POSIX hosts: a file opened read-write was emptied and every read of it returned 0 bytes. Map the mode as a whole; 3 is now O_RDWR (without O_TRUNC). tests: the fake's rdwrback reads a file opened with flags 3; its size and CRC must match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
host:file opened read-write (PS2 open flags 3) could not be read: every read returned 0 bytes, and the file was emptied when it was opened.fix_flagsturned each access bit into its own host flag. For flags 3 that givesO_RDONLY | O_WRONLY | O_TRUNC, and sinceO_RDONLYis 0 on POSIX hosts, that isO_WRONLY | O_TRUNC. The fix maps the access mode (the low two bits) as a whole:O_RDONLYO_RDONLYO_WRONLY | O_TRUNCO_WRONLY | O_TRUNC(unchanged, see the FIXME)O_WRONLY | O_TRUNCO_RDWRFound with a swap file on
host:on a real PS2: pages written to the file read back as nothing.Test:
tests/run-tests.shgets a check that a file opened with flags 3 reads back with the right size and CRC (rdwrbackin the fake ps2link). It fails without the fix and passes with it; all 40 checks pass, as doesmake check.🤖 Generated with Claude Code