fix(libkernel): report ENOTDIR from stat for a file with a trailing slash #2300
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2300"
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 reyani-dev on 2026-10-09T15:01:07Z.
What
On FreeBSD,
stat("file/")fails withENOTDIR: a trailing slash asks for a directory. Onmain:std::filesystem::exists("file/")is true (Win32 ignores the slash), then_wstat64("file/")fails, andFile::FillFileStatthrowsFillFileStat: stat failed for ..., which aborts the title.statreportsENOTDIR, whichstd::filesystem::existsreads as "not found", so the guest gotENOENT.sceKernelStatnow takes thestd::filesystem::statusonce and returnsENOTDIRif the host reportsnot_a_directory, or if the guest path ends in/and the target exists but isn't a directory. A missing path is stillENOENT, andstat("dir/")still succeeds.stat(the POSIX wrapper) goes throughsceKernelStat, so both are covered.The same trailing slash on other calls returns the wrong error without aborting:
open("file/")andunlink("file/")giveEINVALinstead ofENOTDIRon Windows.openis being reworked by several open PRs (#1628, #1777, #2144, #2170), andunlinkis in my #2289, so I kept this tostat.Tested
Windows 11, WinLibs GCC 15.2.0 r7, Release,
-DBUILD_TESTING=ON:New checks in
guest_filesystem_tests, next to the otherstatchecks:stat("present.txt/")returns -1 with errno 20;sceKernelStat("present.txt/")returns0x80020014;stat("<dir>/")succeeds and reports a directory.On
mainthe test process aborts withFillFileStat: stat failed.ctest -E "^agc_|video_out": 249/249 passed, includingguest_path_case, which also usessceKernelStat.tools/check_conventions.pypasses, andtools/pr_overlap.py --branchreports no overlap. It merges cleanly with the open PRs that touchOpen.cppandGuestFilesystem.cpp(#2144, #2170, #1628, #1777, #1755, #1764, #2193, #2115, #1624, #2086, #1620, #2129) and with my #2260 and #2289. #1616 already conflicts withmainon its own.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T16:30:32Z.
Full Linux and Windows builds and tests for this head (
d99a6ceb), using the project's Build workflow. I can't start the upstream manual run, so I ran the samebuild.ymlin my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into currentmain(d70b8998):ctest: 516/516 passedctest: 507/507 passedRun: https://github.com/AchrafReyani/AnyPS5/actions/runs/37948551554
Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T16:30:40Z.
Full Linux and Windows builds and tests for this head (
d99a6ceb), using the project's Build workflow. I can't start the upstream manual run, so I ran the samebuild.ymlin my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into currentmain(d70b8998):ctest: 516/516 passedctest: 507/507 passedRun: https://github.com/AchrafReyani/AnyPS5/actions/runs/37948551554
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:15:45Z.
Checked on Linux merged onto current
main:guest_filesystemaborted at thelstatchecks, because the new directory check overwrotestatus, which thelstatchecks (added by #1624) reuse. I pushed one commit that uses a separateFileStat dirStatusfor it. After that, build and the scoped ctest (73 tests) are green, and the newstatchecks fail when theOpen.cppchange is reverted._wstat64) not run here; relying on your fork run, which predates #1624.Merging once CI is green.
Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T06:34:43Z.
Thanks @adriadam10, the separate
dirStatusis right.I checked the Windows (
_wstat64) side with your commit (c1b714f2) merged onto currentmain03bf8ff3(Windows 11, WinLibs GCC 15.2.0, Release):guest_filesystempasses 3/3 (--repeat until-fail:3), including the new trailing-slash checks and thelstatones;ctest -E "^agc_|video_out"passes 335/335.A fresh full Linux and Windows build of this head is running and will be posted here.
Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T06:53:49Z.
Full Linux and Windows builds and tests for this head (
c1b714f2), using the project's Build workflow. I can't start the upstream manual run, so I ran the samebuild.ymlin my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into currentmain(03bf8ff3):ctest: 628/628 passedctest: 636/636 passedRun: https://github.com/AchrafReyani/AnyPS5/actions/runs/38031421856