feat(libc): implement telldir and seekdir #6211
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6211"
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 milescoviello on 2026-10-15T03:49:58Z.
What
Link's Awakening for PS5 (PPSA99670, catalog release) does not start on
main:RZA5RZawY04istelldir(tools/nid_names.py --nid RZA5RZawY04). The executable also importsseekdir(7WoI+lVawlc). libc exports neither, so loading stops before the title runs. No other catalog title imports them.libc now implements both on the host directory stream that
opendiralready holds, under the stream's lock, the same wayrewinddirdoes:_wtelldir/_wseekdiron Windows,telldir/seekdirelsewhere. The position is the host's cookie, which the guest only passes back toseekdiron the same stream. A null stream setsEBADF, asreaddirandrewinddiralready do.guest_directorynow reads one entry, takestelldir, reads the next entry and the rest of the stream, then checks thatseekdirback returns that same next entry, and checks the null stream for both calls.Tested
Ubuntu 24.04, GCC 13.3, Release, on
maina077a88df:guest_directorypasses 5/5. Without the libc change it does not link (undefined reference to telldir_nid_postfix). Withseekdirmade a no-op it aborts at the check after the seek.guest_*tests pass.--to-intel, run on Linux (RTX 4070 Ti):mainstops at 0 s on the error above. With this change it runs the full 90 s. It reaches its own setup screen (Game module missing; run setup on a computer, since no game data is installed) and submits about 600 frames per 10 s. In a 60 s run with a temporary print in each directory call (not part of this PR), it calls none ofopendir,readdir,telldir,seekdirorclosediron that screen, so the title only proves that the exports load. The test covers the calls themselves.6025f0050on Windows 11 with an RTX 3080 (comment).guest_directorypasses 5 of 5. Onmain, Link's Awakening (PPSA99670, catalog 0.1.0) fails to load withtelldirandseekdirunresolved; with this PR it runs 60 s twice at about 60 fps, showing its game-files setup page.tools/check_conventions.py --base upstream/mainpasses, andtools/pr_overlap.py --branch fix/libc-telldir-seekdirfinds no overlap.macOS: @simonbbby ran this
Directory.cppon macOS 27.2 arm64 in a standalone harness. 82 of 82 saved positions round-trip and the null-stream checks pass, and makingseekdirortelldira no-op fails it. @nicolasfalesy found a catalog title that needs this: Link's Awakening for PS5 (PPSA99670, 0.1.0). On Linux with an Intel Arc GPU (Mesa ANV),main5d9dcc42dstops at load with./app.elf: symbol lookup error: ./app.elf: undefined symbol: RZA5RZawY04(telldir). With this PR it loads and runs the whole 40 s, to its ownGame module missingscreen, since no game files were installed for the test.Not checked on a console.
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T03:50:41Z.
Progress report (
f219248→6025f00)➖ System libraries: 89.65% (+0.0%, +2 implemented functions)
✅ 2 implemented
seekdir_nid_postfixtelldir_nid_postfixImported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-15T04:23:21Z.
Independent macOS POSIX helper check at exact head
7bf7ece122f9f976f71306ff2f2dd076802015cb: macOS 27.2 (26B5112a), native arm64, Apple clang 21.0.0.I built a standalone harness including this head's actual
Directory.cpp, with-std=c++20 -O2 -arch arm64 -ffunction-sections -fdata-sections -Icore/libs -Wl,-dead_strip. The harness creates the realDirectorywrapper around a native stream, then calls the productiontelldir_nid_postfix,seekdir_nid_postfix,readdir_nid_postfixandrewinddir_nid_postfix; there are no replacement implementations of those calls. Unused full-runtime functions are dead-stripped, so guest path resolution and loader initialization are not exercised.A scratch directory has 80 files with spaces/non-ASCII names, plus
.and... The probe saves the cookie before each read, reaches EOF, then seeks to every saved cookie and checks that the same next entry is returned. It also checks rewind and both null-handleerrno == 9cases.SeekNativea no-op → exit 1,seekdir cookie did not restore the expected entry.TellNativereturn 0 → the same expected failure.This adds host macOS cookie/stream semantics coverage, not a full
guest_directoryCTest, guest x86-64 ABI, title, Windows or console result. An x86-64 build of the same probe compiles, but executing it on this Mac fails withBad CPU type in executable, so no Rosetta result is counted. Compilation emits the existing C-linkage warnings fromGeneral.hpp; no warning-free-build claim.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-15T04:25:36Z.
Thanks for the macOS run, and for mutating both calls. I added it to the description.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:16:44Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/tests/GuestDirectory.cppImported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-16T02:40:46Z.
A title that reaches this: Link's Awakening for PS5 (PPSA99670) from the homebrew catalog, on Linux (Intel Arc, Mesa ANV).
main5d9dcc42d: stops at load with./app.elf: symbol lookup error: ./app.elf: undefined symbol: RZA5RZawY04(telldir, libc).main5d9dcc42d+ this PR: it loads and runs for the whole 40 s test, to its own check,[Link's Awakening] [game module] Game module missing; run setup on a computer, then copy its private package(shown on itsGame Filesscreen; no game files were installed for the test). It was stopped by the test after 40 s.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T02:42:14Z.
Thank you, @nicolasfalesy. A catalog title with a before-and-after run on Intel Arc is exactly the evidence this needed. I've added it to the description.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-18T15:41:46Z.
Windows run of head
6025f0050, merged ontomaine5f18ea99(clean merge). Windows 11, RTX 3080, WinLibs GCC 15.2, Release:guest_directorypasses 5/5 (--repeat until-fail:5); no warnings inlibc/src/Directory.cpporGuestDirectory.cpp.main: fails to load with unresolvedRZA5RZawY04(telldir) and7WoI+lVawlc(seekdir) from libSceLibcInternal (0xC0000139, no window). Windows resolves every import at load, so both are needed.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T15:42:23Z.
Thanks @babyhuey for the Windows run. It covers the load-time failure, which I could only describe from Linux. I added it to the description.
AI-assisted: yes (Claude Code)