Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!borland.com!sjc From: sjc@borland.com (Steve Correll) Newsgroups: comp.lang.fortran Subject: Re: getting filename from UNIX file descriptor Message-ID: <1991Jul1.025651.16010@borland.com> Date: 1 Jul 91 02:56:51 GMT References: <51447@ut-emx.uucp> Distribution: usa Organization: Borland International Lines: 21 In article <51447@ut-emx.uucp> pefv700@perv.pe.utexas.edu writes: > >The FORTRAN statement > > INQUIRE(UNIT, name = STRING) > >sets STRING to the name of the file that the FORTRAN logical unit UNIT >refers to. > >How can this be implemented under UNIX with system calls? In the straightforward case, where a previous OPEN statement specified an explicit file name, the Fortran runtime system may remember the name and give it back to you when you execute the INQUIRE. In less straightforward cases (such as a preconnected file) the behavior varies with the implementation; the Fortran 77 standard is deliberately vague with respect to "files", and can even be implemented on a machine without a conventional file system. (As you observe, Unix system calls like "stat" do not let you map from file descriptor to file name--some file descriptors map to no name, and others map to more than one name, due to hard links.)