Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!seismo!mimsy!chris From: chris@mimsy.UUCP Newsgroups: comp.unix.wizards Subject: Re: /dev/stdin for 4.3? Message-ID: <6881@mimsy.UUCP> Date: Tue, 2-Jun-87 03:11:52 EDT Article-I.D.: mimsy.6881 Posted: Tue Jun 2 03:11:52 1987 Date-Received: Thu, 4-Jun-87 01:32:01 EDT References: <7359@brl-adm.ARPA> <5856@brl-smoke.ARPA> <15318@onfcanim.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 35 >In article <5856@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >>...All you need is the open() entry, which should simply snarf >>up the process's corresponding file table index, just >>like a dup() except you don't allocate anything. In article <15318@onfcanim.UUCP> dave@onfcanim.UUCP writes: >I believe it's better to do the equivalent of a full dup(), returning >a newly-opened descriptor. You still need only an open() entry, >but you have to alloc an ofile table slot and increment the reference >count on the file struct. All that is done for you by `open'; you need only discard the inode. Specifically: fdopen(dev, flag) dev_t dev; int flag; { register struct file *fp, *wfp; int rwmode; fp = getf(u.u_r.r_val1); /* never fails */ if ((wfp = getf(minor(dev))) == NULL || fp == wfp) return (EBADF); rwmode = flag & (FREAD|FWRITE); if ((fp->f_flag & rwmode) != rwmode) return (EACCES); irele((struct inode *)fp->f_data); fp->f_count = 0; dupit(u.u_r.r_val1, wfp, u.u_pofile[minor(dev)]); return (0); } -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: seismo!mimsy!chris