Repository navigation
fix(libkernel): return guest errors from file resizing - #2041
Closed
STUPIDCONTEM wants to merge 1 commit into
Closed
STUPIDCONTEM wants to merge 1 commit into
STUPIDCONTEM wants to merge 1 commit into
Conversation
MarcZX10
approved these changes
Oct 9, 2026
MarcZX10
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the complete diff, including the Windows descriptor checks and guest/POSIX error translation. The regression exercises successful resize behavior and the invalid descriptor, length, file type, and access cases. I built the exact head on Linux with GCC 12; guest_file_resize passed (1/1), and conventions/diff checks pass. The PR description reports a full Windows suite pass; I could not independently reproduce Windows here. GitHub currently reports no upstream check results for this fork head.
8 of 9 tasks
Collaborator
|
Closing: on main these paths throw, which is allowed until a title needs the console's error codes. Reopen with the title ID and the log line if one stops at the throw. |
8 of 9 tasks
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.
Evidence review (2026-10-09)
Closed by maintainer; not ready to reopen. Required evidence: Title ID and a log showing the title stops at the file-resize throw. Existing throws are intentional pending that need.
Game/title ID: none verified. No PS5 title execution is claimed.
Deferred after maintainer review: reopening requires a title ID and a log showing execution stops at the existing throw. Synthetic error-path tests do not establish that requirement. See maintainer feedback. The patch and test results below are preserved as historical evidence; this change is excluded from the current proposed integration.
What
sceKernelFtruncateand POSIXftruncatethrew exceptions for ordinary invalid arguments and native failures. Return encoded kernel errors fromsceKernelFtruncate, preserving errno, and translate those results into-1plus guest errno in the POSIX wrapper.On Windows, check the original descriptor's object type and granted write access before
_chsize_s. This rejects read-only descriptors even when the requested size is unchanged, distinguishes invalid descriptors from non-regular files, and leaves genuine native resize failures intact. Open guest sockets return EINVAL; closed/invalid socket descriptors return EBADF. Successful resizing retains the existing host implementation.Error ordering and write-access requirements follow FreeBSD 11 kern_ftruncate and truncate(2). Windows uses documented NtQueryObject access information and _chsize_s. Linux already rejects read-only descriptors with EINVAL and retains its native ftruncate call.
Tested
Windows 10 Pro 19045, WinLibs GCC 15.2.0 UCRT/posix/SEH r7, Ninja Release, BUILD_TESTING=ON, SPIRV-Tools disabled. Based directly on
f145139676a48306681d3a4d5fabf83938759daf; independent of #2029 and #2030. An independent review checked the implementation and expanded the success cases.guest_file_resizefails against upstream with an unhandled invalid_argument exception for negative length.libsbuild passed.Linux and PS5 hardware/titles were not run. This change does not add concurrent resize guarantees or replace the existing host resize implementation. The open shm_open PR #1860 uses ftruncate but does not implement these functions.
Checklist
main; no other open PR implements the same change (historical base; current readiness not asserted)