Repository navigation
feat(libkernel_sys): implement readlink - #1627
Conversation
klosixgaming-arch
left a comment
There was a problem hiding this comment.
LGTM. Thorough implementation of readlink following FreeBSD semantics with proper argument validation, path resolution, symlink status checking, and error mapping via GuestError. The test coverage is excellent - testing non-symlink paths, missing/empty/null paths, full reading, truncation, zero-size buffer, null buffer cases, and case-insensitive path handling on Windows. Good graceful degradation when symlinks aren't available (Windows without privilege). Clean addition to libkernel_sys for ProsperoRadio's import requirements.
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
a2de24b to
067e235
Compare
|
A title that stops on
The "with this branch" build also had my other open PRs merged; only this branch exports |
|
Same title on Windows. Windows 11, RTX 3080, WinLibs GCC 15.2.0 r7, Release,
As on Linux, the second build also had my other open PRs merged; only this branch exports |
067e235 to
c74b3dd
Compare
c74b3dd to
36ef0a9
Compare
36ef0a9 to
d024717
Compare
|
Checked on Linux (merged onto current |
What
Implements
readlink(pd02UI9TbOA) in libkernel_sys. Part of #1578: PPSA99001 (ProsperoRadio) imports it fromlibkernel_sys, which only had the placeholder export. On Windows an import is looked up in its own module and then libc, so it has to live in libkernel_sys.kern_readlinkat/kern_readlink_vp: a path that is not a symbolic link fails withEINVAL, a zerobufsizreturns 0, a longer target is truncated tobufsizwithout a terminator, andbufsizaboveSSIZE_MAXfails withEINVAL. A null path fails withEFAULT, an empty one withENOENT.ResolvePath_nid_no_patch. The target is read withstd::filesystem::read_symlinkand returned with/separators, then copied into the guest buffer, so no host call writes guest memory directly.EIOotherwise, asSceErrorFromErrnodoes in libkernel.Tested
Linux (Ubuntu 24.04, GCC 13, Release): new
guest_kernel_syspasses with--repeat until-fail:3. It covers a file, a directory, a missing path, empty and null paths, and a link: full target, truncation, zero size, null buffer, and a case-insensitive guest path. Where symbolic links can't be created (Windows without the privilege) it prints that the link cases were not tested. The test fails when truncation is removed.check_test_registration.pyandcheck_conventions.pypass. Windows:Export.cppcompiles with MinGW-w64 GCC 13 (-Wall -Wextra -fsyntax-only); not run on Windows. No title run.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)