I want a very simple example of how can a hard link break the file system structure.I saw somewhere that people say it's because of loops, however, I can make a loop with a soft link and so I still want to know what makes hard link break the file system?
Can a hard link break the file system structure?
filesystems;symlink;hard link
It's hard links to directories that can break the filesystem structure. Hard links to other types of files aren't a problem. For example:mkdir fooln foo foo/selfrmdir foormdir foo doesn't actually remove the directory since it has a remaining link the self entry inside foo itself. foo has become detached from the filesystem; it can't be reached anymore, but it still exists. Forbidding hard links to directories prevents this problem. There are garbage-collected filesystems where a detached directory tree is automatically reclaimed, but they've never really taken (it's a significant effort for hardly any benefit).Another problem is with tools that traverse a directory tree. If hard links to directories are allowed, then these tools would have to remember all previously-seen directories and skip them, or else they would loop forever when encountering a directory which is a subdirectory of itself (or of a child of itself, etc.).Loops with symbolic links aren't a problem. If the target of the symbolic link is removed, the existence of the symlink doesn't matter. In recursive traversals, symlinks aren't followed (unless explicitly requested).