in reply to Re: Retriving Filename from Filehandle
in thread Retriving Filename from Filehandle

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 
  • Comment on Re: Re: Retriving Filename from Filehandle

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

    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?