From 1880f548358247da918fc9358c09c92172ad1cc2 Mon Sep 17 00:00:00 2001 From: Philip Guenthe Date: Mon, 18 Jun 2012 01:03:06 +0000 Subject: Polish the rm -rP turd: 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. ok millert@ --- bin/rm/rm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/rm/rm.c b/bin/rm/rm.c index 5d6b46622a1..436b70068a1 100644 --- a/bin/rm/rm.c +++ b/bin/rm/rm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rm.c,v 1.24 2012/06/18 00:33:47 millert Exp $ */ +/* $OpenBSD: rm.c,v 1.25 2012/06/18 01:03:05 guenther Exp $ */ /* $NetBSD: rm.c,v 1.19 1995/09/07 06:48:50 jtc Exp $ */ /*- @@ -198,9 +198,13 @@ rm_tree(char **argv) continue; break; - default: + case FTS_F: + case FTS_NSOK: if (Pflag) - rm_overwrite(p->fts_accpath, NULL); + rm_overwrite(p->fts_accpath, p->fts_info == + FTS_NSOK ? NULL : p->fts_statp); + /* FALLTHROUGH */ + default: if (!unlink(p->fts_accpath) || (fflag && errno == ENOENT)) continue; -- cgit v1.2.3