add -q flag to silence warnings about symlinks to existing dirs (from OpenBSD via brooks)diff -r1.33 -r1.34 src/usr.sbin/mtree/extern.h
(christos)
--- src/usr.sbin/mtree/extern.h 2012/10/05 01:01:07 1.33
+++ src/usr.sbin/mtree/extern.h 2012/10/05 01:05:14 1.34
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: extern.h,v 1.33 2012/10/05 01:01:07 christos Exp $ */ | 1 | /* $NetBSD: extern.h,v 1.34 2012/10/05 01:05:14 christos Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1991, 1993 | 4 | * Copyright (c) 1991, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -60,21 +60,21 @@ void cwalk(void); | @@ -60,21 +60,21 @@ void cwalk(void); | |||
60 | void dump_nodes(const char *, NODE *, int); | 60 | void dump_nodes(const char *, NODE *, int); | |
61 | void init_excludes(void); | 61 | void init_excludes(void); | |
62 | int matchtags(NODE *); | 62 | int matchtags(NODE *); | |
63 | __dead __printflike(1,2) void mtree_err(const char *, ...); | 63 | __dead __printflike(1,2) void mtree_err(const char *, ...); | |
64 | const char *nodetype(u_int); | 64 | const char *nodetype(u_int); | |
65 | u_int parsekey(const char *, int *); | 65 | u_int parsekey(const char *, int *); | |
66 | void parsetags(slist_t *, char *); | 66 | void parsetags(slist_t *, char *); | |
67 | u_int parsetype(const char *); | 67 | u_int parsetype(const char *); | |
68 | void read_excludes_file(const char *); | 68 | void read_excludes_file(const char *); | |
69 | const char *rlink(const char *); | 69 | const char *rlink(const char *); | |
70 | int verify(void); | 70 | int verify(void); | |
71 | 71 | |||
72 | extern int dflag, eflag, iflag, lflag, mflag, | 72 | extern int dflag, eflag, iflag, lflag, mflag, | |
73 | nflag, rflag, sflag, tflag, uflag; | 73 | nflag, qflag, rflag, sflag, tflag, uflag; | |
74 | extern int mtree_Mflag, mtree_Sflag, mtree_Wflag; | 74 | extern int mtree_Mflag, mtree_Sflag, mtree_Wflag; | |
75 | extern size_t mtree_lineno; | 75 | extern size_t mtree_lineno; | |
76 | extern u_int32_t crc_total; | 76 | extern u_int32_t crc_total; | |
77 | extern int ftsoptions, keys; | 77 | extern int ftsoptions, keys; | |
78 | extern char fullpath[]; | 78 | extern char fullpath[]; | |
79 | extern slist_t includetags, excludetags; | 79 | extern slist_t includetags, excludetags; | |
80 | 80 |
--- src/usr.sbin/mtree/mtree.8 2012/10/05 01:01:07 1.56
+++ src/usr.sbin/mtree/mtree.8 2012/10/05 01:05:14 1.57
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | .\" $NetBSD: mtree.8,v 1.56 2012/10/05 01:01:07 christos Exp $ | 1 | .\" $NetBSD: mtree.8,v 1.57 2012/10/05 01:05:14 christos Exp $ | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 1989, 1990, 1993 | 3 | .\" Copyright (c) 1989, 1990, 1993 | |
4 | .\" The Regents of the University of California. All rights reserved. | 4 | .\" The Regents of the University of California. All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" Redistribution and use in source and binary forms, with or without | 6 | .\" Redistribution and use in source and binary forms, with or without | |
7 | .\" modification, are permitted provided that the following conditions | 7 | .\" modification, are permitted provided that the following conditions | |
8 | .\" are met: | 8 | .\" are met: | |
9 | .\" 1. Redistributions of source code must retain the above copyright | 9 | .\" 1. Redistributions of source code must retain the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer. | 10 | .\" notice, this list of conditions and the following disclaimer. | |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | 11 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
12 | .\" notice, this list of conditions and the following disclaimer in the | 12 | .\" notice, this list of conditions and the following disclaimer in the | |
13 | .\" documentation and/or other materials provided with the distribution. | 13 | .\" documentation and/or other materials provided with the distribution. | |
14 | .\" 3. Neither the name of the University nor the names of its contributors | 14 | .\" 3. Neither the name of the University nor the names of its contributors | |
@@ -220,26 +220,32 @@ from | @@ -220,26 +220,32 @@ from | |||
220 | rather than using the results from the system's | 220 | rather than using the results from the system's | |
221 | .Xr getpwnam 3 | 221 | .Xr getpwnam 3 | |
222 | and | 222 | and | |
223 | .Xr getgrnam 3 | 223 | .Xr getgrnam 3 | |
224 | (and related) library calls. | 224 | (and related) library calls. | |
225 | .It Fl P | 225 | .It Fl P | |
226 | Don't follow symbolic links in the file hierarchy, instead consider | 226 | Don't follow symbolic links in the file hierarchy, instead consider | |
227 | the symbolic link itself in any comparisons. | 227 | the symbolic link itself in any comparisons. | |
228 | This is the default. | 228 | This is the default. | |
229 | .It Fl p Ar path | 229 | .It Fl p Ar path | |
230 | Use the file hierarchy rooted in | 230 | Use the file hierarchy rooted in | |
231 | .Ar path , | 231 | .Ar path , | |
232 | instead of the current directory. | 232 | instead of the current directory. | |
233 | .It Fl q | |||
234 | Quiet mode. | |||
235 | Do not complain when a | |||
236 | .Dq missing | |||
237 | directory cannot be created because it already exists. | |||
238 | This occurs when the directory is a symbolic link. | |||
233 | .It Fl R Ar keywords | 239 | .It Fl R Ar keywords | |
234 | Remove the specified (whitespace or comma separated) keywords from the current | 240 | Remove the specified (whitespace or comma separated) keywords from the current | |
235 | set of keywords. | 241 | set of keywords. | |
236 | If | 242 | If | |
237 | .Ql all | 243 | .Ql all | |
238 | is specified, remove all of the other keywords. | 244 | is specified, remove all of the other keywords. | |
239 | .It Fl r | 245 | .It Fl r | |
240 | Remove any files in the file hierarchy that are not described in the | 246 | Remove any files in the file hierarchy that are not described in the | |
241 | specification. | 247 | specification. | |
242 | .It Fl S | 248 | .It Fl S | |
243 | When reading a specification into an internal data structure, | 249 | When reading a specification into an internal data structure, | |
244 | sort the entries. | 250 | sort the entries. | |
245 | Sorting will affect the order of the output produced by the | 251 | Sorting will affect the order of the output produced by the |
--- src/usr.sbin/mtree/mtree.c 2012/10/05 01:01:07 1.38
+++ src/usr.sbin/mtree/mtree.c 2012/10/05 01:05:14 1.39
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: mtree.c,v 1.38 2012/10/05 01:01:07 christos Exp $ */ | 1 | /* $NetBSD: mtree.c,v 1.39 2012/10/05 01:05:14 christos Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1989, 1990, 1993 | 4 | * Copyright (c) 1989, 1990, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -33,61 +33,61 @@ | @@ -33,61 +33,61 @@ | |||
33 | #include "nbtool_config.h" | 33 | #include "nbtool_config.h" | |
34 | #endif | 34 | #endif | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | #if defined(__COPYRIGHT) && !defined(lint) | 37 | #if defined(__COPYRIGHT) && !defined(lint) | |
38 | __COPYRIGHT("@(#) Copyright (c) 1989, 1990, 1993\ | 38 | __COPYRIGHT("@(#) Copyright (c) 1989, 1990, 1993\ | |
39 | The Regents of the University of California. All rights reserved."); | 39 | The Regents of the University of California. All rights reserved."); | |
40 | #endif /* not lint */ | 40 | #endif /* not lint */ | |
41 | 41 | |||
42 | #if defined(__RCSID) && !defined(lint) | 42 | #if defined(__RCSID) && !defined(lint) | |
43 | #if 0 | 43 | #if 0 | |
44 | static char sccsid[] = "@(#)mtree.c 8.1 (Berkeley) 6/6/93"; | 44 | static char sccsid[] = "@(#)mtree.c 8.1 (Berkeley) 6/6/93"; | |
45 | #else | 45 | #else | |
46 | __RCSID("$NetBSD: mtree.c,v 1.38 2012/10/05 01:01:07 christos Exp $"); | 46 | __RCSID("$NetBSD: mtree.c,v 1.39 2012/10/05 01:05:14 christos Exp $"); | |
47 | #endif | 47 | #endif | |
48 | #endif /* not lint */ | 48 | #endif /* not lint */ | |
49 | 49 | |||
50 | #include <sys/param.h> | 50 | #include <sys/param.h> | |
51 | #include <sys/stat.h> | 51 | #include <sys/stat.h> | |
52 | 52 | |||
53 | #include <errno.h> | 53 | #include <errno.h> | |
54 | #include <stdio.h> | 54 | #include <stdio.h> | |
55 | #include <stdlib.h> | 55 | #include <stdlib.h> | |
56 | #include <string.h> | 56 | #include <string.h> | |
57 | #include <unistd.h> | 57 | #include <unistd.h> | |
58 | 58 | |||
59 | #include "extern.h" | 59 | #include "extern.h" | |
60 | 60 | |||
61 | int ftsoptions = FTS_PHYSICAL; | 61 | int ftsoptions = FTS_PHYSICAL; | |
62 | int cflag, Cflag, dflag, Dflag, eflag, iflag, lflag, mflag, | 62 | int cflag, Cflag, dflag, Dflag, eflag, iflag, lflag, mflag, | |
63 | nflag, rflag, sflag, tflag, uflag, Uflag; | 63 | nflag, qflag, rflag, sflag, tflag, uflag, Uflag; | |
64 | char fullpath[MAXPATHLEN]; | 64 | char fullpath[MAXPATHLEN]; | |
65 | 65 | |||
66 | __dead static void usage(void); | 66 | __dead static void usage(void); | |
67 | 67 | |||
68 | int | 68 | int | |
69 | main(int argc, char **argv) | 69 | main(int argc, char **argv) | |
70 | { | 70 | { | |
71 | int ch, status; | 71 | int ch, status; | |
72 | char *dir, *p; | 72 | char *dir, *p; | |
73 | 73 | |||
74 | setprogname(argv[0]); | 74 | setprogname(argv[0]); | |
75 | 75 | |||
76 | dir = NULL; | 76 | dir = NULL; | |
77 | init_excludes(); | 77 | init_excludes(); | |
78 | 78 | |||
79 | while ((ch = getopt(argc, argv, | 79 | while ((ch = getopt(argc, argv, | |
80 | "cCdDeE:f:I:ik:K:lLmMnN:p:PrR:s:StuUWxX:")) | 80 | "cCdDeE:f:I:ik:K:lLmMnN:p:PqrR:s:StuUWxX:")) | |
81 | != -1) { | 81 | != -1) { | |
82 | switch((char)ch) { | 82 | switch((char)ch) { | |
83 | case 'c': | 83 | case 'c': | |
84 | cflag = 1; | 84 | cflag = 1; | |
85 | break; | 85 | break; | |
86 | case 'C': | 86 | case 'C': | |
87 | Cflag = 1; | 87 | Cflag = 1; | |
88 | break; | 88 | break; | |
89 | case 'd': | 89 | case 'd': | |
90 | dflag = 1; | 90 | dflag = 1; | |
91 | break; | 91 | break; | |
92 | case 'D': | 92 | case 'D': | |
93 | Dflag = 1; | 93 | Dflag = 1; | |
@@ -138,26 +138,29 @@ main(int argc, char **argv) | @@ -138,26 +138,29 @@ main(int argc, char **argv) | |||
138 | case 'N': | 138 | case 'N': | |
139 | if (! setup_getid(optarg)) | 139 | if (! setup_getid(optarg)) | |
140 | mtree_err( | 140 | mtree_err( | |
141 | "Unable to use user and group databases in `%s'", | 141 | "Unable to use user and group databases in `%s'", | |
142 | optarg); | 142 | optarg); | |
143 | break; | 143 | break; | |
144 | case 'p': | 144 | case 'p': | |
145 | dir = optarg; | 145 | dir = optarg; | |
146 | break; | 146 | break; | |
147 | case 'P': | 147 | case 'P': | |
148 | ftsoptions &= ~FTS_LOGICAL; | 148 | ftsoptions &= ~FTS_LOGICAL; | |
149 | ftsoptions |= FTS_PHYSICAL; | 149 | ftsoptions |= FTS_PHYSICAL; | |
150 | break; | 150 | break; | |
151 | case 'q': | |||
152 | qflag = 1; | |||
153 | break; | |||
151 | case 'r': | 154 | case 'r': | |
152 | rflag = 1; | 155 | rflag = 1; | |
153 | break; | 156 | break; | |
154 | case 'R': | 157 | case 'R': | |
155 | while ((p = strsep(&optarg, " \t,")) != NULL) | 158 | while ((p = strsep(&optarg, " \t,")) != NULL) | |
156 | if (*p != '\0') | 159 | if (*p != '\0') | |
157 | keys &= ~parsekey(p, NULL); | 160 | keys &= ~parsekey(p, NULL); | |
158 | break; | 161 | break; | |
159 | case 's': | 162 | case 's': | |
160 | sflag = 1; | 163 | sflag = 1; | |
161 | crc_total = ~strtol(optarg, &p, 0); | 164 | crc_total = ~strtol(optarg, &p, 0); | |
162 | if (*p) | 165 | if (*p) | |
163 | mtree_err("illegal seed value -- %s", optarg); | 166 | mtree_err("illegal seed value -- %s", optarg); |
--- src/usr.sbin/mtree/verify.c 2012/03/25 16:07:04 1.40
+++ src/usr.sbin/mtree/verify.c 2012/10/05 01:05:14 1.41
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: verify.c,v 1.40 2012/03/25 16:07:04 christos Exp $ */ | 1 | /* $NetBSD: verify.c,v 1.41 2012/10/05 01:05:14 christos Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1990, 1993 | 4 | * Copyright (c) 1990, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -28,27 +28,27 @@ | @@ -28,27 +28,27 @@ | |||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #if HAVE_NBTOOL_CONFIG_H | 32 | #if HAVE_NBTOOL_CONFIG_H | |
33 | #include "nbtool_config.h" | 33 | #include "nbtool_config.h" | |
34 | #endif | 34 | #endif | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | #if defined(__RCSID) && !defined(lint) | 37 | #if defined(__RCSID) && !defined(lint) | |
38 | #if 0 | 38 | #if 0 | |
39 | static char sccsid[] = "@(#)verify.c 8.1 (Berkeley) 6/6/93"; | 39 | static char sccsid[] = "@(#)verify.c 8.1 (Berkeley) 6/6/93"; | |
40 | #else | 40 | #else | |
41 | __RCSID("$NetBSD: verify.c,v 1.40 2012/03/25 16:07:04 christos Exp $"); | 41 | __RCSID("$NetBSD: verify.c,v 1.41 2012/10/05 01:05:14 christos Exp $"); | |
42 | #endif | 42 | #endif | |
43 | #endif /* not lint */ | 43 | #endif /* not lint */ | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/stat.h> | 46 | #include <sys/stat.h> | |
47 | 47 | |||
48 | #if ! HAVE_NBTOOL_CONFIG_H | 48 | #if ! HAVE_NBTOOL_CONFIG_H | |
49 | #include <dirent.h> | 49 | #include <dirent.h> | |
50 | #endif | 50 | #endif | |
51 | 51 | |||
52 | #include <errno.h> | 52 | #include <errno.h> | |
53 | #include <fnmatch.h> | 53 | #include <fnmatch.h> | |
54 | #include <stdio.h> | 54 | #include <stdio.h> | |
@@ -165,28 +165,37 @@ static void | @@ -165,28 +165,37 @@ static void | |||
165 | miss(NODE *p, char *tail) | 165 | miss(NODE *p, char *tail) | |
166 | { | 166 | { | |
167 | int create; | 167 | int create; | |
168 | char *tp; | 168 | char *tp; | |
169 | const char *type; | 169 | const char *type; | |
170 | u_int32_t flags; | 170 | u_int32_t flags; | |
171 | 171 | |||
172 | for (; p; p = p->next) { | 172 | for (; p; p = p->next) { | |
173 | if (p->flags & F_OPT && !(p->flags & F_VISIT)) | 173 | if (p->flags & F_OPT && !(p->flags & F_VISIT)) | |
174 | continue; | 174 | continue; | |
175 | if (p->type != F_DIR && (dflag || p->flags & F_VISIT)) | 175 | if (p->type != F_DIR && (dflag || p->flags & F_VISIT)) | |
176 | continue; | 176 | continue; | |
177 | strcpy(tail, p->name); | 177 | strcpy(tail, p->name); | |
178 | if (!(p->flags & F_VISIT)) | 178 | if (!(p->flags & F_VISIT)) { | |
179 | printf("missing: %s", path); | 179 | /* Don't print missing message if file exists as a | |
180 | symbolic link and the -q flag is set. */ | |||
181 | struct stat statbuf; | |||
182 | ||||
183 | if (qflag && stat(path, &statbuf) == 0 && | |||
184 | S_ISDIR(statbuf.st_mode)) | |||
185 | p->flags |= F_VISIT; | |||
186 | else | |||
187 | (void)printf("%s missing", path); | |||
188 | } | |||
180 | switch (p->type) { | 189 | switch (p->type) { | |
181 | case F_BLOCK: | 190 | case F_BLOCK: | |
182 | case F_CHAR: | 191 | case F_CHAR: | |
183 | type = "device"; | 192 | type = "device"; | |
184 | break; | 193 | break; | |
185 | case F_DIR: | 194 | case F_DIR: | |
186 | type = "directory"; | 195 | type = "directory"; | |
187 | break; | 196 | break; | |
188 | case F_LINK: | 197 | case F_LINK: | |
189 | type = "symlink"; | 198 | type = "symlink"; | |
190 | break; | 199 | break; | |
191 | default: | 200 | default: | |
192 | putchar('\n'); | 201 | putchar('\n'); |