Repository navigation
fix(libkernel): translate host errno in the file functions' SCE errors - #3681
Merged
adriadam10 merged 1 commit intoOct 11, 2026
Merged
Conversation
SceErrorFromErrno in the libkernel file functions passed host errno values 1-34 through and turned every other value into EIO. Linux numbers EAGAIN 11, which is FreeBSD's EDEADLK, so a read from an empty non-blocking pipe returned SCE_KERNEL_ERROR_EDEADLK, and ENAMETOOLONG, ELOOP, ENOTEMPTY, EDQUOT and EOVERFLOW, whose host values differ from FreeBSD's, all became EIO. Map those host values to the guest's FreeBSD numbers, as SceIoErrorFromErrno in Open.cpp already does for EAGAIN, EDEADLK, EDQUOT and EOVERFLOW. The guest constants the callers pass are all at most 34 and never 11, or GUEST_ENOTEMPTY, so they are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ha6Tsy62AFUyp9a5Mf7vjA
9 tasks done
Collaborator
|
Checked the errno mapping against FreeBSD |
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.
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; fix(libc): resume host foreign exceptions with host unwinder #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