/dev/stdin for SVR2
Tony Andrews
tony at asgb.UUCP
Thu Jun 20 00:14:57 AEST 1985
The following is an implementation of /dev/stdin as described by
Rob Pike last week at Usenix. For those of you who weren't there,
/dev/stdin, when opened, dups file descriptor 0. This eliminates
the need for programs to treat the file name "-" as a special
case meaning the standard input.
To install this code, change the third field of the line for "memory"
in /etc/master from 6 to 26. Apply the following diff to io/mem.c.
This is from the ns32000 port so your file may vary somewhat.
Tony Andrews
Burroughs Corp.
Boulder, CO
...ihnp4!noao!hao!asgb!tony
16a17
> * minor device 3 is stdin (dups fildes 0 when opened) --tony
27a29
> #include "sys/file.h"
32a35,60
> /*
> * mmopen is used only by /dev/stdin --tony
> */
> mmopen(dev)
> dev_t dev;
> {
> register struct file *fp;
> register int fd;
>
> if ((minor(dev) != 3) || (u.u_error != 0))
> return;
>
> if ((fp = getf(fd = u.u_rval1)) == NULL)
> return;
> u.u_ofile[fd] = NULL;
> closef(fp); /* close /dev/stdin */
>
> if ((fp = getf(0)) == NULL) /* dup filedes 0 */
> return;
> if ((fd = ufalloc(1)) < 0)
> return;
> u.u_ofile[fd] = fp;
> fp->f_count++;
> return;
> }
>
37a66,68
> if (minor(dev) == 3)
> panic("mmread on /dev/stdin");
>
64a96,98
>
> if (minor(dev) == 3)
> panic("mmwrite on /dev/stdin");
More information about the Comp.sources.unix
mailing list