kernel: report ENOTDIR from truncate through a file on Windows #2020
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2020
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2020/head"
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?
@lukanatroshvili67 on GitHub · 2026-10-31 12:58 UTC · original
lukanatroshvili67:fix/windows-truncate-enotdir→main· +18 −1 · 1 files · 1 commits · closed without mergingOn Windows,
truncate()on a path that runs through a regular file returnsENOENTinstead ofENOTDIR, which fails this check inkernel_file_system:POSIX
stat()fails withENOTDIRhere, and that already maps correctly. On Windows,std::filesystem::status()fails with "no such file or directory" instead. This change sends that case through a small helper,MissingPathError, which looks at the nearest existing ancestor. If that ancestor is a regular file, it returnsENOTDIR; otherwise it returnsENOENTas before. On Linux and macOS the result is unchanged.Testing (Windows 11, clang-cl 19.1.5)
missing-save.dat→ENOENTand/savedata0→EISDIR, still pass.kernel_file_systemonly reaches this check once the thread-cancel crash from #2015 is fixed (#2017), so I tested with #2017 applied locally. The run then gets to a later, unrelated network check ("Net unknown socket options return protocol-option errors").@coderabbitai[bot] on GitHub · 2026-10-31 13:03 UTC · original
Findings
e3b1ac87-f669-4935-b3e6-c279ca976cafReviewing files that changed from the base of the PR and between
026189166fand04cc483c22.src/kernel/fileSystem.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Walkthrough
MissingPathErrorchecks the nearest existing ancestor of a missing path. It returnsKERNEL_ERROR_ENOTDIRwhen that ancestor is not a directory, andKERNEL_ERROR_ENOENTotherwise.KernelTruncateuses this classification forno_such_file_or_directoryerrors.Suggested reviewers:
overlordxrz-source,nmzikChange: Bug fix
Merge Risk:
Low · up to
04cc4A narrow class of Windows truncate paths can receive an incorrect filesystem error code and should be corrected before merging.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 1 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
@ -1232,0 +1234,4 @@static int MissingPathError(const std::filesystem::path& real_name) {for (auto parent = real_name.parent_path(); !parent.empty(); parent = parent.parent_path()) {std::error_code error;const auto status = std::filesystem::status(parent, error);@coderabbitai[bot] on GitHub · 2026-10-31 13:03 UTC · original
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 15778
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1454
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1938
Check path components in order before classifying the missing path.
On Windows, path normalization removes
..before the file is accessed. For/savedata0/missing/../file/child, the ancestor probe inMissingPathErrorchecks/savedata0/missing/../file, which resolves to the regular file/savedata0/file. The helper then returnsENOTDIR. The previous code returnedENOENT, which is correct becausemissingdoes not exist.Walk the path from the root and stop at the first missing component. A missing component returns
ENOENT. A regular file that is followed by more components returnsENOTDIR.Suggested fix
@coderabbitai[bot] on GitHub · 2026-10-31 13:03 UTC · original · reviewed
Actionable comments posted: 1
e3b1ac87-f669-4935-b3e6-c279ca976cafReviewing files that changed from the base of the PR and between
026189166fand04cc483c22.src/kernel/fileSystem.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Pull request closed