feat(libkernel): implement sceKernelFdatasync #2129
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2129"
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 sktharunbalaji13-cmd on 2026-10-09T09:41:14Z.
What
Implement the missing
sceKernelFdatasynclibkernel export (NID30Rh4ixbKy4), which is imported by Dying Light 2 (PPSA02262). The implementation uses_commiton Windows andfdatasyncon POSIX, following the existingsceKernelFsyncimplementation pattern.Add regression coverage for successful synchronization and invalid POSIX file descriptors. The related open PR #1620 implements a distinct
fdatasync_nid_postfixexport with a different NID, so it does not overlap with this change.Tested
Windows/MinGW Release:
cmake --build build --target guest_filesystem_tests— passed.ctest --test-dir build -R "^guest_filesystem$" --output-on-failure— 1/1 passed.sceKernelFdatasyncis exported and the repository NID helper returns30Rh4ixbKy4.WSL/Linux Release:
cmake --build build-libs --target guest_filesystem_tests— passed.ctest --test-dir build-libs -R '^guest_filesystem$' --output-on-failure— 1/1 passed.Verified the exported symbol; both valid-descriptor and invalid-descriptor assertions passed.
Confirmed the regression before the fix via a link failure for the missing export.
git diff --check— passed.The full test suite and Dying Light 2 runtime were not tested.
Checklist
main; no duplicate PR implements this export/NID.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:15:04Z.
Does Dying Light 2 (PPSA02262) stop at
sceKernelFdatasyncon main? Please add the log line where it stops; an import alone isn't enough for a new export. Also,sceKernel*functions return SCE error codes, so a bad descriptor should give0x80020009, not -1 (the test atGuestFilesystem.cpp:158should check that).Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T07:54:27Z.
Progress report (
de5e541→57be03a)➖ System libraries: 84.52% (+0.0%, +1 implemented functions)
✅ 1 implemented
sceKernelFdatasyncImported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-10T11:16:12Z.
Independent validation on Windows
Built and ran the PR head
8734b923on my own box:Release,BUILD_TESTING=ON.Results:
guest_filesystem_testsPASSES (exit 0).libkernel.prxexportssceKernelFdatasync(verified withnm:T sceKernelFdatasync).GuestFont.cppchange:guest_font_testsPASSES (exit 0) after the font.prxDLLs are present in the tests dir.Rigor check (is the test real?): I removed the
sceKernelFdatasyncimplementation fromStdio.cpp, rebuilt, and confirmedguest_filesystem_testsfails to link —undefined reference to 'sceKernelFdatasync'— then restored it → PASS. So the new test genuinely requires the new export rather than passing unconditionally. This matches the "link failure for the missing export" base regression noted in the PR.One concern — scope / "one topic per PR": this PR bundles two unrelated changes:
sceKernelFdatasyncfeature + itsGuestFilesystem.cpptest, andGuestFont.cpp(the PR's head commit is even titled "test(font): isolate system font failure case").The author checked "One topic per PR", but these are two distinct topics. I'd suggest splitting the font-test change into its own PR so review/rollback stay clean.
Honest limits of what I verified:
== 0path and the export. The invalid-fd== -1assertion is inside#ifndef _WIN32, so it does not run on Windows — I could not verify that path here.fdatasyncpath (no Linux here) or the Dying Light 2 title (no game/ROM).Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by sktharunbalaji13-cmd on 2026-10-10T11:40:19Z.
Status update after the rebase and scope cleanup.
Title evidence (Dying Light 2, PPSA02262) — reported by @tv7 in #1794 (comment):
main: the loader stops atFAIL: unresolved ELF import 30Rh4ixbKy4 from libkernel.prx.FAIL: unresolved ELF import -q-vbO859Tw from libSceVideoOut.prx.This is evidence the import blocker advances past
30Rh4ixbKy4; it is not a claim that the title becomes playable (12 further imports remain unresolved).Scope — the PR now contains only
core/libs/prx/libkernel/File/src/Stdio.cppandcore/libs/tests/GuestFilesystem.cpp. The bundledtest(font)change was dropped, sincemainnow carries that fix (SetFontDirectoryinGuestFont.cpp), which had caused a redefinition build error.Behavior —
sceKernelFdatasyncmaps native failures throughSceErrorFromErrno(errno)and returns0on success, matching the neighbouringsceKernel*file calls; the closed-descriptor assertion expects0x80020009.Tests —
guest_filesystempasses on Windows (MinGW-w64 GCC 15.2.0) and on Linux.Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-10T12:29:14Z.
Built the PR (head
36bc9214) merged with current main and probed the new export against a guest socket:sceKernelFdatasync(socket)returns0x80020009, whilefdatasync_nid_postfix(socket)on the same descriptor returns -1 with errno 22, because the POSIX export checksGuestSockets::FirstDescriptorfirst and this one does not. The EBADF comes from the host rejecting0x10000000as an fd, so it is accidental; on Windows the same call reaches_commitand the UCRT invalid-parameter handler in CrashReport.cpp before returning.Suggest moving the guard and the host call into
sceKernelFdatasyncand havingfdatasync_nid_postfixwrap it, the wayfsync_nid_postfixwrapssceKernelFsync.Probe (linked like
guest_filesystem_tests, Linux):Not run on Windows. AI-assisted.
Imported from boykopovar/AnyPS5. Originally posted by sktharunbalaji13-cmd on 2026-10-10T15:22:19Z.
Thanks @orishamir for catching the guest-socket descriptor issue — that was a real bug.
The fix is in
57be03a4:sceKernelFdatasyncnow checksGuestSockets::FirstDescriptorbefore any native syscall. An open guest socket returns SCE EINVAL (0x80020016); a closed or invalid guest socket returns SCE EBADF (0x80020009). This prevents high guest descriptors from reaching_commiton Windows (which would trigger the UCRT invalid-parameter handler).fdatasync_nid_postfixnow delegates tosceKernelFdatasyncthroughPosixResult, so the socket guard and error mapping live in one place — no duplicated logic.The targeted
guest_filesystem_testspassed on Windows/MinGW and Linux/WSL, including the new assertions for a valid socket (EINVAL), a closed socket (EBADF), and a high invalid descriptor like0x7fffffff(EBADF). The full test suite and Dying Light 2 were not tested.Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-10T16:53:41Z.
Confirmed on
57be03a4merged with current main (Linux):guest_filesystem_testspasses, and the probe from above now givessceKernelFdatasync(socket)=0x80020016for an open guest socket and0x80020009for a bad descriptor, matchingfdatasync_nid_postfix. Nothing further from me on this one.