9

I have seen in this page that inodes have a link counter to know how many files (read: "directory entry") point to this inode. Is there a way to know which directories contain such entries without traversing the whole file system? Is this information stored somewhere?

struct inode {
    kdev_t                       i_dev;
    unsigned long                i_ino;
    umode_t                      i_mode;
    nlink_t                      i_nlink;
    uid_t                        i_uid;
    gid_t                        i_gid;
    …
};
  • The fastest method - with traversal only - might be find -inum <n> -samefile path. – ott-- May 12 '13 at 17:39
  • 2
    @ott-- find is used with either -inum or -samefile but not with both. – Hauke Laging May 12 '13 at 18:06
  • @HaukeLaging you're right, only one of them. – ott-- May 12 '13 at 18:10
10

No. Directory entries pointing to inodes are one-way links. The inodes do not point back to the directory entries.

In order to find a complete list of directory entries that point to an inode, you need to traverse the filesystem until you have found enough directory entries to account for the inode's link count.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.