Hard links to directories: why not?

Martin Weitzel martin at mwtech.UUCP
Thu Jul 19 23:51:27 AEST 1990


In article <13432 at ulysses.att.com> smb at ulysses.att.com (Steven Bellovin) writes:
[question about security issues when hard-linking to directories]
>In article <5222 at milton.u.washington.edu>, wiml at milton.u.washington.edu (William Lewis) writes:
[qoute from a Ritchie and Thompson paper]

>	[...]  The reason for this is to
>	simplify the writing of programs that visit subtrees of the
>	directory structure, and more important, to avoid the
>	separation of portions of the hierarchy. [...]

Exactly!

For those of us who have no symlinks, hard-linking to a directory
(if possible) can sometimes avoid lot's of headaches. If you don't
create circular links, the only "surprise" may be that  ".." sometimes
is not what you normally expect. Minor problems may occur with find and
some backup programs, which may duplicate parts of the disk on the backup
media and hence use more space than expected or available.

BTW: A few years back I wrote a "directory compression program" which
only linked around the files to get rid of empty slots in directories,
that were large some day but shrunk in size later. (This *can* be
done with standard commands, but not in the most efficient way.)
If the directory which was to compress contained sub-directories,
things became a bit complicated, because the ".." entry of the
sub-directories had to be re-linked ... all in all it's a nice
exercise for students who want really to understand how the directory-
hierachies is implemented under unix :-)
-- 
Martin Weitzel, email: martin at mwtech.UUCP, voice: 49-(0)6151-6 56 83



More information about the Comp.unix.wizards mailing list