Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!rpi!zaphod.mps.ohio-state.edu!samsung!aplcen!haven!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: Getting tty name without using ttyname(3) Keywords: ttyname Message-ID: <22602@mimsy.umd.edu> Date: 17 Feb 90 16:35:57 GMT References: <673@compel.UUCP> <1990Feb16.040357.2555@virtech.uucp> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 21 In article <1990Feb16.040357.2555@virtech.uucp> cpcahil@virtech.uucp (Conor P. Cahill) writes: >If you really need the performance gain, you could make a new directory say >/dev/only_ttys which contains links to all the tty devices in /dev. This ought not to be necessary. ttyname() should only stat the right file anyway, because it should be (as the 4.3BSD one is) written as ... fstat the file descriptor ... for (all entries in the device directory) if (this entry has the right inode number && stat works && device fields match) return (name); return (not found); Typically ttyname() makes 1 fstat() call, 1 open() call, 1 or 2 read() or getdirentries() calls, 1 stat() call, and 1 close() call. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris