fix(kernel): return guest errors from scalar file operations #2144
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2144"
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 erick-dsnk on 2026-10-09T09:58:20Z.
What
Return encoded guest errors from
sceKernelRead,sceKernelWrite, andsceKernelLseekfor invalid descriptors, buffers, offsets, and whence values. Translate host errno symbols to guest constants so host-specific numbering (includingEAGAIN) does not leak into the guest ABI. Zero-length null-buffer operations still reach the native call so invalid descriptors reportEBADF.For
sceKernelLseek, whence values outside 0–4 return guestEINVAL. FreeBSD 11 defines 3 and 4 asSEEK_DATAandSEEK_HOLE; these valid modes throw as unsupported because sparse-file seeking is not implemented. The console behavior of those modes is unverified and recorded in TechnicalDebt.Tested
Linux x86-64: incremental full
libsbuild;guest_file_vector,guest_filesystem, andguest_aiotests passed; conventions check against the PR base passed. The new seek regression failed when tested against the old 0–2 guard and passed after restoring the fix.Windows 11 results were reported for the previous head
757cadfe; that run does not cover this seek-mode correction. The current head was not runtime-tested on Windows.Checklist
main; no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by rmz-24 on 2026-10-09T11:49:45Z.
Windows results for
757cadfe: Windows 11 Pro 25H2 (10.0.26200.9457), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, full build pluslibs.guest_file_vectorpasses.guest_*tests pass.Open.cppreset to the base (3bd74c15) and the new test kept,guest_file_vectorfails, as it should:sceKernelLseek: invalid whence=3is thrown at the test'ssceKernelLseek(file, 0, 3).One semantic point on that case. In FreeBSD 11,
whence3 and 4 are valid:SEEK_DATAandSEEK_HOLE(sys/sys/unistd.h), handled bykern_lseekthroughFIOSEEKDATA/FIOSEEKHOLE(sys/kern/vfs_vnops.c). ReturningEINVALfor them makes a supported request look invalid, and the test now asserts that. Keeping the throw for 3 and 4 (or implementing them) and returningEINVALonly for values outside 0-4 would match FreeBSD and the rule that unsupported cases throw. The test could then use, for example,whence = 5for itsEINVALcase.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:15:06Z.
Which title hits one of the read/write/lseek throws on main? Please add the title ID and the log line; that's what makes this change of behaviour needed. Separately,
NativeRead/NativeWrite(Open.cpp:31-54) now return EINVAL above INT_MAX bytes; that's a Windows host limit, not something the console reports, so keep the throw there.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T05:17:56Z.
Which title hits one of the read/write/lseek throws on main? That question is still open. Please also rebase instead of merging main (
c6f88c39); it conflicts inOpen.cppagain.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T08:01:55Z.
Progress report (
32064d3→c6f88c3)📉 System libraries: 85.65% (-0.04%, -1 reverted functions)
⚠️ 1 went back to stubs
sceKernelLseekImported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-10T10:05:28Z.
Additional platform validation on standalone PR head
c6f88c391556eaff4fc9072b6f41be441cb1e79d:Windows: passed — Windows 11, supported WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; CMake 4.3.1 / Ninja.
Release /
BUILD_TESTING=ON: built the selected test targets; 3 CTest cases, 0 failures, 0 CTest skips.Tests:
guest_filesystem,guest_aio,guest_file_vector.Reproduce after building the test targets:
ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^guest_(file_vector|filesystem|aio)$".Integration limitation: a local merge against main
948a526c2has source conflicts; these results validate the standalone PR head, not a resolved merge.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T23:59:01Z.
Review: CHANGES_REQUESTED
Thanks for the work and the Windows runs. Before this can land:
oneandonlydeanasked twice (2026-10-09, 2026-10-10) which title hits one of thesceKernelRead/sceKernelWrite/sceKernelLseekthrows onmain; please add the title ID and the log line. This is a behaviour change (throw → error return) and needs that evidence.mainincore/libs/prx/libkernel/File/src/Open.cpp. Please rebase instead of mergingmain(dropc6f88c39); PRs must not contain merge commits.SceErrorFromErrno(Open.cpp:152) maps every unlisted errno toEIO. That is a plausible but unverified result wheremainthrew; either list only errnos the console is known to return and throw for the rest, or cite the source for the fallback.sceKernelLseekas reverted to a stub (whence 3/4 throw). Keep it counted by implementingSEEK_DATA/SEEK_HOLE, or say in the PR why the regression is intended.docs/dev/TechnicalDebt.md:264is the line you add; after rebasing, keep it away from the end of its section to avoid adjacency conflicts.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T08:05:14Z.
Closing: main already returns the guest error from
sceKernelRead,sceKernelWriteandsceKernelLseekwhen the host call fails (#1307,ce0239c94), and the points from 10-10 are still open. If a title still reaches the null-buffer or whence throws on main, please reopen rebased with its ID and the log line.Pull request closed