diff options
author | Maxim Konovalov <maxim@FreeBSD.org> | 2006-07-03 10:55:22 +0000 |
---|---|---|
committer | Maxim Konovalov <maxim@FreeBSD.org> | 2006-07-03 10:55:22 +0000 |
commit | 190483c011ae0071bcf5d298c1dba722574cb318 (patch) | |
tree | 35c89a96671ac41a2996c77c3f64e00872f36eae /usr.sbin/mtree | |
parent | 1684fc165728f428b4dee60799c10bbe7d9a83ea (diff) | |
download | src-190483c011ae0071bcf5d298c1dba722574cb318.tar.gz src-190483c011ae0071bcf5d298c1dba722574cb318.zip |
o Add an 'optional' keyword, which allows files to be in the
specification, but not in the file hierarchy.
PR: bin/99531
Submitted by: skv
Obtained from: NetBSD, originally from Ed Symanzik
Regress. test: test/test05.sh
MFC after: 1 month
Notes
Notes:
svn path=/head/; revision=160083
Diffstat (limited to 'usr.sbin/mtree')
-rw-r--r-- | usr.sbin/mtree/misc.c | 1 | ||||
-rw-r--r-- | usr.sbin/mtree/mtree.8 | 5 | ||||
-rw-r--r-- | usr.sbin/mtree/mtree.h | 1 | ||||
-rw-r--r-- | usr.sbin/mtree/spec.c | 3 | ||||
-rw-r--r-- | usr.sbin/mtree/test/test05.sh | 25 | ||||
-rw-r--r-- | usr.sbin/mtree/verify.c | 2 |
6 files changed, 36 insertions, 1 deletions
diff --git a/usr.sbin/mtree/misc.c b/usr.sbin/mtree/misc.c index 8f5344e68401..65667d601138 100644 --- a/usr.sbin/mtree/misc.c +++ b/usr.sbin/mtree/misc.c @@ -66,6 +66,7 @@ static KEY keylist[] = { {"mode", F_MODE, NEEDVALUE}, {"nlink", F_NLINK, NEEDVALUE}, {"nochange", F_NOCHANGE, 0}, + {"optional", F_OPT, 0}, #ifdef RMD160 {"ripemd160digest", F_RMD160, NEEDVALUE}, #endif diff --git a/usr.sbin/mtree/mtree.8 b/usr.sbin/mtree/mtree.8 index 371aab039efe..1ee6be39c37a 100644 --- a/usr.sbin/mtree/mtree.8 +++ b/usr.sbin/mtree/mtree.8 @@ -28,7 +28,7 @@ .\" From: @(#)mtree.8 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd March 29, 2005 +.Dd July 03, 2006 .Dt MTREE 8 .Os .Sh NAME @@ -221,6 +221,9 @@ value. The number of hard links the file is expected to have. .It Cm nochange Make sure this file or directory exists but otherwise ignore all attributes. +.It Cm optional +The file is optional; do not complain about the file if it is +not in the file hierarchy. .It Cm uid The file owner as a numeric value. .It Cm uname diff --git a/usr.sbin/mtree/mtree.h b/usr.sbin/mtree/mtree.h index b0d5415cdc4c..fb22f0d62370 100644 --- a/usr.sbin/mtree/mtree.h +++ b/usr.sbin/mtree/mtree.h @@ -78,6 +78,7 @@ typedef struct _node { #define F_RMD160 0x40000 /* RIPEMD160 digest */ #define F_FLAGS 0x80000 /* file flags */ #define F_SHA256 0x100000 /* SHA-256 digest */ +#define F_OPT 0x200000 /* existence optional */ u_int flags; /* items set */ #define F_BLOCK 0x001 /* block special */ diff --git a/usr.sbin/mtree/spec.c b/usr.sbin/mtree/spec.c index ed9431692c73..cb86f94c4f6a 100644 --- a/usr.sbin/mtree/spec.c +++ b/usr.sbin/mtree/spec.c @@ -236,6 +236,9 @@ set(char *t, NODE *ip) errx(1, "line %d: invalid link count %s", lineno, val); break; + case F_OPT: + /* just set flag bit */ + break; case F_SIZE: ip->st_size = strtoq(val, &ep, 10); if (*ep) diff --git a/usr.sbin/mtree/test/test05.sh b/usr.sbin/mtree/test/test05.sh new file mode 100644 index 000000000000..eda544f4ff36 --- /dev/null +++ b/usr.sbin/mtree/test/test05.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# +# $FreeBSD$ +# +# Test for 'optional' keyword. +# + +TMP=`mktemp -d /tmp/mtree.XXXXXX` +mkdir -p ${TMP}/mr ${TMP}/mr/optional-dir ${TMP}/mr/some-dir +touch ${TMP}/mr/optional-file ${TMP}/mr/some-file + +mtree -c -p ${TMP}/mr > ${TMP}/_ +rm -rf ${TMP}/mr/optional-file ${TMP}/mr/optional-dir +mtree -p ${TMP}/mr -K optional < ${TMP}/_ > /dev/null + +res=$? + +if [ $res -ne 0 ] ; then + echo "ERROR 'optional' keyword failed" 1>&2 + rm -rf ${TMP} + exit 1 +fi + +rm -rf ${TMP} +exit 0 diff --git a/usr.sbin/mtree/verify.c b/usr.sbin/mtree/verify.c index cc31ea4e3323..7078dbeca678 100644 --- a/usr.sbin/mtree/verify.c +++ b/usr.sbin/mtree/verify.c @@ -158,6 +158,8 @@ miss(NODE *p, char *tail) int serr; for (; p; p = p->next) { + if (p->flags & F_OPT && !(p->flags & F_VISIT)) + continue; if (p->type != F_DIR && (dflag || p->flags & F_VISIT)) continue; (void)strcpy(tail, p->name); |