/dev/null

Daniel R. Levy levy at ttrdc.UUCP
Wed Nov 20 15:25:37 AEST 1985


I have a question about a very commonly used "device," namely /dev/null.
Can someone explain what happens to data written into it?  Seriously,
now.  At least on the 3B20 and the 3B2 (the only Unix machines I have
handy at this moment to check) /dev/null is implemented as a device
with the same major number as /dev/mem and /dev/kmem, viz:

$ ls -l /dev/null /dev/mem /dev/kmem
crw-r-----   1 root     sys        2,  1 Mar 31  1981 /dev/kmem
crw-r-----   1 root     sys        2,  0 Mar 31  1981 /dev/mem
crw-rw-rw-   1 root     root       2,  2 Nov 19 22:00 /dev/null

This trivia became VERY interesting to me after once blowing away
/dev/null in a careless attempt as root to link it to a file system other
than / on the 3B2/300 in my department (specifically, I tried to link it to
/usr/lib/spell/spellhist).  I was racking my brain as to what I should
mknod, not having another 3B2 handy to refer to (this was on a weekend,
too) and I finally went by analogy to the 3B20 and succeeded (later verifying
it against another department's 3B2).  But I digress...

Seeing that /dev/mem and /dev/kmem are "windows" into the physical memory space
of the computer, I wonder if /dev/null is implemented as a "window" into a
nonexistent section of physical memory, or what?  Does data written into
/dev/null appear on the processor bus during the write (and not just for
the data fetch, but afterward, as if it were being written to a real periph-
eral device)?  (This is letting alone the question of how reads
from /dev/null return an immediate end of file.)  Some kernel wizard surely
can answer this off the top of his or her head, and surely the answer must
be more complicated than what I am surmising, since the kernel buffers
i/o from/to terminals rather than feeding the raw data directly, according
to the few things I have seen and read about "clists" and terminal buffers
with respect to the user-tunable parameter table for the 3B2 kernel.

Thanks in advance....  will NOT be redirected to /dev/null :-).



More information about the Comp.unix.wizards mailing list