Repository navigation
WIP: fd registry service-face family (#1898 #1899 #1901 #1935 #1936 #1937 #1963 #1964 #1966 #1974) - #2015
Merged
Conversation
…974) GNU resolves /proc/$$/fd/N through procfs exactly like /proc/self/fd/N — the kernel serves the same descriptor directory under both names (redir.c opens the spelling literally; procfs decides). The registry classified the numeric-pid spelling as Filesystem, so only the cat-operand face served it, through a private pid rewrite in dev_operand_fd. fd_alias_target now judges the own-pid spelling in the registry (canonical pid field, pid == this process); foreign pids stay Filesystem. dev_operand_fd delegates to the registry alone — its private rewrite layer is gone. Its one behavior delta is GNU's: a leading-zero pid spelling (/proc/0<pid>/fd/3) names no procfs directory and no longer resolves. Regression: special_paths unit pin issue1974_* plus tests/issue1974_proc_pid_fd_alias_regressions.rs (operand, redirect, comsub and pipe-test faces for both spellings; foreign pid fails loudly on Windows).
…ts (rubash#1936, rubash#1901) GNU test.c:556/559 routes -w/-x through sh_eaccess (lib/sh/eaccess.c:194 sh_eaccess) — a mode question asked of the entry itself. The synthetic entries' modes are definitional procfs facts: top-level generated files 0444, per-pid content files 0644, directories 0555, links take their target's access (exe image r-x / owner-writable, cwd directory rwx). Measured against GNU bash 5.3.20 on real procfs. ProcUnaryFacts gains writable/executable in that same definitional style as link_target_is_dir; proc_unary_test answers -w/-x from them instead of falling through to a filesystem that has no such names on Windows (it answered false for every entry, including /proc/self/status and /proc/self/exe). #1901's deliverable is its regression seed: the A-phase convergence (rubash#1922) already put the test face on proc_unary_facts, so the pin asserts every synthetic name the content face serves answers -e/-r true — cat-readable and test-existing can no longer drift apart silently. Regression: tests/issue1936_proc_unary_wx_regressions.rs (full oracle matrix, test and [[ ]] forms), tests/issue1901_proc_test_consistency_regressions.rs (name-by-name -e/-r plus cat agreement). Windows-gated: off Windows the real procfs answers both faces.
…sh#1899) GNU: /dev/shm is the POSIX shared-memory tmpfs, an ordinary writable directory. The Windows path mapper had no arm for the spelling, so it fell into the /dev capability sentinel (\\\\.\\WINUXSH_UNSUPPORTED_DEVICE) and every open failed there — the namespace was unusable even though it is a directory, not a device. shell_path_to_windows gains a /dev/shm arm ahead of the /dev sentinel, following the /var/tmp mapping discipline (rubash#328): the backing directory <temp>/dev/shm (windows_shm_dir, same temp base as windows_var_tmp_dir) is materialized lazily on first resolution. shell_path_to_windows_for_lookup delegates to the same mapper, so test/cd/redirect faces agree. Regression: tests/issue1899_dev_shm_regressions.rs — directory face, redirect create, append, read-back, removal. Windows-gated.
…ubash#1966) GNU redir.c do_redirections binds the here-string/heredoc body to fd 0 whichever spelling wrote it; builtin_read reads that one descriptor (read.def:294). rubash's parser registers an unnumbered <<< in cmd.here_string but a numbered 0<<< / 0<< in heredoc_redirects with fd == Some(0). The resolver (stdin_string_for_command_mut) reads both stores, but the read funnel's here-string admission check consulted only the unnumbered field — read x 0<<< hello fell through to the process stdin and reported EOF with an empty value, while cat 0<<< hello (external face, resolver-driven) worked. Widen the funnel's admission predicate to 'an fd-0 body is registered in either store'; the resolver's fd-0-winner ordering (last redirect wins) is untouched, and no carrier byte handling changes — registration/visibility only. Regression: tests/issue1966_numbered_herestring_read_regressions.rs — basic/spaces/while-loop/numbered-heredoc forms plus unnumbered and 3<<< controls and the later-file-wins ordering.
…ubash#1935) Premise correction, measured on the GNU 5.3.20 oracle (real procfs): the filed seed claimed GNU succeeds on exec 3<>/proc/version — it does not. The anchor is the per-entry mode matrix: the 0444 class (version/stat/cpuinfo/meminfo/ loadavg/uptime) fails write-direction opens at open with EACCES; the 0644 class (per-pid status/cmdline) opens, reads serve, and only the write fails (EINVAL). rubash had no face at all: the ReadWrite probe/bind raw-opened the mapped literal path (ENOENT), and > on an entry created a phantom enclave file. - proc_vfs::proc_content_write_allowed + the registry query synthetic_proc_write_allowed carry the class (stub answers None off Windows; the real procfs serves the path there). - probe_input_redirect_readwrite classifies first: net connects, a closed fd alias fails ENOENT, synthetic content answers by write class, a synthetic link opens its resolved target; plain files keep the raw O_RDWR|O_CREAT open (redir.c:702 redir_open). - set_fd_readwrite_file binds the same classes: 0644 binds the snapshot as the read endpoint and an absorbed sink (synthetic_proc_write_sink) as the write endpoint; an fd alias dups the descriptor or fails ENOENT; a link opens its target through the pair split. - create_redirect_output asks the write class before the mapped create, so > /proc/... can no longer mint a phantom file. - The no-output mirror's fd-0 <> arm and numbered ReadWrite arm run the classified probe instead of raw opens. Residual (documented): writes to a 0644 entry are absorbed rather than failing with GNU's per-write EINVAL text — no Windows handle reproduces it; the open/read contract is exact. Regression: tests/issue1935_proc_readwrite_regressions.rs — 0444 EACCES on <>/>/compound faces with exactly one diagnostic, 0644 bind+read, absorbed output with no phantom file. Windows-gated.
…ry (rubash#1964) GNU redir.c r_appending_to performs ONE open of the word (redir.c:702 redir_open). rubash's append faces raw-opened the mapped literal path instead: probe_output_redirect_append, the no-output mirror's append and redirect_err_append arms, the numbered append arm, the external-command append arm, and the output routing's validation + flush opens. A /dev/tcp target was unreachable through all of them — the setup walk's append probe killed the redirect with a literal-path ENOENT before the real open (preempting even external commands), and synthetic /proc appends went to the enclave literal path. Executor::open_append_target is now the one append opener: net connects, null opens the device, an fd alias resolves through its endpoint (closed alias fails ENOENT), synthetic /proc answers by write class, a synthetic link opens its resolved target, and only plain filesystem spellings reach the session-anchored mapped append open. All seven faces call it; errors stay raw and callers keep their path_error shaping. The numbered mirror arm also gains the session_path anchoring its fd-1 sibling always had. The FIFO pairing open in write_to_fd operates on an already-resolved path, not a spelling, and is unchanged. Regression: tests/issue1964_append_registry_regressions.rs — loopback acceptance/delivery for the no-output, external and builtin-echo append faces, refused-port wording, the <> probe face, a plain-file control, and the synthetic write-class answers (Windows).
…bash#1937) GNU (measured on 5.3.20 / real procfs): the directory open succeeds on every face and the READ fails — read q < /proc/self/cwd reports 'read: 0: read error: Is a directory' (read.def:911), an exec-bound fd 3 binds fine and its read reports the fd-3 form. Windows cannot open a directory handle at all, so rubash's bind failed at open with the mapped path's unrelated shape. - FdReadEndpoint::Directory: reads record the EISDIR strerror in the fd table's read_error channel and serve no record — the read builtin's existing #1495 rendering produces GNU's exact line. - The exec-fd bind (trap_exec walker) and the compound bind (command_input_scope) install the directory endpoint when the registry facts say the synthetic link's target is a directory; set_fd_input_directory carries the bind bookkeeping. - The per-command read slurp records the same read_error for its fd-0 face instead of opening the mapped literal path. Off Windows proc_unary_facts is a stub: a real directory FileFd serves the descriptor and fails its reads natively, unchanged. Residual (documented): the external-child stdin face (cat < /proc/self/cwd) keeps an open-error shape on Windows — there is no directory handle to hand a child process. Regression: tests/issue1937_proc_self_cwd_read_regressions.rs — direct read, exec bind + read -u, compound bind, and a content control. Windows-gated.
…asses (rubash#1898) GNU (measured against the 5.3.20 oracle): reads of either device yield an unbounded zero stream; writes to /dev/zero discard and succeed; /dev/full opens fine and every write fails ENOSPC, which the writing builtin reports through sh_chkwrite (builtins/common.c:320-334) as '<name>: write error: No space left on device' with status 1; test's table for both devices equals /dev/null's (character device: -e -r -w -c true, -x -b -f -s -d false). rubash had neither class: both spellings fell to the /dev capability sentinel or the enclave literal path. - special_paths gains ZeroDevice/FullDevice classes (exact spellings after backslash normalization, the /dev/null pattern), so every face can ask the registry instead of re-deriving. - Reads bind a pump-fed pipe source (Executor::zero_device_file): a real handle children can inherit, reads never see EOF, the pump exits on EPIPE. The input ladder, the <> probe, the exec bind walk and the compound input scope all serve it. - Direct builtin writes route through OutputTarget::FullDevice (no validation open; the write faces produce the sh_chkwrite line with the device's strerror). exec-bound fds carry FdWriteEndpoint::FullDevice, seeded to the same target, so 'echo x >&7' fails identically; /dev/zero writes take the null sink on every face. - The redirect gate's literal-path probes skip both classes (the classified ladders own their outcome), and test answers the device table from the class. - External-child boundaries that cannot carry the failure profile (spawn slot resolution, stage plumbing, operand and materialization hand-offs) decline to the absorbed sink — a documented cross-boundary residual; every in-shell face is exact. Regression: tests/issue1898_dev_zero_full_regressions.rs — bounded zero reads on both devices, bound-fd reads (no EOF confusion), zero-write success, ENOSPC shapes for > / >> / printf and for an exec-bound fd, and the full test table. Platform-neutral pins (the classes answer identically on every host; on Unix the faces deliberately keep the same shapes).
…1937, rubash#1898) FdReadEndpoint::Directory (#1937) and FdWriteEndpoint::FullDevice (#1898) each left a tail of non-exhaustive matches across the executor (E0004 on every CI job): background/exec stdin resolution, coproc stderr planning, mapfile sources, the read timeout poll, fd operand materialization, the fd ledgers, write_diagnostic_fd2 and the child materialization snapshot. Each new arm carries the face's own semantics, recorded at the site: directory endpoints decline to the closest spawnable state or clear their respawn ledger; /dev/full endpoints absorb diagnostics and coproc stderr (their ENOSPC profile cannot cross a spawn boundary), record their ledger by device spelling so a respawned child re-derives the class, and snapshot to an empty read / absorbed sink on materialization.
…e (rubash#1963)
GNU (measured, probes/p1_fd63.sh): every file-open kind against
a closed /dev/fd/63 fails with exactly one line —
'{script}: line N: /dev/fd/63: No such file or directory', status
1, input kinds abort the command. redir.c services an alias PATH
spelling with redir_open over the /dev/fd layer; the
'N: Bad file descriptor' text belongs only to the dup kinds
(r_duplicating_input/output, spellings &N / &N-).
rubash's no-output mirror resolved BOTH shapes through
redirect_target_fd_and_move, whose dev_stdio fallback makes an
alias spelling indistinguishable from a dup spelling at the call
site, so alias targets under file-open kinds were serviced by
validate_builtin_dup_source and failed EBADF-shaped; and
create_redirect_output had no alias arm at all, so an alias
target that reached it was created as a phantom file at the
mapped enclave literal path.
- execution_misc::dup_spelling_source_fd: the dup claim now
requires the &-spelling shape; the mirror's four file-open
arms (structured in/out, numbered out/in) use it, and alias
spellings fall through to the classified opens.
- create_redirect_output gains the registry arm: a closed alias
fails ENOENT pre-shaped like the synthetic arm; an open alias
resolves through its endpoint like the append face, with the
null sink for endpoint shapes that cannot take a handle dup.
Regression: tests/issue1963_dev_fd_redirect_family_regressions.rs
— the p1 matrix asserted as an invariant (status 1, exactly one
stderr line ending in the ENOENT text, command aborted), the
read face, /proc/self/fd spelling parity, and the open-fd
controls. Local execution of this target is queued behind the
shared build slot; the library compiles under -D warnings and
CI covers the lib/regression surfaces.
… table with #1898 Master advanced eight PRs while this family was in flight. The one semantic intersection is PR #2011 (S5 registry faces, niubash#627): it added special_dev_entries() — the listable /dev table — with zero/full deliberately absent and a consistency pin stating that a future /dev/zero simulation (audit D5) must update the table in the same change. #1898 is that simulation: the table now lists zero/full as leaf entries and the doc comment records the move. Everything else auto-merged cleanly (notably #2022's #1965 guard-strip alongside #1966, and #2010's -D warnings hygiene). Verified on the merged tree: cargo check --all-targets -D warnings is clean for the library and every target this family touches; the single remaining error (dead 'status' field in tests/issue1941_1948_sim_layer_option_regressions.rs) is byte-identical to master 1f007cc — master's own debt, not this branch's.
Local verification of the merged tree caught the pump-fed zero source killing the shell with SIGPIPE (exit 141) when a bounded reader closed early: the detached pump thread's write to the broken pipe raises the signal in the shell process. Unix hosts have the real devices, so zero_device_file(target) now opens the target itself there — GNU's semantics exactly, an unbounded kernel-owned zero source — and the pump remains only on Windows, which has no zero device and no SIGPIPE. Call sites pass the classified target (/dev/zero or /dev/full). Also normalizes the od byte-list pin: od -An -tu1 pads fields to display width, so the comparison is whitespace-normalized (the bytes were always correct).
… (rubash#1963)
Local execution of the pin suite on the merged tree showed the
mirror-only fix was insufficient on three faces: (a) ': > /dev/fd/63'
and mapfile printed the ENOENT line TWICE (mirror error + routing
walk diagnostic), (b) 'echo hi < /dev/fd/63' and '<>' printed
NOTHING and ran (a builtin that never reads stdin never opened
its input redirect), (c) ': >>' and ': 2>' to a closed alias were
silently accepted, as was 'exec 3> /dev/fd/63'.
The gate (reject_invalid_redirects) now rejects any file-open
kind (>, >|, &>, >>, &>>, <, <>) whose target is an fd alias
naming a closed fd, with the single '{target}: No such file or
directory' line through reject_redirect_at — GNU redir.c:149-176
redirection_error, delivered once, before any serving face runs.
The judgment is dup_source_fd_open against the ordered effects
recorded so far in the same redirect list, so same-list opens
('3>/dev/null > /dev/fd/3') still resolve. Open aliases pass the
gate untouched; the mirror's classified opens remain the second
line for ungated contexts ([[ ]] validation measured one line).
Also: open_fd_read_endpoint's no-read-endpoint arm now honors
GNU's fresh-open-of-target semantics for write-only descriptors
('exec 63>f; : < /dev/fd/63' measured rc=0 on the oracle for file,
/dev/null, and stdout-dup bindings alike): a File write endpoint
reopens its stored path, any other open descriptor reads against
the null device, and only an endpoint-less descriptor keeps the
EBADF answer. New pin: the exec-bind shape.
… registry (rubash#1964) Local execution of the pin suite showed 'cat >> /dev/tcp/...' still failed with a bare 'No such file or directory': strace showed a successful connect (the classified faces) followed by a raw openat() of the literal target. Three raw mapped-append fall-throughs in the external stdio layer (stdout arm, stderr arm, and the shared-target >>f 2>>f pair arm in external_redirects.rs) and both append faces of the in-process cat fast path (write_cat_output, open_cat_output_sink in external_finish.rs) opened the session-mapped path directly, which for a net target is not a file. All five now go through open_append_target, so the open classifies (net connects, synthetic classes answer by their write class, plain files keep the session-anchored O_APPEND open). The Seek/SeekFrom imports the removed seek-to-end shims used are dropped from mod.rs.
caomengxuan666
marked this pull request as ready for review
October 29, 2026 02:55
This was referenced Oct 29, 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.
WIP: fd registry / service-face family — one mechanism across ten issues: the
special_pathsregistry's classification must be the single judgment every face asks (test verdicts, redirect service, probe ladders).All ten issues landed (per-issue commits):
/proc/<own-pid>/fd/Nas an fd alias; dev_operand_fd's private pid rewrite removed.test -w/-xanswer for synthetic /proc entries from definitionalProcUnaryFacts(0444/0644/0555/link-target classes)./dev/shmmaps to a lazily materialized per-user temp directory instead of the/devcapability sentinel.0<<</0<<bodies are visible to builtin stdin (read funnel admission widened to both registration stores; carrier bytes untouched).exec 3<>/proc/version; the 5.3.20 oracle says EACCES (0444 class) — the fix anchors on the measured mode matrix (0644 opens, reads serve, writes absorbed; per-write EINVAL text is a documented residual).Executor::open_append_target(seven faces converted).< /proc/self/cwd(and other synthetic directory links) now bind a directory endpoint whose reads fail EISDIR in GNU's exactread: N: read error: Is a directoryshape, instead of an open failure on the mapped path. External-child stdin face documented as residual (no directory handle exists on Windows to hand a child)./dev/zeroand/dev/fulljoin the registry as device classes: pump-fed zero source for reads,OutputTarget::FullDevice+FdWriteEndpoint::FullDevicefor the ENOSPC write profile (sh_chkwrite shape on direct and exec-bound faces), device test table, gate probes skip the classes. Cross-boundary child hand-offs decline to an absorbed sink (documented residual)./dev/fd/N,/proc/self/fd/N) under file-open kinds now take the open face (one ENOENT line, command aborted) instead of the dup face'sBad file descriptor;create_redirect_outputgained the registry alias arm (no more phantom enclave file). True dup spellings (&N) keep the EBADF face.Master reconciliation (e54f007): master advanced to 1f007cc in flight; PR #2011's new
special_dev_entries()consistency pin anticipated this family — the /dev table now lists zero/full in the same change, as the pin requires. CI on the merged tree: lib + regression goldens + cross-target + shell functionality all green; the only red is the transitional api-ledger cmp in the niubash pair job (dies with niubash#668, not this branch).Gates: CI (above) covers lib/regression/goldens;
-D warningsverified locally for the lib and all of this family's targets (the one remaining all-targets error is master's own dead-field debt in tests/issue1941_1948_, byte-identical to 1f007cc). The per-issue pins live in tests/.rs targets CI does not run; their local execution is queued behind the shared build slot and is accounted in the cluster REPORT.md.