feat(libc): implement strmode #11664

Merged
B-Howell merged 11 commits from upstream-pr/11664 into main 2026-11-08 01:47:01 +00:00
B-Howell commented 2026-10-27 02:01:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by B-Howell on 2026-10-27T02:01:08Z.


What

  • Implement the BSD strmode export in core/libs/prx/libc/src/StringExtensions.cpp, decoding the mode into the twelve-byte ls -l permissions string as FreeBSD 11.4 lib/libc/string/strmode.c does: file-type character from the top four bits, three rwx triples, s/S and t/T for the setuid/setgid/sticky combinations with the matching execute bit, a space in the ACL slot and a trailing NUL. Declaration added to core/libs/prx/libc/include/Api.hpp beside the other string exports.

  • Signature takes int to match the FreeBSD 11.4 <string.h> prototype void strmode(/* mode_t */ int, char *) and the project's sibling guest chmod and fchmod exports; the console mode_t width and register-width expectations are unverified and the doc entry records that uncertainty.

  • Extend core/libs/tests/GuestStrings.cpp to cover a directory, a regular file, a symlink, every s/S/t/T setuid/setgid/sticky combination against the matching execute bit, each non-regular file-type character (c, b, p, s, w) and the ? fallback.

  • Document the export in docs/dev/debt/libc.md with the registry NID Uo-nB2s+1+A; console behavior is unverified.

Tested

Main refresh at a4ac7624a923 (2026-11-01)

Head a4ac7624a9236910ce1fdc9b27facc34ddb5f143 / tree d49f8b1d74f78b7d04111f838d249c0f38f18d5b ordinarily merges previous public head 000ed8ddbfc4b67ca67b8ed3d034e0f06521741b with upstream main b6e3f68173c767f692f6c04eef04c73eab424e04. #13220 has landed: its original commit e9f09f54fabb6408d3e2711b8df10c10112ab00e is an ancestor of that main, so the write-watch registration fix now comes from main and this PR no longer changes core/libs/tests/write_watch/CMakeLists.txt. The remaining diff against main is the four owned files (Api.hpp, StringExtensions.cpp, GuestStrings.cpp, docs/dev/debt/libc.md); its added and removed lines in those files are identical to the previous head's changes. Git's three-way merge was clean; GitHub reported the previous head as conflicting, and a merge using only the older main base conflicts on that shared CMake file. tools/check_conventions.py from this main passed against this head. No new local build or runtime result is claimed for this head; hosted CI at this head is pending after push. Earlier results below keep their original pins.

Main refresh at 22159353aa90

Head 22159353aa90627dedc7e3fb501250e5940c9b48, tree 235fc990fc5a31f682b1df7d23a9319c5ae28391, ordinarily merges e3c44ac2c60f26c7cbb0c42b447c4d4d61d0fd32 with main c0fb4a6aad1012b7e2abecaf2949e3d26c0e525d, observed at 2026-10-30 20:15:30 UTC; published 6fc8bc373f486b49053870e519b0eba643784f37 remains an ancestor. This is the documented main baseline for this refresh; later remote-main advances are not certified. The four owned contribution files and their additions remain unchanged. Earlier evidence below keeps its original pins.

Fresh Windows/WinLibs GCC 15.2.0 r7 (CMake 4.4.4/Ninja 1.13.2) and WSL Ubuntu 22.04/GCC 11.4 (CMake 3.22.1/Ninja 1.10.1), Release: both configurations and cmake --build <fresh-cache> --target guest_string_tests guest_formatting_tests nid_patcher --parallel 2 pass. ctest --test-dir <fresh-cache> -R '^(guest_strings|guest_formatting|public_headers)$' -V -j1 --repeat until-fail:3 --timeout 30 --no-tests=error passes 18 selected executions at this exact head across both OS = 12 native guest runs + 6 audit-only header runs, with no failures/skips. Builds/OS arms were serial, at most two build jobs. Same-arm production-library binding and Release-active checks were verified, including the existing formatting regression and actual changed-kernel dependency.

The #11664-before-#10270 order is author-confirmed. Reviewer acceptance, later combined validation and actual upstream landing remain separate. The historical hosted web_release timeout and Darwin masked-store failure remain unresolved at their original heads; they are not results for 22159353aa90.

The audit-only case retains its generated 90-second timeout; the 64 header compile batches are excluded. At the 2026-10-30 exact-head readiness audit, 11 latest named checks completed successfully, Linux was skipped, and six macOS checks were queued; no current failed check was reported. Skipped or queued checks are not passes. No new console, GPU, title, macOS, whole-product or full-suite result is claimed.

Current-main integration 6fc8bc373f486b49053870e519b0eba643784f37, tree 4da828c67c90715473314f535e208dc69583af0e, ordinarily merges frozen main 3679074dd61aa6a899a00c19ce2e450b1cacfb60 into published 30abbd1be32adfe2ffe9f3f2de06dc053bad27a4. Owned strmode implementation, declaration and fixture additions are unchanged. Existing clean worktree-specific submodules were aligned to this main's committed pins before the build.

Windows 11, WinLibs GCC 15.2.0 r7, Release: cmake --build build --target guest_string_tests --parallel 2 passes; ctest --test-dir build -R '^(guest_strings|public_headers)$' --repeat until-fail:3 -V passes 2/2 cases, each three repetitions (six passes, no skips), in 65.68 seconds. Conventions against this main pass. No new Linux, macOS/Rosetta, console, full-suite, title or GPU execution is claimed. Historical evidence below retains its exact source/toolchain limits.

#11664-before-#10270 remains author-confirmed; any later combined-head validation is a separate integration step. The #12560 debt-only composition establishes no functional or author-order prerequisite. Current skipped-row source reconciliation is recorded in comment6475614264; it does not clear the compared #10270 scope or the entire overlap warning. Historical hosted outcomes remain at their original heads, and the older Darwin failure has no established current-head cause.

Earlier integrated-head evidence:

Current-main integration at 30abbd1be32adfe2ffe9f3f2de06dc053bad27a4, merging frozen main 319621ba2e578bd053b0baba2877fe70520e0737 by ordinary merge:

  • Windows 11, WinLibs GCC 15.2.0 r7, Release: cmake --build build --target guest_string_tests --parallel 2 passed; ctest --test-dir build -R '^guest_strings$' --repeat until-fail:3 -V passed all three executions (test 517: 0.05, 0.01, 0.01 sec).
  • The four-file contribution is unchanged in behavior; all fetched main content and existing GuestStrings checks are preserved. Independent staged-source review and postcommit python tools/check_conventions.py --base origin/main passed.
  • This integrated head has no new Linux, macOS, Rosetta or console execution claim. The old cancelled hosted conventions run and denied admin-only rerun remain historical; this legitimate main integration does not claim those runs passed. Author-order commitments and future combined validation remain tracked.

Earlier current-main integration at ca2cbc3baa, merging frozen main 750cf6cf48 into the published branch without rewriting its history:

  • Windows 11, WinLibs GCC 15.2.0, Release: a fresh guest_string_tests build and ctest -R '^guest_strings$' --repeat until-fail:3 -V pass all three executions.

  • The implementation is unchanged from 1185982eff; the only manual merge resolution preserves both the strmode debt entry and main's adjacent strtoq entry.

  • Conventions and independent static integration review pass. The merge retains the declaration, implementation and all existing/new GuestStrings cases.

  • No new macOS/Rosetta execution is claimed. The historical masked-store failure and #12284 investigation remain separate evidence; this local Windows run does not diagnose its cause.

Earlier-head evidence follows:

  • ninja guest_string_tests and ctest -R '^guest_strings$' in build-focused on Windows: pass. Console behavior is not exercised.

  • tools/check_conventions.py --base origin/main: all checks passed.

  • tools/pr_overlap.py --branch codex/libc-strmode completed. The historical overlap report flags conflicting lines in GuestStrings.cpp with #10270. Its author subsequently confirmed #11664 before #10270 in comment6475839338; future combined validation remains outstanding. Other base-conflicted shared files were not fully compared by the tool.

  • Built export strmode_nid_postfix present in libc.prx; registry NID Uo-nB2s+1+A matches the symbol via tools/nid_names.py --name strmode.

Historical hosted macOS relinker run: 309/310 passed; masked_store_lowering failed with 'Masked store stub changed the flags'. Cause is not yet established. This PR does not change relinker code. Native Linux comparison: Ubuntu 22.04/WSL, GCC 11.4, Release passed all 1728 masked-store executions, including flags checks, with the test/emitter/matcher sources identical to this PR head. This does not reproduce or clear the Rosetta failure; the historical Rosetta failure remains unexplained.

Write-watch CI prerequisite

This update merges the original #13220 commit (e9f09f54fa) as a second parent. It removes only the duplicate execute-fault and read-fault registrations from the shared write-watch CMake file; the function change remains the first-parent history. Historical function-test results retain their original source/binary pins as recorded above; they are not results on this merged head. A separate configure-only Windows/Linux comparison generated all 18 unique test registrations after the fix, with no fixture build or runtime tests. The hosted macOS checks on this updated head are pending; no macOS runtime result is claimed here.

#13220 landed in upstream main on 2026-11-01. Earlier heads carried its original commit e9f09f54fabb6408d3e2711b8df10c10112ab00e as a second parent; after the 2026-11-01 main refresh above, the fix comes from main and this PR no longer changes the write-watch CMake file. The historical configure-only comparison and the pins recorded here are unchanged.

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:5027432001 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11664). Originally posted by [B-Howell](https://github.com/B-Howell) on 2026-10-27T02:01:08Z. --- ### What - Implement the BSD `strmode` export in `core/libs/prx/libc/src/StringExtensions.cpp`, decoding the mode into the twelve-byte `ls -l` permissions string as FreeBSD 11.4 [`lib/libc/string/strmode.c`](https://github.com/freebsd/freebsd-src/blob/releng/11.4/lib/libc/string/strmode.c) does: file-type character from the top four bits, three `rwx` triples, `s`/`S` and `t`/`T` for the setuid/setgid/sticky combinations with the matching execute bit, a space in the ACL slot and a trailing NUL. Declaration added to `core/libs/prx/libc/include/Api.hpp` beside the other string exports. - Signature takes `int` to match the FreeBSD 11.4 [`<string.h>`](https://github.com/freebsd/freebsd-src/blob/releng/11.4/include/string.h) prototype `void strmode(/* mode_t */ int, char *)` and the project's sibling guest `chmod` and `fchmod` exports; the console `mode_t` width and register-width expectations are unverified and the doc entry records that uncertainty. - Extend `core/libs/tests/GuestStrings.cpp` to cover a directory, a regular file, a symlink, every `s`/`S`/`t`/`T` setuid/setgid/sticky combination against the matching execute bit, each non-regular file-type character (`c`, `b`, `p`, `s`, `w`) and the `?` fallback. - Document the export in `docs/dev/debt/libc.md` with the registry NID `Uo-nB2s+1+A`; console behavior is unverified. ### Tested #### Main refresh at `a4ac7624a923` (2026-11-01) Head `a4ac7624a9236910ce1fdc9b27facc34ddb5f143` / tree `d49f8b1d74f78b7d04111f838d249c0f38f18d5b` ordinarily merges previous public head `000ed8ddbfc4b67ca67b8ed3d034e0f06521741b` with upstream main `b6e3f68173c767f692f6c04eef04c73eab424e04`. #13220 has landed: its original commit `e9f09f54fabb6408d3e2711b8df10c10112ab00e` is an ancestor of that main, so the write-watch registration fix now comes from main and this PR no longer changes `core/libs/tests/write_watch/CMakeLists.txt`. The remaining diff against main is the four owned files (`Api.hpp`, `StringExtensions.cpp`, `GuestStrings.cpp`, `docs/dev/debt/libc.md`); its added and removed lines in those files are identical to the previous head's changes. Git's three-way merge was clean; GitHub reported the previous head as conflicting, and a merge using only the older main base conflicts on that shared CMake file. `tools/check_conventions.py` from this main passed against this head. No new local build or runtime result is claimed for this head; hosted CI at this head is pending after push. Earlier results below keep their original pins. #### Main refresh at `22159353aa90` Head `22159353aa90627dedc7e3fb501250e5940c9b48`, tree `235fc990fc5a31f682b1df7d23a9319c5ae28391`, ordinarily merges `e3c44ac2c60f26c7cbb0c42b447c4d4d61d0fd32` with main `c0fb4a6aad1012b7e2abecaf2949e3d26c0e525d`, observed at 2026-10-30 20:15:30 UTC; published `6fc8bc373f486b49053870e519b0eba643784f37` remains an ancestor. This is the documented main baseline for this refresh; later remote-main advances are not certified. The four owned contribution files and their additions remain unchanged. Earlier evidence below keeps its original pins. Fresh Windows/WinLibs GCC 15.2.0 r7 (CMake 4.4.4/Ninja 1.13.2) and WSL Ubuntu 22.04/GCC 11.4 (CMake 3.22.1/Ninja 1.10.1), Release: both configurations and `cmake --build <fresh-cache> --target guest_string_tests guest_formatting_tests nid_patcher --parallel 2` pass. `ctest --test-dir <fresh-cache> -R '^(guest_strings|guest_formatting|public_headers)$' -V -j1 --repeat until-fail:3 --timeout 30 --no-tests=error` passes **18 selected executions at this exact head across both OS = 12 native guest runs + 6 audit-only header runs**, with no failures/skips. Builds/OS arms were serial, at most two build jobs. Same-arm production-library binding and Release-active checks were verified, including the existing formatting regression and actual changed-kernel dependency. The #11664-before-#10270 order is author-confirmed. Reviewer acceptance, later combined validation and actual upstream landing remain separate. The historical hosted `web_release` timeout and Darwin masked-store failure remain unresolved at their original heads; they are not results for `22159353aa90`. The audit-only case retains its generated 90-second timeout; the 64 header compile batches are excluded. At the 2026-10-30 exact-head readiness audit, 11 latest named checks completed successfully, Linux was skipped, and six macOS checks were queued; no current failed check was reported. Skipped or queued checks are not passes. No new console, GPU, title, macOS, whole-product or full-suite result is claimed. Current-main integration `6fc8bc373f486b49053870e519b0eba643784f37`, tree `4da828c67c90715473314f535e208dc69583af0e`, ordinarily merges frozen main `3679074dd61aa6a899a00c19ce2e450b1cacfb60` into published `30abbd1be32adfe2ffe9f3f2de06dc053bad27a4`. Owned strmode implementation, declaration and fixture additions are unchanged. Existing clean worktree-specific submodules were aligned to this main's committed pins before the build. Windows 11, WinLibs GCC 15.2.0 r7, Release: `cmake --build build --target guest_string_tests --parallel 2` passes; `ctest --test-dir build -R '^(guest_strings|public_headers)$' --repeat until-fail:3 -V` passes 2/2 cases, each three repetitions (six passes, no skips), in 65.68 seconds. Conventions against this main pass. No new Linux, macOS/Rosetta, console, full-suite, title or GPU execution is claimed. Historical evidence below retains its exact source/toolchain limits. #11664-before-#10270 remains author-confirmed; any later combined-head validation is a separate integration step. The #12560 debt-only composition establishes no functional or author-order prerequisite. Current skipped-row source reconciliation is recorded in [comment6475614264](https://github.com/boykopovar/AnyPS5/pull/11664#issuecomment-6475614264); it does not clear the compared #10270 scope or the entire overlap warning. Historical hosted outcomes remain at their original heads, and the older Darwin failure has no established current-head cause. Earlier integrated-head evidence: Current-main integration at `30abbd1be32adfe2ffe9f3f2de06dc053bad27a4`, merging frozen main `319621ba2e578bd053b0baba2877fe70520e0737` by ordinary merge: - Windows 11, WinLibs GCC 15.2.0 r7, Release: `cmake --build build --target guest_string_tests --parallel 2` passed; `ctest --test-dir build -R '^guest_strings$' --repeat until-fail:3 -V` passed all three executions (test 517: 0.05, 0.01, 0.01 sec). - The four-file contribution is unchanged in behavior; all fetched main content and existing GuestStrings checks are preserved. Independent staged-source review and postcommit `python tools/check_conventions.py --base origin/main` passed. - This integrated head has no new Linux, macOS, Rosetta or console execution claim. The old cancelled hosted conventions run and denied admin-only rerun remain historical; this legitimate main integration does not claim those runs passed. Author-order commitments and future combined validation remain tracked. Earlier current-main integration at `ca2cbc3baa`, merging frozen `main` `750cf6cf48` into the published branch without rewriting its history: - Windows 11, WinLibs GCC 15.2.0, Release: a fresh `guest_string_tests` build and `ctest -R '^guest_strings$' --repeat until-fail:3 -V` pass all three executions. - The implementation is unchanged from `1185982eff`; the only manual merge resolution preserves both the strmode debt entry and main's adjacent strtoq entry. - Conventions and independent static integration review pass. The merge retains the declaration, implementation and all existing/new GuestStrings cases. - No new macOS/Rosetta execution is claimed. The historical masked-store failure and #12284 investigation remain separate evidence; this local Windows run does not diagnose its cause. Earlier-head evidence follows: - [x] `ninja guest_string_tests` and `ctest -R '^guest_strings$'` in `build-focused` on Windows: pass. Console behavior is not exercised. - [x] `tools/check_conventions.py --base origin/main`: all checks passed. - [x] `tools/pr_overlap.py --branch codex/libc-strmode` completed. The historical overlap report flags conflicting lines in GuestStrings.cpp with #10270. Its author subsequently confirmed #11664 before #10270 in [comment6475839338](https://github.com/boykopovar/AnyPS5/pull/11664#issuecomment-6475839338); future combined validation remains outstanding. Other base-conflicted shared files were not fully compared by the tool. - [x] Built export `strmode_nid_postfix` present in `libc.prx`; registry NID `Uo-nB2s+1+A` matches the symbol via `tools/nid_names.py --name strmode`. Historical hosted macOS relinker run: 309/310 passed; masked_store_lowering failed with 'Masked store stub changed the flags'. Cause is not yet established. This PR does not change relinker code. Native Linux comparison: Ubuntu 22.04/WSL, GCC 11.4, Release passed all 1728 masked-store executions, including flags checks, with the test/emitter/matcher sources identical to this PR head. This does not reproduce or clear the Rosetta failure; the historical Rosetta failure remains unexplained. <!-- 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. --> ### Write-watch CI prerequisite This update merges the original #13220 commit (e9f09f54fabb6408d3e2711b8df10c10112ab00e) as a second parent. It removes only the duplicate execute-fault and read-fault registrations from the shared write-watch CMake file; the function change remains the first-parent history. Historical function-test results retain their original source/binary pins as recorded above; they are not results on this merged head. A separate configure-only Windows/Linux comparison generated all 18 unique test registrations after the fix, with no fixture build or runtime tests. The hosted macOS checks on this updated head are pending; no macOS runtime result is claimed here. #13220 landed in upstream main on 2026-11-01. Earlier heads carried its original commit `e9f09f54fabb6408d3e2711b8df10c10112ab00e` as a second parent; after the 2026-11-01 main refresh above, the fix comes from main and this PR no longer changes the write-watch CMake file. The historical configure-only comparison and the pins recorded here are unchanged. ### 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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
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!11664
No description provided.