Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Jun 2012 21:10:39 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r237339 - head/bin/rm
Message-ID:  <201206202110.q5KLAdi6067925@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Wed Jun 20 21:10:38 2012
New Revision: 237339
URL: http://svn.freebsd.org/changeset/base/237339

Log:
  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

Modified:
  head/bin/rm/rm.c

Modified: head/bin/rm/rm.c
==============================================================================
--- head/bin/rm/rm.c	Wed Jun 20 21:06:51 2012	(r237338)
+++ head/bin/rm/rm.c	Wed Jun 20 21:10:38 2012	(r237339)
@@ -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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206202110.q5KLAdi6067925>