This is the mail archive of the
libc-hacker@sourceware.cygnus.com
mailing list for the glibc project.
Re: ttyname() and linux+devfs
- To: Clifford Wolf <clifford@clifford.at>
- Subject: Re: ttyname() and linux+devfs
- From: Zack Weinberg <zack@rabi.columbia.edu>
- Date: Thu, 29 Oct 1998 18:39:48 -0500
- cc: libc-alpha@cygnus.com
On Thu, 29 Oct 1998 22:54:04 +0100 (MET), Clifford Wolf wrote:
>
>On Thu, 29 Oct 1998, Martin von Loewis wrote:
>
>> > /dev/vc/*, my cua devices are /dev/cua/* and so on. It would be great if
>> > the ttyname function could make a recursive scan thru the compleate /dev
>> > directory structure instead of lokking only in /dev/ and /dev/pts/.
>>
>> Why not use /proc/self/fd/0 instead?
>
>That's a good question. Why don't making just a readlink() on
>/proc/self/fd/%d (where %d is the fd number)? Would be much faster
>than scanning /dev and works with all /dev structures ...
>
>It would solve the symlink/real-device problem too: afaik the symlinks
>in /proc/self/fd/ point to the filenames which are passed to open() - and
>this are the filenames we would like to know.
It's not a bad idea, but there are several problems. /proc isn't
guaranteed to be there. In 2.0, the /proc/self/fd files are not
normal symlinks. It can be misled if you do something like
ttyname(open("/dev/tty")) /* get real name of controlling terminal? */
although I'm not sure that works now.
This is one of those Hard Problems.
zw