summaryrefslogtreecommitdiffstats
path: root/bin/rm
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2012-06-20 21:10:38 +0000
committerdelphij <delphij@FreeBSD.org>2012-06-20 21:10:38 +0000
commit0dbfe1d7aac5f952613c59a6f339d3cce942ecde (patch)
tree6f3de717cd91b78240a804cc326b6d84a26e132a /bin/rm
parenteb50c82f35336be7dff27205eebac36288ccc0e2 (diff)
downloadFreeBSD-src-0dbfe1d7aac5f952613c59a6f339d3cce942ecde.zip
FreeBSD-src-0dbfe1d7aac5f952613c59a6f339d3cce942ecde.tar.gz
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
Diffstat (limited to 'bin/rm')
-rw-r--r--bin/rm/rm.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/bin/rm/rm.c b/bin/rm/rm.c
index 1f81885..6575a8d 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)
OpenPOWER on IntegriCloud