diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-06-18 01:03:06 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-06-18 01:03:06 +0000 |
commit | 1880f548358247da918fc9358c09c92172ad1cc2 (patch) | |
tree | 1233a221c06fce98b5cd6cb50267745d743ca1e3 /bin | |
parent | a7e024bf8cce2ccb754d7ecef9c9bebf4a8e7c5b (diff) |
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@
Diffstat (limited to 'bin')
-rw-r--r-- | bin/rm/rm.c | 10 |
1 files changed, 7 insertions, 3 deletions
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; |