Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Sep 2012 15:05:58 +0000 (UTC)
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r240749 - projects/mtree/contrib/mtree
Message-ID:  <201209201505.q8KF5wU2040193@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brooks
Date: Thu Sep 20 15:05:57 2012
New Revision: 240749
URL: http://svn.freebsd.org/changeset/base/240749

Log:
  Add -q.  This will cause the warning messages about missing
  directories to not be printed.
  
  Obtained from: OpenBSD

Modified:
  projects/mtree/contrib/mtree/extern.h
  projects/mtree/contrib/mtree/mtree.8
  projects/mtree/contrib/mtree/mtree.c
  projects/mtree/contrib/mtree/verify.c

Modified: projects/mtree/contrib/mtree/extern.h
==============================================================================
--- projects/mtree/contrib/mtree/extern.h	Thu Sep 20 14:55:32 2012	(r240748)
+++ projects/mtree/contrib/mtree/extern.h	Thu Sep 20 15:05:57 2012	(r240749)
@@ -70,7 +70,7 @@ const char *rlink(const char *);
 int	 verify(void);
 
 extern int	dflag, eflag, iflag, lflag, mflag,
-		nflag, rflag, sflag, tflag, uflag;
+		nflag, qflag, rflag, sflag, tflag, uflag;
 extern int	mtree_Mflag, mtree_Sflag, mtree_Wflag;
 extern size_t	mtree_lineno;
 extern u_int32_t crc_total;

Modified: projects/mtree/contrib/mtree/mtree.8
==============================================================================
--- projects/mtree/contrib/mtree/mtree.8	Thu Sep 20 14:55:32 2012	(r240748)
+++ projects/mtree/contrib/mtree/mtree.8	Thu Sep 20 15:05:57 2012	(r240749)
@@ -229,6 +229,12 @@ This is the default.
 Use the file hierarchy rooted in
 .Ar path  ,
 instead of the current directory.
+.It Fl q
+Quiet mode.
+Do not complain when a
+.Dq missing
+directory cannot be created because it already exists.
+This occurs when the directory is a symbolic link.
 .It Fl R Ar keywords
 Remove the specified (whitespace or comma separated) keywords from the current
 set of keywords.

Modified: projects/mtree/contrib/mtree/mtree.c
==============================================================================
--- projects/mtree/contrib/mtree/mtree.c	Thu Sep 20 14:55:32 2012	(r240748)
+++ projects/mtree/contrib/mtree/mtree.c	Thu Sep 20 15:05:57 2012	(r240749)
@@ -60,7 +60,7 @@ __RCSID("$NetBSD: mtree.c,v 1.37 2011/08
 
 int	ftsoptions = FTS_PHYSICAL;
 int	cflag, Cflag, dflag, Dflag, eflag, iflag, lflag, mflag,
-    	nflag, rflag, sflag, tflag, uflag, Uflag;
+    	nflag, qflag, rflag, sflag, tflag, uflag, Uflag;
 char	fullpath[MAXPATHLEN];
 
 __dead2 static	void	usage(void);
@@ -77,7 +77,7 @@ main(int argc, char **argv)
 	init_excludes();
 
 	while ((ch = getopt(argc, argv,
-	    "cCdDeE:f:I:ik:K:lLmMnN:p:PrR:s:StuUWxX:"))
+	    "cCdDeE:f:I:ik:K:lLmMnN:p:PqrR:s:StuUWxX:"))
 	    != -1) {
 		switch((char)ch) {
 		case 'c':
@@ -148,6 +148,9 @@ main(int argc, char **argv)
 			ftsoptions &= ~FTS_LOGICAL;
 			ftsoptions |= FTS_PHYSICAL;
 			break;
+		case 'q':
+			qflag = 1;
+			break;
 		case 'r':
 			rflag = 1;
 			break;

Modified: projects/mtree/contrib/mtree/verify.c
==============================================================================
--- projects/mtree/contrib/mtree/verify.c	Thu Sep 20 14:55:32 2012	(r240748)
+++ projects/mtree/contrib/mtree/verify.c	Thu Sep 20 15:05:57 2012	(r240749)
@@ -175,8 +175,16 @@ miss(NODE *p, char *tail)
 		if (p->type != F_DIR && (dflag || p->flags & F_VISIT))
 			continue;
 		strcpy(tail, p->name);
-		if (!(p->flags & F_VISIT))
-			printf("missing: %s", path);
+		if (!(p->flags & F_VISIT)) {
+			/* Don't print missing message if file exists as a 
+			   symbolic link and the -q flag is set. */
+			struct stat statbuf;
+
+			if (qflag && stat(path, &statbuf) == 0)
+				p->flags |= F_VISIT;
+			else
+				(void)printf("%s missing", path);
+		}
 		switch (p->type) {
 		case F_BLOCK:
 		case F_CHAR:



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