On 7/26/07, Morten Welinder [off-list ref] wrote:
Why the lstat and that stat in the beginning? That's just asking for race
condition. readlink will tell you if it wasn't a link, for example.
Here's an example of the sort of thing I'm trying to avoid:
foo is a symlink to bar
bar is a symlink back to foo
readlink() on either one will succeed, but I'll end up with infinite
recursion because I'll resolve foo to bar, then bar to foo, then foo
back to bar, etc.
To avoid craziness like this the OS refuses to follow a chain of more
than a very small number of symlinks. By experimentation, I found the
limit to be 8 on my Linux box.
I am trying to avoid resolving symlinks manually that the OS would
refuse to resolve anyway.
However, I'm quite open to suggestions for a better way to do it.
Thanks,
Bradford