[comp.sys.att] /dev/fd device driver to be posted

ford@kenobi.commodore.com (Mike Ditto) (07/03/89)

I have written a "/dev/fd" device driver for the Unix PC (actually
it should work on any SysV system aside from the install script).
I am posting it to unix-pc.sources (and comp.sys.att).  Here is an
description of /dev/fd, which will also be in the source posting.

The /dev/fd driver effectively allows you to specify an already-open
file descriptor number where a path name is normally required. This
allows a program that demands a path name to be used to process
standard input or standard output by specifying /dev/fd/0 or /dev/fd/1,
respectively.

/dev/stdin and /dev/sdtout are links to the respective entries in
/dev/fd/.

This is primarily useful when running a poorly-written program that
has no provision for using stdin/stdout.  For example:

	find . -cpio /dev/stdout | compress > /dev/rfp021

(The "-cpio" option of the "find" command demands a file name and
normally can not write to standard output.  This example gives it
the name "/dev/stdout" allowing it to be piped directly to compress
rather than writing to a temporary file.)

Note that some programs which demand a file name do so because
they must lseek(2) on the file, and thus will not work if told
to process stdin and stdin is a pipe.

					-=] Ford [=-

"The number of Unix installations	(In Real Life:  Mike Ditto)
has grown to 10, with more expected."	ford@kenobi.commodore.com
- The Unix Programmer's Manual,		...!ucsd!crash!kenobi!ford
  2nd Edition, June, 1972.		ditto@amix.commodore.com

john@hcr.UUCP (John R. MacMillan) (07/05/89)

In article <MFNA0001@kenobi.commodore.com> ford@kenobi.UUCP writes:
|This is primarily useful when running a poorly-written program that
|has no provision for using stdin/stdout.

It's also useful for supporting a feature in KSH88 (and the PD ksh I
use as soon as I get around to it :-)).  I don't have the book handy
but the syntax is something like:

paste (cut -f2 foo) (cut -f1,3 bar) > foobar

And this isn't one of those poorly-written ones, either; you couldn't
do the above with simple linear pipelines.

As an aside on a somewhat religious matter, I've always felt the
convention that "-" means standard input is somewhat gory;
/dev/stdin eliminates the need for this.
-- 
John R. MacMillan        No parking by the sewer sign a hot dog with a
HCR Corporation          razor broke there's water dripping up the spout
{utzoo,utcsri}!hcr!john  but I don't care let it all hang out -- The Nails