fix(libSceLibcInternal): read statvfs by path on macOS #6668
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6668"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-16T03:30:36Z.
What
libSceLibcInternal does not build on macOS:
statvfsopens the path withO_PATHto get a descriptor forfstatvfs, and macOS has noO_PATH:No open mode stands in for it. On macOS 26.7.1,
O_RDONLYandO_EVTONLYfail withEACCESon a file or directory without read permission, and so doesO_SEARCH | O_DIRECTORYon such a directory, while FreeBSD'sstatvfsonly needs search permission on the path. The hoststatvfsby path behaves as FreeBSD's does there: it succeeds on a file or directory with mode 0, fails withENOTDIRforfile/,EACCESthrough a directory without search permission andENOENTfor a missing path.So on macOS
statvfsnow reads the volume by path with the hoststatvfs, fills the kernelstatfsthe way_fstatfsfills it from the hostfstatvfs(f_bsizefromf_frsize,f_iosizefromf_bsize,f_ffreefromf_favail,ST_RDONLYandST_NOSUID), and converts it with the same code asfstatvfs. A path that must name a directory (trailing slash, final.) and does not fails withENOTDIR, as theO_DIRECTORYopen does elsewhere. Linux and Windows are unchanged.Commits:
struct statvfsand thesfs2svfsconversion fromFilesystemStatistics.cpptoinclude/Statvfs.hpp, unchanged, so both functions share them.statvfsleaves no descriptor open listed/proc/self/fd; on macOS it lists/dev/fd.No debt entry: the guest sees the same results as on Linux.
Tested
macOS 26.7.1, Apple M2, AppleClang 21.0.0, x86-64 build under Rosetta, Release.
maindoes not build libc and libkernel on macOS for other reasons as well (#4627, #4630, #6124 and mugurc's macOS branches address them), so the tests ran in a local tree ofmaince991f1ecwith those merged.main'sPathStatistics.cpp: libSceLibcInternal fails to compile with the error above.main's code withO_EVTONLYin place ofO_PATH: builds;guest_statvfsaborts at line 36, astatvfscall it expects to succeed returning -1.guest_fstatvfs_conversionpasses 3 runs of 3.guest_statvfspasses 5 runs of 5 (directories, a regular file, the same file with mode 0, a FIFO, a bound socket, a symbolic link, theENOTDIR,ENOENTandEFAULTcases, and no descriptor left open after 32 calls);guest_fstatvfs_conversionpasses 3 runs of 3.tools/check_conventions.py --base origin/mainandgit diff --checkpass.Windows 11 (WinLibs GCC 15.2.0 r7, UCRT, Release) and Ubuntu 24.04 under WSL2 (GCC 13.3.0, Release), head
4dcb2b89emerged ontomain5d9dcc42d:guest_statvfsandguest_fstatvfs_conversionpass 3 runs of 3 with the change, and 3 runs of 3 with the code as onmain(FilesystemStatistics.cppandPathStatistics.cpprestored,include/Statvfs.hppremoved) and the tests kept. Both pass either way there, so the conversion moved into the shared header keeps Windows and Linux as before.Overlap: #6222 opens with
O_EVTONLYand, when that is denied, reads the parent directory's volume instead, which is a different volume when the file is a mount point. #6044 movesGuestStatvfs.cpp; whichever lands second rebases.Checklist
main; no other open PR implements the same functions (see Overlap above)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-16T04:24:55Z.
Independent native arm64 filesystem check at exact head
4dcb2b89ed21fe5acde91999a6fc4549666904b4, complementing the Rosetta coverage: macOS 27.2, Apple clang 21.0.0, ordinary user UID 501 (the probe refuses root).Compiled the complete unchanged production
PathStatistics.cppand its actualStatvfs.hpp. An external driver supplies an identityResolvePath_nid_no_patchfor absolute host fixture paths and the final-dot helper; host filesystem calls, errno conversion and guest output conversion are not mocked. This intentionally does not exercise guest mount/path translation or the full runtime.Three fresh-process runs pass:
.. The FIFO case is bounded by an alarm and does not block.file/,file/., traversal through a mode-0 parent, symlink loop and null output. Guest errors are 14/2/20/13/62 as appropriate; non-null failure outputs retain their sentinel bytes.::statvfs; guest fsid and available/free-file relationships are checked./dev/fddescriptor count unchanged.Controls:
PathStatistics.cppfails native compilation atO_PATH, as reported.O_EVTONLYopen/close gate before the production path query, in a scratch source copy, makes the unchanged probe fail on its first mode-0-file case with guesterrno=13. Restoring the untouched PR object passes all three runs. This confirms the permission matrix distinguishes path metadata access from requiring an open mode.No repository source changed. No Rosetta/x86 execution, full
guest_statvfsintegration, Linux/Windows run or title claim.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T04:34:49Z.
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.
core/libs/prx/libSceLibcInternal/FilesystemStatistics.cppcore/libs/prx/libSceLibcInternal/PathStatistics.cppcore/libs/tests/GuestStatvfs.cppcore/libs/prx/libSceLibcInternal/PathStatistics.cppcore/libs/tests/GuestStatvfs.cppImported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-16T07:33:41Z.
Windows and Linux results for
4dcb2b89ed, merged ontomain5d9dcc42d2:main, new tests keptguest_statvfsandguest_fstatvfs_conversion3/3guest_statvfsandguest_fstatvfs_conversion3/3Reverted for the middle column:
FilesystemStatistics.cppas onmain, with the newPathStatistics.cppandinclude/Statvfs.hppremoved. Both tests pass either way on both hosts. So the move of the shared statvfs code intoStatvfs.hppandPathStatistics.cppkeeps Windows and Linux behaving as before; the macOS difference only shows on macOS.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T08:20:20Z.
Checked the diff: the
LibcStatvfs/StatvfsFromStatfsmove is verbatim (same layout asserts), the macOS path is__APPLE__-only so Linux and Windows are unchanged, and the host-to-statfsmapping matches what_fstatfsdoes. macOS runs by @DavidSamir and @simonbbby cover the new path; the Linux/Windows build and ctest gate is the merge queue's Build run. Merged.