Why can't directories be hard-linked on Unix filesystems (e.g. HFS)?
On both my MacBook (OS 10.5.8) and Linux (RHEL4) I've tried to do some directory organiztion using hard links (ln, not ln -s). When I try to hard-link a directory, I get an error message:
{yakut05:81} mkdir tempo
{yakut05:83} ln tempo tempo-link
ln: `tempo': hard link not allowed for directory
{yakut05:84}
The man page for ln doesn't specify this limitation. I wonder if any filesystem gurus out there could explain why it's not allowed? I'm sure it has to do with the inode structure, but I'd like to be clear on the details.
13
answers
|
Answer it!
|
http://developer.apple.com/mac/library/technotes/tn/tn1150.html#HardLinks
That aside, thank you much, Sean. It sounds (paraphrasing) like hard links are dealt with almost as though they were low-level symbolic links, and that system treats directory objects differently than file objects.
Now at least I know what's going on!
developer.apple.com/mac/library/technotes/tn/tn1150.html#HardLinks
L
L
I know. I was too tired to go back and copy past edit the note... The particular plugin they use (or it appears to be the same one) is quite popular, but very clumsy and slow imo.The first time I encountered that editor plugin, I was excited by the possibilities, but equally dissapointed once I used it.. Sorry for the glitch...figured you'd understand. I don't usually do that, btw, just too lazy when I posted.
Total paraphrasing. I'm usually disinclined to commenting by copy-out (clone the results of a net search), but the occasional one doesn't violate values... I have zero experience with macs...well, aside from machine level programming on the first ones (Apple IIE I believe) during engineering course work nearly 30 years ago...but, the question was legit, had merit (imo), was interesting, and seemed like it ought to have an obvious reason, coupled with my foreknowledge that you would already have performed some search...two eyes often better than one in those cases...I rad enough to confirm the logic and figured you'd missed it along the way.I blather. must get some sleep.
With a hard link, there is literally no difference between one link name and the other - they are both pointers to inodes - so the search algorithm would have no way of knowing which was the 'real' name and which was the link.
find handles it, for example), but that wouldn't be the case with hard links.I'm glad this was useful - I found the comment from last year after looking your page, and I wasn't sure whether you would have forgotten about it or found the answer anyway.
L
![]() |

































