find: Allow -type d without statting everything.
fts(3) detects directories even in FTS_NOSTAT mode (so it can descend into them). No functional change is intended, but find commands that use -type d but no primaries that still require stat/lstat calls make considerably fewer system calls.
This commit is contained in:
parent
fd9e2c6a4a
commit
b95de98a6b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=260555
@ -1552,7 +1552,12 @@ c_sparse(OPTION *option, char ***argvp __unused)
|
||||
int
|
||||
f_type(PLAN *plan, FTSENT *entry)
|
||||
{
|
||||
return (entry->fts_statp->st_mode & S_IFMT) == plan->m_data;
|
||||
if (plan->m_data == S_IFDIR)
|
||||
return (entry->fts_info == FTS_D || entry->fts_info == FTS_DC ||
|
||||
entry->fts_info == FTS_DNR || entry->fts_info == FTS_DOT ||
|
||||
entry->fts_info == FTS_DP);
|
||||
else
|
||||
return (entry->fts_statp->st_mode & S_IFMT) == plan->m_data;
|
||||
}
|
||||
|
||||
PLAN *
|
||||
@ -1563,7 +1568,8 @@ c_type(OPTION *option, char ***argvp)
|
||||
mode_t mask;
|
||||
|
||||
typestring = nextarg(option, argvp);
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
if (typestring[0] != 'd')
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
switch (typestring[0]) {
|
||||
case 'b':
|
||||
|
Loading…
Reference in New Issue
Block a user