how can I get filename from file descriptor?

Paul Reger paulr at sequent.UUCP
Fri Aug 25 05:03:25 AEST 1989


In article <19208 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
>In article <20482 at sequent.UUCP> paulr at sequent.UUCP (Paul Reger) writes:
>>What I mean is this ...
>>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,

This being the case maybe to solve the real problem is to provide one
kernel-level mapping:

char *
Name(f)
FILE *f;  /* Or fd... */

Which would yield the name of any file (be it a pipe, stdin, stdout,
stderr, file, a psudo tty or any gawd-awful thingy that exists...
Each would have to be special cased except for the open files which
are actual disk files (posses actual file names...).

>or a file opened
>with fdopen.  (Also, but rather incidentally, I am not terribly thrilled 
>with the idea of fopen having to call getwd.)

Maybe have two sets of kernel open()'s one with 'name saving' one
without.... 

             paulr       (Paul Reger)
     Sequent Computer Systems  Beaverton, OR.
 ... {sun,ucbvax!rutgers!ogccse,uunet}!sequent!paulr



More information about the Comp.unix.wizards mailing list