libkernel_sys: implement fchdir (PPSA99764); branch and commit ready #3288
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 sktharunbalaji13-cmd on 2026-10-11T05:33:09Z.
fchdir(NIDgnyVA6Tj-ak) is missing fromlibkernel_sys, and PPSA99764 Porpoise imports it. Issue #1578 lists Porpoise's missinglibkernel_sysimports aschroot,fchdir,pathconf, and #1578 comment #44 confirms the module split ("libkernelandlibkernel_sysare separate modules; exporting it fromlibkerneldid not resolve this import"), sofchdirhas to be exported fromlibkernel_sys.Bug fixes in the same directory/file area keep landing, but no open issue or PR implements
fchdir(a title/body search returns only #1578).A ready, self-contained implementation following the conventions (one commit, no code comments outside TechnicalDebt, a TechnicalDebt entry, no third-party code):
sktharunbalaji13-cmd:contrib/libkernel-sys-fchdir76329cbb08781e13d757c3ff955acf71f8bd506fWhat
fchdir_nid_postfix(int)incore/libs/prx/libkernel_sys/Export.cpp: sets the guest working directory to the descriptor's directory. ReturnsEBADFfor a descriptor that is not open andENOTDIRfor one that is not a directory, following FreeBSDfchdir(2).SetWorkingDirectory_nid_no_patch, shared withchdir; the refactor is behaviour-neutral (same guest errno values,chdirunchanged).File::DirectoryDescriptorPathbecomes cross-platform: the path recorded when the directory was opened on Windows, and the/proc/self/fdlink target on Linux.Tested
Windows 11, WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release:
guest_kernel_sys_testsand the related directory/filesystem targets build;ctestforguest_kernel_sys,guest_access,guest_working_directory,guest_realpath,guest_path_case,guest_directory,guest_filesystem,guest_directory_buffer,guest_directory_close— 9 passed, 0 failed.nid_patcherexport verified:libkernel_sys.prxexposesgnyVA6Tj-ak(=fchdir).fchdirmakesguest_kernel_sysfail and restoring it makes it pass, so the new cases are a real regression guard.Linux (WSL Ubuntu 24.04, GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1):
libkernel_sys(including the/proc/self/fdbranch) builds.guest_kernel_sys,guest_working_directory,guest_realpath,guest_directory,guest_filesystem,guest_access,guest_path_caseall pass (7/7) when run from an ext4 filesystem./mnt/c(drvfs),guest_accessandguest_path_caseabort; the same binaries pass from/tmp(ext4). This is a WSL drvfs artifact of this machine (permission/case-sensitivity), and neither test is affected by the changed files. A full Linux suite and a baseline differential were not run.Limitations (also recorded in TechnicalDebt): FreeBSD
change_dir's search-permission check (EACCES) is not modelled, a directory renamed after it was opened is still reached through the recorded path, and console behaviour is unverified.tools/check_conventions.py --base origin/mainandtools/check_test_registration.pypass.tools/pr_overlap.py --branchreports one overlap: #3160 (fork/setsid/umask) also editscore/libs/tests/GuestKernelSys.cpp. It implements different functions; the overlap is limited to the shared test file and would be resolved by a rebase.Request
PR intake currently requires 10 merged PRs into
mainand this account has 2 (.github/workflows/pr-intake.yml,minimumMergedPRs = 10), so I did not open a PR to avoid an automatic close. Would a maintainer be able to carry the commit, or sponsor reopening a PR for it? I am happy to rebase onto currentmainand re-run the tests first.AI-assisted: yes