du: tune, and fix some -L bugs with dangling or cyclic symlinks
authorPaul R. Eggert <eggert@cs.ucla.edu>
Sat, 24 Jul 2010 07:19:33 +0000 (00:19 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 24 Jul 2010 07:20:07 +0000 (00:20 -0700)
commit77428214f13e1d7b81348fd301a388cb4ce8a2a0
tree62792ebdfd1e415f65383b52b57c64537836dc6c
parent9a3c600f11b254bc601a96ee607129cba69c8029
du: tune, and fix some -L bugs with dangling or cyclic symlinks

* src/du.c (process_file): Avoid recalculation of hashes
and of file-exclusion for directories.  Do not descend into
the same directory more than once, unless -l is given; this is faster.
Calculate stat buffer lazily, since it
need not be computed at all for excluded files.
Count space if FTS_ERR, since stat buffer is always valid then.
No need for 'print' local variable.
(main): Use FTS_NOSTAT.  Use FTS_TIGHT_CYCLE_CHECK only when not
hashing everything, since process_file finds cycles on its own
when hashing everything.
* tests/du/deref: Add test cases for -L bugs.
src/du.c
tests/du/deref