find(1): Don't treat statfs() error as fatal in f_fstype, which can happen

when a directory is removed in the middle of find.

Instead of a full err(), allow find to continue, plus print a warning with
exitstatus set when appropriate.

Reported by:	100.chksetuid via gordon
Reviewed by:	jilles
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D13024
This commit is contained in:
Xin LI 2017-11-11 19:18:47 +00:00
parent 537d0fb138
commit 0ab69d713c

View File

@ -902,8 +902,13 @@ f_fstype(PLAN *plan, FTSENT *entry)
} else
p = NULL;
if (statfs(entry->fts_accpath, &sb))
err(1, "%s", entry->fts_accpath);
if (statfs(entry->fts_accpath, &sb)) {
if (!ignore_readdir_race || errno != ENOENT) {
warn("statfs: %s", entry->fts_accpath);
exitstatus = 1;
}
return 0;
}
if (p) {
p[0] = save[0];