Repository navigation
fix(tree/namei/look): fold POSIX drive-dialect operands onto the named drive (#1236 #1237 #1242) - #1248
Merged
Conversation
tree handed the raw root operand ('/e/Data', '/cygdrive/e/Data',
'/mnt/e/Data') to GetFullPathNameW, and Win32 resolves a leading '/e'
against the CURRENT drive: from a C: cwd 'tree /e/Data' rejected a
directory that exists on E: - or silently listed the shadow 'C:\e\Data'
where one happened to exist, the cwd-drive-drift form from the #1230
sweep. A bare '/e' listed or rejected '<cwd>:\e' the same way.
The operand now folds once through the shared normalize_api_operand
boundary before any Win32 call; the verbatim spelling is kept apart so
the 'cannot access' message quotes what the user typed instead of the
folded native form, like MSYS does (#1234 display/fold precedent).
Regressions synthesize the dialect spelling from the TempDir's own
drive (dialect/cygdrive/mnt operands list the operand drive, bare-drive
root lists the drive root, foreign-cwd negative, error spelling).
#1237) namei probed every component of the raw operand text with GetFileAttributesW, and Win32 resolves a leading '/e' against the CURRENT drive: all drive-dialect forms ('/e/Data', '/cygdrive/e/Data', '/mnt/e/Data') reported a broken chain ('f e (No such file or directory)') for paths that exist on the named drive, from any cwd. The operand now folds once through the shared make_api_path_operand boundary and the walk runs on the folded native spelling, one incremental prefix per step ('E:\' -> 'E:\probe-wb' -> ...), so every component of a dialect chain resolves on the operand's drive. The header line still prints the operand exactly as the user typed it, and a genuinely missing component keeps the GNU broken-chain report. Regressions synthesize the dialect spelling from the TempDir's own drive (dialect/cygdrive/mnt chains resolve, bare-drive root is a directory step, foreign-cwd negative, missing component still reports, native form unchanged).
…1242) look opened the dictionary file operand as raw text, and CreateFileW resolves a leading '/e' against the CURRENT drive: '/e/words', '/cygdrive/e/words' and '/mnt/e/words' all reported 'cannot open' for a sorted word list that exists on the named drive, answering for the cwd-drive shadow instead. The operand now folds once through the shared normalize_api_operand boundary at the open; the error message keeps quoting the operand spelling as the user typed it (#1234 display/fold precedent). Regressions synthesize the dialect spelling from the TempDir's own drive (dialect/cygdrive/mnt dictionaries open and match, foreign-cwd negative, error spelling, native form unchanged).
Member
Author
独立代码评审:APPROVE结论级:APPROVE(无 BLOCKER;3 条非阻塞备注见末尾。本评审未合并。) 评审基线:head 逐验证点
非阻塞备注
感谢提交里顺带把 #1251(look 空尾行二分越界,非方言缺陷)单独开票而不是塞进本 PR。 |
This was referenced Oct 19, 2026
This was referenced Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second wave of the #1230 drive-dialect audit repairs, following the merged #1243 (mkdir/ln) and #1245 (canonicalize_path_w) precedents. Three read-side commands still handed raw POSIX drive spellings to Win32, which resolves a leading
/eagainst the current drive - so the command answered for a cwd-drive shadow instead of the named path. Fixes #1236, #1237, #1242.Root cause and fix (same boundary as #1243/#1245)
GetFullPathNameW, so from aC:cwdtree /e/Datarejected a directory that exists onE:- or silently listed the shadowC:\e\Datawhere one happened to exist (the dangerous cwd-drift form; the audit'sC:\dleftover was live evidence of it). The operand now folds once throughnormalize_api_operandbefore any Win32 call; the verbatim spelling is kept apart so thecannot accessmessage quotes what the user typed, like MSYS (ln 裸盘符根 /x 形态被 std::filesystem::absolute 拼接到 cwd——链接解析盘符随 cwd 漂移 #1234 display/fold precedent).GetFileAttributesW, so all dialect forms reported a broken chain (f e (No such file or directory)). The operand folds once throughmake_api_path_operandand the walk runs on the folded native spelling, one incremental prefix per step (E:\->E:\probe-wb-> ...). The header still prints the operand as typed; a genuinely missing component keeps the GNU broken-chain report.cannot openfor a word list that exists on the named drive. The operand folds throughnormalize_api_operandat the open; the error keeps quoting the operand spelling./cygdrive/e,/mnt/eand bare/eshare the fold (single-sourced byfold_drive_dialect_w, #1145/#1172/#1231).Live matrix (PowerShell native argv; fixture
E:\probe-wbbuilt for the run and removed after; MSYSls/catconfirm the dialect resolves toE:\probe-wb)C:\beforeD:\beforeC:\afterD:\aftertree -L 2 /e/probe-wbcannot access 'C:\e\probe-wb'cannot access 'D:\e\probe-wb'E:\probe-wb(3 files)E:\probe-wbtree -L 1 /e(bare root)cannot access 'C:\e'cannot access 'D:\e'E:\rootE:\roottree -L 2 /cygdrive/e/probe-wbcannot access 'C:\cygdrive\e\probe-wb'E:\probe-wbE:\probe-wbtree -L 2 /mnt/e/probe-wbcannot access 'C:\mnt\e\probe-wb'E:\probe-wbE:\probe-wbtree -L 2 E:/probe-wb(control)namei /e/probe-wb/probe-marker.txtf e (No such file or directory)d E:\\->d probe-wb->f probe-marker.txtnamei /e(bare root)f e (No such...)d E:\\d E:\\namei /cygdrive/e/probe-wb,namei /mnt/e/probe-wbf cygdrive/f mntbrokenlook -f 2026 /e/probe-wb/probe-marker.txtcannot open '/e/...'look -f ... /cygdrive/e/...,/mnt/e/...dictcannot openlook -f alp E:/probe-wb/dict-sorted.txt(control)tree /e/probe-wb/absent-dir(missing)cannot access '/e/probe-wb/absent-dir'(operand spelling kept)namei /e/probe-wb/absent-child(missing)f absent-child (No such file or directory)look -f 2026 /e/probe-wb/absent.txt(missing)cannot open '/e/probe-wb/absent.txt'(operand spelling kept)Shadow witnesses
C:\e,C:\d,D:\ewereFalsebefore, after, and between every probe batch (tree/namei/look are read-only; the probes never create anything).Tests
tests/unit/tree: 5 new regressions (dialect lists operand drive; cygdrive+mnt; bare-drive root; foreign-cwd negative; error quotes operand spelling).tests/unit/namei/: new file, 6 regressions (dialect chain resolves; bare drive root; cygdrive/mnt; foreign-cwd; missing component still reports; native form unchanged).tests/unit/look/: new file, 5 regressions (dialect opens; cygdrive+mnt; foreign-cwd; error quotes operand spelling; native form unchanged).Local:
scripts/build.py(MSVC + CMake + vcpkg) builds clean;ctest: 3013/3020 in one full parallel run, the 7 failures (ls/mktemp/timeout/wc/which/wpm x2) all pass on isolated retry - concurrent-run flakes, untouched by this branch; all 27 tree/namei/look tests green.Adjacent defect noticed, out of scope
look's line reader turns a trailing newline into an empty final line, which can skew the binary search's lower bound past the last real entry (e.g.-f deltagainstalpha\nbravo\ncharlie\ndelta\nprints nothing even on a plain Windows path). Pre-existing, unrelated to the dialect fold - worth its own issue.