summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2002-03-04 19:56:39 +0000
committermillert <millert@openbsd.org>2002-03-04 19:56:39 +0000
commit7c3d69019b17bbca98a8df85ef63872b659c378f (patch)
tree7bd59566ef5f508f5ca491d2ab91c2e828ef023b
parentoff by one; thanks to joost@pine.nl (diff)
downloadwireguard-openbsd-7c3d69019b17bbca98a8df85ef63872b659c378f.tar.xz
wireguard-openbsd-7c3d69019b17bbca98a8df85ef63872b659c378f.zip
Add a 'preserve' flag to tell mtree not to change the attributes of
a file/directory. This is useful when you want to update children of a directory but not the parent.
-rw-r--r--usr.sbin/mtree/misc.c3
-rw-r--r--usr.sbin/mtree/mtree.84
-rw-r--r--usr.sbin/mtree/mtree.h43
-rw-r--r--usr.sbin/mtree/verify.c7
4 files changed, 31 insertions, 26 deletions
diff --git a/usr.sbin/mtree/misc.c b/usr.sbin/mtree/misc.c
index 66c5d0ad8c1..a8056c8de83 100644
--- a/usr.sbin/mtree/misc.c
+++ b/usr.sbin/mtree/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.11 2002/02/19 19:39:40 millert Exp $ */
+/* $OpenBSD: misc.c,v 1.12 2002/03/04 19:56:39 millert Exp $ */
/* $NetBSD: misc.c,v 1.4 1995/03/07 21:26:23 cgd Exp $ */
/*-
@@ -66,6 +66,7 @@ static KEY keylist[] = {
{"mode", F_MODE, NEEDVALUE},
{"nlink", F_NLINK, NEEDVALUE},
{"optional", F_OPT, 0},
+ {"preserve", F_PRESERVE, 0},
{"rmd160digest",F_RMD160, NEEDVALUE},
{"sha1digest", F_SHA1, NEEDVALUE},
{"size", F_SIZE, NEEDVALUE},
diff --git a/usr.sbin/mtree/mtree.8 b/usr.sbin/mtree/mtree.8
index fb417c43be3..b126cf8e1c9 100644
--- a/usr.sbin/mtree/mtree.8
+++ b/usr.sbin/mtree/mtree.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mtree.8,v 1.18 2001/10/01 16:48:18 jakob Exp $
+.\" $OpenBSD: mtree.8,v 1.19 2002/03/04 19:56:39 millert Exp $
.\" $NetBSD: mtree.8,v 1.4 1995/03/07 21:26:25 cgd Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
@@ -184,6 +184,8 @@ The number of hard links the file is expected to have.
.It Cm optional
The file is optional; don't complain about the file if it's
not in the file hierarchy.
+.It Cm preserve
+The file's attributes should be preserved; don't change owner, group, mode, etc.
.It Cm rmd160digest
The RIPEMD-160 message digest of the file.
.It Cm sha1digest
diff --git a/usr.sbin/mtree/mtree.h b/usr.sbin/mtree/mtree.h
index 7bcdf048b0d..a27c3297843 100644
--- a/usr.sbin/mtree/mtree.h
+++ b/usr.sbin/mtree/mtree.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mtree.h,v 1.7 2001/08/10 02:33:46 millert Exp $ */
+/* $OpenBSD: mtree.h,v 1.8 2002/03/04 19:56:39 millert Exp $ */
/* $NetBSD: mtree.h,v 1.7 1995/03/07 21:26:27 cgd Exp $ */
/*-
@@ -61,26 +61,27 @@ typedef struct _node {
nlink_t st_nlink; /* link count */
u_int32_t file_flags; /* file flags */
-#define F_CKSUM 0x00001 /* check sum */
-#define F_DONE 0x00002 /* directory done */
-#define F_GID 0x00004 /* gid */
-#define F_GNAME 0x00008 /* group name */
-#define F_IGN 0x00010 /* ignore */
-#define F_MAGIC 0x00020 /* name has magic chars */
-#define F_MD5 0x00040 /* MD5 digest */
-#define F_MODE 0x00080 /* mode */
-#define F_NLINK 0x00100 /* number of links */
-#define F_OPT 0x00200 /* existence optional */
-#define F_RMD160 0x00400 /* RIPEMD-160 digest */
-#define F_SHA1 0x00800 /* SHA-1 digest */
-#define F_SIZE 0x01000 /* size */
-#define F_SLINK 0x02000 /* link count */
-#define F_TIME 0x04000 /* modification time */
-#define F_TYPE 0x08000 /* file type */
-#define F_UID 0x10000 /* uid */
-#define F_UNAME 0x20000 /* user name */
-#define F_VISIT 0x40000 /* file visited */
-#define F_FLAGS 0x80000 /* file flags */
+#define F_CKSUM 0x000001 /* checksum */
+#define F_DONE 0x000002 /* directory done */
+#define F_GID 0x000004 /* gid */
+#define F_GNAME 0x000008 /* group name */
+#define F_IGN 0x000010 /* ignore */
+#define F_MAGIC 0x000020 /* name has magic chars */
+#define F_MD5 0x000040 /* MD5 digest */
+#define F_MODE 0x000080 /* mode */
+#define F_NLINK 0x000100 /* number of links */
+#define F_OPT 0x000200 /* existence optional */
+#define F_RMD160 0x000400 /* RIPEMD-160 digest */
+#define F_SHA1 0x000800 /* SHA-1 digest */
+#define F_SIZE 0x001000 /* size */
+#define F_SLINK 0x002000 /* link count */
+#define F_TIME 0x004000 /* modification time */
+#define F_TYPE 0x008000 /* file type */
+#define F_UID 0x010000 /* uid */
+#define F_UNAME 0x020000 /* user name */
+#define F_VISIT 0x040000 /* file visited */
+#define F_FLAGS 0x080000 /* file flags */
+#define F_PRESERVE 0x100000 /* preserve attributes */
u_int32_t flags; /* items set */
#define F_BLOCK 0x001 /* block special */
diff --git a/usr.sbin/mtree/verify.c b/usr.sbin/mtree/verify.c
index a29484b927b..f834c0b093e 100644
--- a/usr.sbin/mtree/verify.c
+++ b/usr.sbin/mtree/verify.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: verify.c,v 1.8 2002/02/16 21:28:05 millert Exp $ */
+/* $OpenBSD: verify.c,v 1.9 2002/03/04 19:56:39 millert Exp $ */
/* $NetBSD: verify.c,v 1.10 1995/03/07 21:26:28 cgd Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static const char sccsid[] = "@(#)verify.c 8.1 (Berkeley) 6/6/93";
#else
-static const char rcsid[] = "$OpenBSD: verify.c,v 1.8 2002/02/16 21:28:05 millert Exp $";
+static const char rcsid[] = "$OpenBSD: verify.c,v 1.9 2002/03/04 19:56:39 millert Exp $";
#endif
#endif /* not lint */
@@ -119,7 +119,8 @@ vwalk()
!fnmatch(ep->name, p->fts_name, FNM_PATHNAME)) ||
!strcmp(ep->name, p->fts_name)) {
ep->flags |= F_VISIT;
- if (compare(ep->name, ep, p))
+ if ((ep->flags & F_PRESERVE) == 0 &&
+ compare(ep->name, ep, p))
rval = MISMATCHEXIT;
if (ep->flags & F_IGN)
(void)fts_set(t, p, FTS_SKIP);