feat(libc): export the std::__sce_v2 filesystem calls #15210
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15210"
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 Danigamer05 on 2026-11-02T20:46:11Z.
What
Export the sixteen
std::__sce_v2::filesystemcalls that are still missing from libc, next to the_Stat, directory and_Current_getprimitives already there:_ZNSt8__sce_v210filesystem6_LstatEPKcPNS0_5permsEPiLXwQTUlXqkY0xCBA90_ZNSt8__sce_v210filesystem6_LstatEPKcPNS0_5permsEkaQWSDpGvYk0xCC140_ZNSt8__sce_v210filesystem10_File_sizeEPKcPi9hFiV-SYaBg0xCBB70_ZNSt8__sce_v210filesystem10_File_sizeEPKcEr2vLEXb2740xCC1F0_ZNSt8__sce_v210filesystem16_Last_write_timeEPKc9uld+FKJiM80xCC240_ZNSt8__sce_v210filesystem16_Last_write_timeEPKcPlS3_orU+cOLgqH00xCBBE0_ZNSt8__sce_v210filesystem20_Set_last_write_timeEPKclO1TzFSNuL+80xCBC60_ZNSt8__sce_v210filesystem9_Make_dirEPKcS2_H7pVgeH6+0Y0xCB900_ZNSt8__sce_v210filesystem11_Remove_dirEPKcz2t8wjOcyl80xCB9A0_ZNSt8__sce_v210filesystem7_UnlinkEPKcJyYWGwYKbfc0xCBDD0_ZNSt8__sce_v210filesystem7_RenameEPKcS2_1rbp++nl5s40xCBD70_ZNSt8__sce_v210filesystem7_ResizeEPKcmS0HHbMy6i9o0xCBDA0_ZNSt8__sce_v210filesystem6_ChmodEPKcNS0_5permsEnwYv13CyIIs0xCC060_ZNSt8__sce_v210filesystem10_Copy_fileEPKcS2_ZG4QXp4iMRk0xCBE00_ZNSt8__sce_v210filesystem8_StatvfsEPKcRNS0_10space_infoEbqk0d4F9WME0xCBD50_ZNSt8__sce_v210filesystem13_Current_set2EPKc3W0yl-6AWxk0xCB8D0The behavior comes from the
libc.prxbundled with PPSA03671 v01.001.005 (J03848509, SHA-256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6).Most of these functions are thin wrappers over libkernel. They call
sceKernelStat,sceKernelMkdir,sceKernelUnlink,sceKernelRename,sceKernelTruncate,sceKernelChmod,sceKernelUtimes,sceKernelOpen,sceKernelRead,sceKernelWrite,sceKernelFstat,sceKernelFchmod,sceKernelClose,statandrmdir. A kernel error in the errno range (0x8002xxxx) gives its errno, and any other kernel error gives 1. Some cases do not follow that pattern:_File_sizewith an error output stores the kernel error code itself, such as0x80020002._LstatreportsENOENT,ENOTDIR,EINVALandENAMETOOLONGas not found and other errors as none._Make_dirreturns 1, 0 forEEXIST, or the negated errno, and takes the mode of an existing template._Set_last_write_timetakes microseconds, floors them to seconds and microseconds and keeps the access time._Copy_filecopies 64 KiB at a time, then copies the source permissions masked with06777._StatvfsreturnsENOSYSwith unknown space._Current_set2returns 0 only for "/" andEOPNOTSUPP(45) otherwise.libc cannot link libkernel; libkernel already links libc. So
FilesystemForwards.hppadds a table of those kernel calls that libkernel registers when it loads, as it already does for its thread calls.VersionedFilesystemCalls.cppmakes the calls through that table in the module's order. The 64 KiB copy buffer is a host allocation instead of the module's heap;ENOMEMis still returned when it cannot be allocated.Tested
Windows x86-64, WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON, main9090972b7e91fd266819cbd77a8b058e177b5682. Exact tested commit:0f12fc9b7ef02af58412f84c73923befc37be536.guest_sce_v2_filesystem_calls,guest_sce_v2_filesystem,guest_filesystem_error,guest_rename_dotandpublic_headers.__errorto its libc and__stack_chk_guardto a local value; every other import would have stopped the run, and none was called. The module's heap is not initialized outside a title, so the two entries of its allocation table that_Copy_fileuses were pointed at the hostmallocandfree.errnoand the resulting tree all agree: every entry's kernelstatresult, mode, size, write time and content hash.ENAMETOOLONG, a remainder of −1 µs was no longer floored, and_Current_set2compared one character. The new CTest failed on each. With the three alterations applied together, plus one to the unreachable mapping rule, the side-by-side run flagged 21 scenarios across_Lstat,_Set_last_write_timeand_Current_set2. The source was then restored byte for byte (SHA-256 checked) and rebuilt, and all 69 tests and all 2,016 scenarios passed again.git diff --checkpass.tools/pr_overlap.pyread 1,699 open PRs at the tested commit and reports no confirmed overlap. It keeps exit 2 for 42 branches that already conflict with main. 229 open PRs touch at least one of the four shared files: the twoCMakeLists.txtlists, libc'sApi.hppanddocs/dev/debt/libc.md. None of them adds the sixteen names or NIDs. Merging each with this branch and with main usinggit merge-treegives the same conflict blocks, and no block contains this change. The exception is #14212, which reformats the whole libc debt file and conflicts with any new entry there.Not tested: Linux, macOS, another SDK, a game, GPU or console. No game compatibility claim. No original module, extracted bytes, harness or log is committed or uploaded.
Checklist
main; no other open PR implements the same functionsNotImplemented_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)🤖 Generated with Claude Code