Why are hard links not created in directories?
Hi All,
Iam Anisha S. I would like to know why hard links are not created for directories? Thanks, Anisha. |
actually they exist, for example the . and .. are both hardlinks. But in general it is not allowed because that may cause strange "side" effects (just imagine - for example - a simple find or ls -r or grep -r may never end).
|
Hello Pan64,
Thanks for the reply. Can you please explain me little more clearer. As per my understanding, Soft links are like shortcuts with different inode number to that of the original file. But whereas ,in a hardlink the inode numbers are same to the original file and deleting the original file doesnt affect it.Its just they cannot be shared across filesytem. In that case why can t we create a hardlink for directory ?? It will replicate the original directory correct ? Thanks, Anisha. |
|
you can't hard link an inode which represent a directory to avoid infinite loop in the directories tree
Code:
cd a this behaviour happens with symlinks, and every (decent) program ignores to follow symlinks in deep searches |
The problem occurs when the filesystem gets repaired.
The directory hierarchy is designed to represent a tree. A directory contains hard links to directories contained within that directory. Each directory has a hard link to its parent. When you allow for a hard link from elsewhere, you create errors in that tree - it is no longer a tree but a network. Analysing a network is much harder than a simple tree - and can take forever (depending on how the network may loop back on itself) and could make recovery impossible. |
Hi jpollard/gengisdave,
Thanks for the info ..It was clear .. |
All times are GMT -5. The time now is 04:16 PM. |