fix(libkernel_sys): translate host errors to guest errno numbers #3685
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3685"
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:20:07Z.
What
GuestErrorinlibkernel_sys/Export.cppturns astd::error_codefromstd::filesysteminto the guesterrno. It passed host values up to 34 through unchanged and reported everything else asEIO. As a result,readlinkseterrno5 (EIO) for:ENAMETOOLONG);ELOOP).A host
EAGAIN(11 on Linux and Windows) would also have come out as the guest'sEDEADLK.This compares the error condition with the portable
std::errcvalues whose numbers differ between the host and FreeBSD, and maps them:resource_unavailable_try_again→ 35resource_deadlock_would_occur→ 11too_many_symbolic_link_levels→ 62filename_too_long→ 63directory_not_empty→ 66value_too_large→ 84The rest is unchanged.
Overlap: #3611 (
implement pathconf) adds the sameGuestEloopandGuestEnametoolongconstants, plus aPathErrorhelper that maps only those two values forpathconf. The two merge without a textual conflict but then define the constants twice, so whichever merges second drops its copies.Source: FreeBSD
sys/sys/errno.hfor the guest numbers.Tested
Ubuntu 24.04, GCC 13.3, on
main12c22662.guest_kernel_sys: new checks:readlinkon a path with a 300-character name setserrno63.readlinkthrough a two-link loop (loopA→loopB→loopA) setserrno62.mainwithout the change and passes with it.guest_filesystemandguest_kernel_stack_protectpass.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:50:36Z.
Checked the six mappings against FreeBSD
sys/sys/errno.h(EDEADLK 11, EAGAIN 35, ELOOP 62, ENAMETOOLONG 63, ENOTEMPTY 66, EOVERFLOW 84), built on Linux and ranguest_kernel_sys(passes; fails with theExport.cppchange reverted). Merging.Note for #3611: it defines
GuestEloop/GuestEnametoolongtoo and conflicts with this inExport.cpp; after this lands it should reuse these constants andGuestError.