feat(libScePosixForWebKit): implement opendir, closedir, readdir, readdir_r #12386

Merged
PrivacyOnion merged 1 commit from upstream-pr/12386 into main 2026-10-29 09:35:38 +00:00
PrivacyOnion commented 2026-10-28 12:08:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-10-28T12:08:24Z.


What

Declare and implement opendir, closedir, readdir, and readdir_r in libScePosixForWebKit, forward them to libc directory operations, and add unit test coverage for traversal and argument validation.

Tested

Windows 11 x86_64; verified conventions with check_conventions.py, test registration with check_test_registration.py, no PR overlap with pr_overlap.py, and unit test suite passing. Verified directory traversal, entry properties (nameLength, recordLength, fileNumber), EOF handling, readdir_r, and null/empty/invalid argument rejection.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5050206879 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12386). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-10-28T12:08:24Z. --- ### What Declare and implement `opendir`, `closedir`, `readdir`, and `readdir_r` in `libScePosixForWebKit`, forward them to libc directory operations, and add unit test coverage for traversal and argument validation. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 x86_64; verified conventions with check_conventions.py, test registration with check_test_registration.py, no PR overlap with pr_overlap.py, and unit test suite passing. Verified directory traversal, entry properties (nameLength, recordLength, fileNumber), EOF handling, readdir_r, and null/empty/invalid argument rejection. ### 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-28 12:21:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T12:21:35Z.

Review: COMMENTED


Reviewed exact head 0b03cad03a7205155a315d82e4c28deebe24a3d5. The four export names hash to the NIDs listed in the debt note; the wrappers use the existing libc directory API and the traversal/entry/EOF/error tests exercise the important behavior. The documented uncertainty about any PS5-specific WebKit sandboxing or path filtering remains appropriately visible. I found no functional issue in the forwarding code. Exact-head conventions pass; diff --check reports one extra blank line at end of Export.cpp. Hosted Windows is still pending, so I have not approved.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5682479816 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12386#pullrequestreview-5682479816). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T12:21:35Z. **Review:** COMMENTED --- Reviewed exact head 0b03cad03a7205155a315d82e4c28deebe24a3d5. The four export names hash to the NIDs listed in the debt note; the wrappers use the existing libc directory API and the traversal/entry/EOF/error tests exercise the important behavior. The documented uncertainty about any PS5-specific WebKit sandboxing or path filtering remains appropriately visible. I found no functional issue in the forwarding code. Exact-head conventions pass; diff --check reports one extra blank line at end of Export.cpp. Hosted Windows is still pending, so I have not approved.
adriadam10 commented 2026-10-28 12:29:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-28T12:29:19Z.

Review: CHANGES_REQUESTED


The forwarding to the libc directory functions looks right, and the four names hash to the NIDs in the debt note. Two things to fix:

  • core/libs/tests/GuestPosixFilesystem.cpp:176-205: the new calls pass root.string() / root / "missing-directory", which are absolute host paths. On Linux the guest path resolver maps an absolute path under the guest root, not onto the host, so opendir returns null and the Require(testDirectory != nullptr) fails on the Linux job (a drive-letter path only works on Windows). The rest of this test uses the alias; please open "/anyps5-posix-test" and "/anyps5-posix-test/missing-directory" instead.
  • core/libs/prx/libScePosixForWebKit/Export.cpp:285 and the end of the file: a double blank line and a blank line at EOF (git diff --check).
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5682571374 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12386#pullrequestreview-5682571374). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-28T12:29:19Z. **Review:** CHANGES_REQUESTED --- The forwarding to the libc directory functions looks right, and the four names hash to the NIDs in the debt note. Two things to fix: - `core/libs/tests/GuestPosixFilesystem.cpp:176-205`: the new calls pass `root.string()` / `root / "missing-directory"`, which are absolute host paths. On Linux the guest path resolver maps an absolute path under the guest root, not onto the host, so `opendir` returns null and the `Require(testDirectory != nullptr)` fails on the Linux job (a drive-letter path only works on Windows). The rest of this test uses the alias; please open `"/anyps5-posix-test"` and `"/anyps5-posix-test/missing-directory"` instead. - `core/libs/prx/libScePosixForWebKit/Export.cpp:285` and the end of the file: a double blank line and a blank line at EOF (`git diff --check`).
MarcZX10 commented 2026-10-29 05:40:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T05:40:38Z.

Review: APPROVED


Re-checked — approved

The two issues from review are resolved: the fixture now uses guest path aliases, and the trailing blank lines are gone. The four ABI wrappers still forward directly to the existing directory API, and the added tests cover null/missing paths, traversal, EOF, record fields, and close/read errors.

What I ran

  • Reviewed exact head 634e7eb41fb02b44068bf664de34cf72a744741c against current main 52c09d567d2fa453494dd720fcf53a98149468e4.
  • Ran git merge-tree --write-tree, git diff --check, and python3 tools/check_conventions.py --base refs/review/main-20261029c --head refs/review/pr-12386-latest.
  • Checked the exact-head test and hosted-check reports.

Results

Check Result
Current-main merge preview Clean
git diff --check Passed
Conventions Passed
Focused guest_posix_filesystem Author reports 3 of 3 passes on this head on Windows
Hosted checks Eligibility, conventions, labels, report, and Windows pass; Linux/product jobs are skipped

I did not run the C++ test locally. The author’s exact-head run and the clean integration resolve the remaining review points.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5693349450 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12386#pullrequestreview-5693349450). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T05:40:38Z. **Review:** APPROVED --- # Re-checked — approved The two issues from review are resolved: the fixture now uses guest path aliases, and the trailing blank lines are gone. The four ABI wrappers still forward directly to the existing directory API, and the added tests cover null/missing paths, traversal, EOF, record fields, and close/read errors. ## What I ran - Reviewed exact head `634e7eb41fb02b44068bf664de34cf72a744741c` against current `main` `52c09d567d2fa453494dd720fcf53a98149468e4`. - Ran `git merge-tree --write-tree`, `git diff --check`, and `python3 tools/check_conventions.py --base refs/review/main-20261029c --head refs/review/pr-12386-latest`. - Checked the exact-head test and hosted-check reports. ## Results | Check | Result | |---|---| | Current-main merge preview | Clean | | `git diff --check` | Passed | | Conventions | Passed | | Focused `guest_posix_filesystem` | Author reports 3 of 3 passes on this head on Windows | | Hosted checks | Eligibility, conventions, labels, report, and Windows pass; Linux/product jobs are skipped | I did not run the C++ test locally. The author’s exact-head run and the clean integration resolve the remaining review points.
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!12386
No description provided.