diff options
author | Xin LI <delphij@FreeBSD.org> | 2012-06-20 21:10:38 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2012-06-20 21:10:38 +0000 |
commit | 930e3238946d6fd3fa318e048289b6d6225784ef (patch) | |
tree | 6f3de717cd91b78240a804cc326b6d84a26e132a /bin/rm | |
parent | 32abc7ddc1d8beeadda437bad73dd3e1df2fb4f2 (diff) | |
download | src-test2-930e3238946d6fd3fa318e048289b6d6225784ef.tar.gz src-test2-930e3238946d6fd3fa318e048289b6d6225784ef.zip |
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
Notes
Notes:
svn path=/head/; revision=237339
Diffstat (limited to 'bin/rm')
-rw-r--r-- | bin/rm/rm.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/bin/rm/rm.c b/bin/rm/rm.c index 1f81885d52cc..6575a8de891e 100644 --- a/bin/rm/rm.c +++ b/bin/rm/rm.c @@ -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) |