Skip to content

fix(fs_win): api_path restores the root separator on bare-drive landings - #1871

Merged
caomengxuan666 merged 2 commits into
mainfrom
fix/1869-api-path-drive-root
Nov 25, 2026
Merged

caomengxuan666 merged 2 commits into
mainfrom
fix/1869-api-path-drive-root

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Refs #1869 — UNVERIFIED-BY-CAPTAIN (code-only lane delivery; captain review pending)

Defect

fs_win::imp::api_path collapses . components lexically and then trims a trailing \.. When the operand lands exactly on a drive root through a dot segment, the trim shaves the root down to the bare drive:

  • cwd C:\, operand . → join spells C:\. → trimmed to C:
  • operand C:\. → trimmed to C:
  • cwd C:\, operand .\. → \. collapse leaves C:\. → trimmed to C:

The result is emitted as \\?\C:, which is not a valid path — every consumer of the shared layer then fails with ERROR_INVALID_PARAMETER where GNU stats the root. Host baseline (X299, recorded in #1869): stat dot-segment shapes all "Invalid argument", find/touch DEFECT, pathchk single-shape DEFECT, fmt/fold/paste error-class DEFECT; du/ls OK (ls carries its own fold, #1863 — untouched here).

Fix (single landing point, shared layer)

In api_path (rust2/crates/winux-cmds/src/fs_win.rs), after the collapse + tail truncation: if the result is exactly a bare drive (C: form), restore the root separator so it emits \\?\C:\, never \\?\C:. One shared-layer fix; beneficiaries: stat/pathchk/ln/rm/touch/tee/du/find/glob directly, fmt/fold/paste via file_meta, cp's symlink-creation face. ls's lex_collapse is not touched; the S4/S5 verbatim .. faces are out of scope.

Pins (fail-first, two-phase on CI)

The fix lives in the cfg(windows) imp, which cannot execute on the lane's Linux host (no mingw linker locally; the windows-gnu target check-compiles the new code clean). Fail-first therefore runs on this PR's rust-tests job (windows-2025) in two phases:

  1. Pins-only commit (7259b32): three discriminating pins must go red, the guard pin green —
    • issue1869_root_cwd_dot_operand (cwd C:\, .)
    • issue1869_drive_root_dot_suffix (C:\.)
    • issue1869_root_cwd_dot_backslash_dot (cwd C:\, .\.)
    • issue1869_drive_root_guards (C:\; non-root cwd .; root cwd ./x)
  2. Fix commit on top: all green.

Phase results (executed, rust-tests job):

  • Phase 1, pins only (run 45590552460): lib target 1072 passed / 3 failed — the failure set is exactly the three discriminating pins, each with left: "\\\\?\\C:" vs right: "\\\\?\\C:\\"; the guard pin passed. No other failures.
  • Phase 2, with the fix (run 45590911037): 1075 passed / 0 failed — all four issue1869_* pins green, delta vs phase 1 is exactly the three pins flipping.
  • Locally (Linux host): cargo check --target x86_64-pc-windows-gnu -p winux-cmds --tests compiles the cfg(windows) imp and the pins clean; cargo fmt --check shows no diff in fs_win.rs. The pins were not executed locally (no mingw linker on the lane host) — execution evidence is the CI runs above, not a local run.
  • Other workflow jobs (build-windows matrix, gate shards) were still pending when this note was written; the designated CI surface for this change is rust-tests.

Owed verification (explicit debt)

X299 is down. The post-fix host L4 matrix — stat/find/touch/pathchk/fmt/fold/paste re-run against the recorded DEFECT baseline — has not run and is owed after X299 recovers. CI rust-tests green is the only execution evidence in this PR; nothing here claims host verification.

What this PR deletes / net lines

  • Deleted: nothing. No mechanism is removed; the change is one guard at the single shared landing point plus test pins.
  • Net lines: +51 / −0, one file (rust2/crates/winux-cmds/src/fs_win.rs): pins +42, fix +9 (guard + comment). Production-code delta is the +9.

Fail-first pins for #1869: cwd=C:\ with '.', the absolute 'C:\.',
and cwd=C:\ with '.\.' all collapse to the bare drive in api_path
and come out as the invalid \\?\C:; three guard shapes (plain root,
non-root '.', root './x') already land correctly. Refs #1869.
… drive

After the '.' collapse and tail truncation, a dot-segment landing on
a drive root ('C:\.', or '.' / '.\.' joined against a root cwd) came
out as the bare drive, and api_path emitted the invalid \\?\C: —
every shared-layer consumer (stat/find/touch/pathchk, fmt/fold/paste
via file_meta, ...) failed with ERROR_INVALID_PARAMETER where GNU
stats the root. A bare-drive result now regains its root separator
and spells \\?\C:\. Refs #1869.
@caomengxuan666

Copy link
Copy Markdown
Member Author

CAPTAIN-VERIFY — merging.

Reviewed head 2bab64f (pins 7259b32 → fix). The shared-layer fix for #1869:

  • Fix: imp::api_path restores the root separator when the collapse + tail truncation lands exactly on a bare drive (C:), so it emits \\?\C:\ and never \\?\C:. Single landing point in the shared layer; ls's lex_collapse untouched; verbatim .. faces out of scope. Production increment +9 lines in one file.
  • Fail-first, CI two-stage (as designed): with only the six pins pushed, rust-tests (windows-2025) went red on exactly the three discriminating shapes with the exact signature left: "\\?\C:" vs right: "\\?\C:\", guards green, no other reds; with the fix, lib 1075 pass / 0 fail. Full PR CI: 28 pass / 0 fail.
  • Still owed, recorded on fs_win api_path mangles drive-root paths (C:\. -> \?\C:), shared by stat/rm/touch/du/find and more #1869: the X299 real-machine L4 matrix (stat/find/touch/pathchk/fmt/fold/paste re-tested against the recorded DEFECT baseline) runs after X299 returns; the coverage conclusion above the shared layer is by construction, not per-command host measurement. fs_win api_path mangles drive-root paths (C:\. -> \?\C:), shared by stat/rm/touch/du/find and more #1869 stays open until that matrix runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant