From fred@gymble.UUCP (Fred Blonder) Fri Jun 21 00:34:53 1985
Relay-Version: version B 2.10.2 9/18/84; site gatech.CSNET
Posting-Version: version B 2.10.1 6/24/83; site gymble.UUCP
Path: gatech!akgua!whuxlm!whuxl!houxm!ihnp4!mhuxn!mhuxr!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!umcp-cs!gymble!fred
From: fred@gymble.UUCP (Fred Blonder)
Newsgroups: net.sources
Subject: ``file descriptor'' pseudo-device driver for 4.2BSD
Message-ID: <173@gymble.UUCP>
Date: 21 Jun 85 04:34:53 GMT
Date-Received: 23 Jun 85 03:29:53 GMT
Distribution: net
Organization: U of Maryland, Laboratory for Parallel Computation, C.P., MD
Lines: 272

I'm re-posting this due to popular demand:

This is a pseudo-device driver which implements a
series of devices: /dev/fd0 - /dev/fd19 which are
surreptitiously equivalenced to whatever file (if
any) is associated with the corresponding file
descriptor in the process which is attempting to
open that file. In other words: opening the file
/dev/fd<n> is almost the same as doing the system
call: dup(n). It's different in that if the file
is a device, the driver's open routine is called.
If the corresponding file descriptor is a pipe
(socket) a dup() sys call is faked.

This can be used to force programs to read from
their standard input, or write to their standard
output, even if they haven't been designed to do
so.  For instance:

	ln -s /dev/fd0 xx.c
	cc xx.c
	{ Type a C program here. }
	^D
	a.out

Or, to see if a certain source file compiled into a
particular object file:

	cc source.c -o /dev/fd1 | cmp - objectfile

Be sure to make these mods in your conf directory.

In the config file:
	pseudo-device	fd

In the ``files'' file:
	sys/dev_fd.c		optional fd

<**************************************************************>
