3 ms·
So, which systems allow hard links to directories?
by bloak 5y ago
So, which systems allow hard links to directories?
- dfox 5y agoThere is a difference between “allows hardlinks to directories to exists” and “allows user to straighforwardly create them”. As for existence most unix filesystems have exactly zero issue with that, while on systems that allow you to link(2) to directory you have to be root to do that. Hardlinks to directories not only break bunch of userspace expectations, but more importantly create a structure that cannot be unlink(2)ed (unlink(2) does not work on directories and rmdir(2) works only for directories with st_nlink==2). So even on systems that allow creation of that it is restricted to root.
- eqvinox 5y ago~None. It breaks too many assumptions when you can have the file system tree loop around on itself.~ Edit: WTF, apparently it's a core Apple Time Capsule feature. Okay. Cool. Never touching that. Edit²: https://arstechnica.com/gadgets/2011/07/mac-os-x-10-7/12/ https://arstechnica.com/gadgets/2011/07/mac-os-x-10-7/12/ claims that hard links are actually hidden files(?) on HFS+: > One particularly scary example is the implementation of hard links on HFS+. To keep track of hard links, HFS+ creates a separate file for each hard link inside a hidden directory at the root level of the volume. Hidden directories are kind of creepy to begin with, but the real scare comes when you remember that Time Machine is implemented using hard links to avoid unnecessary data duplication.
- dfox 5y agoHFS+ is still only somewhat extended HFS and the filesystem itself does not support hardlinks to anything. The support for hardlinks is simulated in upper layers which while being questionable design on its own somewhat alleviates the usual problems with directory hardlinks.
- masklinn 5y agomacOS. IIRC ln(1) can't create directory hardlinks, but link(2) allows it (on HFS+, directory hardlinks were not ported over to APFS). Directory hardlink support was originally added for time machine.
- deleted 5y ago[deleted]
- LeoPanthera 5y agomacOS allows it as of 10.5, but it is not exposed to the user. The "Time Machine" backup tool built into macOS relies on it. AT&T UNIX System V allowed it for the root user only.
- masklinn 5y ago> macOS allows it as of 10.5, but it is not exposed to the user. Depends what you mean by "not exposed to the user": while ln(1) can't create directory hardlinks it works fine via link(2) (on HFS+), with the limitation that hardlinked directories can't be siblings. And of course directory hardlinks are fucking terrifying because `unlink(1)` will not work, and `rm(1)` will recursively remove directory contents, so you need to go through `unlink(2)` in C.
- themadsens 5y agoEvery (posix) directory has "." and ".." which are both hardlinks to a directory ..