Sync from the stable (b5) branch of coreutils:
authorJim Meyering <jim@meyering.net>
Wed, 25 Jan 2006 16:45:04 +0000 (16:45 +0000)
committerJim Meyering <jim@meyering.net>
Wed, 25 Jan 2006 16:45:04 +0000 (16:45 +0000)
commit9d5fcc62b3ae5309a5be907ca53511d13760e9c1
tree655fb3f1af82fac2b9935dd1d4d663c527d62e38
parent5f15ae5074582b8909cd74b23a79c1a9ae9ecee4
Sync from the stable (b5) branch of coreutils:

(fts_children): Don't let close() clobber errno from
failed fchdir().

(fts_stat): When following a symlink-to-directory,
don't necessarily interpret stat-fails+lstat-succeeds as indicating
a dangling symlink.  That can also happen at least for ELOOP.
The fix: return FTS_SLNONE only when the stat errno is ENOENT.
FYI, this bug predates the inclusion of fts.c in coreutils.

(fts_open): Put new maxarglen declaration and uses
in their own block, so pre-c99 compilers don't object.

Avoid the double-free (first in fts_read, second in fts_close) that
would occur when an `active' directory is made inaccessible (e.g.,
via chmod a-x) during a traversal.

(fts_read): After a failed fchdir, update sp->fts_cur
before returning.  Reproduce this failure by
mkdir -p a/b; cd a; chmod a-x . b
Reported by Stavros Passas.
lib/fts.c