From skv@FreeBSD.org  Tue Jun 27 07:22:55 2006
Return-Path: <skv@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 25D1616A403
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 27 Jun 2006 07:22:55 +0000 (UTC)
	(envelope-from skv@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by mx1.FreeBSD.org (Postfix) with ESMTP id CA70F445C2
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 27 Jun 2006 07:22:54 +0000 (GMT)
	(envelope-from skv@FreeBSD.org)
Received: from freefall.freebsd.org (skv@localhost [127.0.0.1])
	by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k5R7MsUk033480
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 27 Jun 2006 07:22:54 GMT
	(envelope-from skv@freefall.freebsd.org)
Received: (from skv@localhost)
	by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k5R7MsDC033479;
	Tue, 27 Jun 2006 07:22:54 GMT
	(envelope-from skv)
Message-Id: <200606270722.k5R7MsDC033479@freefall.freebsd.org>
Date: Tue, 27 Jun 2006 07:22:54 GMT
From: skv@freebsd.org
Reply-To: skv@freebsd.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: [patch] mtree: import "optional" keyword from NetBSD
X-Send-Pr-Version: 3.2

>Number:         99531
>Category:       bin
>Synopsis:       [patch] mtree: import "optional" keyword from NetBSD
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    maxim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 27 07:30:18 GMT 2006
>Closed-Date:    Fri Jul 28 16:33:58 GMT 2006
>Last-Modified:  Fri Nov 24 20:00:28 GMT 2006
>Originator:     Sergey Skvortsov
>Release:        FreeBSD 6.1-STABLE i386
>Organization:
<Organization of PR author (multiple lines)>
>Environment:

>Description:

Import very useful "optional" keyword:

http://netbsd.gw.com/cgi-bin/man-cgi?mtree++NetBSD-current

>How-To-Repeat:

>Fix:

Index: misc.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/mtree/misc.c,v
retrieving revision 1.16
diff -u -r1.16 misc.c
--- misc.c	29 Mar 2005 11:44:17 -0000	1.16
+++ misc.c	27 Jun 2006 06:57:36 -0000
@@ -66,6 +66,7 @@
 	{"mode",	F_MODE,		NEEDVALUE},
 	{"nlink",	F_NLINK,	NEEDVALUE},
 	{"nochange",	F_NOCHANGE,	0},
+	{"optional",	F_OPT,		0},
 #ifdef RMD160
 	{"ripemd160digest", F_RMD160,	NEEDVALUE},
 #endif
Index: mtree.8
===================================================================
RCS file: /home/ncvs/src/usr.sbin/mtree/mtree.8,v
retrieving revision 1.53
diff -u -r1.53 mtree.8
--- mtree.8	31 Jul 2005 03:30:47 -0000	1.53
+++ mtree.8	27 Jun 2006 06:53:30 -0000
@@ -221,6 +221,9 @@
 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 Sy optional
+The file is optional; don't complain about the file if it's
+not in the file hierarchy.
 .It Cm uid
 The file owner as a numeric value.
 .It Cm uname
Index: mtree.h
===================================================================
RCS file: /home/ncvs/src/usr.sbin/mtree/mtree.h,v
retrieving revision 1.7
diff -u -r1.7 mtree.h
--- mtree.h	29 Mar 2005 11:44:17 -0000	1.7
+++ mtree.h	27 Jun 2006 06:56:36 -0000
@@ -78,6 +78,7 @@
 #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 */
Index: spec.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/mtree/spec.c,v
retrieving revision 1.22
diff -u -r1.22 spec.c
--- spec.c	29 Mar 2005 11:44:17 -0000	1.22
+++ spec.c	27 Jun 2006 07:02:42 -0000
@@ -236,6 +236,9 @@
 				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)
Index: verify.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/mtree/verify.c,v
retrieving revision 1.24
diff -u -r1.24 verify.c
--- verify.c	11 Aug 2005 15:43:55 -0000	1.24
+++ verify.c	27 Jun 2006 07:00:48 -0000
@@ -158,6 +158,8 @@
 	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);
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: maxim 
State-Changed-When: Mon Jul 3 11:01:17 UTC 2006 
State-Changed-Why:  
Committed to HEAD.  Thanks! 


Responsible-Changed-From-To: freebsd-bugs->maxim 
Responsible-Changed-By: maxim 
Responsible-Changed-When: Mon Jul 3 11:01:17 UTC 2006 
Responsible-Changed-Why:  
MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99531 
State-Changed-From-To: patched->closed 
State-Changed-By: maxim 
State-Changed-When: Fri Jul 28 16:33:42 UTC 2006 
State-Changed-Why:  
Merged to RELENG_6. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99531 

From: Ulrich Spoerlein <uspoerlein@gmail.com>
To: bug-followup@FreeBSD.org, skv@FreeBSD.org
Cc:  
Subject: Re: bin/99531: [patch] mtree: import "optional" keyword from NetBSD
Date: Fri, 24 Nov 2006 19:32:02 +0100

 The patch to misc.c has not been MFC'ed yet. Simply run the test05.sh on
 a RELENG_6 system. It will fail.
 
 Here's the necessary diff for RELENG_6
 
 Index: mtree/misc.c
 ===================================================================
 RCS file: /home/ncvs/src/usr.sbin/mtree/misc.c,v
 retrieving revision 1.16
 diff -u -p -r1.16 misc.c
 --- mtree/misc.c	29 Mar 2005 11:44:17 -0000	1.16
 +++ mtree/misc.c	24 Nov 2006 18:29:21 -0000
 @@ -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
 
 Ulrich Spoerlein

From: Maxim Konovalov <maxim@macomnet.ru>
To: Ulrich Spoerlein <uspoerlein@gmail.com>
Cc: skv@freebsd.org, bug-followup@freebsd.org
Subject: Re: bin/99531: [patch] mtree: import "optional" keyword from NetBSD
Date: Fri, 24 Nov 2006 22:59:20 +0300 (MSK)

 On Fri, 24 Nov 2006, 18:40-0000, Ulrich Spoerlein wrote:
 
 >  The patch to misc.c has not been MFC'ed yet. Simply run the test05.sh on
 >  a RELENG_6 system. It will fail.
 
 Fixed.  Thanks for spotting this.
 
 -- 
 Maxim Konovalov
>Unformatted:
