Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!rutgers!njin!princeton!phoenix.Princeton.EDU!pfalstad From: pfalstad@phoenix.Princeton.EDU (Paul John Falstad) Newsgroups: comp.lang.c Subject: Re: FILE *foo to filename? Keywords: inode, filename Message-ID: <3714@idunno.Princeton.EDU> Date: 31 Oct 90 04:06:40 GMT References: <272cd831-5edcomp.lang.c@vpnet.chi.il.us> Sender: news@idunno.Princeton.EDU Organization: Princeton University, Princeton, New Jersey Lines: 19 In article <272cd831-5edcomp.lang.c@vpnet.chi.il.us> akcs.dgy@vpnet.chi.il.us (Donald Yuniskis) writes: >Given: > FILE *foo; >whats a clean way of obtaining the filename assoctiated with foo? >An initial thought is stat(fileno(foo)..) to get inode number but then what? >Any help is appreciated... thx, dgy You don't want to do this. If the file's link count is more than one, you can't do it at all, and even if the file's link count is equal to one, you'd have to search the whole file system to get the right filename. Even assuming you know that FILE *foo is actually a file and not a pipe, socket, etc. (This is actually a comp.unix.* question.) -- Paul Falstad, pfalstad@phoenix.princeton.edu PLink:HYPNOS GEnie:P.FALSTAD I would bring back hanging, and go into rope. I would cut off the more disreputable parts of the body and use the space for playing fields.