how can I get filename from file descriptor?

Leslie Mikesell les at chinet.chi.il.us
Thu Aug 24 13:36:26 AEST 1989


In article <19208 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:

>>Have the FILE structure have a name field in it:
>>    char *name;
>>then when the fopen() call is made, have it fill in the field ....

>This is all well and good, but you will have to define what happens
>when you ask for the name of stdin, stdout, stderr, or a file opened
>with fdopen.  (Also, but rather incidentally, I am not terribly thrilled 
>with the idea of fopen having to call getwd.)

It would _almost_ be worthwhile to have open() store the pathname of
the thing being opened so that it could be retreived by some sort
of fcntl(), just like it would almost be worthwhile to store a
per-process cwd.  The problem would be that these pathnames are
subject to change if someone mv's or rm's any of the components and
it's probably not worth the effort to keep them updated.

Les Mikesell



More information about the Comp.unix.wizards mailing list