feat(libkernel_sys): implement symlink #3491
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3491"
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 babyhuey on 2026-10-11T11:35:17Z.
What
Exports
symlink(waIF+5fE5HQ) from libkernel_sys, the module titles import it from, next toreadlinkandlink. The target text is stored as given, soreadlinkreturns it unchanged, and a link to a missing target is allowed, as on FreeBSD. On the host it is a directory symlink when the target is an existing directory and a file symlink otherwise. Windows callsCreateSymbolicLinkWwithSYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE, since MinGW'sstd::filesystem::create_symlinkreturnsENOSYSthere; Linux usesstd::filesystem. Errors return -1 witherrno:EFAULTand an empty oneENOENTEEXISTENOENTSeCreateSymbolicLinkPrivilege),EPERMAn absolute target throws (
NotImplemented): a guest absolute path such as/app0/...would point at the wrong place once stored on the host. Any other host failure throws as well.PS5VR (PPSA99177) stops at it on
main0f863c10, now thatfstatfs(#3439) is in (catalog build,eboot.binandsce_module/libc.prxunwrapped as #2605 requires; tracked in #1578):app.elf: symbol lookup error: app.elf: undefined symbol: waIF+5fE5HQFAIL: unresolved ELF import waIF+5fE5HQ (symlink) from libkernel_sys.prxsceAgcCreatePrimState: invalid user configuration register offsetsTested
Linux (Ubuntu 24.04, GCC 13), Release:
guest_kernel_syspasses 5/5 (--repeat until-fail:5). The new cases create a relative link and read it back withreadlink, check it resolves to the same file, create a dangling link, and check each error above througherrno. Where symbolic links can't be created (Windows without the privilege), the test checks forEPERMand skips the success cases, as #3169 does forlstat.check_conventions.pypasses. Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release, Developer Mode off and not elevated:guest_kernel_syspasses 5/5 with no warnings;CreateSymbolicLinkWreturnsERROR_PRIVILEGE_NOT_HELD, so the test checksEPERMand skips the success cases. The success cases have only run on Linux. The first head usedcreate_symlink, which fails on Windows withENOSYS.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-11T11:35:41Z.
Progress report (
0f863c1→6bc537c)📉 System libraries: 85.72% (-0.02%, +1 declared functions)
🆕 1 declared as stubs
symlink_nid_postfixImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:54:42Z.
Checked build and
guest_kernel_syson Linux (libs scope, 18/18 pass); the new cases don't link without the change.symlinkfollowslink(EFAULT/ENOENT/EEXIST, absolute targets and other host failures throw). The Windows privilege path is code-reviewed only. Merging.Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T12:01:08Z.
Windows validation of the current head
6bc537cemerged ontomain0f863c10(Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,BUILD_TESTING=ON, Developer Mode on, full build includinglibs):guest_kernel_sysaborts at the first symlink call:(exit
0xc0000409). The cause isstd::filesystem::create_symlink/create_directory_symlink: on this MinGW-w64 toolchain they fail withstd::errc::function_not_supported(generic 40), which the export then throws instead of reaching itsEPERMbranch. A standalone program built with the sameg++shows the same. The existing readlink symlink cases inGuestKernelSys.cppare already skipped on MinGW for that reason.A working Windows path is
CreateSymbolicLinkW(link, target, SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE | (directory ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0)), mappingERROR_PRIVILEGE_NOT_HELDtoEPERMandERROR_ALREADY_EXISTS/ERROR_FILE_EXISTStoEEXIST;lstatalready recognises the resulting reparse point since #2898, so the round trip can be tested here. Happy to rerun once the branch is updated.Validation run with Claude Code assistance.
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T12:23:38Z.
Follow-up now that this is merged: on
main1e8fff68(Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Release, full build)guest_kernel_sysis red, deterministically, with the failure reported above:std::filesystem::create_symlinkis not implemented in this MinGW-w64 libstdc++, so every Windowssymlinkcall throws. A fix branch usingCreateSymbolicLinkW(unprivileged-create flag, directory flag when the target is a directory,ERROR_PRIVILEGE_NOT_HELD→EPERM, existing names →EEXIST) with a real Windows round trip in the test is being prepared and will be linked from here.Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T12:28:59Z.
The fix is babyhuey's open #3510; my Developer-Mode-on validation and two remaining points are posted there, so no separate branch from me.