Repository navigation
fix(libSceLibcInternal): read statvfs by path on macOS - #6668
DavidSamir wants to merge 3 commits into
Conversation
…sion fstatvfs kept the guest struct statvfs and the sfs2svfs conversion from the kernel's statfs to itself. Both move to include/Statvfs.hpp so that statvfs can convert a volume the same way without opening the path. Nothing changes for fstatvfs.
statvfs opened the path with O_PATH, which macOS does not have, so libSceLibcInternal did not build there. No open mode stands in for it: on macOS O_RDONLY and O_EVTONLY fail with EACCES on a file or directory without read permission, and O_SEARCH on such a directory, where FreeBSD's statvfs only needs search permission on the path. On macOS statvfs now asks the host statvfs by path, which needs exactly that, fills the kernel statfs the way _fstatfs fills it from the host fstatvfs, and converts it with the code fstatvfs uses. A path that must name a directory and does not fails with ENOTDIR, as the O_DIRECTORY open does elsewhere. Other hosts are unchanged.
…n macOS The check that statvfs leaves no descriptor open listed /proc/self/fd, which macOS does not have. macOS lists the process's descriptors in /dev/fd; Linux keeps /proc/self/fd.
|
Independent native arm64 filesystem check at exact head Compiled the complete unchanged production Three fresh-process runs pass:
Controls:
No repository source changed. No Rosetta/x86 execution, full |
|
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.
|
|
Windows and Linux results for 4dcb2b8, merged onto
Reverted for the middle column: AI-assisted: yes |
Replaces this branch's statvfs fix. Opening the path with O_EVTONLY, and its parent when that failed, still needed read permission on a directory, while FreeBSD's statvfs only needs search permission on the path. The PR uses the host statvfs by path, which behaves as FreeBSD's does, and shares the statfs-to-statvfs conversion. The O_EVTONLY descriptor path and the metadata-only checks in _fstatfs that existed only for it are removed, matching mugurc's series. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replaces this branch's statvfs fix. Opening the path with O_EVTONLY, and its parent when that failed, still needed read permission on a directory, while FreeBSD's statvfs only needs search permission on the path. The PR uses the host statvfs by path, which behaves as FreeBSD's does, and shares the statfs-to-statvfs conversion. The O_EVTONLY descriptor path and the metadata-only checks in _fstatfs that existed only for it are removed, matching mugurc's series. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 ofmaince991f1 with 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 ontomain5d9dcc4: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)