fix(libkernel): translate host errno in the file functions' SCE errors #3681
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3681"
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 zmeizy on 2026-10-11T15:18:44Z.
What
SceErrorFromErrnoinlibkernel/File/src/Stdio.cppbuilds0x80020000 | errnofrom the hosterrno. It passes values up to 34 through unchanged and turns everything else intoEIO. Up to 34, Linux and FreeBSD numbering agree except for 11: LinuxEAGAINis 11, which is FreeBSDEDEADLK. Above 34 the two differ, so real errors were reported asEIO. For example, a non-blockingsceKernelReadvon an empty pipe returned0x8002000b(EDEADLK) instead of0x80020023(EAGAIN).sceKernelMkdirwith a too-long name returnedEIOinstead ofENAMETOOLONG(0x8002003f). The POSIX wrappers derive the guesterrnofrom these codes, soreadvandmkdirreported the wrongerrnoas well.This maps the host values that differ to their FreeBSD numbers, using the host's own macros, so the mapping is the same on Linux and Windows:
EAGAIN→ 35EDEADLK→ 11ENAMETOOLONG→ 63ENOTEMPTY→ 66ELOOP→ 62EDQUOT→ 69EOVERFLOW→ 84Values up to 34 still pass through, and anything else still becomes
EIO. The guest constants the file passes in itself are unchanged.Sources: FreeBSD
sys/sys/errno.hfor the guest numbers.Open.cpp'sSceIoErrorFromErrnoalready applies the same values forEAGAIN,EDEADLK,EDQUOTandEOVERFLOW.Related: #2144 rewrites the separate mapping in
Open.cpp; this PR changes onlyStdio.cpp's. Both add anErrorEagainconstant and#include <fcntl.h>toGuestFileVector.cpp(#2144 forsceKernelRead, this PR forsceKernelReadv), so whichever merges second drops the duplicate constant.Tested
Ubuntu 24.04, GCC 13.3, on
maina11c8f7f.guest_file_vector: new check that a non-blockingsceKernelReadvon an empty pipe returns0x80020023andreadvsetserrno35 (skipped on Windows, which has noO_NONBLOCKpipes).guest_filesystem: new check thatsceKernelMkdirwith a 300-character name returns0x8002003fandmkdirsetserrno63.mainwithout the change and pass with it.ctest --timeout 120 --parallel 4with the change: 832 tests. 4 fail, none related to this change:guest_truncate: the container runs as root, which ignores the read-only bit.guest_kernel_stack_protect: also fails onmain; #3520 fixes it.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (n/a).mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_01Ha6Tsy62AFUyp9a5Mf7vjA
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:51:01Z.
Checked the errno mapping against FreeBSD
sys/sys/errno.h(EAGAIN 35, EDEADLK 11, ENAMETOOLONG 63, ELOOP 62, ENOTEMPTY 66, EDQUOT 69, EOVERFLOW 84) and againstOpen.cpp's existing mapping; build and ctest ofcore/libspass, and both new checks fail when theStdio.cppchange is reverted. Merging.