Repository navigation
fix(executor): classify emulated chmod operand stat errors by the path walk (Refs #3425) - #3440
Merged
Merged
Conversation
…h walk (Refs #3425) The emulated chmod discarded the operand metadata error in its apply arms and printed a hardcoded ENOENT text for every failure, so `chmod 600 a/b` (a a regular file) reported 'No such file or directory' where GNU coreutils reports the walk's ENOTDIR. Route the operand stat through the CpNode machinery (the same root external_cp builds via cp_operand_root) and render the apply-arm failure with CpNode::stat_classified + posix_errors::message: a walk that dies at a non-directory component reports ENOTDIR, a genuinely missing component keeps ENOENT. The base mode and is_dir for symbolic clauses now come from the node's stat as well. GNU anchor: coreutils 9.4 src/chmod.c:231 — error (0, ent->fts_errno, 'cannot access %s'), i.e. fts's walk errno verbatim. Regression pin tests/issue3425_chmod_stat_classification.rs (6 tests, 12 probe shapes; base is expected 2/6, head 6/6 — legs not run on this lane, see REPORT; CI is the first check). UNVERIFIED-BY-CAPTAIN
Member
Author
Captain review — PASSReviewed at head Measured
Delimitations attached to this review
Merge conditionsUpdate-branch first (master moved to |
caomengxuan666
marked this pull request as ready for review
November 12, 2026 16:03
This was referenced Nov 12, 2026
caomengxuan666
added a commit
that referenced
this pull request
Nov 15, 2026
…3486) The node-stat anchor from #3440 classifies the operand correctly, but the apply arm then re-stats and chmods through the joined string path, which dies ENOENT on the dead cwd component even though the node stat just succeeded. Apply through the node instead (CpNode::set_mode_bits_checked: fchmodat against the anchor for an At node, set_permissions for a Plain node), the walk GNU's forked child gets (coreutils 9.4 chmod.c:231). Regression pins in tests/issue3448_chmod_apply_dead_cwd.rs cover the v3 probe cells: chmod 600 a / u+x a / 600 d/f land under a dead cwd, a/b still reports ENOTDIR, nope still ENOENT. Co-authored-by: 曹梦轩 <[email protected]>
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.
Refs #3425 — UNVERIFIED-BY-CAPTAIN
根因
模拟
chmod在 apply 臂里丢弃了操作数metadata的错误,对一切失败都印硬编码 ENOENT 文本:chmod 600 a/b(a为普通文件)报No such file or directory,而 GNU 报路径行走的 ENOTDIR。GNU 锚点
GNU coreutils 9.4
src/chmod.c:231:error (0, ent->fts_errno, _("cannot access %s"))——fts 行走的 errno 原样输出;行走死在第一个非目录分量上即 ENOTDIR。本地 oracle 实测(probe-3425.sh,12 形,~/workspace/fix-3425/probe-3425.gnu.txt):a/b、a/b/c、a/b d、f1 f2 a/b、+x a/b、a/皆Not a directory;missing、missing/sub、d/missing皆No such file or directory;a、d/f、d皆 rc 0 且 mode 落 600。修法
操作数 stat 走
CpNode机制(external_cp同款根:cp_operand_root——死 cwd 下为锚相对根,其余为 plain joined path),apply 臂失败用CpNode::stat_classified+posix_errors::message渲染;符号子句的 base mode 与is_dir同样取自 node stat。行走死在非目录分量上报 ENOTDIR,真正缺失的分量保持 ENOENT。锚面或竞态下 node stat 已成而内层 metadata 失败时,保留 raw verdict 不分类(旧行为)。同 #3416 的机制(
CpNode::stat_classified),推广到 chmod 的 plain host path;cp 的两道门未动。未碰src/lexer/continuation.rs,未改docs/api-ledger.md,未引入任何 trust/签名/加载期校验机制。测试
新钉
tests/issue3425_chmod_stat_classification.rs(6 tests,覆盖 12 个探针形;stderr 字节 + rc + 落盘 mode):chmod_through_file_reports_enotdir(a/b、a/b/c)chmod_through_file_multi_operand_reports_enotdir(a/b d、f1 f2 a/b)chmod_missing_operands_stay_enoent(missing、missing/sub、d/missing)chmod_plain_operands_still_land(a、d/f、d落 600)chmod_symbolic_mode_through_file_reports_enotdir(+x a/b)chmod_file_trailing_slash_reports_enotdir(a/)Fail-first 预期:base 2/6 过(仅两守恒 tests),head 6/6。本地腿未跑:本机无 cargo、本轮 box 构建槽已满(盘 1.8G 空、Mem 1.66G),按简报先推草稿 PR、以 CI 编译为首道验证;钉双边/lib/
-D warnings/卫生全腿待队长复核轮上 X299/box 跑。cargo fmt --check本地亦无法跑(无工具链),改动按文件既有格式手写;CI fmt 腿为准。本 PR 删除了什么
无删除。本 PR 只改一处 chmod 操作数 stat 路径并新增一支回归钉:无文件删除、无公开 API 删除、无行为删除;唯一行为变化是诊断错误类按 GNU 订正(经普通文件的操作数由 ENOENT 改为 ENOTDIR,缺失操作数保持 ENOENT)。