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 -W: don't attempt to change the perms/tim...
details: https://anonhg.NetBSD.org/src/rev/617d96f35b2e
branches: trunk
changeset: 516594:617d96f35b2e
user: lukem <lukem%NetBSD.org@localhost>
date: Thu Oct 25 14:47:39 2001 +0000
description:
Add -W: don't attempt to change the perms/time/flags on existing entries, nor
set them when creating new directories. (AKA the ``don't whack'' option).
Concept suggested by Todd Vierling.
diffstat:
usr.sbin/mtree/compare.c | 12 ++++++++++--
usr.sbin/mtree/extern.h | 3 ++-
usr.sbin/mtree/mtree.8 | 19 ++++++++++++++-----
usr.sbin/mtree/mtree.c | 13 ++++++++-----
usr.sbin/mtree/verify.c | 12 ++++++++----
5 files changed, 42 insertions(+), 17 deletions(-)
diffs (212 lines):
diff -r 1cd06216cd2f -r 617d96f35b2e usr.sbin/mtree/compare.c
--- a/usr.sbin/mtree/compare.c Thu Oct 25 14:46:41 2001 +0000
+++ b/usr.sbin/mtree/compare.c Thu Oct 25 14:47:39 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compare.c,v 1.32 2001/10/22 07:07:46 lukem Exp $ */
+/* $NetBSD: compare.c,v 1.33 2001/10/25 14:47:39 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.32 2001/10/22 07:07:46 lukem Exp $");
+__RCSID("$NetBSD: compare.c,v 1.33 2001/10/25 14:47:39 lukem Exp $");
#endif
#endif /* not lint */
@@ -151,6 +151,8 @@
}
break;
}
+ if (Wflag)
+ goto afterpermwhack;
if (iflag && !uflag) {
if (s->flags & F_FLAGS)
SETFLAGS(p->fts_accpath, s->st_flags,
@@ -333,6 +335,12 @@
(void)printf(")\n");
tab = "\t";
}
+
+ /*
+ * from this point, no more permission checking or whacking
+ * occurs, only checking of stuff like checksums and symlinks.
+ */
+ afterpermwhack:
if (s->flags & F_CKSUM) {
if ((fd = open(p->fts_accpath, O_RDONLY, 0)) < 0) {
LABEL;
diff -r 1cd06216cd2f -r 617d96f35b2e usr.sbin/mtree/extern.h
--- a/usr.sbin/mtree/extern.h Thu Oct 25 14:46:41 2001 +0000
+++ b/usr.sbin/mtree/extern.h Thu Oct 25 14:47:39 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.16 2001/10/25 03:00:14 lukem Exp $ */
+/* $NetBSD: extern.h,v 1.17 2001/10/25 14:47:39 lukem Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -53,6 +53,7 @@
int verify(void);
extern int dflag, eflag, iflag, lflag, mflag, rflag, sflag, tflag, uflag;
+extern int Wflag;
extern size_t lineno;
extern int crc_total, ftsoptions, keys;
extern char fullpath[];
diff -r 1cd06216cd2f -r 617d96f35b2e usr.sbin/mtree/mtree.8
--- a/usr.sbin/mtree/mtree.8 Thu Oct 25 14:46:41 2001 +0000
+++ b/usr.sbin/mtree/mtree.8 Thu Oct 25 14:47:39 2001 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: mtree.8,v 1.25 2001/10/22 07:11:46 lukem Exp $
+.\" $NetBSD: mtree.8,v 1.26 2001/10/25 14:47:39 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 22, 2001
+.Dd October 26, 2001
.Dt MTREE 8
.Os
.Sh NAME
@@ -41,7 +41,7 @@
.Nd map a directory hierarchy
.Sh SYNOPSIS
.Nm ""
-.Op Fl cdDelrUux
+.Op Fl cdDelrUuWx
.Bk -words
.Op Fl i | Fl m
.Ek
@@ -195,6 +195,14 @@
.Fl U
except a status of 2 is returned if the file hierarchy did not match
the specification.
+.It Fl W
+Don't attempt to set various file attributes such as the
+ownership, mode, flags, or time
+when creating new directories or changing existing entries.
+This option will be most useful when used in conjunction with
+.Fl u
+or
+.Fl U .
.It Fl x
Don't descend below mount points in the file hierarchy.
.El
@@ -528,8 +536,9 @@
.Fl l ,
.Fl D ,
.Fl E ,
-.Fl I
+.Fl I ,
+.Fl R ,
and
-.Fl R
+.Fl W
flags, and support for full paths appeared in
.Nx 1.6 .
diff -r 1cd06216cd2f -r 617d96f35b2e usr.sbin/mtree/mtree.c
--- a/usr.sbin/mtree/mtree.c Thu Oct 25 14:46:41 2001 +0000
+++ b/usr.sbin/mtree/mtree.c Thu Oct 25 14:47:39 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mtree.c,v 1.21 2001/10/22 07:07:46 lukem Exp $ */
+/* $NetBSD: mtree.c,v 1.22 2001/10/25 14:47:39 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.21 2001/10/22 07:07:46 lukem Exp $");
+__RCSID("$NetBSD: mtree.c,v 1.22 2001/10/25 14:47:39 lukem Exp $");
#endif
#endif /* not lint */
@@ -62,7 +62,7 @@
int ftsoptions = FTS_PHYSICAL;
int cflag, dflag, Dflag, eflag, iflag, lflag, mflag,
- rflag, sflag, tflag, uflag, Uflag;
+ rflag, sflag, tflag, uflag, Uflag, Wflag;
char fullpath[MAXPATHLEN];
int main(int, char **);
@@ -77,7 +77,7 @@
setprogname(argv[0]);
dir = NULL;
- while ((ch = getopt(argc, argv, "cdDeE:f:I:iK:k:lmp:rR:s:tUux")) != -1)
+ while ((ch = getopt(argc, argv, "cdDeE:f:I:iK:k:lmp:rR:s:tUuWx")) != -1)
switch((char)ch) {
case 'c':
cflag = 1;
@@ -147,6 +147,9 @@
case 'u':
uflag = 1;
break;
+ case 'W':
+ Wflag = 1;
+ break;
case 'x':
ftsoptions |= FTS_XDEV;
break;
@@ -193,7 +196,7 @@
usage(void)
{
- (void)fprintf(stderr, "usage: mtree [-cdDelrUux] [-i|-m] [-f spec]"
+ (void)fprintf(stderr, "usage: mtree [-cdDelrUuWx] [-i|-m] [-f spec]"
" [-k key] [-K addkey] [-R removekey]\n"
"\t\t[-I inctags] [-E exctags] [-p path] [-s seed]\n");
exit(1);
diff -r 1cd06216cd2f -r 617d96f35b2e usr.sbin/mtree/verify.c
--- a/usr.sbin/mtree/verify.c Thu Oct 25 14:46:41 2001 +0000
+++ b/usr.sbin/mtree/verify.c Thu Oct 25 14:47:39 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: verify.c,v 1.22 2001/10/22 07:07:46 lukem Exp $ */
+/* $NetBSD: verify.c,v 1.23 2001/10/25 14:47:39 lukem 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.22 2001/10/22 07:07:46 lukem Exp $");
+__RCSID("$NetBSD: verify.c,v 1.23 2001/10/25 14:47:39 lukem Exp $");
#endif
#endif /* not lint */
@@ -172,13 +172,17 @@
create = 0;
if (!(p->flags & F_VISIT) && uflag) {
+ if (Wflag)
+ goto makeit;
if (!(p->flags & (F_UID | F_UNAME)))
(void)printf(" (not created: user not specified)");
else if (!(p->flags & (F_GID | F_GNAME)))
(void)printf(" (not created: group not specified)");
else if (!(p->flags & F_MODE))
(void)printf(" (not created: mode not specified)");
- else if (mkdir(path, S_IRWXU))
+ else
+ makeit:
+ if (mkdir(path, S_IRWXU))
(void)printf(" (not created: %s)",
strerror(errno));
else {
@@ -195,7 +199,7 @@
miss(p->child, tp + 1);
*tp = '\0';
- if (!create)
+ if (!create || Wflag)
continue;
/* XXXLUKEM: what about devices? */
if (chown(path, p->st_uid, p->st_gid)) {
Home |
Main Index |
Thread Index |
Old Index