Polish previous revision: if the fts_* routines have lstat()'ed the

directory entry then use the struct stat from that instead of doing
it again, and skip the rm_overwrite() call if fts_read() indicated
that the entry couldn't be a regular file.

Obtained from:	OpenBSD
MFC after:	1 week
This commit is contained in:
Xin LI 2012-06-20 21:10:38 +00:00
parent 32abc7ddc1
commit 930e323894

View File

@ -301,10 +301,16 @@ rm_tree(char **argv)
if (fflag)
continue;
/* FALLTHROUGH */
default:
case FTS_F:
case FTS_NSOK:
if (Pflag)
if (!rm_overwrite(p->fts_accpath, NULL))
if (!rm_overwrite(p->fts_accpath, p->fts_info ==
FTS_NSOK ? NULL : p->fts_statp))
continue;
/* FALLTHROUGH */
default:
rval = unlink(p->fts_accpath);
if (rval == 0 || (fflag && errno == ENOENT)) {
if (rval == 0 && vflag)