How to get all the hard links that link to the same file quickly?

Peng Yu pengyu.ut at gmail.com
Sat Apr 23 12:40:00 UTC 2011


Hi,

I'm looking for a fast way to get all the hard links that point to the
same file.

file="/blah/blah"
find $(stat -c %m "$file") -inum $(stat -c %i "$file")

Currently, I have a slow way. It traverses the mount point that the
file is on and look for all the files that have the same inum. But
traversing the whole file system is a slow operation. Does the linux
OS keep a table somewhere all the paths pointing to any file or the
linux OS only keep the number of the paths that point to a given inum
but does not keep the actual paths?

-- 
Regards,
Peng




More information about the ubuntu-users mailing list