Hard links to directories: why not?
Alan J Rosenthal
flaps at dgp.toronto.edu
Mon Jul 23 01:13:34 AEST 1990
In article <10527 at odin.corp.sgi.com> schuman at sgi.com (Aaron Schuman) writes:
>>A foolish user could create loops in the directory structure.
mvadh at cbnews.att.com (andrew.d.hay) writes:
>it would be easy to have ln disallow this:
>1) resolve argv[1] and argv[2] to absolute paths
>2) determine which path is shorter
>3) strncmp() both paths for the shorter length
>4) if you have a match, you're trying to create a loop
It's true that if they match, you're creating a loop. However, it's not true
that if they don't match you're not creating a loop.
Here's a counterexample:
Suppose your filesystem is on /mnt.
Do this:
mkdir /mnt/a
ln /mnt/a /mnt/b
mkdir /mnt/a/c
ln /mnt/a /mnt/b/c/d
Now /mnt/a/c/d and /mnt/a are the same. So you can refer to
/mnt/a/c/d/c/d/c/d/c/d/c/d, etc.
ajr
More information about the Comp.unix.wizards
mailing list