feat(libkernel): implement fdatasync #1620

Merged
babyhuey merged 1 commit from upstream-pr/1620 into main 2026-10-09 21:50:46 +00:00
babyhuey commented 2026-10-08 15:03:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-08T15:03:33Z.


What

Implements fdatasync (KIbJFQ0I1Cg) in libkernel. Part of #1578: PPSA99001 (ProsperoRadio) imports it.

  • Host descriptors use fdatasync on Linux and _commit on Windows; host errors map through SceErrorFromErrno like the neighbouring calls.
  • Guest socket descriptors fail with EINVAL when open and EBADF otherwise, as fchmod and futimes already do (FreeBSD fdatasync on a socket returns EINVAL).

Tested

Linux (Ubuntu 24.04, GCC 13, Release): guest_filesystem passes with --repeat until-fail:3; it now checks fdatasync on a file, a closed descriptor (Linux only, as for futimes), an open socket and a closed socket. The test fails when the socket branch is removed. check_conventions.py passes. Windows: Stdio.cpp compiles with MinGW-w64 GCC 13 (-Wall -Wextra -fsyntax-only); not run on Windows. No title run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4788775287 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1620). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-08T15:03:33Z. --- ### What Implements `fdatasync` (`KIbJFQ0I1Cg`) in libkernel. Part of #1578: PPSA99001 (ProsperoRadio) imports it. - Host descriptors use `fdatasync` on Linux and `_commit` on Windows; host errors map through `SceErrorFromErrno` like the neighbouring calls. - Guest socket descriptors fail with `EINVAL` when open and `EBADF` otherwise, as `fchmod` and `futimes` already do (FreeBSD `fdatasync` on a socket returns `EINVAL`). ### Tested Linux (Ubuntu 24.04, GCC 13, Release): `guest_filesystem` passes with `--repeat until-fail:3`; it now checks `fdatasync` on a file, a closed descriptor (Linux only, as for `futimes`), an open socket and a closed socket. The test fails when the socket branch is removed. `check_conventions.py` passes. Windows: `Stdio.cpp` compiles with MinGW-w64 GCC 13 (`-Wall -Wextra -fsyntax-only`); not run on Windows. No title run. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
hikazey commented 2026-10-08 17:25:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hikazey on 2026-10-08T17:25:13Z.


Windows run, since the description says it wasn't run there: Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7, the CI build), Release, configured like CI, Ryzen 9 5900X. This commit merged onto main 7995d657, which merges cleanly.

build guest_filesystem
this PR 5/5 passed
socket check removed from fdatasync_nid_postfix (_commit gets the guest socket descriptor), test kept 5/5 aborted
full suite with this PR 457/457 passed

So the _commit branch works for a regular file on Windows, and the socket cases catch a missing socket check there too. The closed-descriptor case stays Linux-only, as the test has it.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6065368455 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1620#issuecomment-6065368455). Originally posted by [hikazey](https://github.com/hikazey) on 2026-10-08T17:25:13Z. --- Windows run, since the description says it wasn't run there: Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7, the CI build), Release, configured like CI, Ryzen 9 5900X. This commit merged onto `main` `7995d657`, which merges cleanly. | build | `guest_filesystem` | | --- | --- | | this PR | 5/5 passed | | socket check removed from `fdatasync_nid_postfix` (`_commit` gets the guest socket descriptor), test kept | 5/5 aborted | | full suite with this PR | 457/457 passed | So the `_commit` branch works for a regular file on Windows, and the socket cases catch a missing socket check there too. The closed-descriptor case stays Linux-only, as the test has it. AI-assisted: yes (Claude Code).
babyhuey commented 2026-10-08 17:37:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-08T17:37:00Z.


Fork CI while the upstream run waits for approval: Build run, all jobs green on f63f4ff0 (Linux 466/466, Windows 457/457, relinker on Linux, macOS and Windows). It builds the branch head, not the merge with main. Thanks @hikazey for the merged Windows run above.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6065571398 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1620#issuecomment-6065571398). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-08T17:37:00Z. --- Fork CI while the upstream run waits for approval: [Build run](https://github.com/babyhuey/AnyPS5/actions/runs/37812338461), all jobs green on f63f4ff0 (Linux 466/466, Windows 457/457, relinker on Linux, macOS and Windows). It builds the branch head, not the merge with `main`. Thanks @hikazey for the merged Windows run above.
github-actions[bot] commented 2026-10-08 21:25:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T21:25:36Z.


Progress report (54f28f2 → 6768210)

📈 System libraries: 85.31% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel fdatasync_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6069352977 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1620#issuecomment-6069352977). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-08T21:25:36Z. --- <!-- progress-report --> ### Progress report (54f28f2 → 6768210) 📈 **System libraries**: 85.31% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `fdatasync_nid_postfix` | </details>
adriadam10 commented 2026-10-09 21:50:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:50:42Z.


Checked on Linux: build and full ctest green (guest_filesystem included), the NID matches fdatasync, and the behaviour (fd closed → EBADF, socket → EINVAL) matches prosper. Windows _commit path confirmed by @hikazey's run above. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6089849522 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1620#issuecomment-6089849522). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T21:50:42Z. --- Checked on Linux: build and full ctest green (`guest_filesystem` included), the NID matches `fdatasync`, and the behaviour (fd closed → EBADF, socket → EINVAL) matches prosper. Windows `_commit` path confirmed by @hikazey's run above. Merging.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1620
No description provided.