Re: Symlink loop detection

Colin Plumb (colin@nyx.net)
Wed, 15 Apr 1998 05:29:30 -0600 (MDT)


> This obviously doesn't work.
> (a->b->c->d->c... for example)

Okay, let's work it through
Step 1: remembered = /, cur = a
Step 2: remembered = a, cur = b
Step 3: remembered = b, cur = c
Step 4: remembered = b, cur = d
Step 5: remembered = d, cur = c
Step 6: remembered = d, cur = d <-- Loop detected

No algorithm except remembering every place you've ever been
will detect a cycle instantly. All of the "clever" algorithms
that use constant space sacrifice instant detection and
settle for "soon enough" detection.

-- 
	-Colin

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu