Repository navigation
chmod: apply mode through the CpNode under a dead cwd (Refs #3448) - #3486
Merged
Merged
Conversation
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.
Member
Author
|
车道验证腿进展(2026-11-13 09:5x CST,X299-2607 Windows):
Linux 腿(新钉 fail-first + 修后 5/5、全量 lib 与 base 对齐)本轮未跑成,卡点:本地写墙 EDQUOT、box 盘 100% 满(他仓树不得删)、老服务器 ssh 未恢复、新服务器无 Rust 工具链。钉与 REPORT 已落盘,Linux 腿留复核轮。 |
Member
Author
|
CI 初核(2026-11-13 10:0x CST):本 PR 的 CI 红与 base 逐字相同,非本 PR 引入——
|
Member
Author
|
【WIN-AGENT-AUDIT】 PR #3486 第1轮 — 建议:PENDING(缺腿) 机制核查:
腿(逐项):
F 点:无。 续作记录:未动代码。 未跑/VOID 的腿:
|
Member
Author
|
【WIN-AGENT-REWORK】 PR #3486 第2轮 — 建议:PASS(缺腿补齐) 本轮补腿(WSL Linux /root/rubash-wsl,CARGO_INCREMENTAL=0,cargo test --locked -j 2):
未动代码;其余腿按第1轮审计记录全绿。判词翻 PASS,按协议 squash 合并。 |
caomengxuan666
marked this pull request as ready for review
November 15, 2026 04:42
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 #3448
根因
PR #3440(Refs #3425)让 node-stat anchor 正确分类 chmod 操作数 stat 错误,但 chmod apply 本体仍用字符串路径:
external_chmod的 unix apply 臂在node.stat_classified()成功后,又做std::fs::metadata(&host)+std::fs::set_permissions(&host, ...),其中host是 session-cwd 字符串 + 操作数的拼接路径。dead cwd 下该路径在 dead 分量上死 ENOENT,于是chmod 600 a报 ENOENT、mode 永不落地——分类对了,apply 到不了文件。修法
CpNode::set_mode_bits_checked(&self, mode: u32) -> io::Result<()>(#[cfg(unix)],src/executor/external_file_builtins.rs,紧贴 cp preserve 面已有的set_mode_bits):At 节点走fchmodat(dirfd, rel, mode, 0),Plain 节点走std::fs::set_permissions;失败返回原样 errno。set_mode_bits本身吞错误,chmod 的 apply 臂需要失败值来报诊断,故加 fallible 双生而非改其签名。external_chmodunix apply 臂:classified Ok后改调node.set_mode_bits_checked(new_mode);失败时failures += 1并以posix_errors::message打印原样 errno(与 [bug] Simulated chmod stat classification: intermediate non-directory reported as ENOENT instead of ENOTDIR #3425 的classified Err臂同一诊断形)。classified Err臂(ENOTDIR/ENOENT 分类)逐字未动;非 unix 臂逐字未动;apply_chmod_mode(只算新 mode)未动。tests/issue3448_chmod_apply_dead_cwd.rs(#![cfg(unix)],5 格):v3 rename 构造(cd t; (cd ..; mv t t_gone),session 留在被改名 inode 里)——chmod 600 a/u+x a/600 d/f在 dead cwd 下落地(mode 600/744/600),a/b仍报 ENOTDIR、nope仍报 ENOENT,mode 不变。GNU 锚点
coreutils 9.4
src/chmod.c:231(fts errno 原样上报);bash 侧 fork 的子进程继承目录 inode 作 cwd(execute_cmd.c execute_disk_command)。Oracle:v3 探针(probe-dead-cwd3.sh)以 GNU bash + coreutils 9.4 本轮重跑:m1chmod 600 a/brc 1 ENOTDIR、m2chmod 600 arc 0 mode 600、m3chmod 600 noperc 1 ENOENT,与钉期望逐字一致。Base(master 3745712)三落地格均红(rc 1 ENOENT、mode 不变)。本 PR 删除了什么
无产品面删除。删除的是 chmod unix apply 臂里“stat 成功后再以字符串路径二次 stat + set_permissions”的旧路径(约 15 行),由节点方法
set_mode_bits_checked的一次 fchmodat/set_permissions 替代;被删路径的“stat 刚成功又 ENOENT”竞态分支随之消失(失败现由 fchmodat 自身的 errno 直接报告)。验证状态
UNVERIFIED-BY-CAPTAIN — 队长复核前未验证。已过:rustfmt(两触文件)、utf8-boundary-hygiene、marker-lint、GNU oracle 对拍。待复核轮:Linux 腿(新钉 stem fail-first + 修后 5/5、全量 lib 与 base 对齐、
RUSTFLAGS="-D warnings"check)与 X299 Windows 腿(check + 新钉空编译)。本地写墙 EDQUOT 致工作树暂存 /tmp,见 REPORT。REPORT:工作区根(写墙恢复后落
~/workspace/fix-3448/REPORT.md,现暂存 lane 侧 /tmp/fix-3448-REPORT.md)。