11

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;
    …
};
qdii
  • 926

1 Answers1

14

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.

Celada
  • 44,132