Bug #1219
open
find shouldn't use FTW_CHDIR
Added by Yuri Pankov almost 11 years ago.
Updated almost 11 years ago.
Category:
cmd - userland programs
Description
It's usefulness is doubtful and leads to subtle problems with -acl (missing starting paths), as well as other extensions I'm thinking of.
Some numbers:
sirius:yuri:~$ time for i in `seq 1 10`; do /usr/bin/find src/illumos/illumos-gate/ > /dev/null; done
real 0m31.085s
user 0m2.289s
sys 0m28.558s
sirius:yuri:~$ time for i in `seq 1 10`; do ~/ws/local/usr/src/cmd/find/find src/illumos/illumos-gate/ > /dev/null; done
real 0m34.175s
user 0m2.319s
sys 0m31.732s
You'd need, at the very least, to be careful about:
- The behaviour of -exec (which you'd change if you didn't make
doexec()
chdir instead
- The various symlink-following implications if any (see also, the various trickery done in rm to try to avoid people fooling it, presuming that this is also necessary for find).
-exec explicitly disables FTW_CHDIR
case EXEC:
case OK:
walkflags &= ~FTW_CHDIR;
cmd/find/find.c, near line 559, and I hope -exec doesn't change the symlinks handling...
The comments about exec and symlinks were separate.
My concern with links is whether it would in any way affect when and where find is willing to chase a link. I don't think it will, but we should check.
Rich Lowe wrote:
The comments about exec and symlinks were separate.
They aren't so separate as you meant them to be, as -exec disables FTW_CHDIR, and I don't think -exec changing behaviour of symlinks handling would be accepted (trying to rephrase my reply...).
My concern with links is whether it would in any way affect when and where find is willing to chase a link. I don't think it will, but we should check.
Ok.
Also available in: Atom
PDF