Repository navigation
fix(fs): collapse '..' at the api_path boundary; directory-open probe decides by attribute (#1872) - #1873
Conversation
…e/touch) Fail-first pins for the '..' component face split from #1869: api_path string pins (trailing/mid/root-climb/guard shapes) and applet-layer pins for stat, touch, and the fmt/fold/paste directory error class. No production code changes.
… decides by attribute (#1872) imp::api_path now collapses '.' and '..' components lexically (collapse_dot_segments) where it previously collapsed '.' only: a verbatim path carrying a dot segment is rejected by the attribute layer with ERROR_INVALID_FILENAME (probed on a real host), so every '..' operand failed stat/touch with Invalid argument and broke the fmt/fold/paste is_dir routing probe. The fmt/fold/paste directory translation no longer gates on the open's error kind (a drive root fails ERROR_PATH_NOT_FOUND, an ordinary directory ERROR_ACCESS_DENIED); the three copies of the probe expression collapse into fsutil::failed_open_is_directory.
|
CAPTAIN-VERIFY — merging. Reviewed head Fail-first on a real Windows host: 9/9 red with signatures matching the field report verbatim, 9/9 green after; the full acceptance matrix re-ran green on the host (stat/touch 9/9, fmt/fold/paste error classes correct including Closes the |
Refs #1872
Refs #1869 (承接:本单是 #1871 关单矩阵暴露的
..残面,#1871 的盘根修复不动)UNVERIFIED-BY-CAPTAIN — code-only 交付,队长复核后合入。
机制定位(devin-windows 实机探针,std/FFI 直测)
两个面、一个主根:
imp::api_path只折叠.、明文留下..,于是 verbatim 串带着点段抵达属性层——GetFileAttributesW("\\\\?\\C:\\l4probe\\..")、"..\\l4probe"中段形、"\\\\?\\C:\\."均为 error 123 (ERROR_INVALID_FILENAME),折叠后的拼写正常应答。即:任何含..组件的操作数对 stat/touch 必红(Invalid argument),且 fmt/fold/paste 在 open 失败后用来判定目录类的file_meta探针同路被污染、目录类永不触发,只剩原始 Permission denied 漏出。File::open("C:\\")本身失败为 error 3 (ERROR_PATH_NOT_FOUND)(普通目录是 error 5 ACCESS_DENIED)——三个 applet 的目录路由都以kind == PermissionDenied为门,根形永远进不去,报成 No such file or directory。find/pathchk/du/ls/rm/tee 全绿的原因也随之清楚:它们或走平路径(Win32 自行规范化)、或自带词法折叠(ls 的
lex_collapse,其注释里正写着为 api_path 不折叠..打的补丁)。修复(共享层单点 ×2)
imp::api_path:新增collapse_dot_segments,在既有.折叠所在的同一操作数边界上对./..一并做词法折叠——..弹前一组件、钳制于根(盘符/UNC server+share 不可弹)、落盘根恢复分隔符(fs_win api_path mangles drive-root paths (C:\. -> \?\C:), shared by stat/rm/touch/du/find and more #1869 规则)、尾随分隔符保留;无点段的拼写逐字节直通。原地删除旧的.专用字符串手术。fsutil::failed_open_is_directory(新共享谓词):目录类翻译不再看 open 的 error kind,只看属性探针。fmt/fold/paste 三处复制的PermissionDenied && file_meta…表达式收敛为对该谓词的一次调用(同根多点,已按简报口径在此说明)。ls 的
lex_collapse就此对 api_path 输出成为幂等空转(其另一输入 abs_probe_path 仍需要它),本 PR 不动 ls。fail-first 留痕(devin-windows,gnu 工具链跑 crate 测试)
85247df:9/9 红,红签名与实机报告逐字吻合(fmtdir/..→ "cannot open … Permission denied"、fmtC:\→ "No such file or directory"、api_path 三组串钉、stat/touch/fold/paste applet 钉)。45709dd:9/9 绿;全量 lib 测试 1083 过、1 红df::tests::type_filters——已在 pristine161d6d66同机 A/B 复现,为 devin-windows 主机环境存量红,与本 PR 无关。实机验收(devin-windows,本分支 driver 构建跑 #1872 形状集)
.@根、C:\.、C:\、..@l4probe、..@ctrl、C:\l4probe\..、C:\l4probe\..\l4probe、ctrl\..\ctrl、..\ctrl);touch 经ctrl\..\newfile1872在正确父目录建文件、同形删除 rc=0。C:\与全部..形)——与 CTRL 错误类逐项对齐,fs_win api_path mangles drive-root paths (C:\. -> \?\C:), shared by stat/rm/touch/du/find and more #1869 的.面无回退。..形 rc=0;rm 对C:\l4probe\..报 Is a directory;tee 目录操作数 Permission denied(与其 CTRL 类一致,未变)。删除节 / 净行账
.专用手术(两处 while 循环)——被collapse_dot_segments单一机制取代;fmt/fold/paste 三份PermissionDenied && file_meta探针表达式——收敛为 fsutil 单一谓词。无断言删改、无测试删除。残注
collapse_dot_segments内按 ls::lex_collapse 同规则防御性实现,但未立静态钉:UNC 操作数先经 winux-core 的 shell-tree 映射,静态期望串不可靠;实机矩阵为盘形全覆盖。