Repository navigation
fix(executor): classify emulated cp operand stat errors by the path walk - #3426
Conversation
The emulated cp gated both operand stats on the boolean CpNode::exists() and printed a hardcoded ENOENT text for every failure, so a source (or multi-source target) spelled through a regular file — whose walk dies ENOTDIR at the non-directory component, the verdict coreutils copy.c reports from the stat errno — came out as 'No such file or directory'. CpNode::stat_classified keeps the stat's own error and re-derives the verdict for a bare NotFound (the Windows face answers ERROR_PATH_NOT_FOUND for both shapes): the deepest existing proper ancestor decides, non-directory = ENOTDIR, directory = the absence is genuine. Both cp gates now render the classified error through posix_errors::message, the rendering rm/touch/cat already used. Regression: tests/issue3416_cp_stat_classification.rs (through-file source/target fail on base, all pass on head; missing operands stay ENOENT; family faces conserved).
|
Captain review — PASS (dossier: review-3426/CAPTAIN-VERIFY.md) What was verified, and how:
Two notes for the record:
#3425 delimitation confirmed independently: the chmod cell is wrong identically on base and head, and chmod's apply arm is a separate call chain that does not consume Environment note: the old server was banner-dead for most of this review window, so the captain's legs ran on the box against the lane's hash-verified trees (file hashes match the PR head byte-for-byte) instead of the planned server trees; the server-side driver bundle is staged at Ready to merge under the conditions in the dossier §9 (draft → ready, merge-body with the deletion section as drafted, closing-word scan clean: sole |
Fixes #3416
What
The emulated
cp's operand gates collapsed every stat failure into a hardcoded ENOENT text: the source gate tested the booleanCpNode::exists()and the multi-source target gate did the same. A path spelled through a regular file (cp -r a/b destwithaa plain file) dies its walk at the non-directory component, and GNU coreutils reports that walk's ENOTDIR — the name and exit status were already right, only the errno class in the message was wrong:cp: cannot stat 'a/b': Not a directorycp: cannot stat 'a/b': No such file or directoryMechanism
CpNodegainsstat_classified(): it keepsstat()'s own error and re-derives the walk verdict for a bareNotFound— the shape where the class is genuinely lost (the Windows face answersERROR_PATH_NOT_FOUNDfor both a missing component and a through-file walk; unix kernels report ENOTDIR natively, which std carries asErrorKind::NotADirectory). The re-derivation walks the node's proper ancestors deepest-first (plain paths viafs::metadata, anchor roots via cumulative-prefixfstatat): the first ancestor that stats as a non-directory is where the walk died (ENOTDIR, synthesized in the portableErrorKindform — nolibc::naming); an existing directory ancestor means the missing component is genuinely absent and the raw ENOENT stands.Both
cpoperand gates (sourcecannot statand multi-sourcetarget) now print the classified error throughposix_errors::message, the same rendering the family's other tools (rm/touch/cat) already used — which is why they measured SAME in the probe round and this one did not.Evidence
Three-way probe (GNU coreutils 9.4 / base
f6e8c674/ this head), 22 shapes over the whole emulated file-builtin family — the through-file shapes flip to GNU-identical, every conservation shape is byte-identical before and after:cpplain/-r/deep/target (ENOTDIR), plain-missing stays ENOENT,rm/rm -f/touch/catunchanged,mv/ln/install/statare not rubash-emulated (real binaries; SAME by construction). Regression pintests/issue3416_cp_stat_classification.rs(5 tests): the two through-file tests fail on base, all five pass on head; neighbour pin issue3276 stays 19/19; lib failure name-set empty.One measured sibling is deliberately NOT folded into this PR: the same probe round found the emulated
chmod's apply arm discards its metadata error the same way (chmod 600 a/bprints the ENOENT text on base and on this head). chmod does not consumeCpNode— it is a separate call chain with its own mode-store semantics — so it is filed as #3425 with the full probe evidence for its own lane, rather than widening this PR's surface.本 PR 删除了什么
Nothing — no code or tests removed; two hardcoded diagnostic strings are replaced by the classified rendering and the
exists()gates by stat gates at the same two sites.