Unix – Why Does the Root Directory Have a Reference to Its Parent?

filesystemsunix

I'm currently developing a fake filesystem for a browsergame.
I recently implemented ".." and "." folders so every folder has a reference to its parent.
Then I checked in my terminal if "/" also has these folders.
Actually I was very surprised that it has a directory ".." which obviously is a reference to itself.

Is the reason for this consistency or is there a better explanation?

Edit:
I'm basically looking for the document where this is documented.

Best Answer

There is this POSIX definition :

3.144 Empty Directory

A directory that contains, at most, directory entries for dot and dot-dot, and has exactly one link to it (other than its own dot entry, if one exists), in dot-dot.

This definition is repeated with different phrasings in the POSIX descriptions of all file-commands.
For example for rmdir :

The definition of an empty directory is one that contains, at most, directory entries for dot and dot-dot.

This above convoluted definition for an Empty Directory is apparently behind this funny convention, and its purpose is to avoid any exceptions to the rule, not even for slash (/).