diff options
author | delphij <delphij@FreeBSD.org> | 2012-06-20 21:10:38 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2012-06-20 21:10:38 +0000 |
commit | 0dbfe1d7aac5f952613c59a6f339d3cce942ecde (patch) | |
tree | 6f3de717cd91b78240a804cc326b6d84a26e132a | |
parent | eb50c82f35336be7dff27205eebac36288ccc0e2 (diff) | |
download | FreeBSD-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
-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 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) |