fix(libkernel): return SCE error codes from sceKernelFsync #3682
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3682"
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:19:19Z.
What
sceKernelFsyncreturned the raw result of the hostfsync(_commiton Windows), which is -1 on failure, not an SCE error code. Guest sockets, whose descriptors are not host descriptors, went straight to the host call.fsyncthen read the hosterrno, which uses host numbering.This makes
sceKernelFsyncbehave likesceKernelFdatasyncnext to it:EINVAL(0x80020016).EBADF(0x80020009).SceErrorFromErrno(errno).fsyncderiveserrnofrom that code throughPosixResult, asfdatasyncdoes.Sources: FreeBSD
fsync(2)listsEBADFfor an invalid descriptor andEINVALfor a descriptor that refers to a socket. The SCE codes follow the0x80020000 | errnoscheme used by the rest of the file.Overlap: #3578 changes the Windows line of
sceKernelFsynctoNativeSync. The two touch the same lines, so whichever merges second needs a one-line rebase. The behaviour does not conflict.Tested
Ubuntu 24.04, GCC 13.3, on
maina11c8f7f.guest_filesystem: new checks mirroring the existingfdatasyncones:fsyncsetserrno9 andsceKernelFsyncreturns0x80020009.fsyncsetserrno22 andsceKernelFsyncreturns0x80020016.fsyncsetserrno9 andsceKernelFsyncreturns0x80020009.sceKernelFsync(0x7fffffff)returns0x80020009.mainwithout the change and passes with it.guest_*tests (ctest -R '^guest_' --parallel 4) with the change: all pass exceptguest_truncate(the container runs as root) andguest_kernel_stack_protect(fails onmaintoo; #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:58:01Z.
Rebased onto current
main(#3578 landed first and touched the same line): the Windows branch ofsceKernelFsyncnow callsNativeSync(fd)and mapserrnowithSceErrorFromErrno, exactly likesceKernelFdatasync. The rest is unchanged.guest_filesystempasses on Linux. Merging once CI is green.