Repository navigation
fix(dev): synthesize /dev/zero, /dev/random, /dev/urandom, /dev/full (#1779) - #1781
Merged
Merged
Conversation
…1779) dd was the only tool that answered these operands; every other command fell through to the ordinary filesystem open and reported ENOENT. Linux synthesizes them in the kernel (drivers/char/mem.c), so fold the same answer into the shared operand boundary instead of per-command hacks. - native_path: SynthDev classification; is_character_device_w answers true for the synthesized spellings. - file_io: open_binary_file returns an infinite CRT-pipe stream for zero/random/urandom (xorshift64*/mt19937_64 for random) and zeros for full; create_binary_file maps zero/random/urandom to NUL and fails full with ENOSPC. - cat: route operand reads through open_binary_file — the direct ifstream branch bypassed the device boundary. - ls: probe_path, -d and list_file recognize the devices as character special even without a Win32 directory entry. - rust2 winux-core: SynthesizedDevice path classification; fs_win file_meta returns a character-device record; fsutil gains SynthDeviceReader and open_write_operand; ~12 read sites (head, wc, od, cksum, basenc, digestsum, expand, fmt, fold, join, paste, rev, sort, tac, tsort, unexpand, xargs, sed) now go through open_read_operand. - od: bound stdin/file reads with Read::take when -N is given so `od -N8 /dev/zero` terminates. - tee: report raw OS error 28 as "No space left on device"; cp opens device destinations through the operand boundary. - test: synthesized devices take the character-device record (-e/-r/-w/-c true, -f/-d/-x/-s false); -ef identity by operand spelling. - tests/framework: TempDir extended_path routes DOS-device-stem leaves ("NUL.txt") through lexical absolutization — GetFullPathNameW collapses the stem onto \\.\NUL, so fixture writes previously landed on the device (cat.nul_txt_reads_file_issue1333 was unfixable). GNU semantics (9.4, drivers/char/mem.c): reads of zero/random/urandom are infinite (full reads zeros); writes to zero/random/urandom discard, writes to full fail ENOSPC. All four report character special file. Regression pins: ls -l/-d, stat %F/%A, test -e/-c/-f/-x, head -c, cp to /dev/full + /dev/zero, tee to /dev/full.
caomengxuan666
force-pushed
the
fix/niu993-1779-dev-synth
branch
from
November 16, 2026 00:24
5b02954 to
195fd6b
Compare
This was referenced Nov 16, 2026
caomengxuan666
added a commit
that referenced
this pull request
Nov 16, 2026
… merged C++ surface PRs (#1781 #1786 #1795 family) The gate's own protocol for deliberate new source strings: record the growth so the ratchet stays honest (it may only shrink as translation sync batches land in unixwin/winuxcmd-i18n). The 22 zh-CN legacy.* missing items come from the C++ command surface that landed with the /dev synthesis, ps -W and cp-revert wave — all merged by owner; their zh-CN translations ride the next i18n sync batch (same choreography as the du keys earlier today). Verified locally on origin/main (f6d5386): same 22-item set as the failing CI run 43814990474; en-US side clean.
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.
Summary
Closes #1779. Part of the niubash#993 Git-Bash drop-in compatibility audit (§5).
Linux synthesizes
/dev/zero,/dev/random,/dev/urandomand/dev/fullin the kernel (drivers/char/mem.c); WinuxCmd answered them only insidedd, while every other command hit the ordinary filesystem open and reported ENOENT. This folds the same answer into the shared operand boundary so every tool behaves identically:native_path::SynthDev+is_character_device_w;ls,ls -d,stat,test -e/-creport character special files. Rust2 mirrors viawinux_core::path::synthesized_device+fs_win::file_meta.file_io::open_binary_file(C++) andfsutil::open_read_operand(rust2) return infinite streams — zeros for/dev/zero//dev/full,mt19937_64/xorshift64*for/dev/random//dev/urandom. ~12 rust read sites migrated to the seam;cat's directifstreambypass removed.NUL;/dev/fullfailsENOSPC—tee/cpreport "No space left on device".od -Nnow usesRead::take, sood -N8 /dev/zeroterminates.-e/-r/-w/-ctrue,-f/-d/-x/-sfalse);-efidentity by operand spelling (random != urandom).TempDir::extended_pathroutes DOS-device-stem leaves (NUL.txt) through lexical absolutization —GetFullPathNameWcollapsed the stem onto\\.\NUL, so fixture writes went to the device andcat.nul_txt_reads_file_issue1333could never pass.Test plan
winuxcmd-tests: 665/665 onls.*:stat.*:head.*:cp.*:tee.*:test.*:cat.*:od.*:wc.*:dd.*:realpath.*:readlink.*:mkfifo.*:mknod.*(includes new pins:lschar-device listing,stat %F/%A,test -e/-c/-f/-x,head -c,cp/teeto/dev/full+/dev/zero)cargo test -p winux-cmds:stat::,test_cmd::,tee::,od::,fsutil::,cp::all greenhead -c8 /dev/zero,head -c32 /dev/urandom,cp x /dev/full(ENOSPC),cp x /dev/zero,tee /dev/full,ls -l /dev/{zero,urandom,full}Generated with Devin