how to find a loop in the file system in Linux? i am indexing all files for making search fast(O(1))… i am using c programming language to implement by using the library functions in dir.h…. I can scan through entire file system but it goes in a loop if there is loop in the filesystem(example loop mount)… how to find the loop in file system.. i have seen updatedb command reporting when there is loop in file system… i don’t understand the logic… can anyone pls help find solution for this?
Share
I found this interesting comment here about finding loops in a DAG:
So, roughly speaking, while you are traversing the directory tree, create a DAG which represents the structure of the tree with the data at the node refering to the inode of the file. Then, you just check to make sure you don’t visit a node more than once.