feat(libkernel_sys): implement fchmodat #4553
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4553"
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 Nixitov on 2026-10-12T15:32:21Z.
What
Implement
fchmodatin libkernel_sys next toopenat. 2 Ship 2 Harkinian (PPSA99621) importsnsBDTu22CBU(fchmodat, throughstd::filesystem::permissions) and stops at start-up onmain.AT_FDCWD(-100) and absolute paths go through the path resolver; any other relative path is joined to the directory descriptor's host path, the same way as foropenatandfchdir. A flag other than0orAT_SYMLINK_NOFOLLOW(0x200) returnsEINVAL; a symbolic link underAT_SYMLINK_NOFOLLOWthrows, while a regular file is changed either way. The mode is masked to07777.A failing host
chmodis translated to the FreeBSD number (ENAMETOOLONG63,ELOOP62,ENOENT2,EACCES13,ENOTDIR20,EINVAL22,EPERM1,EROFS30, otherwiseEIO5), so the guest does not see Linux-only numbers. The host path join and the Windows read-only mapping are recorded indocs/dev/debt/libkernel_sys.md.Tested
Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release.
guest_kernel_syspasses: the checks cover theAT_FDCWDand directory-descriptor cases, the resulting mode on the host, the invalid-flagEINVAL,ENOENT,EFAULTandEBADF, a null path, and (Linux only)ELOOP-> 62 andENAMETOOLONG-> 63 through a self-referential symlink and a 300-byte component.mshivam019/tmm64-ps5releasev1.1.0, assettmm-ps5-2160p120-v1.1.0-camera-controls-windows.zip),eboot.binunwrapped from its SELF and relinked with the built relinker--windows: onmainit stops atFAIL: unresolved ELF import nsBDTu22CBU from libkernel_sys.prx; with this change it passesfchmodatand stops attCFbw1wGrqk(unlinkat).python tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T15:35:14Z.
Progress report (
759c665→603d94a)📉 System libraries: 88.01% (-0.03%, +1 declared functions)
🆕 1 declared as stubs
fchmodat_nid_postfixImported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-12T16:52:02Z.
Thanks bot. This is a same-file overlap only, not a duplicate function:
pathconf) and #4592 both editcore/libs/prx/libkernel_sys/Export.cppat the include block and theGuestAtFdcwdconstant, whichfchmodatalso adds next to.fchmodatis distinct frompathconf.Happy to rebase after either lands; nothing here depends on them.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T06:09:08Z.
Linux test (Arch, GCC 16.2.1, Release), this PR merged onto
main7e181fcc3:guest_kernel_syspasses.One Linux-only gap: the failure path returns the host
errnoas is (Fail(errno)after::chmod), and Linux numbers above 34 are not FreeBSD's. With a local check added toGuestKernelSys.cpp(not pushed):The
errnovalues achmodcan return that are the same number on both (ENOENT,EACCES,ENOTDIR,EPERM,EROFS,EIO) are fine. Mapping the host error the wayDirectoryErrorincore/libs/prx/libc/src/Directory.cppdoes (ENAMETOOLONGto 63,ELOOPto 62) would cover the two above. Windows'_wchmodonly setsENOENT/EACCES/EINVAL, so it is not affected.Imported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-13T14:00:13Z.
Good catch — the failure path passed the host errno straight through, so a Linux
ELOOP(40) orENAMETOOLONG(36) would have reached the guest as a number FreeBSD does not use.fchmodatnow translates the host error before returning:ENOENT2,EACCES13,ENOTDIR20,EINVAL22,EPERM1,EROFS30,ENAMETOOLONG63,ELOOP62, otherwiseEIO5 — the same shape asDirectory.cpp's mapping for the path-length and symlink-loop cases. Windows_wchmodonly setsENOENT/EACCES/EINVAL, so it is unaffected.Added a Linux-only test (a self-referential symlink and a 300-byte path component) asserting
ELOOP→ 62 andENAMETOOLONG→ 63. Thanks for the Linux run.Imported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-13T14:09:30Z.
Rebased onto current
main(renameat/unlinkat/mkdiratnow sit next tofchmodat; the conflicts were placement only) and re-verified:guest_kernel_syspasses andcheck_conventions.pyis clean on the rebased head.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:21:00Z.
Checked
fchmodatagainst the diff: path resolution, flag handling, host→FreeBSD errno mapping (ELOOP 62, ENAMETOOLONG 63) and the debt entry; the new checks inguest_kernel_syspass on Linux.Added one commit on top: after the latest
mainthe test declaredlongNametwice (GuestKernelSys.cpp), so the file no longer compiled; the fchmodat check now reuses the existing 256-byte name (which also gives ENAMETOOLONG 63).Merging once the full Build is green.