Getting tty name without using ttyname(3)

Chris Torek chris at mimsy.umd.edu
Sun Feb 18 03:35:57 AEST 1990


In article <1990Feb16.040357.2555 at virtech.uucp> cpcahil at 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 at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list