1

I have read that hard links to directories are not allowed in Unix because they might cause loops in the file system. Assume I have a sub directory inside directory, how the link to the sub directory is represented if not by a hard link? Does it represented by soft link? it seems very unlikely to be the answer because how it will be possible to access a directory in that way as even the root wont be able to store them.

Thanks a lot to the helpers.

roy cabouly
  • 487
  • 4
  • 12

1 Answers1

2

Unix systems generally do not allow user specified hard links to directories.

Subdirectory entries, . and .. are indeed hard links, but they're managed by the system to ensure consistency.

that other guy
  • 116,971
  • 11
  • 170
  • 194
  • So when I create a directory via mkdir it makes an hard link to a new directory and that hardlink is managed by the system so it cant make loops in the file system?What means only hrad links created by the user are not allowed to reference to directories? – roy cabouly Jun 03 '19 at 17:25
  • Right. The kernel is free to create directory hard links and frequently does (`mkdir mydir` creates three: `mydir`, `mydir/.` and `mydir/..`), but the user is not allowed to create custom ones. Technically `mydir/./././.` and `mydir/../mydir/../mydir/..` are loops, but it's well established and all tools know about them. – that other guy Jun 03 '19 at 17:39