Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/mtree add -q flag to silence warnings about symlink...



details:   https://anonhg.NetBSD.org/src/rev/3860125661d7
branches:  trunk
changeset: 781873:3860125661d7
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Oct 05 01:05:14 2012 +0000

description:
add -q flag to silence warnings about symlinks to existing dirs (from OpenBSD
via brooks)

diffstat:

 usr.sbin/mtree/extern.h |   4 ++--
 usr.sbin/mtree/mtree.8  |   8 +++++++-
 usr.sbin/mtree/mtree.c  |  11 +++++++----
 usr.sbin/mtree/verify.c |  17 +++++++++++++----
 4 files changed, 29 insertions(+), 11 deletions(-)

diffs (124 lines):

diff -r cb64bfd1d5ca -r 3860125661d7 usr.sbin/mtree/extern.h
--- a/usr.sbin/mtree/extern.h   Fri Oct 05 01:01:07 2012 +0000
+++ b/usr.sbin/mtree/extern.h   Fri Oct 05 01:05:14 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.33 2012/10/05 01:01:07 christos Exp $     */
+/*     $NetBSD: extern.h,v 1.34 2012/10/05 01:05:14 christos Exp $     */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -70,7 +70,7 @@
 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;
diff -r cb64bfd1d5ca -r 3860125661d7 usr.sbin/mtree/mtree.8
--- a/usr.sbin/mtree/mtree.8    Fri Oct 05 01:01:07 2012 +0000
+++ b/usr.sbin/mtree/mtree.8    Fri Oct 05 01:05:14 2012 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: mtree.8,v 1.56 2012/10/05 01:01:07 christos Exp $
+.\"    $NetBSD: mtree.8,v 1.57 2012/10/05 01:05:14 christos Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -230,6 +230,12 @@
 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.
diff -r cb64bfd1d5ca -r 3860125661d7 usr.sbin/mtree/mtree.c
--- a/usr.sbin/mtree/mtree.c    Fri Oct 05 01:01:07 2012 +0000
+++ b/usr.sbin/mtree/mtree.c    Fri Oct 05 01:05:14 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mtree.c,v 1.38 2012/10/05 01:01:07 christos Exp $      */
+/*     $NetBSD: mtree.c,v 1.39 2012/10/05 01:05:14 christos Exp $      */
 
 /*-
  * Copyright (c) 1989, 1990, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)mtree.c    8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: mtree.c,v 1.38 2012/10/05 01:01:07 christos Exp $");
+__RCSID("$NetBSD: mtree.c,v 1.39 2012/10/05 01:05:14 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -60,7 +60,7 @@
 
 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];
 
 __dead static  void    usage(void);
@@ -77,7 +77,7 @@
        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 @@
                        ftsoptions &= ~FTS_LOGICAL;
                        ftsoptions |= FTS_PHYSICAL;
                        break;
+               case 'q':
+                       qflag = 1;
+                       break;
                case 'r':
                        rflag = 1;
                        break;
diff -r cb64bfd1d5ca -r 3860125661d7 usr.sbin/mtree/verify.c
--- a/usr.sbin/mtree/verify.c   Fri Oct 05 01:01:07 2012 +0000
+++ b/usr.sbin/mtree/verify.c   Fri Oct 05 01:05:14 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: verify.c,v 1.40 2012/03/25 16:07:04 christos Exp $     */
+/*     $NetBSD: verify.c,v 1.41 2012/10/05 01:05:14 christos Exp $     */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)verify.c   8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: verify.c,v 1.40 2012/03/25 16:07:04 christos Exp $");
+__RCSID("$NetBSD: verify.c,v 1.41 2012/10/05 01:05:14 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -175,8 +175,17 @@
                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 &&
+                           S_ISDIR(statbuf.st_mode))
+                               p->flags |= F_VISIT;
+                       else
+                               (void)printf("%s missing", path);
+               }
                switch (p->type) {
                case F_BLOCK:
                case F_CHAR:



Home | Main Index | Thread Index | Old Index