feat(libkernel): implement lutimes #4622

Merged
jagrat04 merged 1 commit from upstream-pr/4622 into main 2026-10-13 07:48:08 +00:00
jagrat04 commented 2026-10-12 16:55:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jagrat04 on 2026-10-12T16:55:09Z.


What

Implement lutimes (PmZfv0lup1c) in libkernel:

  • Add followLink parameter to NativeUtimes (defaulting to true for utimes and futimes).
  • On Windows, pass FILE_FLAG_OPEN_REPARSE_POINT when followLink is false so timestamps are set on the symbolic link or reparse point itself rather than the target file.
  • On Linux, delegate to ::lutimes when followLink is false.
  • Export lutimes_nid_postfix with standard path validation, invalid microsecond checks, and path resolution.
  • Add test coverage in GuestFileTimestamps for fractional timestamps, invalid microseconds, null/empty/missing paths, and symbolic links.

Tested

  • Windows 11 (x86_64), GuestFileTimestamps test suite: verified fractional timestamps, invalid microsecond rejection, error reporting (EFAULT, ENOENT, EINVAL), and symlink timestamp modification without altering target file times.
  • python tools/check_conventions.py --base origin/main passed cleanly.

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
  • Unblocks: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4832490937 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4622). Originally posted by [jagrat04](https://github.com/jagrat04) on 2026-10-12T16:55:09Z. --- ### What Implement `lutimes` (`PmZfv0lup1c`) in `libkernel`: - Add `followLink` parameter to `NativeUtimes` (defaulting to `true` for `utimes` and `futimes`). - On Windows, pass `FILE_FLAG_OPEN_REPARSE_POINT` when `followLink` is false so timestamps are set on the symbolic link or reparse point itself rather than the target file. - On Linux, delegate to `::lutimes` when `followLink` is false. - Export `lutimes_nid_postfix` with standard path validation, invalid microsecond checks, and path resolution. - Add test coverage in `GuestFileTimestamps` for fractional timestamps, invalid microseconds, null/empty/missing paths, and symbolic links. ### Tested - Windows 11 (x86_64), `GuestFileTimestamps` test suite: verified fractional timestamps, invalid microsecond rejection, error reporting (`EFAULT`, `ENOENT`, `EINVAL`), and symlink timestamp modification without altering target file times. - `python tools/check_conventions.py --base origin/main` passed cleanly. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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] Unblocks: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-12 17:34:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T17:34:11Z.


Progress report (510a218 → 8d08caa)

➖ System libraries: 87.92% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel lutimes_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6129348175 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4622#issuecomment-6129348175). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T17:34:11Z. --- <!-- progress-report --> ### Progress report (510a218 → 8d08caa) ➖ **System libraries**: 87.92% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `lutimes_nid_postfix` | </details>
adriadam10 commented 2026-10-12 21:06:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T21:06:30Z.

Review: CHANGES_REQUESTED


Thanks for the PR. The implementation of lutimes_nid_postfix looks right, but the test aborts on Linux:

  • core/libs/tests/GuestFileTimestamps.cpp:152: CheckTimes(path, fd, second) uses fd, which was closed at line 129 (close fixture descriptor). guest_file_timestamps aborts with FillFileStat: fstat failed for fd 6. Check the target with stat_nid_postfix(path...) instead, or reopen it.
  • Same block: the symlink case only checks that the target is unchanged. Also stat/lstat the link itself and require its mtime to be first, otherwise nothing shows the link was modified.
  • The branch conflicts with main in docs/dev/debt/libkernel.md (the "Windows file timestamps" line); please rebase.

Please rerun ctest -R guest_file_timestamps locally after the fix.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5495944073 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4622#pullrequestreview-5495944073). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T21:06:30Z. **Review:** CHANGES_REQUESTED --- Thanks for the PR. The implementation of `lutimes_nid_postfix` looks right, but the test aborts on Linux: - `core/libs/tests/GuestFileTimestamps.cpp:152`: `CheckTimes(path, fd, second)` uses `fd`, which was closed at line 129 (`close fixture descriptor`). `guest_file_timestamps` aborts with `FillFileStat: fstat failed for fd 6`. Check the target with `stat_nid_postfix(path...)` instead, or reopen it. - Same block: the symlink case only checks that the target is unchanged. Also `stat`/`lstat` the link itself and require its mtime to be `first`, otherwise nothing shows the link was modified. - The branch conflicts with `main` in `docs/dev/debt/libkernel.md` (the "Windows file timestamps" line); please rebase. Please rerun `ctest -R guest_file_timestamps` locally after the fix.
jagrat04 commented 2026-10-13 01:01:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jagrat04 on 2026-10-13T01:01:26Z.


@adriadam10 Thanks for the review! Updated as requested:

  • Rebased cleanly onto latest origin/main resolving the debt doc conflict.
  • In core/libs/tests/GuestFileTimestamps.cpp: verified the target file timestamps using stat_nid_postfix(path.c_str(), &targetStatus) rather than the closed file descriptor, and verified the symlink's own mtime was updated to first using lstat_nid_postfix on Linux / reparse point query on Windows.
  • Verified locally with ctest -R guest_file_timestamps (passed) and tools/check_conventions.py --base origin/main.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6135779023 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4622#issuecomment-6135779023). Originally posted by [jagrat04](https://github.com/jagrat04) on 2026-10-13T01:01:26Z. --- @adriadam10 Thanks for the review! Updated as requested: - Rebased cleanly onto latest `origin/main` resolving the debt doc conflict. - In `core/libs/tests/GuestFileTimestamps.cpp`: verified the target file timestamps using `stat_nid_postfix(path.c_str(), &targetStatus)` rather than the closed file descriptor, and verified the symlink's own mtime was updated to `first` using `lstat_nid_postfix` on Linux / reparse point query on Windows. - Verified locally with `ctest -R guest_file_timestamps` (passed) and `tools/check_conventions.py --base origin/main`.
github-actions[bot] commented 2026-10-13 05:51:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T05:51:36Z.


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
#4938 docs/dev/debt/libkernel.md L97-98
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6139206804 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4622#issuecomment-6139206804). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T05:51:36Z. --- <!-- 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 | |---|---|---|---| | #4938 | `docs/dev/debt/libkernel.md` [L97-98](https://github.com/boykopovar/AnyPS5/blob/a373241de4403f7e8272be09ccf1a6b0866a8c69/docs/dev/debt/libkernel.md#L97-L98) | | |
adriadam10 commented 2026-10-13 07:48:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T07:48:04Z.

Review: APPROVED


Checked the build and guest_file_timestamps on Linux merged onto current main (full libs ctest green), and that the new test fails without the change; the symlink checks (target untouched, link mtime updated) and the error cases match utimes. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5500352308 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4622#pullrequestreview-5500352308). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T07:48:04Z. **Review:** APPROVED --- Checked the build and `guest_file_timestamps` on Linux merged onto current main (full libs ctest green), and that the new test fails without the change; the symlink checks (target untouched, link mtime updated) and the error cases match `utimes`. 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!4622
No description provided.