Repository navigation
fix(libkernel): report lookup errors when creating through a trailing slash - #10319
oneandonlydean merged 4 commits into
Conversation
|
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.
|
harisibrar1
left a comment
There was a problem hiding this comment.
Checked against main 11d6efa and FreeBSD 11.4 lookup() (vfs_lookup.c, the TRAILINGSLASH/WILLBEDIR → ENOENT block and the TRAILINGSLASH on a non-directory → ENOTDIR block):
- The behaviour matches
lookup(): a missing final name with a trailing slash givesENOENT, existing directories keepEISDIR/EEXIST, and an existing file with a trailing slash still takes the host'sENOTDIRpath. Open.cpp is unchanged on main since your base, so the fix is still needed. git merge-treeagainst current main now conflicts indocs/dev/debt/libkernel.md, where main rewrote the neighbouringfcntlline. #8544 is already merged (85f2f2d), so the declared merge order is satisfied and only a rebase is needed.- The new
/parent-test-mount/missing-create/check inGuestFilesystem.cppalso runs on Windows, and the PR says Windows wasn't compiled. A Windows CI or local run ofguest_filesystemwould confirm that_wopen'sEINVALis corrected there as intended; I couldn't run it myself.
Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
|
@harisibrar1 thanks for the review.
|
MarcZX10
left a comment
There was a problem hiding this comment.
The Linux tests exercise the missing-name, exclusive-create, no-file-created, and symlink-loop cases, and the lookup correction is appropriately limited to O_CREAT after EISDIR/EINVAL. Two integration checks remain before approval:
- Rebase onto current
main, as required by CONTRIBUTING.md. This branch is based onaeeaefa, 6,761 commits behind currentmain; the nearbyfcntldebt history and the existingGuestFilesystemtest code have since moved. - Please run
guest_filesystemandguest_path_errorson Windows. The change specifically maps Windows_wopen'sEINVAL, but Windows was not compiled for the reported runs and the hosted Windows product job is skipped for this path. Confirm both aliased and plain paths, including the symlink-loop case where the platform permits it, on the rebased head.
|
Windows run for this PR, as asked in the last review. Build: head
Probe (identical in all three runs of each variant):
No file was created by any of these calls. So on Windows, Not tested: the symlink-loop case. This account can't create symlinks (no Developer Mode or admin rights; |
a42c741 to
b919ecf
Compare
|
@MarcZX10 thanks. Rebased onto current On Windows, @BunnyFl's run above covers what you asked, on this change merged onto a recent
Two parts could not be run on Windows. |
|
@MarrasFederico #11135 edits the |
b919ecf to
7b0f1b6
Compare
|
@orezraey thanks for the heads-up, agreed. Whichever lands second keeps both changes. I've just rebased this one onto current |
|
@MarrasFederico merged main into your branch to resolve the conflict in |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed the updated head 182c8be21791edf8acac4dcb0868163e6eeb54a4. It now includes current base 10bec5c322eb581b3e959e6c7e18bcf09e068e96, resolving the requested rebase/conflict. The Windows workflow passes on this exact head; the earlier Linux build and focused guest path/filesystem/archive tests passed on the immediately preceding rebased tree, and the latest merge is reported as main plus the debt-file conflict resolution. The Windows report also covers plain and aliased missing paths, both create modes, no-file-created behavior, and unchanged existing-path behavior. guest_path_errors and the symlink-loop case were not run on Windows because the target requires Unix symlinks. I did not rerun Linux locally on the final merge commit.
✅ AMD GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (11, not counted against this PR)Validation IDs already present on main (5 IDs in 552 tests)Skipped (55)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
…e CreateFileW on Windows On Windows 11 build 26300, CreateFileW with OPEN_ALWAYS, CREATE_NEW or CREATE_ALWAYS on a path ending in a separator creates a regular file for a missing name and opens an existing file, also in the \?\ form. Windows Server 2025 (26100) and Windows 11 26200 return ERROR_INVALID_NAME there, which the correction from #10319 turns into ENOENT. On 26300, open and sceKernelOpen with O_CREAT on "missing/" returned a descriptor and left a file named "missing", and guest_filesystem failed on every run. The Windows open now looks up a creating path that ends in a separator before CreateFileW: a missing name takes the not-found path (ENOENT, or ENOTDIR below a file), a name that is not a directory fails with ENOTDIR, as FreeBSD 11.4's lookup does, and only a directory reaches CreateFileW. guest_filesystem checks O_CREAT, O_CREAT | O_EXCL and O_CREAT | O_TRUNC through an alias, a guest path and, on Windows, a native drive path, which skips the resolver's non-directory check.
…e CreateFileW on Windows On Windows 11 build 26300, CreateFileW with OPEN_ALWAYS, CREATE_NEW or CREATE_ALWAYS on a path ending in a separator creates a regular file for a missing name and opens an existing file, also in the \?\ form. Windows Server 2025 (26100) and Windows 11 26200 return ERROR_INVALID_NAME there, which the correction from boykopovar#10319 turns into ENOENT. On 26300, open and sceKernelOpen with O_CREAT on "missing/" returned a descriptor and left a file named "missing", and guest_filesystem failed on every run. The Windows open now looks up a creating path that ends in a separator before CreateFileW: a missing name takes the not-found path (ENOENT, or ENOTDIR below a file), a name that is not a directory fails with ENOTDIR, as FreeBSD 11.4's lookup does, and only a directory reaches CreateFileW. guest_filesystem checks O_CREAT, O_CREAT | O_EXCL and O_CREAT | O_TRUNC through an alias, a guest path and, on Windows, a native drive path, which skips the resolver's non-directory check. (cherry picked from commit 9ec24c5)
What
openandsceKernelOpenwithO_CREATon a missing final name followed by/reported the host error (EISDIRon Linux; the existing debt recordsEINVALon Windows). FreeBSD 11.4 lookup rejects this case withENOENT, because only a directory can be created through a trailing slash.After a native open fails with
EISDIRorEINVAL, a trailing-separator creation request now checks the path's status. A missing path reports guestENOENT; metadata errors are mapped explicitly, includingELOOP. Other requests and existing directories keep their original result. This applies to ordinary and aliased guest paths, with both plain and exclusive creation covered. Failed requests create no file. The resolved debt item is removed; a concise replacement records the non-atomic host lookup/open sequence and that this has not been measured on a PS5.#8544, which edited the neighbouring
fcntldebt line, is merged, and the branch is rebased onto currentmainas one commit. #8658 adds a macOS existing-directory check at the native-open call; this correction is placed after the Windows directory fallback to avoid the insertion conflict.Tested
Ubuntu 26.04.1, kernel 7.0.0-38, GCC 15.2.0, Release,
BUILD_TESTING=ON. Windows was not compiled here; BunnyFl's Windows run is below. No title was run.main(7b0f1b6).ctest --test-dir build -R 'guest_(path|filesystem|app_archive)' --output-on-failure -j12.main'sOpen.cpp,guest_path_errorsandguest_filesystemfail (checked again on the rebased head). Removing the lookup correction fails again; losing explicit metadata-error propagation fails the symlink-loop regression. The restored implementation passes.mainc8d34aa8f4):guest_filesystempasses 3 of 3, and fails 3 of 3 at the new aliased check with only the test lines applied._wopen'sEINVALintoENOENTfor plain and aliased paths, with and withoutO_EXCL, and creates no file.main's results.guest_path_errorsis built only underif(UNIX)(it uses::symlink), and the symlink-loop case was not run on Windows: that account cannot create symlinks.python3 tools/check_conventions.py --base origin/mainand whitespace checks pass.pr_overlap --branchscan flagged only the adjacentfcntldebt line of fix(libkernel): report O_RDWR from F_GETFL on both ends of a pipe #8544, now merged. It finds no code conflict. Its not-compared PRs were inspected manually: feat(libkernel): sceKernelRaiseException on macOS hosts #4630, feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021, test: organize library tests and label CTest suites #6044, fix(libkernel): provide default arguments block for DT_INIT on Linux #6149, fix(libkernel): prevent use-after-free on pthread semaphore destruction and notification race #6740, feat(libSceDbgThreadSanitizer): add no-op implementations for __tsan_acquire and __tsan_release #6830, feat(libkernel): support SEEK_DATA and SEEK_HOLE in lseek #6936, fix(libkernel): retire an EV_ONESHOT note through its delete callback and follow Windows $Deleted paths #7049, feat(libkernel): support kevent read and write events on regular files #7088, fix(libkernel): return EACCES for unknown ranges on direct-memory release paths #7105, feat(libkernel): report open, read and close notes on watched files #7121, fix(threads): run Windows pthread and small fiber stacks in guest VA range #7149, Macos port #7201, fix(libkernel): support lstat on long Windows paths #7202, perf(agc): keep unimported label stores on the CPU #7464, fix(libkernel): bound equeue pending events #7509, feat(libkernel): initialize created guest thread MXCSR to 0x9fc0 at entry boundary #7565, fix(libkernel): handle kevent timer re-adds and the AIO, LIO, SENDFILE and PROCDESC filters as measured on a PS5 #7653, feat(libkernel): implement pthread_condattr_getclock #8010, feat(libkernel): enumerate archived app directories #8520, feat(libs): add four sysctl MIB mappings and an IME setter #8553, fix(libkernel): defer raises while a thread holds the address-wait lock on Linux and macOS #9074, feat(libSceLibcInternal): implement posix_spawn process creation and reaping #9133, fix(libkernel): change O_APPEND on a Windows file through fcntl #9256, feat(libkernel): implement the unnamed ksem semaphores #9284, feat(libkernel): implement the named ksem semaphores #9293, feat(libkernel_sys): implement POSIX message queues #9297, feat(libkernel_sys): implement kmq_notify registration #9302, feat(libkernel): keep the SIGIO owner of a pipe for F_GETOWN and F_SETOWN #9557, feat(libkernel): sync each write on a file whose O_FSYNC flag is set #9561, feat(libkernel): answer tcgetpgrp and tcsetpgrp on a pipe with its SIGIO owner #9566, feat(libkernel): support EV_CLEAR on a kqueue watched by another kqueue #9575, feat(libkernel): implement execv, execvp and execve process replacement #9669 and feat(libkernel_sys): implement setlogin #9693. The macOS patches concern existing directories, the otherOpen.cppedits concern notifications, archives, argument copying or seek/write, and the test edits cover other scenarios. The debt edits concern other behaviors; fix(libkernel): change O_APPEND on a Windows file through fcntl #9256/feat(libkernel): keep the SIGIO owner of a pipe for F_GETOWN and F_SETOWN #9557/feat(libkernel): sync each write on a file whose O_FSYNC flag is set #9561/feat(libkernel): answer tcgetpgrp and tcsetpgrp on a pipe with its SIGIO owner #9566 also edit the neighboring longfcntlparagraph and may need a documentation rebase after the declared order. test: organize library tests and label CTest suites #6044 deletes an obsolete whole test file and requires rebasing independently.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)