Talk:Hardlink

I encountered mention of the directory hardlink problem at

 but didn't understand why the case there would be a problem.

Linus example is:

a and b are two hardlinks.

We have {a,b}/{dir1,dir2}.

We try to do

$ mv a/dir1 a/dir2

$ mv b/dir2 b/dir1

How do we handle that? It would move dir1 inside dir2 and dir2 inside dir1.

Yeah dir1 and dir2 would have hardlinks to each other and b would have a hardlink to dir1 and a would have a hardlink to dir2. Eventually, the recursive nesting would go too deep for the string path reference, but then the namespace can simply reject going deeper.

Link 1 above didn't summarize the issue clearly. 

What I missed was a and b are hardlinks to the same directory.

The problem I have is with "at the same time". The solution to me is that every file (including directories as files) should have a canonical enumeration. It's position on the disc and something similar to the disks ARC path should be enough to start with. When a process requests the file the system gets the enumeration compares it to open enumerations and if it isn't one of them, it adds it to the list. If it does find it, it looks at the locks on the enumeration to see if the process can go ahead. This results in the second operation resulting in a "file not found".