Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Gonic0:fix/libkernel-statfs-noexec-macos
Nov 12, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Gonic0:fix/libkernel-statfs-noexec-macos

Conversation

@Gonic0

@Gonic0 Gonic0 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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:

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 fix(prx): build the macOS libraries on current main #16591 and fix(libSceLibcInternal): clamp the string count as size_t on macOS #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

…acOS

FillStatfs read the macOS MNT_NOEXEC flag through fstatfs on a
descriptor it does not receive, so libkernel no longer compiled on
macOS. The callers now work out the flag, through fstatfs for a
descriptor and statfs for a path on macOS, and from ST_NOEXEC
elsewhere, and pass it in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 6936 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 7121 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 7447 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 9293 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 9297 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 9302 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 11625 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 12682 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 12688 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 12700 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 12965 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 15037 core/libs/prx/libkernel/File/src/Stdio.cpp

@JJenkx

JJenkx commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 496ee893aa, merged onto main 364ceeba2f (47740aa974, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • exec_arguments, guest_addresses, guest_aio, guest_aio_bad_descriptors, guest_amm_pool, guest_app_icon, guest_app_info, guest_append_streams, guest_append_writes, guest_available_cpumask, guest_closed_standard_descriptors_windows, guest_closed_standard_streams_load_windows, guest_cond_recursive_mutex, guest_cond_timedwait, guest_cond_unowned_mutex, guest_coredump_attach, guest_coredump_user_data, guest_cpu_time_clocks, guest_credentials, guest_current_cpu, guest_deferred_module_sweep, guest_deferred_module_sweep_failed, guest_direct_memory_for_app, guest_directory_buffer, guest_directory_close, guest_directory_entries, guest_directory_removed_entries, guest_directory_rewind, guest_dup, guest_dynamic_loader, guest_dynamic_loader_variant_names, guest_elf_phdr_match, guest_equeue_events, guest_exception_fault, guest_exception_handler, guest_execvp, guest_file_timestamps, guest_file_vector, guest_file_vector_memory, guest_filesystem, guest_freebsd_clocks, guest_fstat_fault, guest_fstatfs, guest_getitimer, guest_getlogin, guest_getrlimit, guest_getrusage, guest_host_standard_buffering_windows, guest_host_standard_error_windows, guest_host_streams, guest_itimer, guest_itimer_pending_default, guest_itimer_short_expiry, guest_jit_shared_memory, guest_kernel_errors, guest_kernel_fcntl, guest_kernel_fcntl_sync, guest_kernel_is_stack, guest_kernel_rename, guest_kernel_resident_fmem_export, guest_kernel_resident_fmem_export_patched, guest_kernel_stack_protect, guest_kernel_sync, guest_kill, guest_kqueue, guest_kqueue_cleared_race, guest_low_address_memory, guest_memory, guest_mlock, guest_mmap_executable, guest_mmap_fixed_anonymous, guest_module_info, guest_mprotect_unmapped, guest_msync, guest_mutex_contention, guest_mutex_raise_exception, guest_named_shm_windows_mapping, guest_nanosleep, guest_nanosleep_long_request, guest_nanosleep_timer_self_test, guest_once, guest_operation_mode, guest_output_pointer_fault, guest_page_table_stats, guest_parent_process, guest_path_name_length, guest_pipe_fault, guest_poll, guest_positioned_close, guest_positioned_race, guest_posix_cond_broadcast, guest_posix_exit, guest_posix_mutex_trylock, guest_posix_named_sem, guest_posix_sem_init, guest_posix_sem_post, guest_posix_specific, guest_process_abi_type, guest_process_arguments, guest_process_time, guest_process_time_counter, guest_process_time_counter_scaled, guest_process_time_rdtsc, guest_process_time_rdtsc_scaled, guest_process_time_scaled, guest_process_time_tsc, guest_process_time_tsc_scaled, guest_protection_report, guest_pthread_atfork, guest_pthread_attr, guest_pthread_attr_errors, guest_pthread_attr_stack, guest_pthread_barrier, guest_pthread_cancel, guest_pthread_cancel_recovery, guest_pthread_cancel_recovery_coarse, guest_pthread_cond, guest_pthread_cond_setname, guest_pthread_condattr, guest_pthread_destroyed_objects, guest_pthread_destructor_lifetime, guest_pthread_detach_attr, guest_pthread_final_release_race, guest_pthread_frame_chain, guest_pthread_getname, guest_pthread_handle_after_exit, guest_pthread_join_detach, guest_pthread_join_self, guest_pthread_key, guest_pthread_mutex_errors, guest_pthread_mutex_prioceiling, guest_pthread_mutex_spin, guest_pthread_mutexattr, guest_pthread_posix_calls, guest_pthread_released_handle, guest_pthread_rename, guest_pthread_rwlock, guest_pthread_schedparam, guest_pthread_second_join, guest_pthread_sem, guest_pthread_setname, guest_pthread_spin, guest_pthread_stack, guest_pthread_start, guest_pthread_timed_locks, guest_pthread_yield, guest_raise_exception, guest_raise_exiting_thread, guest_raise_in_host_code, guest_raise_in_system_call, guest_raise_leaves_host_code, guest_raise_nested_sleep, guest_raise_short_sleep, guest_raise_short_sleep_without_wake, guest_recvmsg_memory, guest_rename_dot, guest_rtprio_thread, guest_rwlock_retire, guest_sandbox_certificate_failure, guest_sandbox_certificate_trust, guest_sandbox_certificates, guest_sandbox_random_word, guest_sanitizer_replace_tables, guest_sched_params, guest_sched_priority, guest_select, guest_select_wait, guest_sem_canceled_wake, guest_sem_canceled_wake_coarse, guest_sem_getvalue_uninit, guest_semaphore, guest_semaphore_handoff, guest_semaphore_trace, guest_sendfile, guest_setrlimit, guest_shm_open, guest_sigaltstack, guest_signal_handler_mask, guest_signal_interrupt, guest_signal_sets, guest_signals, guest_sigtimedwait, guest_sleep_wake, guest_sleep_wake_coarse, guest_socket_address_length, guest_socket_connect_listening, guest_socket_descriptor_flags, guest_socket_descriptors, guest_socket_error, guest_socket_events, guest_socket_on_non_socket, guest_socket_options, guest_socket_options_multicast, guest_socket_pair, guest_socket_port_zero, guest_socket_read_write, guest_socket_send_before_connect, guest_socket_stream_options, guest_socket_timeouts, guest_software_version, guest_stream_close, guest_sync_on_address, guest_sysarch, guest_system_command, guest_system_configuration, guest_system_flexible_memory, guest_tcp, guest_terminal, guest_termios_speed, guest_thermal_sensors, guest_thread_cpu_clock, guest_thread_sanitizer, guest_thread_self, guest_timed_wait_cpu, guest_tls_get_addr, guest_truncate, guest_truncate_extend, guest_truncate_race, guest_udp, guest_umtx_op, guest_underscore_entries, guest_underscore_jumps, guest_unwind_module_info, guest_user_context, guest_user_context_exit, guest_usleep, guest_wait_trace, guest_waitpid, guest_windows_directory_link_types, host_cpu, host_performance_process_invalid, host_performance_session, kernel_error, nid_patcher_symbol_versions, param_json_parser, param_sfo_parser pass in 3 of 3 runs, none skipped.

AI-assisted: yes.

@milescoviello milescoviello left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@011010

011010 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

macOS is the platform this fixes, and it had no macOS run yet. Verified on Apple M4 (Mac mini), macOS 27.0.1 (26A434), Apple clang 21.0.0, x86-64 Release under Rosetta 2, main 316a35712f.

  • On main, libkernel does not build on macOS at all: core/libs/prx/libkernel/File/src/Stdio.cpp:716:19: error: use of undeclared identifier 'descriptor', from fix(libkernel): build the file, module and rtld calls on macOS hosts #10552.
  • With this PR: libkernel builds (unpatched/libkernel.prx, 1,206,088 bytes), and these pass: guest_fstatfs 1.38 s, guest_kernel_sys_paths_statfs and _patched 1.53 s together, plus guest_filesystem and guest_fstatvfs_conversion in the same run, 3 of 3.

Nothing else I ran regressed. The Windows run above covers the platform that did not need this fix; this covers the one that did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants