How to find if a folder is being pointed as a symlink by another folder? Eg. say A --> B, C --> D and No one is pointing to another folder say "E".
How do I know its folder E where no one is pointing.
NOTE: All folders are in AWS EFS and all links are soft links.
There is no way to tell this. Soft links (symlinks) are not reference counted and to try to figure out whether or not E
is being referenced is not possible with certainty.
If you are maintaining a formal process to create all the symlinks and are not worried about any symlinks that are created outside of your formal process, then you could possibly maintain a refcount in some meta data associated with targets. In your example they would B
and D
(and E
) only remove the ones that have a reference count of 0.
Now you'd run into the issue of A
--> B
--> C
and then if B
gets unlinked you'd have to dec the refcount. There are many other issues with trying to do this at a symlink level.