Skip to content

fix(libkernel): translate fsync errors for guest callers - #2030

Closed
STUPIDCONTEM wants to merge 1 commit into
boykopovar:mainfrom
STUPIDCONTEM:fix/fsync-error-results
Closed

STUPIDCONTEM wants to merge 1 commit into
boykopovar:mainfrom
STUPIDCONTEM:fix/fsync-error-results

Conversation

@STUPIDCONTEM

@STUPIDCONTEM STUPIDCONTEM commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Evidence review (2026-10-09)

Game/title evidence has not been established. Validation below is host regression/build evidence only; it does not establish title compatibility. Older checked items and test results describe their stated revisions, not current merge readiness.

Game/title ID: none verified. No PS5 title execution is claimed.

What

sceKernelFsync returned the host's -1 on failure instead of an encoded kernel error. It also sent guest socket descriptors to the host CRT, which could only report an invalid descriptor.

Translate native failures through the existing kernel error mapping and preserve the caller's errno in the kernel entry point. The POSIX fsync wrapper now decodes the kernel result into -1 plus guest errno. Open guest sockets return EINVAL, and invalid/closed descriptors return EBADF.

The socket/invalid-descriptor distinction follows FreeBSD 11 fsync; the kernel encoding is the project's existing KernelErrors/SceErrorFromErrno convention. Regular files still use the existing host flush operation.

Tested

Windows 10 Pro 19045, WinLibs MinGW-w64 GCC 15.2.0 UCRT/posix/SEH r7, Ninja Release, BUILD_TESTING=ON, SPIRV-Tools disabled. Based directly on f145139676a48306681d3a4d5fabf83938759daf; independent of #2029.

  • New guest_fsync fails against upstream at kernel result encodes the guest error.
  • With the fix, it checks negative/large invalid descriptors, closed regular descriptors, open/closed sockets, successful regular-file flushes, kernel errno preservation, and POSIX errno translation.
  • Focused guest_fsync, guest_filesystem, and guest_kernel_sync: 3/3 passed.
  • Full default and explicit libs builds succeed.
  • Full CTest suite: 489/489 passed, 27.52 s.
  • Committed-head conventions, whitespace, and test-registration checks pass.

Linux and PS5 hardware/title behavior were not tested. The regression checks API results, not crash/power-loss durability.

Overlap review: #1738 registers a terminal test at the same CMake insertion point; it changes different production functions and is not a dependency. #2001 deletes the POSIX fsync wrapper as part of broader removals; it does not implement the error translation here. This PR remains independently based on main; overlapping hunks need reconciliation if either change lands first.

An external review approved this exact head and reports a Linux/GCC 12.2 build plus passing guest_fsync (1/1). This is reviewer-reported validation, separate from the local Windows results above.

Checklist

  • Based on current main; no other open PR implements the same change (historical base; current readiness not asserted)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes — OpenAI Codex assisted with implementation, testing, and this description.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full three-file diff at 7ea7f59. The kernel API now returns the project’s encoded error and preserves errno; the POSIX wrapper uses the existing PosixResult path. The new test covers regular files, sockets, invalid/closed descriptors, and errno behavior. Exact-head Linux/GCC 12.2 build passed and guest_fsync passed (1/1, 0.05 s); conventions and diff checks pass. The author reports the Windows run and full CTest. GitHub currently reports no checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build libkernel needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants