Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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;
    …
};
share|improve this question
    
The fastest method - with traversal only - might be find -inum <n> -samefile path. –  ott-- May 12 '13 at 17:39
1  
@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
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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