Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site asgb.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!ittvax!dcdwest!sdcsvax!bmcg!asgb!tony From: tony@asgb.UUCP (Tony Andrews) Newsgroups: net.sources Subject: /dev/stdin for SVR2 Message-ID: <723@asgb.UUCP> Date: Wed, 19-Jun-85 10:14:57 EDT Article-I.D.: asgb.723 Posted: Wed Jun 19 10:14:57 1985 Date-Received: Thu, 20-Jun-85 11:36:45 EDT Organization: Burroughs Corp. ASG, Boulder Colo. Lines: 55 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");