Repository navigation
fix(fd): report EISDIR for reads of directory redirects on Windows (Refs #3777) - #3780
Merged
Merged
Conversation
…efs #3777) Root cause (three layers, all Windows-only): - probe_input_redirect_gate validated '< word' with a plain File::open, so a directory target died in reject_invalid_redirects with EACCES before the builtin ever ran; the gate now uses open_redirect_input_file, the same FILE_FLAG_BACKUP_SEMANTICS retry opener the bind ladder uses. - fd::read_some mapped ReadFile's ERROR_INVALID_FUNCTION (1) on a directory handle to 'Invalid argument'; it now reports EISDIR, the errno GNU read(2) returns (builtins/read.def:911). - read_file_bytes_buffered swallowed chunk read errors; it now records the first hard read error on an otherwise empty record (#1495 discipline), so the read builtin renders 'read: 0: read error: Is a directory' instead of silent EOF. GNU anchor: builtins/read.def:911 (read error report); redir.c:237/:298 (redirect open). Verified on X299: probe 'read x < $PWD/d' now prints 'read: 0: read error: Is a directory', rc=1; /dev/null control silent rc=1.
compound_stdin_open_failure probed a plain '< word' target with a bare
File::open, so '{ cat; } < dir' and 'while read ... done < dir' died
with EACCES before the body ever ran — the same defect as the reject
gate fixed in the parent commit, in the compound's own validation
layer. The probe now routes through probe_input_redirect_gate (the
FILE_FLAG_BACKUP_SEMANTICS retry opener the bind uses); the gate owns
the FIFO carve-out (rubash#1820), so the separate FIFO arm is folded
in. GNU anchor: redir.c:767-955 (compound fd-0 open).
Member
Author
|
[WIN-AGENT-AUDIT] PR #3780 第1轮 — 建议:PASS(作者标注 UNVERIFIED-BY-CAPTAIN,缺新钉但有存量钉覆盖+直探已验) 机制核查:
腿:
F 点:无阻断。提示项(不判 FAIL):(a) PR 未新增钉,靠存量 issue1495/2101 覆盖——issue2101 仍有 compound 重定向与外部命令 4 格残差(作者已披露,issue #3777 可部分关);(b) issue2101 钉自身 Windows 可移植性缺陷(cat//proc)建议另行跟进。 续作记录:无。 未跑/VOID 的腿:base fail-first 数字、lib 双边、GNU Linux oracle 复跑(如上)。 |
caomengxuan666
marked this pull request as ready for review
November 16, 2026 16:40
This was referenced Nov 16, 2026
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.
根因
Windows 上
read x < 目录在三个层面各错一步,合起来使目录重定向永远到不了 GNU 的 EISDIR 诊断(builtins/read.def:911):src/executor/shell_options.rs,probe_input_redirect_gate):< word的合法性探针用裸File::open校验;目录在 Windows 上裸 open 即 EACCES,于是命令在reject_invalid_redirects就被以Permission denied驳回,根本到不了带FILE_FLAG_BACKUP_SEMANTICS重试的绑定梯子(open_redirect_input_file/open_file_read)。门现在改用同一重试 opener 校验。src/fd/windows_impl.rs,read_some):目录句柄上的ReadFile返回ERROR_INVALID_FUNCTION(1),GNU 的read(2)在此返回 EISDIR。fd 层现在把目录句柄上的读失败翻译为 EISDIR(ErrorKind::IsADirectory),所有目录描述符的读者(read、mapfile、emulated cat drain)看到的都是 GNU 的失败。src/executor/fd_table.rs,read_file_bytes_buffered):chunk 读错被静默吞掉(Err(_) => break),目录绑到 fd 上读出来是静默 EOF。现在按 [bug]readfrom a directory fails silently (GNU: "read: 0: read error: Is a directory") #1495 纪律记录首个硬读错(空记录时),read 内置据此渲染read: 0: read error: Is a directory。GNU 锚点
builtins/read.def:911:read 内置的读错报告(read: <fd>: read error: <strerror>)。redir.c:237/:298:重定向打开(do_redirections/redirection_expand)。验证(X299,UNVERIFIED-BY-CAPTAIN)
issue1495_read_directory_regressions:1/1 绿;read x < \$PWD/d得read: 0: read error: Is a directory,rc=1;/dev/null对照静默 rc=1。issue3770_read_writeonly_fd0:8/8 绿;issue3655_heredoc_vs_file_redirect:10/10 绿。RUSTFLAGS="-D warnings" cargo check --locked --lib --bins:rc=0。issue2101_directory_stdin_regressions:修前 0/6 → 修后 2/6(其余 4 格为 compound 重定向与外部 cat 自身的目录读面,另见 REPORT)。本 PR 删除了什么
无。未删除任何功能或文件;仅将目录重定向在 reject 门与读路径上的错误形态由 EACCES / 静默 EOF 改为 GNU 的 EISDIR 诊断。
UNVERIFIED-BY-CAPTAIN
队长尚未复核;Linux 腿与剩余 #2101 四格的归宿见
~/workspace/fix-3777/REPORT.md。