Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/mtree features:



details:   https://anonhg.NetBSD.org/src/rev/65bf63ab3640
branches:  trunk
changeset: 515740:65bf63ab3640
user:      lukem <lukem%NetBSD.org@localhost>
date:      Thu Oct 04 04:51:27 2001 +0000

description:
features:
- add a new keyword - "tags" - which is a comma separated list of tags
  associated with that file.
- add "-E tags"; exclude files in -D output with matching tags
- add "-I tags"; only include files in -D output with matching tags
  (default is to list all)

fixes:
- move all extern variable references from individual files into extern.h
- `quote' some more user-specified strings in error messages
- man page: list an options arguments in the description, and sort xrefs.

diffstat:

 usr.sbin/mtree/compare.c |   6 +--
 usr.sbin/mtree/create.c  |   9 +----
 usr.sbin/mtree/extern.h  |   9 +++++-
 usr.sbin/mtree/misc.c    |  11 +++----
 usr.sbin/mtree/mtree.8   |  55 +++++++++++++++++++++++++++++--------
 usr.sbin/mtree/mtree.c   |  71 +++++++++++++++++++++++++++++++++++++++++------
 usr.sbin/mtree/mtree.h   |   4 ++-
 usr.sbin/mtree/spec.c    |  42 +++++++++++++++++++++++++---
 usr.sbin/mtree/verify.c  |   8 +----
 9 files changed, 164 insertions(+), 51 deletions(-)

diffs (truncated from 549 to 300 lines):

diff -r 00997704ed29 -r 65bf63ab3640 usr.sbin/mtree/compare.c
--- a/usr.sbin/mtree/compare.c  Thu Oct 04 04:27:48 2001 +0000
+++ b/usr.sbin/mtree/compare.c  Thu Oct 04 04:51:27 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compare.c,v 1.27 2001/10/01 02:30:40 lukem Exp $       */
+/*     $NetBSD: compare.c,v 1.28 2001/10/04 04:51:27 lukem Exp $       */
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)compare.c  8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: compare.c,v 1.27 2001/10/01 02:30:40 lukem Exp $");
+__RCSID("$NetBSD: compare.c,v 1.28 2001/10/04 04:51:27 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -57,8 +57,6 @@
 #include "mtree.h"
 #include "extern.h"
 
-extern int iflag, lflag, mflag, tflag, uflag;
-
 #define        INDENTNAMELEN   8
 #define MARK                                                                  \
 do {                                                                          \
diff -r 00997704ed29 -r 65bf63ab3640 usr.sbin/mtree/create.c
--- a/usr.sbin/mtree/create.c   Thu Oct 04 04:27:48 2001 +0000
+++ b/usr.sbin/mtree/create.c   Thu Oct 04 04:51:27 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: create.c,v 1.30 2001/10/01 02:30:40 lukem Exp $        */
+/*     $NetBSD: create.c,v 1.31 2001/10/04 04:51:27 lukem Exp $        */
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)create.c   8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: create.c,v 1.30 2001/10/01 02:30:40 lukem Exp $");
+__RCSID("$NetBSD: create.c,v 1.31 2001/10/04 04:51:27 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -66,11 +66,6 @@
 #define        MAXLINELEN      80
 #define VISFLAGS        VIS_CSTYLE
 
-extern int crc_total, ftsoptions;
-extern int dflag, sflag;
-extern int keys;
-extern char fullpath[MAXPATHLEN];
-
 static gid_t gid;
 static uid_t uid;
 static mode_t mode;
diff -r 00997704ed29 -r 65bf63ab3640 usr.sbin/mtree/extern.h
--- a/usr.sbin/mtree/extern.h   Thu Oct 04 04:27:48 2001 +0000
+++ b/usr.sbin/mtree/extern.h   Thu Oct 04 04:51:27 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.12 2001/10/01 02:30:40 lukem Exp $        */
+/*     $NetBSD: extern.h,v 1.13 2001/10/04 04:51:27 lukem Exp $        */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -51,4 +51,11 @@
 NODE   *spec(void);
 int     verify(void);
 
+extern int     dflag, eflag, iflag, lflag, mflag, rflag, sflag, tflag, uflag;
+extern size_t  lineno;
+extern int     crc_total, ftsoptions, keys;
+extern char    fullpath[];
+extern char    **includetags, **excludetags;
+
+
 #include "stat_flags.h"
diff -r 00997704ed29 -r 65bf63ab3640 usr.sbin/mtree/misc.c
--- a/usr.sbin/mtree/misc.c     Thu Oct 04 04:27:48 2001 +0000
+++ b/usr.sbin/mtree/misc.c     Thu Oct 04 04:51:27 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: misc.c,v 1.12 2001/09/11 15:10:45 thorpej Exp $        */
+/*     $NetBSD: misc.c,v 1.13 2001/10/04 04:51:27 lukem Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: misc.c,v 1.12 2001/09/11 15:10:45 thorpej Exp $");
+__RCSID("$NetBSD: misc.c,v 1.13 2001/10/04 04:51:27 lukem Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -50,8 +50,6 @@
 #include "mtree.h"
 #include "extern.h"
 
-extern size_t lineno;
-
 typedef struct _key {
        const char      *name;          /* key name */
        u_int           val;            /* value */
@@ -73,6 +71,7 @@
        {"nlink",       F_NLINK,        NEEDVALUE},
        {"optional",    F_OPT,          0},
        {"size",        F_SIZE,         NEEDVALUE},
+       {"tags",        F_TAGS,         NEEDVALUE},
        {"time",        F_TIME,         NEEDVALUE},
        {"type",        F_TYPE,         NEEDVALUE},
        {"uid",         F_UID,          NEEDVALUE},
@@ -100,7 +99,7 @@
        k = (KEY *)bsearch(&tmp, keylist, sizeof(keylist) / sizeof(KEY),
            sizeof(KEY), keycompare);
        if (k == NULL)
-               mtree_err("unknown keyword %s", name);
+               mtree_err("unknown keyword `%s'", name);
 
        if (needvaluep)
                *needvaluep = k->flags & NEEDVALUE ? 1 : 0;
@@ -117,7 +116,7 @@
        k = (KEY *)bsearch(&tmp, typelist, sizeof(typelist) / sizeof(KEY),
            sizeof(KEY), keycompare);
        if (k == NULL)
-               mtree_err("unknown file type %s", name);
+               mtree_err("unknown file type `%s'", name);
 
        return (k->val);
 }
diff -r 00997704ed29 -r 65bf63ab3640 usr.sbin/mtree/mtree.8
--- a/usr.sbin/mtree/mtree.8    Thu Oct 04 04:27:48 2001 +0000
+++ b/usr.sbin/mtree/mtree.8    Thu Oct 04 04:51:27 2001 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: mtree.8,v 1.16 2001/10/01 02:30:40 lukem Exp $
+.\"    $NetBSD: mtree.8,v 1.17 2001/10/04 04:51:27 lukem Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -33,7 +33,7 @@
 .\"
 .\"     @(#)mtree.8    8.2 (Berkeley) 12/11/93
 .\"
-.Dd October 1, 2001
+.Dd October 4, 2001
 .Dt MTREE 8
 .Os
 .Sh NAME
@@ -61,6 +61,12 @@
 .Op Fl R Ar keywords
 .Ek
 .Bk -words
+.Op Fl E Ar tags
+.Ek
+.Bk -words
+.Op Fl I Ar tags
+.Ek
+.Bk -words
 .Op Fl s Ar seed
 .Ek
 .Sh DESCRIPTION
@@ -89,20 +95,38 @@
 .Fl K ,
 and
 .Fl R
-can be used to control which other keywords are printed.
+can be used to control which other keywords are printed,
+and
+.Fl E
+and
+.Fl R
+can be used to control which files are printed.
+.It Fl E Ar tags
+Add the comma separated tags to the
+.Dq exclusion
+list.
+Regular files with tags which are in the exclusion list are not printed with
+.Fl D .
 .It Fl e
 Don't complain about files that are in the file hierarchy, but not in the
 specification.
-.It Fl f
+.It Fl f Ar spec
 Read the specification from
 .Ar file  ,
 instead of from the standard input.
+.It Fl I Ar tags
+Add the comma separated tags to the
+.Dq inclusion
+list.
+Only regular files with tags which are in the inclusion list are printed with
+.Fl D .
+If no inclusion list is provided, the default is to display all files.
 .It Fl i
 If specified, set the schg and/or sappnd flags.
-.It Fl K
+.It Fl K Ar keywords
 Add the specified (whitespace or comma separated) keywords to the current
 set of keywords.
-.It Fl k
+.It Fl k Ar keywords
 Use the ``type'' keyword plus the specified (whitespace or comma separated)
 keywords instead of the current set of keywords.
 .It Fl l
@@ -126,17 +150,17 @@
 or while the system is running in insecure mode). See
 .Xr init 8
 for information on security levels.
-.It Fl p
+.It Fl p Ar path
 Use the file hierarchy rooted in
 .Ar path  ,
 instead of the current directory.
+.It Fl R Ar keywords
+Remove the specified (whitespace or comma separated) keywords from the current
+set of keywords.
 .It Fl r
 Remove any files in the file hierarchy that are not described in the
 specification.
-.It Fl R
-Remove the specified (whitespace or comma separated) keywords from the current
-set of keywords.
-.It Fl s
+.It Fl s Ar seed
 Display a single checksum to the standard error output that represents all
 of the files for which the keyword
 .Cm cksum
@@ -211,6 +235,13 @@
 The file owner as a symbolic name.
 .It Cm size
 The size, in bytes, of the file.
+.It Cm tags
+Comma delimited tags to be matched with
+.Fl E
+and
+.Fl I .
+These may be specified without leading or trailing commas, but will be
+stored internally with them.
 .It Cm time
 The last modification time of the file.
 .It Cm type
@@ -336,8 +367,8 @@
 .Xr cksum 1 ,
 .Xr md5 1 ,
 .Xr stat 2 ,
+.Xr fts 3 ,
 .Xr strsvis 3 ,
-.Xr fts 3 ,
 .Xr chown 8
 .Sh HISTORY
 The
diff -r 00997704ed29 -r 65bf63ab3640 usr.sbin/mtree/mtree.c
--- a/usr.sbin/mtree/mtree.c    Thu Oct 04 04:27:48 2001 +0000
+++ b/usr.sbin/mtree/mtree.c    Thu Oct 04 04:51:27 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mtree.c,v 1.18 2001/10/01 02:30:40 lukem Exp $ */
+/*     $NetBSD: mtree.c,v 1.19 2001/10/04 04:51:27 lukem 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.18 2001/10/01 02:30:40 lukem Exp $");
+__RCSID("$NetBSD: mtree.c,v 1.19 2001/10/04 04:51:27 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -53,34 +53,36 @@
 #include <errno.h>
 #include <fts.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 
 #include "mtree.h"
 #include "extern.h"
 
-extern int crc_total;
-
 int    ftsoptions = FTS_PHYSICAL;
 int    cflag, dflag, Dflag, eflag, iflag, lflag, mflag,
        rflag, sflag, tflag, uflag, Uflag;
 int    keys;
 char   fullpath[MAXPATHLEN];
+char   **excludetags, **includetags;
 
+static void    addtag(char ***, int *, char *);
        int     main(int, char **);
+static void    parsetags(char ***, int *, char *);
 static void    usage(void);
 
 int
 main(int argc, char **argv)
 {
-       int ch;
-       char *dir, *p;
-       int status;



Home | Main Index | Thread Index | Old Index