Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/mtree - support "all" as a valid keyword for -k, -K...



details:   https://anonhg.NetBSD.org/src/rev/2fa2f713b73a
branches:  trunk
changeset: 515812:2fa2f713b73a
user:      lukem <lukem%NetBSD.org@localhost>
date:      Fri Oct 05 13:14:56 2001 +0000

description:
- support "all" as a valid keyword for -k, -K and -R.
- parsekey(): support "all" as a keyword which returns a value with all bits
  set that pertain to a valid keyword.
- dump_nodes():
        - only print out a keyword if it's requested AND it's set in the node
        - UNAME falls back to UID if the user name can't be determined
        - GNAME falls back to GID if the group name can't be determined
- rework man page:
        - use Sy instead of Cm
        - use Pq, Dq, Ql, etc instead of ``...''

diffstat:

 usr.sbin/mtree/misc.c  |   13 +++-
 usr.sbin/mtree/mtree.8 |  138 +++++++++++++++++++++++++++++++-----------------
 usr.sbin/mtree/spec.c  |   61 +++++++++++++-------
 3 files changed, 138 insertions(+), 74 deletions(-)

diffs (truncated from 428 to 300 lines):

diff -r f4c6bec2e428 -r 2fa2f713b73a usr.sbin/mtree/misc.c
--- a/usr.sbin/mtree/misc.c     Fri Oct 05 12:55:24 2001 +0000
+++ b/usr.sbin/mtree/misc.c     Fri Oct 05 13:14:56 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: misc.c,v 1.14 2001/10/05 01:03:24 lukem Exp $  */
+/*     $NetBSD: misc.c,v 1.15 2001/10/05 13:14:56 lukem Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: misc.c,v 1.14 2001/10/05 01:03:24 lukem Exp $");
+__RCSID("$NetBSD: misc.c,v 1.15 2001/10/05 13:14:56 lukem Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -93,9 +93,18 @@
 u_int
 parsekey(const char *name, int *needvaluep)
 {
+       static int allbits;
        KEY *k, tmp;
 
+       if (allbits == 0) {
+               int i;
+
+               for (i = 0; i < sizeof(keylist) / sizeof(KEY); i++)
+                       allbits |= keylist[i].val;
+       }
        tmp.name = name;
+       if (strcmp(name, "all") == 0)
+               return (allbits);
        k = (KEY *)bsearch(&tmp, keylist, sizeof(keylist) / sizeof(KEY),
            sizeof(KEY), keycompare);
        if (k == NULL)
diff -r f4c6bec2e428 -r 2fa2f713b73a usr.sbin/mtree/mtree.8
--- a/usr.sbin/mtree/mtree.8    Fri Oct 05 12:55:24 2001 +0000
+++ b/usr.sbin/mtree/mtree.8    Fri Oct 05 13:14:56 2001 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: mtree.8,v 1.19 2001/10/05 01:03:24 lukem Exp $
+.\"    $NetBSD: mtree.8,v 1.20 2001/10/05 13:14:56 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 4, 2001
+.Dd October 5, 2001
 .Dt MTREE 8
 .Os
 .Sh NAME
@@ -126,9 +126,17 @@
 .It Fl K Ar keywords
 Add the specified (whitespace or comma separated) keywords to the current
 set of keywords.
+If
+.Ql all
+is specified, add all the keywords.
 .It Fl k Ar keywords
-Use the ``type'' keyword plus the specified (whitespace or comma separated)
+Use the
+.Sy type
+keyword plus the specified (whitespace or comma separated)
 keywords instead of the current set of keywords.
+If
+.Ql all
+is specified, use all the keywords.
 .It Fl l
 Do
 .Dq loose
@@ -157,13 +165,16 @@
 .It Fl R Ar keywords
 Remove the specified (whitespace or comma separated) keywords from the current
 set of keywords.
+If
+.Ql all
+is specified, remove all the keywords.
 .It Fl r
 Remove any files in the file hierarchy that are not described in the
 specification.
 .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
+.Sy cksum
 was specified.
 The checksum is seeded with the specified value.
 .It Fl U
@@ -188,106 +199,113 @@
 Don't descend below mount points in the file hierarchy.
 .El
 .Pp
-Specifications are mostly composed of ``keywords'', i.e. strings that
+Specifications are mostly composed of
+.Dq keywords ,
+i.e. strings that
 that specify values relating to files.
 No keywords have default values, and if a keyword has no value set, no
 checks based on it are performed.
 .Pp
 Currently supported keywords are as follows:
-.Bl -tag -width Cm
-.It Cm cksum
+.Bl -tag -width Sy
+.It Sy cksum
 The checksum of the file using the default algorithm specified by
 the
 .Xr cksum 1
 utility.
-.It Cm flags
+.It Sy flags
 The file flags as a symbolic name.  See
 .Xr chflags 1
 for information on these names.  If no flags are to be set the string
-.Dq none
+.Ql none
 may be used to override the current default.
 Note that the schg and sappnd flags are treated specially (see the
 .Fl i
 and
 .Fl m
 options).
-.It Cm ignore
+.It Sy ignore
 Ignore any file hierarchy below this file.
-.It Cm gid
+.It Sy gid
 The file group as a numeric value.
-.It Cm gname
+.It Sy gname
 The file group as a symbolic name.
-.It Cm link
+.It Sy link
 The file the symbolic link is expected to reference.
-.It Cm md5
+.It Sy md5
 The MD5 cryptographic checksum of the file.
-.It Cm mode
+.It Sy mode
 The current file's permissions as a numeric (octal) or symbolic
 value.
-.It Cm nlink
+.It Sy nlink
 The number of hard links the file is expected to have.
-.It Cm optional
+.It Sy optional
 The file is optional; don't complain about the file if it's
 not in the file hierarchy.
-.It Cm uid
+.It Sy uid
 The file owner as a numeric value.
-.It Cm uname
+.It Sy uname
 The file owner as a symbolic name.
-.It Cm size
+.It Sy size
 The size, in bytes, of the file.
-.It Cm tags
+.It Sy 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
+.It Sy time
 The last modification time of the file.
-.It Cm type
+.It Sy type
 The type of the file; may be set to any one of the following:
 .sp
-.Bl -tag -width Cm -compact
-.It Cm block
+.Bl -tag -width Sy -compact
+.It Sy block
 block special device
-.It Cm char
+.It Sy char
 character special device
-.It Cm dir
+.It Sy dir
 directory
-.It Cm fifo
+.It Sy fifo
 fifo
-.It Cm file
+.It Sy file
 regular file
-.It Cm link
+.It Sy link
 symbolic link
-.It Cm socket
+.It Sy socket
 socket
 .El
 .El
 .Pp
 The default set of keywords are
-.Cm flags ,
-.Cm gid ,
-.Cm link ,
-.Cm mode ,
-.Cm nlink ,
-.Cm size ,
-.Cm time ,
+.Sy flags ,
+.Sy gid ,
+.Sy link ,
+.Sy mode ,
+.Sy nlink ,
+.Sy size ,
+.Sy time ,
+.Sy type ,
 and
-.Cm uid .
+.Sy uid .
 .Pp
 There are four types of lines in a specification.
 .Pp
 The first type of line sets a global value for a keyword, and consists of
-the string ``/set'' followed by whitespace, followed by sets of keyword/value
+the string
+.Ql /set
+followed by whitespace, followed by sets of keyword/value
 pairs, separated by whitespace.
 Keyword/value pairs consist of a keyword, followed by an equals sign
-(``=''), followed by a value, without whitespace characters.
+.Pq Ql = ,
+followed by a value, without whitespace characters.
 Once a keyword has been set, its value remains unchanged until either
 reset or unset.
 .Pp
 The second type of line unsets keywords and consists of the string
-``/unset'', followed by whitespace, followed by one or more keywords,
+.Ql /unset ,
+followed by whitespace, followed by one or more keywords,
 separated by whitespace.
 .Pp
 The third type of line is a file specification and consists of a file
@@ -295,7 +313,15 @@
 separated keyword/value pairs.
 The file name may be preceded by whitespace characters.
 The file name may contain any of the standard file name matching
-characters (``['', ``]'', ``?'' or ``*''), in which case files
+characters
+.Po
+.Ql [ ,
+.Ql \] ,
+.Ql ?
+or
+.Ql *
+.Pc , 
+in which case files
 in the hierarchy will be associated with the first pattern that
 they match.
 .Nm
@@ -303,12 +329,21 @@
 .Xr strsvis 3
 (in VIS_CSTYLE format) to encode file names containing
 non-printable characters. Whitespace characters are encoded as
-``\es'' (space), ``\et'' (tab), and ``\en'' (new line).
-``#'' characters in file names are escaped by a preceding backslash (``\e'')
+.Ql \es
+(space),
+.Ql \et
+(tab), and
+.Ql \en
+(new line).
+.Ql #
+characters in file names are escaped by a preceding backslash
+.Ql \e
 to distinguish them from comments.
 .Pp
 Each of the keyword/value pairs consist of a keyword, followed by an
-equals sign (``=''), followed by the keyword's value, without
+equals sign
+.Pq Ql = ,
+followed by the keyword's value, without
 whitespace characters.
 These values override, without changing, the global value of the
 corresponding keyword.
@@ -318,12 +353,14 @@
 for in that directory hierarchy.
 Which brings us to the last type of line in a specification: a line
 containing only the string
-.Dq Nm \&..
+.Dq Sy \&..
 causes the current directory
 path to ascend one level.
 .Pp
 Empty lines and lines whose first non-whitespace character is a hash
-mark (``#'') are ignored.
+mark
+.Pq Ql #
+are ignored.



Home | Main Index | Thread Index | Old Index