fix(libkernel): translate scalar POSIX I/O errors #1307
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1307"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by ebarr24 on 2026-10-07T23:04:04Z.
What
AnyPS5 relinks guest executables into native Windows/Linux user-space programs. Its libkernel POSIX imports
read,_read,write,_write, andlseekcurrently let ordinary file failures escape as host exceptions. Translate recognized failures to-1and guesterrno, including LinuxEAGAIN11 to FreeBSD guest 35. Preserve successful values, 64-bit seek offsets, previous errno on success, directsceKernelbehaviour, and unsupported-operation diagnostics.The public synthetic VABI regression exercises file and pipe I/O, invalid descriptors/access modes/buffers/whence, zero-length null buffers, sparse seeking beyond 4 GiB, and Linux nonblocking-pipe EAGAIN. This corrects an existing Status file capability, with no measured title progress or library/shader badge increase.
Tested
df16c4c256be3c44e03eb9149a6ce5f8e8a038b2: Full build passed. The identicalguest_posix_scalar_iofixture ran successful I/O controls, then deliberately aborted at its contract assertion becauseread(-1, buffer, 1)threwsceKernelRead: read failed, fd=-1, errno=9instead of returning-1with guest EBADF. Zero skipped.2799d71161978bd4e2f1a548451f50ce3b422942: Full build/focused regression passed; complete Windows CTest 405 passed, 0 failed, 0 skipped. Conventions and diff checks passed.--repeat until-fail:3. The scalar regression, including unconditional Linux nonblocking-pipe EAGAIN mapping, passed every repetition. Each skipped GPU execution test has an individually checked 32-lane subgroup capability guard and is unrelated to scalar I/O. Exact runner subgroup width is unmeasured. The Windows job in this workflow passed separately.Checklist
main; no other open PR implements the same fix (complete inventory and shared-file review)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T03:26:12Z.
Please have
sceKernelRead/sceKernelWrite/sceKernelLseek(Open.cpp:141-163) return the SCE error and route the POSIX wrappers throughPosixResult, asopen/stat/unlinkalready do, instead of matching the exception text inPosixScalarResult(Stdio.cpp:287).Imported from boykopovar/AnyPS5. Originally posted by hikazey on 2026-10-08T09:22:56Z.
Linux data point from a real title: DOOM Shareware PPSA99666 v1.1.1 (lowbit/ps5-doom) needs this on Linux. While it scans
/download0for WADs, it opens the directory itself withO_RDONLYand reads a 12-byte header from it. Onmain(0e173a46, with #1278 and #1279 merged locally) that aborts the process:straceshows the host call isread(7, …, 12) = -1 EISDIR. With this PR merged locally the read returns an error to the title, and it continues to its launcher and E1M1 (Ubuntu 24.04 container, GCC 14.2, Mesa llvmpipe). The bundledlibc.prxalso has to be excluded (#1497).AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:48:09Z.
Review: CHANGES_REQUESTED
Thanks, and thanks @hikazey for the DOOM data point (a
readon a directory aborting onEISDIRis a good reason for this fix).Still open from @oneandonlydean's review, which isn't addressed yet:
PosixScalarResult(Stdio.cpp:287-309) matches the exception text prefix and reads the hosterrnoafter the throw. Please makesceKernelRead/sceKernelWrite/sceKernelLseek(Open.cpp:141-163) return the SCE error and have the POSIX wrappers go throughPosixResult, likeopen/stat/unlinkdo. That removes the string match and most ofGuestScalarIoErrno's duplicated table.windowsjob is red on the current head; please check it.mainincore/libs/CMakeLists.txt(test block adjacency); please rebase.The regression test itself looks good and covers the right cases; it should keep working after the rework. Happy to re-review once updated.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T08:59:25Z.
Review: APPROVED
Took over the three open points, pushed on top of your commit:
sceKernelRead/sceKernelWrite/sceKernelLseek(Open.cpp) now return the SCE error instead of throwing on a native failure (SceIoErrorFromErrno: host EAGAIN -> 35, EDEADLK -> 11, EDQUOT/EOVERFLOW -> FreeBSD values; 1..34 are identical on FreeBSD). The POSIX wrappers go throughPosixResultlikeopen/stat/unlink;PosixScalarResult, the exception-text match and the duplicated errno table are gone.main(conflicts incore/libs/CMakeLists.txtandStdio.cpp).sceKernelRead/Write/Lseekon fd -1, the direct nonblocking-pipe EAGAIN, andreadon a directory returning EISDIR (the DOOM case, non-Windows).Checked on Linux:
guest_posix_scalar_io,guest_directory_entries,guest_file_vector,guest_parent_processpass; the new test fails without the code changes. Merging once CI is green on the new head.