Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!unmvax!ogccse!blake!uw-beaver!tektronix!sequent!paulr From: paulr@sequent.UUCP (Paul Reger) Newsgroups: comp.unix.wizards Subject: Re: how can I get filename from file descriptor? Keywords: Name of file given the FILE * or fd. Message-ID: <20644@sequent.UUCP> Date: 24 Aug 89 19:03:25 GMT References: <20613@adm.BRL.MIL> <1019@virtech.UUCP> <20482@sequent.UUCP> <19208@mimsy.UUCP> Reply-To: paulr@crg3.UUCP (Paul Reger) Organization: Sequent Computer Systems, Inc Lines: 32 In article <19208@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >In article <20482@sequent.UUCP> paulr@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