feat(libkernel): implement getlogin #9171
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9171"
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 DavidSamir on 2026-10-21T14:11:02Z.
What
getloginwas a discovery stub inlibkernel_systhat threwNotImplemented. It is now implemented in libkernel, inlibkernel/System/src/Login.cppbesidegetlogin_r, and the libkernel_sys stub is removed. It follows FreeBSD 11lib/libc/gen/getlogin.c: a staticMAXLOGNAME(33-byte) buffer filled by libkernel'sgetlogin_r. On an error it setserrnotogetlogin_r's error and returns NULL, and an empty name also returns NULL.Moved to libkernel so libkernel imports reach it on Windows. The PS5 3.20 export lists have
getloginin libkernel as well as libkernel_sys, and on Windows a libkernel import never searches libkernel_sys (WindowsEntryStubBuilder.cpp:175). With the libkernel export and no libkernel_sys stub, both imports reach it, and the duplicate-export rule holds.futimesat dropped: #9161 implements it. The last commit takes it back out of this PR and restores its stub, so the PR's total change is
getloginonly.Tested
Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release. This is a CPU-side export, so no GPU is involved.
guest_kernel_sys_login(core/libs/tests/GuestKernelSysLogin.cpp):getloginagainstgetlogin_r, including the error and empty-name cases and the same static buffer on a second call.main'sExport.Discovery.cppthe test aborts withgetlogin_nid_postfix not implemented. On this branch it passes.guest_kernel_sysstill passes, andtools/check_conventions.pypasses, including the duplicate-export rule.getloginrenamed inLogin.cpp, the test fails to link (undefined reference to getlogin_nid_postfix), so it reaches libkernel's export, which is the only one.tools/pr_overlap.pycrashes on this machine's partial clone, so I rangit merge-treeagainst every open PR that touchesLogin.cpporExport.Discovery.cpp. It merges cleanly with all of them.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)Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T19:18:20Z.
Independent Windows run of this PR (data only).
Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against
mainis clean. I built onlyguest_kernel_sys_login_tests;ctest -N -R guest_kernel_sys_loginlists exactly one test.PR head tested:
312fccbf0b64f7cd61a1793756852805203862fd.Results (3 runs each):
guest_kernel_sys_loginpasses 3/3.core/libs/prx/libkernel_sys/Export.Discovery.cppwith the version from the PR's merge base (663de1ab21), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards.Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-22T02:06:15Z.
Linux: Ubuntu 24.04.1 LTS (WSL2), GCC 13.3.0, Release; head
4051c0af7merged ontomain8c26eac3c.guest_kernel_sys_loginpasses 3/3.getloginrenamed inLogin.cpp, the test fails to link:undefined reference to getlogin_nid_postfix, as listed.Run from the PC (Windows host, Linux in WSL2), not from the PR author's machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T08:30:12Z.
Review: DISMISSED
Review
Moving
getloginto libkernel is a sensible way to serve both import paths, and the dedicated link test is useful. I found one error-path mismatch and test-coverage gaps to resolve before approval.Host lookup failures
The new wrapper sets guest
errnoonly whengetlogin_r_nid_postfixreturns a nonzero code. In the same file, however,ReadLoginthrowsstd::system_errorwhen the host lookup/conversion fails andstd::runtime_errorwhen no account name is available. Those cases do not return through this wrapper’sNULLplus guest-errnopath.Please make the host lookup failures return or translate to an error code that
getlogincan expose, or document why exceptions are the intended guest-visible behavior. Add a deterministic test for the selected behavior.Test report
GuestKernelSysLogin.cppconditionally checks the error and empty-name branches based on the host account result; it does not force either case. In particular, a normal non-empty Windows username takes only the success path, and the host lookup code throws rather than producing an empty name. Please make those cases deterministic or revise the Tested description to state which path actually ran.Current base and overlap scan
This head is 608 commits behind current
main(merge base663de1ab21). Please rebase/update and rerun the focused test.The current overlap report flags both
core/libs/prx/libkernel_sys/Export.Discovery.cppandcore/libs/CMakeLists.txt. The manual scan in the PR description coveredLogin.cppandExport.Discovery.cpp, but not the CMake test registration, and predates newer open PRs. Please rerun the overlap check against currentmainfor all changed files and update the PR notes with any order/dependency that is actually needed. I did not find a duplicategetloginimplementation in the listed kernel PRs.Checks
git diff --checkagainst currentmain: passed.tools/check_conventions.pyagainst currentmain: passed.The move to libkernel and the static-buffer success path look reasonable; the failure behavior and current-base validation need follow-up.
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-22T09:50:26Z.
Thanks @MarcZX10. New commits, no force-push:
Host lookup failures: throwing is the intended behaviour, and I've kept it.
getloginonly forwardsgetlogin_r, and thegetlogin_rentry already onmain(docs/dev/debt/libkernel.md) says: "Account lookup or encoding failures, a missing or empty account name, and POSIX account records exceeding the 16 KiB lookup buffer throw; there is no replacement name or retry". That follows the repository rule that behaviour we can't confirm on the console throws instead of returning a guessed code. The console's behaviour without a login session is unknown. SogetloginreturnsNULLwith errno only for the codesgetlogin_rreturns (ERANGE,EFAULT).Deterministic paths (
146c781256): aLoginNameForTest_nid_no_patchseam sets the namegetlogin_rreads, soguest_kernel_sys_loginnow forces each path, whatever the host account is:getlogin_rwith a buffer one byte short givesERANGEwithout writing to it;NULLfromgetloginwith errnoERANGE(its buffer is 33 bytes);The original host-account check still runs first, and it states which path the host took.
Negative control: with
getloginnot setting errno, the test fails at line 57, the 40-byte case.Current base (
badef62185): merges currentmain.guest_kernel_sys_login,guest_getlogin,guest_login_dialogandguest_login_servicepass on Windows 11 (WinLibs GCC 15.2), andcheck_conventions.pypasses.Overlap, rerun on all changed files:
git merge-treeadds no conflict with any PR sharingcore/libs/CMakeLists.txtorExport.Discovery.cpp. #5021, #6044, #7201, #7275, #7622, #8285, #8650, #9019, #9040, #9103, #9208, #9212, #9219, #9221, #9224, #9294 and #9382 all have the same conflict hunks as againstmain. The one new overlap is #9693 (setlogin, opened today), which editsLogin.cppin two places next to mine. I've proposed the order on that PR and will record it here.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T18:41:58Z.
Review: COMMENTED
I reviewed the implementation and its focused test. One documentation follow-up: please extend the existing
getlogin_rentry indocs/dev/debt/libkernel.mdto covergetlogintoo. The implementation follows FreeBSD 11 for the static 33-byte result, return value, anderrno, but thosegetloginsemantics have not been checked against a PS5. The current debt entry documents the host-account behavior and gaps forgetlogin_r, not the new API wrapper. This is not a finding about the implementation logic; it keeps the unmeasured behavior visible under the repository technical-debt convention. The current hosted product suites are skipped, so the local focused test report is the runtime evidence available here.