Linking Files: Hard Link vs. Soft Link?

Smoot Carl-Mitchell smoot at tic.com
Wed Apr 15 18:40:55 UTC 2009


On Wed, 2009-04-15 at 12:35 -0300, Derek Broughton wrote:

> Fascinating discussion. I have practically never used hard links simply
> because symlinks work across filesystems, and KDE only does symlinks, so
> I'm really not that familiar with hard links, but I don't understand that
> particular point.  If, for instance, you have your music collection set up
> with hierarchies for artist and genre, then the "leaf" of both is probably
> an "album", which is probably a directory.  There's no intrinsic reason why
> a directory should be treated differently from a file afaict.

There is no technical reason a directory cannot be hardlinked.  However,
if this was allowed in general then the filesystem structure would no
longer be a tree, but could be any directed graph with loops. Programs
like tar or cpio which recursively walk the tree would be a lot more
complicated.  They would have to have algorithms which could do loop
detection to prevent infinite loops when walking the filesystem.  It was
a lot simpler to disallow multiple hardlinks to directories (with the
exception of the ".." and "." references)  Symlinks for the most part
have taken care of the imposition of the hardlink limitations.
-- 
Smoot Carl-Mitchell
Computer Systems and
Network Consultant
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005




More information about the ubuntu-users mailing list