fix(libkernel): give FillStatfs the noexec flag so statfs builds on macOS #17767

Merged
Gonic0 merged 1 commit from upstream-pr/17767 into main 2026-11-12 05:07:21 +00:00
Gonic0 commented 2026-11-09 15:10:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Gonic0 on 2026-11-09T15:10:02Z.


What

libkernel no longer compiles on macOS on main:

core/libs/prx/libkernel/File/src/Stdio.cpp:716:19: error: use of undeclared identifier 'descriptor'

#9161 split the shared part of NativeFstatfs into FillStatfs, which NativeStatfs now also uses for a path. The macOS branch that sets KERNEL_MNT_NOEXEC from fstatfs(descriptor) ended up inside FillStatfs, which only receives the statvfs result.

FillStatfs now takes the flag, and each caller works it out:

  • NativeFstatfs on macOS: fstatfs on the descriptor, as before #9161.
  • NativeStatfs on macOS: statfs on the path, so the path form also reports noexec mounts.
  • Elsewhere: ST_NOEXEC from the statvfs result, as before.

Windows has its own NativeStatfs and NativeFstatfs, which do not use FillStatfs.

Tested

macOS 27.3, Apple M5 Pro, Apple clang, x86-64 Release under Rosetta 2. Tree: main b673b14c39 with this change and #16591, #17425 and #17532, which macOS still needs to build. Between that commit and main ffe575754a, nothing in Stdio.cpp changed, and the broken line is still there.

  • Without this change, ninja -k 0 libs fails on Stdio.cpp:716 (above). The other failures are the ones #16591 and #17532 fix.
  • With it, libs (407 libraries, NID patching included) and relinker build.
  • ctest -R 'statfs|fstatfs|statvfs|kernel_sys_paths': 12 of 12 pass (guest_kernel_sys_paths_statfs and its patched form, guest_fstatfs, guest_statvfs, guest_fstatvfs, guest_fstatvfs_conversion and the other path tests).
  • No test checks KERNEL_MNT_NOEXEC, so the flag itself is covered only by reading the code.
  • Linux and Windows: not built locally. On Linux the flag comes from the same ST_NOEXEC test as before.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5226125069 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17767). Originally posted by [Gonic0](https://github.com/Gonic0) on 2026-11-09T15:10:02Z. --- ### What `libkernel` no longer compiles on macOS on `main`: ``` core/libs/prx/libkernel/File/src/Stdio.cpp:716:19: error: use of undeclared identifier 'descriptor' ``` #9161 split the shared part of `NativeFstatfs` into `FillStatfs`, which `NativeStatfs` now also uses for a path. The macOS branch that sets `KERNEL_MNT_NOEXEC` from `fstatfs(descriptor)` ended up inside `FillStatfs`, which only receives the `statvfs` result. `FillStatfs` now takes the flag, and each caller works it out: - `NativeFstatfs` on macOS: `fstatfs` on the descriptor, as before #9161. - `NativeStatfs` on macOS: `statfs` on the path, so the path form also reports `noexec` mounts. - Elsewhere: `ST_NOEXEC` from the `statvfs` result, as before. Windows has its own `NativeStatfs` and `NativeFstatfs`, which do not use `FillStatfs`. ### Tested macOS 27.3, Apple M5 Pro, Apple clang, x86-64 Release under Rosetta 2. Tree: `main` `b673b14c39` with this change and #16591, #17425 and #17532, which macOS still needs to build. Between that commit and `main` `ffe575754a`, nothing in `Stdio.cpp` changed, and the broken line is still there. - Without this change, `ninja -k 0 libs` fails on `Stdio.cpp:716` (above). The other failures are the ones #16591 and #17532 fix. - With it, `libs` (407 libraries, NID patching included) and `relinker` build. - `ctest -R 'statfs|fstatfs|statvfs|kernel_sys_paths'`: 12 of 12 pass (`guest_kernel_sys_paths_statfs` and its patched form, `guest_fstatfs`, `guest_statvfs`, `guest_fstatvfs`, `guest_fstatvfs_conversion` and the other path tests). - No test checks `KERNEL_MNT_NOEXEC`, so the flag itself is covered only by reading the code. - Linux and Windows: not built locally. On Linux the flag comes from the same `ST_NOEXEC` test as before. ### 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 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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
milescoviello commented 2026-11-09 17:06:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-09T17:06:09Z.

Review: APPROVED


Read 496ee893aa.

  • Linux: FillStatfs now takes noexec, and both callers compute it as (host.f_flag & ST_NOEXEC) != 0 from the statvfs they already have. That is exactly what FillStatfs did on main, so nothing changes there.
  • macOS: NativeFstatfs goes back to fstatfs(descriptor) as before #9161, and NativeStatfs uses statfs(path) for the path case, which main never set KERNEL_MNT_NOEXEC for. The rest of the flag and size filling is unchanged and shared.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5829607325 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17767#pullrequestreview-5829607325). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-11-09T17:06:09Z. **Review:** APPROVED --- Read `496ee893aa`. - **Linux:** `FillStatfs` now takes `noexec`, and both callers compute it as `(host.f_flag & ST_NOEXEC) != 0` from the `statvfs` they already have. That is exactly what `FillStatfs` did on `main`, so nothing changes there. - **macOS:** `NativeFstatfs` goes back to `fstatfs(descriptor)` as before #9161, and `NativeStatfs` uses `statfs(path)` for the path case, which `main` never set `KERNEL_MNT_NOEXEC` for. The rest of the flag and size filling is unchanged and shared. AI-assisted: yes (Claude Code)
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!17767
No description provided.