in reply to Retriving Filename from Filehandle

No. Filehandles are not neccessarily attached to a physical file with a filename. But maybe it would help to know why you want the filename, and then maybe we can offer alternate suggestions.

Replies are listed 'Best First'.
Re: Re: Retriving Filename from Filehandle
by Snowman (Acolyte) on Dec 18, 2001 at 22:40 UTC

    The reason I ask is that a friend asked why if you can do

     stat <filehandle> 
    and have it return the files inode and other infromation, why not it's filename?

    Maybe this is an idea for a new module. but not one I would know how to write

    --
    The Snowman
    snowman@notreally.co.uk 

      Given a file name, it is nearly trivial to find the i-node and other information (that is part of the purpose of a file name, after all). Given an i-node number (and device number), finding the file name(s) requires searching the entire file system (once you've determined which file system from the device number). That is, the mapping is one-way.

      And an i-node can have no file name or can have hundreds of file names.

      Why? Because the mapping needs to be efficient in the one direction but the "need" to go the other direction doesn't justify the extra overhead and complexity so most file systems don't implement the other direction.

              - tye (but my friends call me "Tye")

        i-node? Because Unix is the only operating system in the world?