Repository navigation
fix(libkernel): report ENOTDIR from stat for a file with a trailing slash - #2300
Conversation
|
Full Linux and Windows builds and tests for this head (
Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37948551554 |
1 similar comment
|
Full Linux and Windows builds and tests for this head (
Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37948551554 |
…lash On Windows the existence check accepts "file/", then _wstat64 rejects it and FillFileStat throws, aborting the title. On Linux the host reports ENOTDIR, which became ENOENT. A trailing slash on something that is not a directory now returns ENOTDIR on both hosts, as on FreeBSD. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Checked on Linux merged onto current
|
d99a6ce to
c1b714f
Compare
|
Thanks @adriadam10, the separate I checked the Windows (
A fresh full Linux and Windows build of this head is running and will be posted here. |
|
Full Linux and Windows builds and tests for this head (
Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/38031421856 |
…at-trailing-slash fix(libkernel): report ENOTDIR from stat for a file with a trailing slash
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(fix(kernel): return guest errors from scalar file operations #2144, fix(files): isolate guest descriptors from host resources #2170, fix(libkernel): honour open flags when Windows falls back to a directory descriptor #1628, feat(libkernel): open /dev/random and /dev/urandom for reading #1777, fix(libkernel): give flock BSD semantics on Windows #1755, fix(libkernel): return EWOULDBLOCK from a contended LOCK_NB flock #1764, feat(libs): implement font, libc, libkernel and misc prx stubs #2193, fix(libkernel): report Linux file birth times accurately #2115, feat(libkernel): implement lstat #1624, fix(libkernel): report EISDIR for path truncation #2086, feat(libkernel): implement fdatasync #1620, feat(libkernel): implement sceKernelFdatasync #2129) and with my fix(libkernel): report POSIX rename errors from sceKernelRename #2260 and fix(libkernel): return EPERM when unlinking a directory #2289. fix(linux): resolve loader and APR failures exposed by HFW #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