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
This commit is contained in:
parent
1684fc1657
commit
190483c011
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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)
|
||||
|
25
usr.sbin/mtree/test/test05.sh
Normal file
25
usr.sbin/mtree/test/test05.sh
Normal file
@ -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
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user