[CLUE-Tech] Finding all hard links to a file

David Anselmi anselmi at anselmi.us
Sat May 15 17:57:04 MDT 2004


Angelo Bertolli wrote:
> A question came up on another mailing list, but was never answered
> there,  and I was curious if anyone had an idea:
> how to (quickly) search for all files with the same inode number.  It
> would seem like a relatively simple thing:  just a program which when
> given a file name,  reads it's inode number, and then traverses the
> inode table looking for matches and spitting out their locations.
> However, without using find -inum,  I can't think of any quicker way.

I think that using find (i.e., traversing the directory tree) is the 
(only?) way to do this.  The "inode table" you want to look at *is* the 
directory tree.

There is an inode list.  Each inode is either free or it points to a 
file (well, to a file's block list).  There is nothing in the inode that 
tells you the file name.

File names are kept in directories (which, at least originally, were 
files).  The directory tells you the file name and the file's inode. 
They are the only way the two are connected and they are optimized for 
looking up inodes given a name (not the other way round).

Of course it's been a while since I read Bach so much has changed 
(including my memory).  Feel free to correct me or point out (Linux) 
filesystems that work differently.

Now another question: In "The Unix Programming Environment", K&P use od 
to display the contents of a directory file (showing the mapping between 
inodes and names).  On Linux, cat, od, dd, and vim seem to know when I 
give them a directory and refuse to show what's in it (at least the 
inode number).  Why?  Is there a way anymore to see the contents of a 
directory file?

Peace,
Dave



More information about the clue-tech mailing list