feat(libSceLibcInternal): implement guest utime #2024

Closed
QRMOE wants to merge 4 commits from upstream-pr/2024 into main
QRMOE commented 2026-10-09 05:15:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by QRMOE on 2026-10-09T05:15:17Z.


What

Adds utime (1nTKA7pN1jw), reported missing by ProsperoRadio in #1578. Converts the guest's two 64-bit seconds fields to zero-microsecond timevals and forwards through the existing guest utimes path. Null times request the current clock.

Preserves the caller's guest errno on success, while retaining the delegated error on failure. Guest errno shares host errno storage, so successful host filesystem work can otherwise overwrite it.

Reference: FreeBSD utime. Path resolution and timestamp updates use the existing filesystem implementation, including the separate precision work proposed in #1518.

Review correction

MarcZX100's Linux review reproduced guest_utime failing on the original head ca87abb: successful utime changed guest errno from 71 to 22. The wrapper now explicitly restores errno only when utimes returns zero.

Adds guest_utime_forwarding, which links the production wrapper with a controlled backend that changes errno on success. It checks explicit/null times, 64-bit seconds, zero fractions, return values, exactly one backend call, and retention of failure errno. This test fails against the original PR implementation and passes with the correction. The native timestamp test now also checks errno preservation for null/current times and seeds errno before each rejected call.

Tested

Author's updated run: Windows 11, WinLibs MinGW-w64 GCC 15.2.0 r7 UCRT/posix/SEH, Ninja Release, BUILD_TESTING=ON, SPIRV-Tools enabled; base f145139676a48306681d3a4d5fabf83938759daf.

  • Full libs target and both utime test targets build successfully, including library NID patching.
  • guest_utime, guest_utime_forwarding, and guest_errors pass (3/3).
  • The new controlled-backend regression fails against original head ca87abb at the successful errno-preservation assertion.
  • Conventions, diff whitespace, and test registration checks pass.

The corrected head has not been run on Linux by the author; a Linux rerun is still needed before merge. The earlier independent Linux review tested the original head and found the failure described above. The existing guest_filesystem rename-back failure (line 113, errno 13) was reproduced on unchanged upstream main during the initial Windows validation; no pass is claimed for that test. Console behavior, games, and the complete CTest suite have not been run. These tests do not establish that a homebrew title now starts.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; this update corrects a review failure in the same implementation
  • No comments added in code
  • No silent success stubs added
  • No investigation notes, reports or images added to the repository
  • No third-party dependencies added
  • Generic behavior, not specific to one title
  • Depends on: none
  • AI-assisted: yes — OpenAI Codex assisted with implementation, tests and this description.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4796300637 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2024). Originally posted by [QRMOE](https://github.com/QRMOE) on 2026-10-09T05:15:17Z. --- ### What Adds `utime` (`1nTKA7pN1jw`), reported missing by ProsperoRadio in [#1578](https://github.com/boykopovar/AnyPS5/issues/1578). Converts the guest's two 64-bit seconds fields to zero-microsecond timevals and forwards through the existing guest `utimes` path. Null times request the current clock. Preserves the caller's guest errno on success, while retaining the delegated error on failure. Guest errno shares host errno storage, so successful host filesystem work can otherwise overwrite it. Reference: [FreeBSD utime](https://github.com/freebsd/freebsd-src/blob/main/lib/libc/gen/utime.c). Path resolution and timestamp updates use the existing filesystem implementation, including the separate precision work proposed in #1518. ### Review correction [MarcZX100's Linux review](https://github.com/boykopovar/AnyPS5/pull/2024#pullrequestreview-5466022518) reproduced `guest_utime` failing on the original head `ca87abb`: successful `utime` changed guest errno from 71 to 22. The wrapper now explicitly restores errno only when `utimes` returns zero. Adds `guest_utime_forwarding`, which links the production wrapper with a controlled backend that changes errno on success. It checks explicit/null times, 64-bit seconds, zero fractions, return values, exactly one backend call, and retention of failure errno. This test fails against the original PR implementation and passes with the correction. The native timestamp test now also checks errno preservation for null/current times and seeds errno before each rejected call. ### Tested Author's updated run: Windows 11, WinLibs MinGW-w64 GCC 15.2.0 r7 UCRT/posix/SEH, Ninja Release, `BUILD_TESTING=ON`, SPIRV-Tools enabled; base `f145139676a48306681d3a4d5fabf83938759daf`. - Full `libs` target and both utime test targets build successfully, including library NID patching. - `guest_utime`, `guest_utime_forwarding`, and `guest_errors` pass (3/3). - The new controlled-backend regression fails against original head `ca87abb` at the successful errno-preservation assertion. - Conventions, diff whitespace, and test registration checks pass. The corrected head has not been run on Linux by the author; a Linux rerun is still needed before merge. The earlier independent Linux review tested the original head and found the failure described above. The existing `guest_filesystem` rename-back failure (line 113, errno 13) was reproduced on unchanged upstream main during the initial Windows validation; no pass is claimed for that test. Console behavior, games, and the complete CTest suite have not been run. These tests do not establish that a homebrew title now starts. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; this update corrects a review failure in the same implementation - [x] No comments added in code - [x] No silent success stubs added - [x] No investigation notes, reports or images added to the repository - [x] No third-party dependencies added - [x] Generic behavior, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes — OpenAI Codex assisted with implementation, tests and this description.
MarcZX10 commented 2026-10-09 05:20:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T05:20:56Z.

Review: COMMENTED


I reviewed the complete three-file diff at ca87abbce02646ba28834358f1930a4cd06abebc and built the exact head on Linux/GCC 12.2. The target builds, but the focused CTest fails at GuestUtime.cpp:72: after seeding guest errno to 71, a successful utime call does not preserve it. A temporary diagnostic confirmed it is 22. GitHub reports no checks on this head yet.

This makes the current PR test fail in the Linux CTest job, despite the reported Windows pass. utime delegates to utimes in the cited FreeBSD implementation; here the forwarding utimes_nid_postfix path changes guest errno on success. Please either preserve the prior guest errno on a successful call (while keeping the error value on failure), or revise the errno-preservation claim and test if that behavior is intentionally unspecified. Then please run the focused test on Linux and Windows before merge.

I also ran check_conventions.py and git diff --check; both pass. The temporary diagnostic edit was restored; the PR source diff remains unchanged.

Reference: FreeBSD utime.c (https://raw.githubusercontent.com/freebsd/freebsd-src/main/lib/libc/gen/utime.c).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5466022518 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2024#pullrequestreview-5466022518). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T05:20:56Z. **Review:** COMMENTED --- I reviewed the complete three-file diff at `ca87abbce02646ba28834358f1930a4cd06abebc` and built the exact head on Linux/GCC 12.2. The target builds, but the focused CTest fails at `GuestUtime.cpp:72`: after seeding guest errno to 71, a successful `utime` call does not preserve it. A temporary diagnostic confirmed it is 22. GitHub reports no checks on this head yet. This makes the current PR test fail in the Linux CTest job, despite the reported Windows pass. `utime` delegates to `utimes` in the cited FreeBSD implementation; here the forwarding `utimes_nid_postfix` path changes guest errno on success. Please either preserve the prior guest errno on a successful call (while keeping the error value on failure), or revise the errno-preservation claim and test if that behavior is intentionally unspecified. Then please run the focused test on Linux and Windows before merge. I also ran `check_conventions.py` and `git diff --check`; both pass. The temporary diagnostic edit was restored; the PR source diff remains unchanged. Reference: FreeBSD `utime.c` (https://raw.githubusercontent.com/freebsd/freebsd-src/main/lib/libc/gen/utime.c).
github-actions[bot] commented 2026-10-09 05:35:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T05:35:55Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1772 __error_nid_postfix
#1841 core/libs/prx/libSceLibcInternal/CMakeLists.txt L1 __error_nid_postfix
#1860 __error_nid_postfix
#2051 __error_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6074993641 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2024#issuecomment-6074993641). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T05:35:55Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1772 | | `__error_nid_postfix` | | | #1841 | `core/libs/prx/libSceLibcInternal/CMakeLists.txt` [L1](https://github.com/boykopovar/AnyPS5/blob/d9484c719b2a5ac6201e27f8657e0fb0f01e648c/core/libs/prx/libSceLibcInternal/CMakeLists.txt#L1) | `__error_nid_postfix` | | | #1860 | | `__error_nid_postfix` | | | #2051 | | `__error_nid_postfix` | |
MarcZX10 commented 2026-10-09 06:01:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T06:01:13Z.

Review: APPROVED


Reviewed the complete current diff at ade10c77. I independently built the exact head on Linux with GCC 12 and ran guest_utime, guest_utime_forwarding, and guest_errors: 3/3 passed in 0.02 s. Conventions and git diff --check pass. This confirms the errno regression from my earlier review is fixed. The test-registration helper could not run here because it requires Ninja, which is not installed; the registered CTest cases were built and run directly. The author reports the focused tests pass on Windows. The upstream Build/Conventions/Progress workflows remain action_required and need maintainer approval before merge. Approved based on the completed platform test evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5466280212 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2024#pullrequestreview-5466280212). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T06:01:13Z. **Review:** APPROVED --- Reviewed the complete current diff at ade10c77. I independently built the exact head on Linux with GCC 12 and ran guest_utime, guest_utime_forwarding, and guest_errors: 3/3 passed in 0.02 s. Conventions and git diff --check pass. This confirms the errno regression from my earlier review is fixed. The test-registration helper could not run here because it requires Ninja, which is not installed; the registered CTest cases were built and run directly. The author reports the focused tests pass on Windows. The upstream Build/Conventions/Progress workflows remain action_required and need maintainer approval before merge. Approved based on the completed platform test evidence.
oneandonlydean commented 2026-10-09 09:30:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:30:53Z.


Closing: the #1578 list only shows that utime is imported; no title is shown stopping at it on main. Reopen when it's a title's next stop on main, with the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078247652 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2024#issuecomment-6078247652). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:30:53Z. --- Closing: the #1578 list only shows that `utime` is imported; no title is shown stopping at it on main. Reopen when it's a title's next stop on main, with the log line.
TheAggie commented 2026-10-10 13:07:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T13:07:33Z.


@oneandonlydean utime is now a title's next stop on current main, so here is the log line the close note asked for, plus a check of this branch.

vkQuake (PPSA99010), Windows 11 Pro 26200, MinGW-w64 GCC 15.2.0, Release. The title was relinked with relinker --windows --registry against main cf8b129e2:

  • On main: FAIL: unresolved ELF import 1nTKA7pN1jw from libSceLibcInternal.prx (utime). main exports utime only from libc, and vkQuake imports it from libSceLibcInternal.
  • With this branch (ade10c77 merged onto main cf8b129e2, clean): the title gets past utime and stops at FAIL: unresolved ELF import 04AjkP0jO9U from libkernel.prx (_umtx_op, #1482 / #2051).
  • guest_utime and guest_utime_forwarding pass.

tools/import_audit.py lists 14 absent imports for vkQuake on main, 13 with this branch.

Could you reopen it? (GitHub doesn't let @QRMOE reopen a PR a maintainer closed.)

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6097819636 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2024#issuecomment-6097819636). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-10T13:07:33Z. --- @oneandonlydean `utime` is now a title's next stop on current `main`, so here is the log line the close note asked for, plus a check of this branch. vkQuake (PPSA99010), Windows 11 Pro 26200, MinGW-w64 GCC 15.2.0, Release. The title was relinked with `relinker --windows --registry` against `main` cf8b129e2: - On `main`: `FAIL: unresolved ELF import 1nTKA7pN1jw from libSceLibcInternal.prx` (`utime`). `main` exports `utime` only from `libc`, and vkQuake imports it from `libSceLibcInternal`. - With this branch (ade10c77 merged onto `main` cf8b129e2, clean): the title gets past `utime` and stops at `FAIL: unresolved ELF import 04AjkP0jO9U from libkernel.prx` (`_umtx_op`, #1482 / #2051). - `guest_utime` and `guest_utime_forwarding` pass. `tools/import_audit.py` lists 14 absent imports for vkQuake on `main`, 13 with this branch. Could you reopen it? (GitHub doesn't let @QRMOE reopen a PR a maintainer closed.) AI-assisted (Claude Code).
TheAggie commented 2026-10-10 13:39:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T13:39:49Z.


Following up on my vkQuake note: a triage of the whole homebrew catalog on main cf8b129e2 (Windows 11, MinGW-w64 GCC 15.2.0; each release ZIP checked against its catalog sha256, relinked with relinker --windows --registry, run for 12 s) puts utime (1nTKA7pN1jw, libSceLibcInternal) as the most common first stop: 6 titles. With this branch each moves on:

Title main with this branch
ccleste (PPSA59322) utime _umtx_op
RommPS (PPSA76677) utime _umtx_op
vkQuake (PPSA99010) utime _umtx_op
PSXS5 (PPSA97510) utime pthread_sigmask
SwanStationPS5 (PPSA98510) utime pthread_sigmask
Capy Mobile (PPSA92280) utime all imports resolve; it runs and throws sysctlbyname_nid_postfix: unsupported name kern.sdk_version

The "with this branch" column comes from one build of main with this branch plus #1872, #2765 and #2478, which add unrelated imports (pthread_set_name_np, alarm, dup/dup2). @oneandonlydean, could this be reopened?

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6098084827 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2024#issuecomment-6098084827). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-10T13:39:49Z. --- Following up on my vkQuake note: a triage of the whole homebrew catalog on `main` cf8b129e2 (Windows 11, MinGW-w64 GCC 15.2.0; each release ZIP checked against its catalog sha256, relinked with `relinker --windows --registry`, run for 12 s) puts `utime` (`1nTKA7pN1jw`, libSceLibcInternal) as the most common first stop: 6 titles. With this branch each moves on: | Title | `main` | with this branch | |---|---|---| | ccleste (PPSA59322) | `utime` | `_umtx_op` | | RommPS (PPSA76677) | `utime` | `_umtx_op` | | vkQuake (PPSA99010) | `utime` | `_umtx_op` | | PSXS5 (PPSA97510) | `utime` | `pthread_sigmask` | | SwanStationPS5 (PPSA98510) | `utime` | `pthread_sigmask` | | Capy Mobile (PPSA92280) | `utime` | all imports resolve; it runs and throws `sysctlbyname_nid_postfix: unsupported name kern.sdk_version` | The "with this branch" column comes from one build of `main` with this branch plus #1872, #2765 and #2478, which add unrelated imports (`pthread_set_name_np`, `alarm`, `dup`/`dup2`). @oneandonlydean, could this be reopened? AI-assisted (Claude Code).
babyhuey commented 2026-10-10 17:36:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T17:36:49Z.


@QRMOE utime is now the next stop on main for six catalog titles: ccleste (PPSA59322), RommPS (PPSA76677), Capy Mobile (PPSA92280), PSXS5 (PPSA97510), SwanStationPS5 (PPSA98510) and vkQuake (PPSA99010), with undefined symbol: 1nTKA7pN1jw on Linux and FAIL: unresolved ELF import 1nTKA7pN1jw (utime) from libSceLibcInternal.prx on Windows (#1578). This branch still merges cleanly onto main 57f96fd2.

The intake check now needs 10 merged PRs. If you can't open it again yet, would you like me to open it from my fork with your commits and authorship kept, the way #2858 carries Recapi's _fstatfs? I'd run the tests and the six titles on Linux and Windows first.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6100329325 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2024#issuecomment-6100329325). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T17:36:49Z. --- @QRMOE `utime` is now the next stop on `main` for six catalog titles: ccleste (PPSA59322), RommPS (PPSA76677), Capy Mobile (PPSA92280), PSXS5 (PPSA97510), SwanStationPS5 (PPSA98510) and vkQuake (PPSA99010), with `undefined symbol: 1nTKA7pN1jw` on Linux and `FAIL: unresolved ELF import 1nTKA7pN1jw (utime) from libSceLibcInternal.prx` on Windows (#1578). This branch still merges cleanly onto `main` 57f96fd2. The intake check now needs 10 merged PRs. If you can't open it again yet, would you like me to open it from my fork with your commits and authorship kept, the way #2858 carries Recapi's `_fstatfs`? I'd run the tests and the six titles on Linux and Windows first.
QRMOE commented 2026-10-10 18:32:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by QRMOE on 2026-10-10T18:32:41Z.


@babyhuey Yes, please go ahead and open it from your fork. Thank you for offering to test it on both platforms.

Please keep my original commits and authorship, and credit @QRMOE in the new PR description. If the work is rebased or squashed, please retain the original author credit.

Please use the corrected revision ade10c77, which includes the successful-call errno fix and guest_utime_forwarding. Running the focused tests and all six titles on Linux and Windows against current main before submitting sounds good. Please link the replacement PR here so I can follow it.

AI-assisted: yes, OpenAI Codex helped draft this reply.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6100831389 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2024#issuecomment-6100831389). Originally posted by [QRMOE](https://github.com/QRMOE) on 2026-10-10T18:32:41Z. --- @babyhuey Yes, please go ahead and open it from your fork. Thank you for offering to test it on both platforms. Please keep my original commits and authorship, and credit @QRMOE in the new PR description. If the work is rebased or squashed, please retain the original author credit. Please use the corrected revision [ade10c77](https://github.com/QRMOE/AnyPS5/tree/ade10c77f2d8392f503809bfeafb7bc92aed4927), which includes the successful-call errno fix and `guest_utime_forwarding`. Running the focused tests and all six titles on Linux and Windows against current main before submitting sounds good. Please link the replacement PR here so I can follow it. AI-assisted: yes, OpenAI Codex helped draft this reply.
babyhuey commented 2026-10-10 18:59:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T18:59:49Z.


@QRMOE opened as #2967 with your four commits from ade10c77 rebased onto main 9c5d67fb, your authorship kept and you credited in the description. Both tests pass 5/5 on Linux and Windows, and all six titles get past utime on both. Capy Mobile now resolves every import and on Windows gets as far as creating its swapchain before stopping at kern.sdk_version (#2701).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6101072295 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2024#issuecomment-6101072295). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T18:59:49Z. --- @QRMOE opened as #2967 with your four commits from ade10c77 rebased onto `main` 9c5d67fb, your authorship kept and you credited in the description. Both tests pass 5/5 on Linux and Windows, and all six titles get past `utime` on both. Capy Mobile now resolves every import and on Windows gets as far as creating its swapchain before stopping at `kern.sdk_version` (#2701).

Pull request closed

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!2024
No description provided.