tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: zero-length symlinks



On Nov 3,  2:57pm, Sverre Froyen wrote:
} On 2013-11-03, at 11:47, Hubert Feyrer <hubert%feyrer.de@localhost> wrote:
} > On Sat, 2 Nov 2013, David Holland wrote:
} >> > I think "not sensible" is not a good enough reason to prohibit
} >> > something.
} >> 
} >> Yeah yeah, but still nowadays we don't allow adding hard links to
} >> directories. So while that's a valid premise, it's not universal.
} > 
} > FWIW, the idea not allowing hard links to directories is that
} > ".." wouldn't be unique any more. I don't see such a thing with
} > a symlink pointing to ".
} 
} On Unix System V, the link command would allow hard-linking
} directories when used as root. A quick test shows that NetBSD
} does not allow this. Was the feature removed from NetBSD (or BSD)
} at some point or was it an addition to Bell Labs Unix after
} Berkeley received the Bell Labs sources? Perhaps a feature unique
} to the v7 file system.

     It has to do with the fact that historically mkdir(2) was
actually mkdir(3), it wasn't an atomic syscall and was a sequence
of operation performed by a library routine.  The library routine
called link(2) to hook the new directory into the directory tree.
Once mkdir(2) was created and the kernel became responsible for
everything link(2) lost the ability to create hard links to
directories.  The reason being that hard links to directories means
that the tree of directories is no longer a DAG and that causes
serious problems for the tree traversing code.

     I don't know at what point this happened in BSD, but certainly,
it was long before NetBSD came on the scene.  BTW, I doubt that
modern System V, i.e. SVR4 would allow you to make hard links to
directories (that capability probably went away somewhat before
SVR4 came about).

}-- End of excerpt from Sverre Froyen


Home | Main Index | Thread Index | Old Index