CVS commit: src/usr.sbin/mtree

2021-04-03 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Apr  3 13:37:18 UTC 2021

Modified Files:
src/usr.sbin/mtree: compare.c

Log Message:
Deal with the case when a device gets recreated (eg when mtree is called by
MAKEDEV) and the stat buffer contains information about the original device
before checking/setting the owner/group/mode of the new device file.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/usr.sbin/mtree/compare.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/compare.c
diff -u src/usr.sbin/mtree/compare.c:1.59 src/usr.sbin/mtree/compare.c:1.60
--- src/usr.sbin/mtree/compare.c:1.59	Thu Mar 18 20:02:18 2021
+++ src/usr.sbin/mtree/compare.c	Sat Apr  3 13:37:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: compare.c,v 1.59 2021/03/18 20:02:18 cheusov Exp $	*/
+/*	$NetBSD: compare.c,v 1.60 2021/04/03 13:37:18 simonb 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.59 2021/03/18 20:02:18 cheusov Exp $");
+__RCSID("$NetBSD: compare.c,v 1.60 2021/04/03 13:37:18 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -137,6 +137,7 @@ compare(NODE *s, FTSENT *p)
 {
 	uint32_t len, val, flags;
 	int fd, label;
+	bool was_unlinked;
 	const char *cp, *tab;
 #if !defined(NO_MD5) || !defined(NO_RMD160) || !defined(NO_SHA1) || !defined(NO_SHA2)
 	char *digestbuf;
@@ -144,6 +145,7 @@ compare(NODE *s, FTSENT *p)
 
 	tab = NULL;
 	label = 0;
+	was_unlinked = false;
 	switch(s->type) {
 	case F_BLOCK:
 		if (!S_ISBLK(p->fts_statp->st_mode))
@@ -210,19 +212,22 @@ typeerr:		LABEL;
 			  s->st_mode | nodetoino(s->type),
 			  s->st_rdev) == -1) ||
 			(lchown(p->fts_accpath, p->fts_statp->st_uid,
-			  p->fts_statp->st_gid) == -1) )
+			  p->fts_statp->st_gid) == -1) ) {
 printf(", not modified: %s%s\n",
 strerror(errno),
 flavor == F_FREEBSD9 ? "" : ")");
-			 else
+			} else {
 printf(", modified%s\n",
 flavor == F_FREEBSD9 ? "" : ")");
+was_unlinked = true;
+			}
 		} else
 			printf(")\n");
 		tab = "\t";
 	}
 	/* Set the uid/gid first, then set the mode. */
-	if (s->flags & (F_UID | F_UNAME) && s->st_uid != p->fts_statp->st_uid) {
+	if (s->flags & (F_UID | F_UNAME) &&
+	(was_unlinked || s->st_uid != p->fts_statp->st_uid)) {
 		LABEL;
 		printf(flavor == F_FREEBSD9 ?
 		"%suser expected %lu found %lu" : "%suser (%lu, %lu",
@@ -233,13 +238,15 @@ typeerr:		LABEL;
 strerror(errno),
 flavor == F_FREEBSD9 ? "" : ")");
 			else
-printf(", modified%s\n",
+printf(", modified%s%s\n",
+was_unlinked ? " by unlink" : "",
 flavor == F_FREEBSD9 ? "" : ")");
 		} else
 			printf(")\n");
 		tab = "\t";
 	}
-	if (s->flags & (F_GID | F_GNAME) && s->st_gid != p->fts_statp->st_gid) {
+	if (s->flags & (F_GID | F_GNAME) &&
+	(was_unlinked || s->st_gid != p->fts_statp->st_gid)) {
 		LABEL;
 		printf(flavor == F_FREEBSD9 ?
 		"%sgid expected %lu found %lu" : "%sgid (%lu, %lu",
@@ -250,7 +257,8 @@ typeerr:		LABEL;
 strerror(errno),
 flavor == F_FREEBSD9 ? "" : ")");
 			else
-printf(", modified%s\n",
+printf(", modified%s%s\n",
+was_unlinked ? " by unlink" : "",
 flavor == F_FREEBSD9 ? "" : ")");
 		}
 		else
@@ -258,8 +266,8 @@ typeerr:		LABEL;
 		tab = "\t";
 	}
 	if (s->flags & F_MODE &&
-	s->st_mode != (p->fts_statp->st_mode & MBITS)) {
-		if (lflag) {
+	(was_unlinked || s->st_mode != (p->fts_statp->st_mode & MBITS))) {
+		if (lflag && !was_unlinked) {
 			mode_t tmode, mode;
 
 			tmode = s->st_mode;
@@ -287,7 +295,8 @@ typeerr:		LABEL;
 strerror(errno),
 flavor == F_FREEBSD9 ? "" : ")");
 			else
-printf(", modified%s\n",
+printf(", modified%s%s\n",
+was_unlinked ? " by unlink" : "",
 flavor == F_FREEBSD9 ? "" : ")");
 		}
 		else



CVS commit: src/usr.sbin/mtree

2021-03-18 Thread Aleksey Cheusov
Module Name:src
Committed By:   cheusov
Date:   Thu Mar 18 20:02:19 UTC 2021

Modified Files:
src/usr.sbin/mtree: compare.c crc.c extern.h verify.c

Log Message:
mtree: use POSIX type uint32_t instead of u_int32_t


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/usr.sbin/mtree/compare.c
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/mtree/crc.c
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/mtree/extern.h
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/mtree/verify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/compare.c
diff -u src/usr.sbin/mtree/compare.c:1.58 src/usr.sbin/mtree/compare.c:1.59
--- src/usr.sbin/mtree/compare.c:1.58	Thu Nov 21 18:39:50 2013
+++ src/usr.sbin/mtree/compare.c	Thu Mar 18 20:02:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: compare.c,v 1.58 2013/11/21 18:39:50 christos Exp $	*/
+/*	$NetBSD: compare.c,v 1.59 2021/03/18 20:02:18 cheusov 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.58 2013/11/21 18:39:50 christos Exp $");
+__RCSID("$NetBSD: compare.c,v 1.59 2021/03/18 20:02:18 cheusov Exp $");
 #endif
 #endif /* not lint */
 
@@ -135,7 +135,7 @@ do {	\
 int
 compare(NODE *s, FTSENT *p)
 {
-	u_int32_t len, val, flags;
+	uint32_t len, val, flags;
 	int fd, label;
 	const char *cp, *tab;
 #if !defined(NO_MD5) || !defined(NO_RMD160) || !defined(NO_SHA1) || !defined(NO_SHA2)

Index: src/usr.sbin/mtree/crc.c
diff -u src/usr.sbin/mtree/crc.c:1.9 src/usr.sbin/mtree/crc.c:1.10
--- src/usr.sbin/mtree/crc.c:1.9	Fri Oct  5 00:40:51 2012
+++ src/usr.sbin/mtree/crc.c	Thu Mar 18 20:02:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: crc.c,v 1.9 2012/10/05 00:40:51 christos Exp $	*/
+/*	$NetBSD: crc.c,v 1.10 2021/03/18 20:02:18 cheusov Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)crc.c	8.1 (Berkeley) 6/17/93";
 #else
-__RCSID("$NetBSD: crc.c,v 1.9 2012/10/05 00:40:51 christos Exp $");
+__RCSID("$NetBSD: crc.c,v 1.10 2021/03/18 20:02:18 cheusov Exp $");
 #endif
 #endif /* not lint */
 
@@ -53,7 +53,7 @@ __RCSID("$NetBSD: crc.c,v 1.9 2012/10/05
 
 #include "extern.h"
 
-static const u_int32_t crctab[] = {
+static const uint32_t crctab[] = {
 	0x0,
 	0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
 	0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6,
@@ -114,15 +114,15 @@ static const u_int32_t crctab[] = {
  * locations to store the crc and the number of bytes read.  It returns 0 on
  * success and 1 on failure.  Errno is set on failure.
  */
-u_int32_t crc_total = ~0;		/* The crc over a number of files. */
+uint32_t crc_total = ~0;		/* The crc over a number of files. */
 
 int
-crc(int fd, u_int32_t *cval, u_int32_t *clen)
+crc(int fd, uint32_t *cval, uint32_t *clen)
 {
 	u_char *p;
 	int nr;
-	u_int32_t thecrc, len;
-	u_int32_t crctot;
+	uint32_t thecrc, len;
+	uint32_t crctot;
 	u_char buf[16 * 1024];
 
 #define	COMPUTE(var, ch)	(var) = (var) << 8 ^ crctab[(var) >> 24 ^ (ch)]

Index: src/usr.sbin/mtree/extern.h
diff -u src/usr.sbin/mtree/extern.h:1.39 src/usr.sbin/mtree/extern.h:1.40
--- src/usr.sbin/mtree/extern.h:1.39	Thu Apr 24 17:22:41 2014
+++ src/usr.sbin/mtree/extern.h	Thu Mar 18 20:02:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.39 2014/04/24 17:22:41 christos Exp $	*/
+/*	$NetBSD: extern.h,v 1.40 2021/03/18 20:02:18 cheusov Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -62,7 +62,7 @@ enum flavor {
 void	 addtag(slist_t *, char *);
 int	 check_excludes(const char *, const char *);
 int	 compare(NODE *, FTSENT *);
-int	 crc(int, u_int32_t *, u_int32_t *);
+int	 crc(int, uint32_t *, uint32_t *);
 void	 cwalk(FILE *);
 void	 dump_nodes(FILE *, const char *, NODE *, int);
 void	 init_excludes(void);
@@ -83,7 +83,7 @@ extern int	bflag, dflag, eflag, iflag, j
 extern int	mtree_Mflag, mtree_Sflag, mtree_Wflag;
 extern size_t	mtree_lineno;
 extern enum flavor	flavor;
-extern u_int32_t crc_total;
+extern uint32_t crc_total;
 extern int	ftsoptions, keys;
 extern char	fullpath[];
 extern slist_t	includetags, excludetags;

Index: src/usr.sbin/mtree/verify.c
diff -u src/usr.sbin/mtree/verify.c:1.46 src/usr.sbin/mtree/verify.c:1.47
--- src/usr.sbin/mtree/verify.c:1.46	Fri Jan 23 20:28:24 2015
+++ src/usr.sbin/mtree/verify.c	Thu Mar 18 20:02:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: verify.c,v 1.46 2015/01/23 20:28:24 christos Exp $	*/
+/*	$NetBSD: verify.c,v 1.47 2021/03/18 20:02:18 cheusov 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.46 2015/01/23 20:28:24 christos Exp $");
+__RCSID("$NetBSD: verify.c,v 1.47 2021/03/18 20:02:18 cheusov Exp $");
 #endif
 #endif /* not lint */
 
@@ -178,7 +178,7 @@ miss(NODE *p, char *tail)
 	int create;
 	char *tp;
 	const char 

CVS commit: src/usr.sbin/mtree

2020-06-16 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Jun 16 14:26:39 UTC 2020

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
Use more markup. Bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.75 src/usr.sbin/mtree/mtree.8:1.76
--- src/usr.sbin/mtree/mtree.8:1.75	Tue Jun 16 13:34:38 2020
+++ src/usr.sbin/mtree/mtree.8	Tue Jun 16 14:26:39 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mtree.8,v 1.75 2020/06/16 13:34:38 sborrill Exp $
+.\"	$NetBSD: mtree.8,v 1.76 2020/06/16 14:26:39 wiz Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -56,7 +56,7 @@
 .\"
 .\" @(#)mtree.8	8.2 (Berkeley) 12/11/93
 .\"
-.Dd January 22, 2015
+.Dd June 16, 2020
 .Dt MTREE 8
 .Os
 .Sh NAME
@@ -618,7 +618,9 @@ they match.
 .Nm
 uses
 .Xr strsvis 3
-(in VIS_OCTAL format) to encode path names containing
+(in
+.Dv VIS_OCTAL
+format) to encode path names containing
 non-printable characters.
 Whitespace characters are encoded as
 .Ql \e040
@@ -631,7 +633,9 @@ When flavor
 .Sy netbsd6
 is selected,
 .Xr strsvis 3
-(in VIS_CSTYLE format) is used and whitespace characters are encoded as
+(in
+.Dv VIS_CSTYLE
+format) is used and whitespace characters are encoded as
 .Ql \es
 (space),
 .Ql \et



CVS commit: src/usr.sbin/mtree

2020-06-16 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Tue Jun 16 13:34:38 UTC 2020

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
Describe correctly how whitespace is formatted as the docs did not
match the source.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.74 src/usr.sbin/mtree/mtree.8:1.75
--- src/usr.sbin/mtree/mtree.8:1.74	Thu Dec 13 07:34:03 2018
+++ src/usr.sbin/mtree/mtree.8	Tue Jun 16 13:34:38 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mtree.8,v 1.74 2018/12/13 07:34:03 wiz Exp $
+.\"	$NetBSD: mtree.8,v 1.75 2020/06/16 13:34:38 sborrill Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -618,9 +618,20 @@ they match.
 .Nm
 uses
 .Xr strsvis 3
-(in VIS_CSTYLE format) to encode path names containing
+(in VIS_OCTAL format) to encode path names containing
 non-printable characters.
 Whitespace characters are encoded as
+.Ql \e040
+(space),
+.Ql \e011
+(tab), and
+.Ql \e012
+(new line).
+When flavor
+.Sy netbsd6
+is selected,
+.Xr strsvis 3
+(in VIS_CSTYLE format) is used and whitespace characters are encoded as
 .Ql \es
 (space),
 .Ql \et



CVS commit: src/usr.sbin/mtree

2018-12-12 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Dec 13 07:34:03 UTC 2018

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
Use \(en.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.73 src/usr.sbin/mtree/mtree.8:1.74
--- src/usr.sbin/mtree/mtree.8:1.73	Thu Dec 13 03:18:18 2018
+++ src/usr.sbin/mtree/mtree.8	Thu Dec 13 07:34:03 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mtree.8,v 1.73 2018/12/13 03:18:18 dholland Exp $
+.\"	$NetBSD: mtree.8,v 1.74 2018/12/13 07:34:03 wiz Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -235,7 +235,7 @@ will match less stringent ones.
 For example, a file marked mode 0444
 will pass a check for mode 0644.
 .Dq Loose
-checks apply only to read, write and execute permissions -- in
+checks apply only to read, write and execute permissions \(em in
 particular, if other bits like the sticky bit or suid/sgid bits are
 set either in the specification or the file, exact checking will be
 performed.



CVS commit: src/usr.sbin/mtree

2018-12-12 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Thu Dec 13 03:18:18 UTC 2018

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
Fix naming inconsistency; PR 53769 from silas.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.72 src/usr.sbin/mtree/mtree.8:1.73
--- src/usr.sbin/mtree/mtree.8:1.72	Wed Feb 22 14:15:15 2017
+++ src/usr.sbin/mtree/mtree.8	Thu Dec 13 03:18:18 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mtree.8,v 1.72 2017/02/22 14:15:15 abhinav Exp $
+.\"	$NetBSD: mtree.8,v 1.73 2018/12/13 03:18:18 dholland Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -374,7 +374,7 @@ the starting directory); otherwise,
 it will be matched against basenames only.
 Comments are permitted in
 the
-.Ar exclude-list
+.Ar exclude-file
 file.
 .It Fl x
 Don't descend below mount points in the file hierarchy.



CVS commit: src/usr.sbin/mtree

2018-11-18 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sun Nov 18 23:03:36 UTC 2018

Modified Files:
src/usr.sbin/mtree: create.c

Log Message:
Adjust test, we only want to return the structure member if the result is not 
NULL.

Heads up by Sascha Wildner @ DragonFly BSD.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/usr.sbin/mtree/create.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.75 src/usr.sbin/mtree/create.c:1.76
--- src/usr.sbin/mtree/create.c:1.75	Sun Dec 31 03:04:44 2017
+++ src/usr.sbin/mtree/create.c	Sun Nov 18 23:03:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.75 2017/12/31 03:04:44 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.76 2018/11/18 23:03:36 sevan Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)create.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: create.c,v 1.75 2017/12/31 03:04:44 christos Exp $");
+__RCSID("$NetBSD: create.c,v 1.76 2018/11/18 23:03:36 sevan Exp $");
 #endif
 #endif /* not lint */
 
@@ -117,7 +117,7 @@ cwalk(FILE *fp)
 	host[sizeof(host) - 1] = '\0';
 	if ((user = getlogin()) == NULL) {
 		struct passwd *pw;
-		user = (pw = getpwuid(getuid())) == NULL ? pw->pw_name :
+		user = (pw = getpwuid(getuid())) != NULL ? pw->pw_name :
 		"";
 	}
 



CVS commit: src/usr.sbin/mtree

2017-12-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 31 03:04:44 UTC 2017

Modified Files:
src/usr.sbin/mtree: create.c

Log Message:
factor out common code from Poul-Henning Kamp.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/usr.sbin/mtree/create.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.74 src/usr.sbin/mtree/create.c:1.75
--- src/usr.sbin/mtree/create.c:1.74	Thu Dec 14 13:34:41 2017
+++ src/usr.sbin/mtree/create.c	Sat Dec 30 22:04:44 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.74 2017/12/14 18:34:41 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.75 2017/12/31 03:04:44 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)create.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: create.c,v 1.74 2017/12/14 18:34:41 christos Exp $");
+__RCSID("$NetBSD: create.c,v 1.75 2017/12/31 03:04:44 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -179,14 +179,58 @@ cwalk(FILE *fp)
 }
 
 static void
+dosum(FILE *fp, int indent, FTSENT *p, int *offset, int flag,
+char * (*func)(const char *, char *), const char *key)
+{
+	char *digestbuf;
+
+	if ((keys & flag) == 0)
+		return;
+
+	digestbuf = (*func)(p->fts_accpath, NULL);
+	if (digestbuf != NULL) {
+		output(fp, indent, offset, "%s=%s", key, digestbuf);
+		free(digestbuf);
+		return;
+	}
+
+	if (qflag) {
+		warn("%s: %s failed", p->fts_path, key);
+		return;
+	}
+
+	mtree_err("%s: %s failed: %s", p->fts_path, key, strerror(errno));
+}
+
+static char *
+crcFile(const char *fname, char *dummy __unused)
+{
+	char *ptr;
+	uint32_t val, len;
+	int fd, e;
+
+	if ((fd = open(fname, O_RDONLY)) == -1)
+		goto out;
+
+	e = crc(fd, , );
+	close(fd);
+	if (e)
+		goto out;
+
+	if (asprintf(, "%u", val) < 0)
+		goto out;
+
+	return ptr;
+out:
+	mtree_err("%s: %s", fname, strerror(errno));
+	return NULL;
+}
+
+static void
 statf(FILE *fp, int indent, FTSENT *p)
 {
-	u_int32_t len, val;
-	int fd, offset;
+	int offset;
 	const char *name = NULL;
-#if !defined(NO_MD5) || !defined(NO_RMD160) || !defined(NO_SHA1) || !defined(NO_SHA2)
-	char *digestbuf;
-#endif
 
 	offset = fprintf(fp, "%*s%s%s", indent, "",
 	S_ISDIR(p->fts_statp->st_mode) ? "" : "", vispath(p->fts_name));
@@ -239,65 +283,25 @@ statf(FILE *fp, int indent, FTSENT *p)
 		output(fp, indent, , "time=%jd.%09ld",
 		(intmax_t)p->fts_statp->st_mtime, (long)0);
 #endif
-	if (keys & F_CKSUM && S_ISREG(p->fts_statp->st_mode)) {
-		if ((fd = open(p->fts_accpath, O_RDONLY, 0)) < 0 ||
-		crc(fd, , ))
-			mtree_err("%s: %s", p->fts_accpath, strerror(errno));
-		close(fd);
-		output(fp, indent, , "cksum=%lu", (long)val);
-	}
+	if (S_ISREG(p->fts_statp->st_mode))  {
+		dosum(fp, indent, p, , F_CKSUM, crcFile, "cksum");
 #ifndef NO_MD5
-	if (keys & F_MD5 && S_ISREG(p->fts_statp->st_mode)) {
-		if ((digestbuf = MD5File(p->fts_accpath, NULL)) == NULL)
-			mtree_err("%s: MD5File failed: %s", p->fts_accpath,
-			strerror(errno));
-		output(fp, indent, , "%s=%s", MD5KEY, digestbuf);
-		free(digestbuf);
-	}
+		dosum(fp, indent, p, , F_MD5, MD5File, MD5KEY);
 #endif	/* ! NO_MD5 */
 #ifndef NO_RMD160
-	if (keys & F_RMD160 && S_ISREG(p->fts_statp->st_mode)) {
-		if ((digestbuf = RMD160File(p->fts_accpath, NULL)) == NULL)
-			mtree_err("%s: RMD160File failed: %s", p->fts_accpath,
-			strerror(errno));
-		output(fp, indent, , "%s=%s", RMD160KEY, digestbuf);
-		free(digestbuf);
-	}
+		dosum(fp, indent, p, , F_RMD160, RMD160File, RMD160KEY);
 #endif	/* ! NO_RMD160 */
 #ifndef NO_SHA1
-	if (keys & F_SHA1 && S_ISREG(p->fts_statp->st_mode)) {
-		if ((digestbuf = SHA1File(p->fts_accpath, NULL)) == NULL)
-			mtree_err("%s: SHA1File failed: %s", p->fts_accpath,
-			strerror(errno));
-		output(fp, indent, , "%s=%s", SHA1KEY, digestbuf);
-		free(digestbuf);
-	}
+		dosum(fp, indent, p, , F_SHA1, SHA1File, SHA1KEY);
 #endif	/* ! NO_SHA1 */
 #ifndef NO_SHA2
-	if (keys & F_SHA256 && S_ISREG(p->fts_statp->st_mode)) {
-		if ((digestbuf = SHA256_File(p->fts_accpath, NULL)) == NULL)
-			mtree_err("%s: SHA256_File failed: %s", p->fts_accpath,
-			strerror(errno));
-		output(fp, indent, , "%s=%s", SHA256KEY, digestbuf);
-		free(digestbuf);
-	}
+		dosum(fp, indent, p, , F_SHA256, SHA256_File, SHA256KEY);
 #ifdef SHA384_BLOCK_LENGTH
-	if (keys & F_SHA384 && S_ISREG(p->fts_statp->st_mode)) {
-		if ((digestbuf = SHA384_File(p->fts_accpath, NULL)) == NULL)
-			mtree_err("%s: SHA384_File failed: %s", p->fts_accpath,
-			strerror(errno));
-		output(fp, indent, , "%s=%s", SHA384KEY, digestbuf);
-		free(digestbuf);
-	}
+		dosum(fp, indent, p, , F_SHA384, SHA384_File, SHA384KEY);
 #endif
-	if (keys & F_SHA512 && S_ISREG(p->fts_statp->st_mode)) {
-		if ((digestbuf = SHA512_File(p->fts_accpath, NULL)) == NULL)
-			mtree_err("%s: SHA512_File failed: %s", p->fts_accpath,
-			   

CVS commit: src/usr.sbin/mtree

2017-12-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 14 18:34:41 UTC 2017

Modified Files:
src/usr.sbin/mtree: create.c spec.c specspec.c

Log Message:
use uintmax_t for nlink_t from FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/usr.sbin/mtree/create.c
cvs rdiff -u -r1.89 -r1.90 src/usr.sbin/mtree/spec.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/mtree/specspec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.73 src/usr.sbin/mtree/create.c:1.74
--- src/usr.sbin/mtree/create.c:1.73	Thu Apr 24 13:22:41 2014
+++ src/usr.sbin/mtree/create.c	Thu Dec 14 13:34:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.73 2014/04/24 17:22:41 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.74 2017/12/14 18:34:41 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)create.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: create.c,v 1.73 2014/04/24 17:22:41 christos Exp $");
+__RCSID("$NetBSD: create.c,v 1.74 2017/12/14 18:34:41 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -224,7 +224,8 @@ statf(FILE *fp, int indent, FTSENT *p)
 		output(fp, indent, , "device=%#jx",
 		(uintmax_t)p->fts_statp->st_rdev);
 	if (keys & F_NLINK && p->fts_statp->st_nlink != 1)
-		output(fp, indent, , "nlink=%u", p->fts_statp->st_nlink);
+		output(fp, indent, , "nlink=%ju",
+		(uintmax_t)p->fts_statp->st_nlink);
 	if (keys & F_SIZE &&
 	(flavor == F_FREEBSD9 || S_ISREG(p->fts_statp->st_mode)))
 		output(fp, indent, , "size=%ju",

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.89 src/usr.sbin/mtree/spec.c:1.90
--- src/usr.sbin/mtree/spec.c:1.89	Thu Apr 24 13:22:41 2014
+++ src/usr.sbin/mtree/spec.c	Thu Dec 14 13:34:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.89 2014/04/24 17:22:41 christos Exp $	*/
+/*	$NetBSD: spec.c,v 1.90 2017/12/14 18:34:41 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = "@(#)spec.c	8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: spec.c,v 1.89 2014/04/24 17:22:41 christos Exp $");
+__RCSID("$NetBSD: spec.c,v 1.90 2017/12/14 18:34:41 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -363,7 +363,8 @@ dump_nodes(FILE *fp, const char *dir, NO
 			appendfield(fp, pathlast, "device=%#jx",
 			(uintmax_t)cur->st_rdev);
 		if (MATCHFLAG(F_NLINK))
-			appendfield(fp, pathlast, "nlink=%d", cur->st_nlink);
+			appendfield(fp, pathlast, "nlink=%ju",
+			(uintmax_t)cur->st_nlink);
 		if (MATCHFLAG(F_SLINK))
 			appendfield(fp, pathlast, "link=%s",
 			vispath(cur->slink));

Index: src/usr.sbin/mtree/specspec.c
diff -u src/usr.sbin/mtree/specspec.c:1.3 src/usr.sbin/mtree/specspec.c:1.4
--- src/usr.sbin/mtree/specspec.c:1.3	Wed Jan  7 15:50:36 2015
+++ src/usr.sbin/mtree/specspec.c	Thu Dec 14 13:34:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: specspec.c,v 1.3 2015/01/07 20:50:36 joerg Exp $	*/
+/*	$NetBSD: specspec.c,v 1.4 2017/12/14 18:34:41 christos Exp $	*/
 
 /*-
  * Copyright (c) 2003 Poul-Henning Kamp
@@ -31,7 +31,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: specspec.c,v 1.3 2015/01/07 20:50:36 joerg Exp $");
+__RCSID("$NetBSD: specspec.c,v 1.4 2017/12/14 18:34:41 christos Exp $");
 
 #include 
 #include 
@@ -73,7 +73,7 @@ shownode(NODE *n, int f, char const *pat
 	if (f & F_MODE)
 		printf(" mode=%o", n->st_mode);
 	if (f & F_NLINK)
-		printf(" nlink=%d", (int)n->st_nlink);
+		printf(" nlink=%ju", (uintmax_t)n->st_nlink);
 	if (f & F_SIZE)
 		printf(" size=%jd", (intmax_t)n->st_size);
 	if (f & F_UID)



CVS commit: src/usr.sbin/mtree

2017-09-06 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Thu Sep  7 04:04:14 UTC 2017

Modified Files:
src/usr.sbin/mtree: only.c

Log Message:
Don't modify strings stored in hash, otherwise filling up of
directory hierarchy stops if the same hash value occurs in
directory and leaf.

Fix the issue that
"./usr/share/locale/pl/LC_MESSAGES/gettext-tools.mo" isn't included
in sets file in the case of MKUNPRIVED=no.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/mtree/only.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/only.c
diff -u src/usr.sbin/mtree/only.c:1.2 src/usr.sbin/mtree/only.c:1.3
--- src/usr.sbin/mtree/only.c:1.2	Tue Feb  5 00:59:03 2013
+++ src/usr.sbin/mtree/only.c	Thu Sep  7 04:04:13 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: only.c,v 1.2 2013/02/05 00:59:03 christos Exp $	*/
+/*	$NetBSD: only.c,v 1.3 2017/09/07 04:04:13 nakayama Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include 
 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: only.c,v 1.2 2013/02/05 00:59:03 christos Exp $");
+__RCSID("$NetBSD: only.c,v 1.3 2017/09/07 04:04:13 nakayama Exp $");
 #endif
 
 #include 
@@ -89,11 +89,14 @@ static void
 hash_insert(char *str, uint32_t h)
 {
 	struct hentry *e;
+	char *x;
 
 	if ((e = malloc(sizeof(*e))) == NULL)
 		mtree_err("memory allocation error");
+	if ((x = strdup(str)) == NULL)
+		mtree_err("memory allocation error");
 
-	e->str = str;
+	e->str = x;
 	e->hash = h;
 	e->next = table[h];
 	table[h] = e;
@@ -110,10 +113,7 @@ fill(char *str)
 
 	*ptr = '\0';
 	if (!hash_find(str, )) {
-		char *x = strdup(str);
-		if (x == NULL)
-			mtree_err("memory allocation error");
-		hash_insert(x, h);
+		hash_insert(str, h);
 		fill(str);
 	}
 	*ptr = '/';
@@ -135,6 +135,7 @@ load_only(const char *fname)
 			err(1, "Duplicate entry %s", line);
 		hash_insert(line, h);
 		fill(line);
+		free(line);
 	}
 
 	fclose(fp);



CVS commit: src/usr.sbin/mtree

2017-02-22 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb 22 14:15:15 UTC 2017

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.71 src/usr.sbin/mtree/mtree.8:1.72
--- src/usr.sbin/mtree/mtree.8:1.71	Fri Jan 23 03:31:58 2015
+++ src/usr.sbin/mtree/mtree.8	Wed Feb 22 14:15:15 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mtree.8,v 1.71 2015/01/23 03:31:58 wiz Exp $
+.\"	$NetBSD: mtree.8,v 1.72 2017/02/22 14:15:15 abhinav Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -161,7 +161,7 @@ The
 .Sy freebsd9
 and
 .Sy netbsd6
-flavors attempt to preserve output compatiblity and command line option
+flavors attempt to preserve output compatibility and command line option
 backward compatibility with
 .Fx 9.0
 and



CVS commit: src/usr.sbin/mtree

2015-01-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 23 20:28:24 UTC 2015

Modified Files:
src/usr.sbin/mtree: verify.c

Log Message:
fix tools build.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/mtree/verify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/verify.c
diff -u src/usr.sbin/mtree/verify.c:1.45 src/usr.sbin/mtree/verify.c:1.46
--- src/usr.sbin/mtree/verify.c:1.45	Thu Jan 22 21:27:01 2015
+++ src/usr.sbin/mtree/verify.c	Fri Jan 23 15:28:24 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: verify.c,v 1.45 2015/01/23 02:27:01 christos Exp $	*/
+/*	$NetBSD: verify.c,v 1.46 2015/01/23 20:28:24 christos 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.45 2015/01/23 02:27:01 christos Exp $);
+__RCSID($NetBSD: verify.c,v 1.46 2015/01/23 20:28:24 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -149,10 +149,12 @@ vwalk(void)
 		if (!eflag  !(dflag  p-fts_info == FTS_SL)) {
 			printf(extra: %s, RP(p));
 			if (rflag) {
+#if HAVE_STRUCT_STAT_ST_FLAGS
 if (rflag  1 
 lchflags(p-fts_accpath, 0) == -1)
 	printf( (chflags %s),
 	strerror(errno));
+#endif
 if ((S_ISDIR(p-fts_statp-st_mode)
 ? rmdir : unlink)(p-fts_accpath)) {
 	printf(, not removed: %s,



CVS commit: src/usr.sbin/mtree

2015-01-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 23 02:27:01 UTC 2015

Modified Files:
src/usr.sbin/mtree: mtree.8 mtree.c verify.c

Log Message:
attempt to reset file flags when -rr


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/usr.sbin/mtree/mtree.8
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/mtree/mtree.c
cvs rdiff -u -r1.44 -r1.45 src/usr.sbin/mtree/verify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.69 src/usr.sbin/mtree/mtree.8:1.70
--- src/usr.sbin/mtree/mtree.8:1.69	Sun Feb  3 14:16:06 2013
+++ src/usr.sbin/mtree/mtree.8	Thu Jan 22 21:27:01 2015
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.69 2013/02/03 19:16:06 christos Exp $
+.\	$NetBSD: mtree.8,v 1.70 2015/01/23 02:27:01 christos Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -56,7 +56,7 @@
 .\
 .\ @(#)mtree.8	8.2 (Berkeley) 12/11/93
 .\
-.Dd February 3, 2013
+.Dd January 22, 2014
 .Dt MTREE 8
 .Os
 .Sh NAME
@@ -299,6 +299,10 @@ is specified, remove all of the other ke
 .It Fl r
 Remove any files in the file hierarchy that are not described in the
 specification.
+Repeating the flag more than once will attempt to reset all the
+file flags via
+.Xr lchflags 2
+before attempting to remove the file in case the file was immutable.
 .It Fl S
 When reading a specification into an internal data structure,
 sort the entries.

Index: src/usr.sbin/mtree/mtree.c
diff -u src/usr.sbin/mtree/mtree.c:1.49 src/usr.sbin/mtree/mtree.c:1.50
--- src/usr.sbin/mtree/mtree.c:1.49	Thu Apr 24 13:22:41 2014
+++ src/usr.sbin/mtree/mtree.c	Thu Jan 22 21:27:01 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.c,v 1.49 2014/04/24 17:22:41 christos Exp $	*/
+/*	$NetBSD: mtree.c,v 1.50 2015/01/23 02:27:01 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1990, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)mtree.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: mtree.c,v 1.49 2014/04/24 17:22:41 christos Exp $);
+__RCSID($NetBSD: mtree.c,v 1.50 2015/01/23 02:27:01 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -195,7 +195,7 @@ main(int argc, char **argv)
 			qflag = 1;
 			break;
 		case 'r':
-			rflag = 1;
+			rflag++;
 			break;
 		case 'R':
 			while ((p = strsep(optarg,  \t,)) != NULL)

Index: src/usr.sbin/mtree/verify.c
diff -u src/usr.sbin/mtree/verify.c:1.44 src/usr.sbin/mtree/verify.c:1.45
--- src/usr.sbin/mtree/verify.c:1.44	Sun Feb  3 14:15:17 2013
+++ src/usr.sbin/mtree/verify.c	Thu Jan 22 21:27:01 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: verify.c,v 1.44 2013/02/03 19:15:17 christos Exp $	*/
+/*	$NetBSD: verify.c,v 1.45 2015/01/23 02:27:01 christos 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.44 2013/02/03 19:15:17 christos Exp $);
+__RCSID($NetBSD: verify.c,v 1.45 2015/01/23 02:27:01 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -149,6 +149,10 @@ vwalk(void)
 		if (!eflag  !(dflag  p-fts_info == FTS_SL)) {
 			printf(extra: %s, RP(p));
 			if (rflag) {
+if (rflag  1 
+lchflags(p-fts_accpath, 0) == -1)
+	printf( (chflags %s),
+	strerror(errno));
 if ((S_ISDIR(p-fts_statp-st_mode)
 ? rmdir : unlink)(p-fts_accpath)) {
 	printf(, not removed: %s,



CVS commit: src/usr.sbin/mtree

2015-01-22 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Jan 23 03:31:58 UTC 2015

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
Pull into this year.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.70 src/usr.sbin/mtree/mtree.8:1.71
--- src/usr.sbin/mtree/mtree.8:1.70	Fri Jan 23 02:27:01 2015
+++ src/usr.sbin/mtree/mtree.8	Fri Jan 23 03:31:58 2015
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.70 2015/01/23 02:27:01 christos Exp $
+.\	$NetBSD: mtree.8,v 1.71 2015/01/23 03:31:58 wiz Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -56,7 +56,7 @@
 .\
 .\ @(#)mtree.8	8.2 (Berkeley) 12/11/93
 .\
-.Dd January 22, 2014
+.Dd January 22, 2015
 .Dt MTREE 8
 .Os
 .Sh NAME



CVS commit: src/usr.sbin/mtree

2015-01-07 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Wed Jan  7 20:50:36 UTC 2015

Modified Files:
src/usr.sbin/mtree: specspec.c

Log Message:
st_nlink on Linux is not int, so add an explicit cast.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/mtree/specspec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/specspec.c
diff -u src/usr.sbin/mtree/specspec.c:1.2 src/usr.sbin/mtree/specspec.c:1.3
--- src/usr.sbin/mtree/specspec.c:1.2	Fri Oct  5 01:27:29 2012
+++ src/usr.sbin/mtree/specspec.c	Wed Jan  7 20:50:36 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: specspec.c,v 1.2 2012/10/05 01:27:29 christos Exp $	*/
+/*	$NetBSD: specspec.c,v 1.3 2015/01/07 20:50:36 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2003 Poul-Henning Kamp
@@ -31,7 +31,7 @@
 #endif
 
 #include sys/cdefs.h
-__RCSID($NetBSD: specspec.c,v 1.2 2012/10/05 01:27:29 christos Exp $);
+__RCSID($NetBSD: specspec.c,v 1.3 2015/01/07 20:50:36 joerg Exp $);
 
 #include err.h
 #include grp.h
@@ -73,7 +73,7 @@ shownode(NODE *n, int f, char const *pat
 	if (f  F_MODE)
 		printf( mode=%o, n-st_mode);
 	if (f  F_NLINK)
-		printf( nlink=%d, n-st_nlink);
+		printf( nlink=%d, (int)n-st_nlink);
 	if (f  F_SIZE)
 		printf( size=%jd, (intmax_t)n-st_size);
 	if (f  F_UID)



CVS commit: src/usr.sbin/mtree

2014-10-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Oct 27 21:46:45 UTC 2014

Modified Files:
src/usr.sbin/mtree: getid.c

Log Message:
fix pasto; thanks John-Mark Gurney...


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/mtree/getid.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/getid.c
diff -u src/usr.sbin/mtree/getid.c:1.9 src/usr.sbin/mtree/getid.c:1.10
--- src/usr.sbin/mtree/getid.c:1.9	Sun Mar 30 20:00:22 2014
+++ src/usr.sbin/mtree/getid.c	Mon Oct 27 17:46:45 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: getid.c,v 1.9 2014/03/31 00:00:22 christos Exp $	*/
+/*	$NetBSD: getid.c,v 1.10 2014/10/27 21:46:45 christos Exp $	*/
 /*	from: NetBSD: getpwent.c,v 1.48 2000/10/03 03:22:26 enami Exp */
 /*	from: NetBSD: getgrent.c,v 1.41 2002/01/12 23:51:30 lukem Exp */
 
@@ -65,7 +65,7 @@
 #endif
 
 #include sys/cdefs.h
-__RCSID($NetBSD: getid.c,v 1.9 2014/03/31 00:00:22 christos Exp $);
+__RCSID($NetBSD: getid.c,v 1.10 2014/10/27 21:46:45 christos Exp $);
 
 #include sys/param.h
 
@@ -236,7 +236,7 @@ grscan(int search, gid_t gid, const char
 			continue;
 		}
 		/* skip comments */
-		if (pwline[0] == '#')
+		if (grline[0] == '#')
 			continue;
 		if (grmatchline(search, gid, name))
 			return 1;



CVS commit: src/usr.sbin/mtree

2014-03-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar 31 00:00:22 UTC 2014

Modified Files:
src/usr.sbin/mtree: getid.c

Log Message:
say why we can't use the password or the group databases.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/mtree/getid.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/getid.c
diff -u src/usr.sbin/mtree/getid.c:1.8 src/usr.sbin/mtree/getid.c:1.9
--- src/usr.sbin/mtree/getid.c:1.8	Wed Oct 16 13:27:42 2013
+++ src/usr.sbin/mtree/getid.c	Sun Mar 30 20:00:22 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: getid.c,v 1.8 2013/10/16 17:27:42 christos Exp $	*/
+/*	$NetBSD: getid.c,v 1.9 2014/03/31 00:00:22 christos Exp $	*/
 /*	from: NetBSD: getpwent.c,v 1.48 2000/10/03 03:22:26 enami Exp */
 /*	from: NetBSD: getgrent.c,v 1.41 2002/01/12 23:51:30 lukem Exp */
 
@@ -65,7 +65,7 @@
 #endif
 
 #include sys/cdefs.h
-__RCSID($NetBSD: getid.c,v 1.8 2013/10/16 17:27:42 christos Exp $);
+__RCSID($NetBSD: getid.c,v 1.9 2014/03/31 00:00:22 christos Exp $);
 
 #include sys/param.h
 
@@ -206,7 +206,12 @@ grstart(void)
 	}
 	if (grfile[0] == '\0')			/* sanity check */
 		return 0;
-	return (_gr_fp = fopen(grfile, r)) ? 1 : 0;
+
+	_gr_fp = fopen(grfile, r);
+	if (_gr_fp != NULL)
+		return 1;
+	warn(Can't open `%s', grfile);
+	return 0;
 }
 
 
@@ -350,7 +355,11 @@ pwstart(void)
 	}
 	if (pwfile[0] == '\0')			/* sanity check */
 		return 0;
-	return (_pw_fp = fopen(pwfile, r)) ? 1 : 0;
+	_pw_fp = fopen(pwfile, r);
+	if (_pw_fp != NULL)
+		return 1;
+	warn(Can't open `%s', pwfile);
+	return 0;
 }
 
 



CVS commit: src/usr.sbin/mtree

2013-11-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov 21 18:39:50 UTC 2013

Modified Files:
src/usr.sbin/mtree: compare.c

Log Message:
From Brooks Davis:
When comparing a directory to an mtree file NetBSD mtree has output like
this:

xxx:size (4, 5)
md5digest (0x6de9439834c9147569741d3c9c9fc010, 
0xa5d119ab8edcda0ef7f381da8=
f52f92f)
=2E/yyy missing

FreeBSD's historical behavior is this:

xxx changed
size expected 4 found 5
md5digest expected 6de9439834c9147569741d3c9c9fc010 found 
a5d119ab8edcda0e=
f7f381da8f52f92f
=2E/yyy missing

FreeBSD's mergemaster -U command depends on the latter behavior so
the following patch alters the freebsd9 mode of mtree to output
that format.  I don't think programs should rely on this output one way
or another since it's clearly meant for humans, but this seems like the
easiest short term fix.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.sbin/mtree/compare.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/compare.c
diff -u src/usr.sbin/mtree/compare.c:1.57 src/usr.sbin/mtree/compare.c:1.58
--- src/usr.sbin/mtree/compare.c:1.57	Thu Oct 17 13:22:59 2013
+++ src/usr.sbin/mtree/compare.c	Thu Nov 21 13:39:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: compare.c,v 1.57 2013/10/17 17:22:59 christos Exp $	*/
+/*	$NetBSD: compare.c,v 1.58 2013/11/21 18:39:50 christos 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.57 2013/10/17 17:22:59 christos Exp $);
+__RCSID($NetBSD: compare.c,v 1.58 2013/11/21 18:39:50 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -72,13 +72,18 @@ __RCSID($NetBSD: compare.c,v 1.57 2013/
 #define	INDENTNAMELEN	8
 #define MARK\
 do {	\
-	len = printf(%s: , RP(p));	\
-	if (len  INDENTNAMELEN) {	\
+	if (flavor == F_FREEBSD9) {	\
+		len = printf(%s changed\n, RP(p));			\
 		tab = \t;		\
-		printf(\n);		\
 	} else {			\
-		tab = ;		\
-		printf(%*s, INDENTNAMELEN - (int)len, );		\
+		len = printf(%s: , RP(p));\
+		if (len  INDENTNAMELEN) {\
+			tab = \t;	\
+			printf(\n);	\
+		} else {		\
+			tab = ;	\
+			printf(%*s, INDENTNAMELEN - (int)len, );	\
+		}			\
 	}\
 } while (0)
 #define	LABEL if (!label++) MARK
@@ -171,7 +176,8 @@ compare(NODE *s, FTSENT *p)
 		break;
 #endif
 typeerr:		LABEL;
-		printf(\ttype (%s, %s)\n,
+		printf(flavor == F_FREEBSD9 ?
+		\ttype expected %s found %s\n : \ttype (%s, %s)\n,
 		nodetype(s-type), inotype(p-fts_statp-st_mode));
 		return (label);
 	}
@@ -193,7 +199,9 @@ typeerr:		LABEL;
 	(s-type == F_BLOCK || s-type == F_CHAR) 
 	s-st_rdev != p-fts_statp-st_rdev) {
 		LABEL;
-		printf(%sdevice (%#jx, %#jx,
+		printf(flavor == F_FREEBSD9 ?
+		%sdevice expected %#jx found %#jx :
+		%sdevice (%#jx, %#jx,
 		tab, (uintmax_t)s-st_rdev,
 		(uintmax_t)p-fts_statp-st_rdev);
 		if (uflag) {
@@ -203,10 +211,12 @@ typeerr:		LABEL;
 			  s-st_rdev) == -1) ||
 			(lchown(p-fts_accpath, p-fts_statp-st_uid,
 			  p-fts_statp-st_gid) == -1) )
-printf(, not modified: %s)\n,
-strerror(errno));
+printf(, not modified: %s%s\n,
+strerror(errno),
+flavor == F_FREEBSD9 ?  : ));
 			 else
-printf(, modified)\n);
+printf(, modified%s\n,
+flavor == F_FREEBSD9 ?  : ));
 		} else
 			printf()\n);
 		tab = \t;
@@ -214,28 +224,34 @@ typeerr:		LABEL;
 	/* Set the uid/gid first, then set the mode. */
 	if (s-flags  (F_UID | F_UNAME)  s-st_uid != p-fts_statp-st_uid) {
 		LABEL;
-		printf(%suser (%lu, %lu,
+		printf(flavor == F_FREEBSD9 ?
+		%suser expected %lu found %lu : %suser (%lu, %lu,
 		tab, (u_long)s-st_uid, (u_long)p-fts_statp-st_uid);
 		if (uflag) {
 			if (lchown(p-fts_accpath, s-st_uid, -1))
-printf(, not modified: %s)\n,
-strerror(errno));
+printf(, not modified: %s%s\n,
+strerror(errno),
+flavor == F_FREEBSD9 ?  : ));
 			else
-printf(, modified)\n);
+printf(, modified%s\n,
+flavor == F_FREEBSD9 ?  : ));
 		} else
 			printf()\n);
 		tab = \t;
 	}
 	if (s-flags  (F_GID | F_GNAME)  s-st_gid != p-fts_statp-st_gid) {
 		LABEL;
-		printf(%sgid (%lu, %lu,
+		printf(flavor == F_FREEBSD9 ?
+		%sgid expected %lu found %lu : %sgid (%lu, %lu,
 		tab, (u_long)s-st_gid, (u_long)p-fts_statp-st_gid);
 		if (uflag) {
 			if (lchown(p-fts_accpath, -1, s-st_gid))
-printf(, not modified: %s)\n,
-strerror(errno));
+printf(, not modified: %s%s\n,
+strerror(errno),
+flavor == F_FREEBSD9 ?  : ));
 			else
-printf(, modified)\n);
+printf(, modified%s\n,
+flavor == F_FREEBSD9 ?  : ));
 		}
 		else
 			printf()\n);
@@ -260,15 +276,19 @@ typeerr:		LABEL;
 		}
 
 		LABEL;
-		printf(%spermissions (%#lo, 

CVS commit: src/usr.sbin/mtree

2013-10-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Oct 17 17:22:59 UTC 2013

Modified Files:
src/usr.sbin/mtree: compare.c create.c spec.c

Log Message:
Our sys/param.h ends up calling header files that define intmax_t. This
should not be the case (but sys/param.h is not a standard header so all bets
are off). FreeBSD's does not, so explicitly include stdint.h to get it.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/usr.sbin/mtree/compare.c
cvs rdiff -u -r1.71 -r1.72 src/usr.sbin/mtree/create.c
cvs rdiff -u -r1.87 -r1.88 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/compare.c
diff -u src/usr.sbin/mtree/compare.c:1.56 src/usr.sbin/mtree/compare.c:1.57
--- src/usr.sbin/mtree/compare.c:1.56	Mon Sep  9 19:27:43 2013
+++ src/usr.sbin/mtree/compare.c	Thu Oct 17 13:22:59 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: compare.c,v 1.56 2013/09/09 23:27:43 christos Exp $	*/
+/*	$NetBSD: compare.c,v 1.57 2013/10/17 17:22:59 christos 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.56 2013/09/09 23:27:43 christos Exp $);
+__RCSID($NetBSD: compare.c,v 1.57 2013/10/17 17:22:59 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -48,6 +48,7 @@ __RCSID($NetBSD: compare.c,v 1.56 2013/
 #include errno.h
 #include fcntl.h
 #include stdio.h
+#include stdint.h
 #include stdlib.h
 #include string.h
 #include time.h

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.71 src/usr.sbin/mtree/create.c:1.72
--- src/usr.sbin/mtree/create.c:1.71	Wed Oct 16 13:24:20 2013
+++ src/usr.sbin/mtree/create.c	Thu Oct 17 13:22:59 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.71 2013/10/16 17:24:20 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.72 2013/10/17 17:22:59 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)create.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: create.c,v 1.71 2013/10/16 17:24:20 christos Exp $);
+__RCSID($NetBSD: create.c,v 1.72 2013/10/17 17:22:59 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -55,6 +55,7 @@ __RCSID($NetBSD: create.c,v 1.71 2013/1
 #include pwd.h
 #include stdio.h
 #include stdarg.h
+#include stdint.h
 #include stdlib.h
 #include string.h
 #include time.h

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.87 src/usr.sbin/mtree/spec.c:1.88
--- src/usr.sbin/mtree/spec.c:1.87	Wed Oct 16 13:26:14 2013
+++ src/usr.sbin/mtree/spec.c	Thu Oct 17 13:22:59 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.87 2013/10/16 17:26:14 christos Exp $	*/
+/*	$NetBSD: spec.c,v 1.88 2013/10/17 17:22:59 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = @(#)spec.c	8.2 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: spec.c,v 1.87 2013/10/16 17:26:14 christos Exp $);
+__RCSID($NetBSD: spec.c,v 1.88 2013/10/17 17:22:59 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -81,6 +81,7 @@ __RCSID($NetBSD: spec.c,v 1.87 2013/10/
 #include pwd.h
 #include stdarg.h
 #include stdio.h
+#include stdint.h
 #include stdlib.h
 #include string.h
 #include unistd.h



CVS commit: src/usr.sbin/mtree

2013-10-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 16 17:24:20 UTC 2013

Modified Files:
src/usr.sbin/mtree: create.c

Log Message:
Restore old behavior of not printing sizes for directories, since it varies
depending on filesystem implementation. (Brooks Davis)


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/usr.sbin/mtree/create.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.70 src/usr.sbin/mtree/create.c:1.71
--- src/usr.sbin/mtree/create.c:1.70	Mon Sep  9 19:27:43 2013
+++ src/usr.sbin/mtree/create.c	Wed Oct 16 13:24:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.70 2013/09/09 23:27:43 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.71 2013/10/16 17:24:20 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)create.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: create.c,v 1.70 2013/09/09 23:27:43 christos Exp $);
+__RCSID($NetBSD: create.c,v 1.71 2013/10/16 17:24:20 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -221,7 +221,7 @@ statf(int indent, FTSENT *p)
 	if (keys  F_NLINK  p-fts_statp-st_nlink != 1)
 		output(indent, offset, nlink=%u, p-fts_statp-st_nlink);
 	if (keys  F_SIZE 
-	(flavor != F_NETBSD6 || S_ISREG(p-fts_statp-st_mode)))
+	(flavor == F_FREEBSD9 || S_ISREG(p-fts_statp-st_mode)))
 		output(indent, offset, size=%ju,
 		(uintmax_t)p-fts_statp-st_size);
 	if (keys  F_TIME)



CVS commit: src/usr.sbin/mtree

2013-10-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 16 17:26:14 UTC 2013

Modified Files:
src/usr.sbin/mtree: spec.c

Log Message:
Default a bare . with no type to F_DIR. For FreeBSD compatibility (Brooks
Davis)


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.86 src/usr.sbin/mtree/spec.c:1.87
--- src/usr.sbin/mtree/spec.c:1.86	Mon Sep  9 19:27:43 2013
+++ src/usr.sbin/mtree/spec.c	Wed Oct 16 13:26:14 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.86 2013/09/09 23:27:43 christos Exp $	*/
+/*	$NetBSD: spec.c,v 1.87 2013/10/16 17:26:14 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = @(#)spec.c	8.2 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: spec.c,v 1.86 2013/09/09 23:27:43 christos Exp $);
+__RCSID($NetBSD: spec.c,v 1.87 2013/10/16 17:26:14 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -217,6 +217,12 @@ noparent:		mtree_err(no parent node);
 /*
  * empty tree
  */
+			/*
+			 * Allow a bare . root node by forcing it to
+			 * type=dir for compatibility with FreeBSD.
+			 */
+			if (strcmp(centry-name, .) == 0  centry-type == 0)
+centry-type = F_DIR;
 			if (strcmp(centry-name, .) != 0 ||
 			centry-type != F_DIR)
 mtree_err(



CVS commit: src/usr.sbin/mtree

2013-10-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 16 17:27:42 UTC 2013

Modified Files:
src/usr.sbin/mtree: getid.c

Log Message:
skip comment lines on password and group databases (Brooks Davis)


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/mtree/getid.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/getid.c
diff -u src/usr.sbin/mtree/getid.c:1.7 src/usr.sbin/mtree/getid.c:1.8
--- src/usr.sbin/mtree/getid.c:1.7	Mon Apr 28 16:24:17 2008
+++ src/usr.sbin/mtree/getid.c	Wed Oct 16 13:27:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: getid.c,v 1.7 2008/04/28 20:24:17 martin Exp $	*/
+/*	$NetBSD: getid.c,v 1.8 2013/10/16 17:27:42 christos Exp $	*/
 /*	from: NetBSD: getpwent.c,v 1.48 2000/10/03 03:22:26 enami Exp */
 /*	from: NetBSD: getgrent.c,v 1.41 2002/01/12 23:51:30 lukem Exp */
 
@@ -65,7 +65,7 @@
 #endif
 
 #include sys/cdefs.h
-__RCSID($NetBSD: getid.c,v 1.7 2008/04/28 20:24:17 martin Exp $);
+__RCSID($NetBSD: getid.c,v 1.8 2013/10/16 17:27:42 christos Exp $);
 
 #include sys/param.h
 
@@ -230,6 +230,9 @@ grscan(int search, gid_t gid, const char
 ;
 			continue;
 		}
+		/* skip comments */
+		if (pwline[0] == '#')
+			continue;
 		if (grmatchline(search, gid, name))
 			return 1;
 	}
@@ -371,6 +374,9 @@ pwscan(int search, uid_t uid, const char
 ;
 			continue;
 		}
+		/* skip comments */
+		if (pwline[0] == '#')
+			continue;
 		if (pwmatchline(search, uid, name))
 			return 1;
 	}



CVS commit: src/usr.sbin/mtree

2013-09-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Sep  9 23:27:43 UTC 2013

Modified Files:
src/usr.sbin/mtree: compare.c create.c spec.c

Log Message:
use intmax_t instead of long long. fixes wrong cast for time_t.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/usr.sbin/mtree/compare.c
cvs rdiff -u -r1.69 -r1.70 src/usr.sbin/mtree/create.c
cvs rdiff -u -r1.85 -r1.86 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/compare.c
diff -u src/usr.sbin/mtree/compare.c:1.55 src/usr.sbin/mtree/compare.c:1.56
--- src/usr.sbin/mtree/compare.c:1.55	Thu Oct  4 20:59:35 2012
+++ src/usr.sbin/mtree/compare.c	Mon Sep  9 19:27:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: compare.c,v 1.55 2012/10/05 00:59:35 christos Exp $	*/
+/*	$NetBSD: compare.c,v 1.56 2013/09/09 23:27:43 christos 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.55 2012/10/05 00:59:35 christos Exp $);
+__RCSID($NetBSD: compare.c,v 1.56 2013/09/09 23:27:43 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -192,9 +192,9 @@ typeerr:		LABEL;
 	(s-type == F_BLOCK || s-type == F_CHAR) 
 	s-st_rdev != p-fts_statp-st_rdev) {
 		LABEL;
-		printf(%sdevice (%#llx, %#llx,
-		tab, (long long)s-st_rdev,
-		(long long)p-fts_statp-st_rdev);
+		printf(%sdevice (%#jx, %#jx,
+		tab, (uintmax_t)s-st_rdev,
+		(uintmax_t)p-fts_statp-st_rdev);
 		if (uflag) {
 			if ((unlink(p-fts_accpath) == -1) ||
 			(mknod(p-fts_accpath,
@@ -283,9 +283,9 @@ typeerr:		LABEL;
 	}
 	if (s-flags  F_SIZE  s-st_size != p-fts_statp-st_size) {
 		LABEL;
-		printf(%ssize (%lld, %lld)\n,
-		tab, (long long)s-st_size,
-		(long long)p-fts_statp-st_size);
+		printf(%ssize (%ju, %ju)\n,
+		tab, (uintmax_t)s-st_size,
+		(uintmax_t)p-fts_statp-st_size);
 		tab = \t;
 	}
 	/*

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.69 src/usr.sbin/mtree/create.c:1.70
--- src/usr.sbin/mtree/create.c:1.69	Sun Feb  3 14:15:17 2013
+++ src/usr.sbin/mtree/create.c	Mon Sep  9 19:27:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.69 2013/02/03 19:15:17 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.70 2013/09/09 23:27:43 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)create.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: create.c,v 1.69 2013/02/03 19:15:17 christos Exp $);
+__RCSID($NetBSD: create.c,v 1.70 2013/09/09 23:27:43 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -216,22 +216,22 @@ statf(int indent, FTSENT *p)
 		p-fts_statp-st_mode  MBITS);
 	if (keys  F_DEV 
 	(S_ISBLK(p-fts_statp-st_mode) || S_ISCHR(p-fts_statp-st_mode)))
-		output(indent, offset, device=%#llx,
-		(long long)p-fts_statp-st_rdev);
+		output(indent, offset, device=%#jx,
+		(uintmax_t)p-fts_statp-st_rdev);
 	if (keys  F_NLINK  p-fts_statp-st_nlink != 1)
 		output(indent, offset, nlink=%u, p-fts_statp-st_nlink);
 	if (keys  F_SIZE 
 	(flavor != F_NETBSD6 || S_ISREG(p-fts_statp-st_mode)))
-		output(indent, offset, size=%lld,
-		(long long)p-fts_statp-st_size);
+		output(indent, offset, size=%ju,
+		(uintmax_t)p-fts_statp-st_size);
 	if (keys  F_TIME)
 #if defined(BSD4_4)  !defined(HAVE_NBTOOL_CONFIG_H)
-		output(indent, offset, time=%ld.%09ld,
-		(long)p-fts_statp-st_mtimespec.tv_sec,
+		output(indent, offset, time=%jd.%09ld,
+		(intmax_t)p-fts_statp-st_mtimespec.tv_sec,
 		p-fts_statp-st_mtimespec.tv_nsec);
 #else
-		output(indent, offset, time=%ld.%09ld,
-		(long)p-fts_statp-st_mtime, (long)0);
+		output(indent, offset, time=%jd.%09ld,
+		(intmax_t)p-fts_statp-st_mtime, (long)0);
 #endif
 	if (keys  F_CKSUM  S_ISREG(p-fts_statp-st_mode)) {
 		if ((fd = open(p-fts_accpath, O_RDONLY, 0))  0 ||

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.85 src/usr.sbin/mtree/spec.c:1.86
--- src/usr.sbin/mtree/spec.c:1.85	Thu Dec 20 11:43:16 2012
+++ src/usr.sbin/mtree/spec.c	Mon Sep  9 19:27:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.85 2012/12/20 16:43:16 christos Exp $	*/
+/*	$NetBSD: spec.c,v 1.86 2013/09/09 23:27:43 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = @(#)spec.c	8.2 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: spec.c,v 1.85 2012/12/20 16:43:16 christos Exp $);
+__RCSID($NetBSD: spec.c,v 1.86 2013/09/09 23:27:43 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -350,16 +350,18 @@ dump_nodes(const char *dir, NODE *root, 
 			appendfield(pathlast, mode=%#o, cur-st_mode);
 		if (MATCHFLAG(F_DEV) 
 		(cur-type == F_BLOCK || cur-type == F_CHAR))
-			appendfield(pathlast, device=%#llx, (long long)cur-st_rdev);
+			appendfield(pathlast, device=%#jx,
+			(uintmax_t)cur-st_rdev);
 		if 

CVS commit: src/usr.sbin/mtree

2013-04-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Apr  8 17:39:11 UTC 2013

Modified Files:
src/usr.sbin/mtree: mtree.c

Log Message:
move flags only used in main() inside main(), from Ed Schouten


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.sbin/mtree/mtree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.c
diff -u src/usr.sbin/mtree/mtree.c:1.47 src/usr.sbin/mtree/mtree.c:1.48
--- src/usr.sbin/mtree/mtree.c:1.47	Sun Feb  3 14:15:17 2013
+++ src/usr.sbin/mtree/mtree.c	Mon Apr  8 13:39:11 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.c,v 1.47 2013/02/03 19:15:17 christos Exp $	*/
+/*	$NetBSD: mtree.c,v 1.48 2013/04/08 17:39:11 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1990, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)mtree.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: mtree.c,v 1.47 2013/02/03 19:15:17 christos Exp $);
+__RCSID($NetBSD: mtree.c,v 1.48 2013/04/08 17:39:11 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -59,8 +59,8 @@ __RCSID($NetBSD: mtree.c,v 1.47 2013/02
 #include extern.h
 
 int	ftsoptions = FTS_PHYSICAL;
-int	bflag, cflag, Cflag, dflag, Dflag, eflag, iflag, jflag, lflag, mflag,
-	nflag, qflag, rflag, sflag, tflag, uflag, Uflag, wflag;
+int	bflag, dflag, eflag, iflag, jflag, lflag, mflag, nflag, qflag, rflag,
+	sflag, tflag, uflag;
 char	fullpath[MAXPATHLEN];
 
 static struct {
@@ -79,11 +79,13 @@ main(int argc, char **argv)
 {
 	int	ch, status;
 	unsigned int	i;
+	int	cflag, Cflag, Dflag, Uflag, wflag;
 	char	*dir, *p;
 	FILE	*spec1, *spec2;
 
 	setprogname(argv[0]);
 
+	cflag = Cflag = Dflag = Uflag = wflag = 0;
 	dir = NULL;
 	init_excludes();
 	spec1 = stdin;



CVS commit: src/usr.sbin/mtree

2013-02-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb  5 00:59:04 UTC 2013

Modified Files:
src/usr.sbin/mtree: only.c

Log Message:
fill up the directory hierarchy so that leaf files are not ignored if
specified by themselves.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/mtree/only.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/only.c
diff -u src/usr.sbin/mtree/only.c:1.1 src/usr.sbin/mtree/only.c:1.2
--- src/usr.sbin/mtree/only.c:1.1	Sun Feb  3 14:15:17 2013
+++ src/usr.sbin/mtree/only.c	Mon Feb  4 19:59:03 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: only.c,v 1.1 2013/02/03 19:15:17 christos Exp $	*/
+/*	$NetBSD: only.c,v 1.2 2013/02/05 00:59:03 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include sys/cdefs.h
 
 #if defined(__RCSID)  !defined(lint)
-__RCSID($NetBSD: only.c,v 1.1 2013/02/03 19:15:17 christos Exp $);
+__RCSID($NetBSD: only.c,v 1.2 2013/02/05 00:59:03 christos Exp $);
 #endif
 
 #include sys/param.h
@@ -86,14 +86,10 @@ hash_find(const char *str, uint32_t *h)
 }
 
 static void
-hash_insert(char *str)
+hash_insert(char *str, uint32_t h)
 {
-	uint32_t h;
 	struct hentry *e;
 
-	if (hash_find(str, h))
-		err(1, Duplicate entry %s, str);
-
 	if ((e = malloc(sizeof(*e))) == NULL)
 		mtree_err(memory allocation error);
 
@@ -103,6 +99,26 @@ hash_insert(char *str)
 	table[h] = e;
 }
 
+static void
+fill(char *str)
+{
+	uint32_t h;
+	char *ptr = strrchr(str, '/');
+
+	if (ptr == NULL)
+		return;
+
+	*ptr = '\0';
+	if (!hash_find(str, h)) {
+		char *x = strdup(str);
+		if (x == NULL)
+			mtree_err(memory allocation error);
+		hash_insert(x, h);
+		fill(str);
+	}
+	*ptr = '/';
+}
+
 void
 load_only(const char *fname)
 {
@@ -113,8 +129,13 @@ load_only(const char *fname)
 	if ((fp = fopen(fname, r)) == NULL)
 		err(1, Cannot open `%s', fname);
 
-	while ((line = fparseln(fp, len, lineno, NULL, FPARSELN_UNESCALL)))
-		hash_insert(line);
+	while ((line = fparseln(fp, len, lineno, NULL, FPARSELN_UNESCALL))) {
+		uint32_t h;
+		if (hash_find(line, h))
+			err(1, Duplicate entry %s, line);
+		hash_insert(line, h);
+		fill(line);
+	}
 
 	fclose(fp);
 	loaded = true;



CVS commit: src/usr.sbin/mtree

2013-02-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Feb  3 19:15:18 UTC 2013

Modified Files:
src/usr.sbin/mtree: Makefile create.c extern.h mtree.8 mtree.c verify.c
Added Files:
src/usr.sbin/mtree: only.c

Log Message:
add the ability to only output paths included in a spec file when creating
from a directory (-c)


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/mtree/Makefile
cvs rdiff -u -r1.68 -r1.69 src/usr.sbin/mtree/create.c
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/mtree/extern.h
cvs rdiff -u -r1.67 -r1.68 src/usr.sbin/mtree/mtree.8
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/mtree/mtree.c
cvs rdiff -u -r0 -r1.1 src/usr.sbin/mtree/only.c
cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/mtree/verify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/Makefile
diff -u src/usr.sbin/mtree/Makefile:1.33 src/usr.sbin/mtree/Makefile:1.34
--- src/usr.sbin/mtree/Makefile:1.33	Thu Oct  4 21:26:56 2012
+++ src/usr.sbin/mtree/Makefile	Sun Feb  3 14:15:16 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.33 2012/10/05 01:26:56 christos Exp $
+#	$NetBSD: Makefile,v 1.34 2013/02/03 19:15:16 christos Exp $
 #	from: @(#)Makefile	8.2 (Berkeley) 4/27/95
 
 .include bsd.own.mk
@@ -8,7 +8,7 @@ PROG=	mtree
 CPPFLAGS+= -DMTREE
 MAN=	mtree.8
 SRCS=	compare.c crc.c create.c excludes.c misc.c mtree.c spec.c specspec.c \
-	verify.c getid.c pack_dev.c
+	verify.c getid.c pack_dev.c only.c
 .if (${HOSTPROG:U} == )
 DPADD+= ${LIBUTIL}
 LDADD+= -lutil

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.68 src/usr.sbin/mtree/create.c:1.69
--- src/usr.sbin/mtree/create.c:1.68	Thu Dec 20 11:43:16 2012
+++ src/usr.sbin/mtree/create.c	Sun Feb  3 14:15:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.68 2012/12/20 16:43:16 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.69 2013/02/03 19:15:17 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)create.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: create.c,v 1.68 2012/12/20 16:43:16 christos Exp $);
+__RCSID($NetBSD: create.c,v 1.69 2013/02/03 19:15:17 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -134,6 +134,10 @@ cwalk(void)
 			fts_set(t, p, FTS_SKIP);
 			continue;
 		}
+		if (!find_only(p-fts_path)) {
+			fts_set(t, p, FTS_SKIP);
+			continue;
+		}
 		switch(p-fts_info) {
 		case FTS_D:
 			if (!bflag)

Index: src/usr.sbin/mtree/extern.h
diff -u src/usr.sbin/mtree/extern.h:1.37 src/usr.sbin/mtree/extern.h:1.38
--- src/usr.sbin/mtree/extern.h:1.37	Thu Dec 20 11:43:16 2012
+++ src/usr.sbin/mtree/extern.h	Sun Feb  3 14:15:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.37 2012/12/20 16:43:16 christos Exp $	*/
+/*	$NetBSD: extern.h,v 1.38 2013/02/03 19:15:17 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -42,6 +42,7 @@
 #include err.h 
 #include fts.h
 #include util.h
+#include stdbool.h
 
 #if HAVE_NETDB_H
 /* For MAXHOSTNAMELEN on some platforms. */
@@ -74,6 +75,8 @@ u_int	 parsetype(const char *);
 void	 read_excludes_file(const char *);
 const char *rlink(const char *);
 int	 verify(FILE *);
+void	 load_only(const char *fname);
+bool	 find_only(const char *path);
 
 extern int	bflag, dflag, eflag, iflag, jflag, lflag, mflag,
 		nflag, qflag, rflag, sflag, tflag, uflag;

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.67 src/usr.sbin/mtree/mtree.8:1.68
--- src/usr.sbin/mtree/mtree.8:1.67	Thu Dec 20 15:31:01 2012
+++ src/usr.sbin/mtree/mtree.8	Sun Feb  3 14:15:17 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.67 2012/12/20 20:31:01 wiz Exp $
+.\	$NetBSD: mtree.8,v 1.68 2013/02/03 19:15:17 christos Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -273,6 +273,8 @@ rather than using the results from the s
 and
 .Xr getgrnam 3
 (and related) library calls.
+.It Fl O Ar onlypaths
+Only include files included in this list of pathnames.
 .It Fl P
 Don't follow symbolic links in the file hierarchy, instead consider
 the symbolic link itself in any comparisons.

Index: src/usr.sbin/mtree/mtree.c
diff -u src/usr.sbin/mtree/mtree.c:1.46 src/usr.sbin/mtree/mtree.c:1.47
--- src/usr.sbin/mtree/mtree.c:1.46	Thu Dec 20 14:09:25 2012
+++ src/usr.sbin/mtree/mtree.c	Sun Feb  3 14:15:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.c,v 1.46 2012/12/20 19:09:25 christos Exp $	*/
+/*	$NetBSD: mtree.c,v 1.47 2013/02/03 19:15:17 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1990, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)mtree.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: mtree.c,v 1.46 2012/12/20 19:09:25 christos Exp $);
+__RCSID($NetBSD: mtree.c,v 1.47 2013/02/03 19:15:17 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -90,7 +90,7 @@ main(int argc, char **argv)
 	spec2 = NULL;
 
 	while ((ch = getopt(argc, argv,
-	   

CVS commit: src/usr.sbin/mtree

2013-02-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Feb  3 19:16:06 UTC 2013

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
fix man page.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.68 src/usr.sbin/mtree/mtree.8:1.69
--- src/usr.sbin/mtree/mtree.8:1.68	Sun Feb  3 14:15:17 2013
+++ src/usr.sbin/mtree/mtree.8	Sun Feb  3 14:16:06 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.68 2013/02/03 19:15:17 christos Exp $
+.\	$NetBSD: mtree.8,v 1.69 2013/02/03 19:16:06 christos Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -56,7 +56,7 @@
 .\
 .\ @(#)mtree.8	8.2 (Berkeley) 12/11/93
 .\
-.Dd December 20, 2012
+.Dd February 3, 2013
 .Dt MTREE 8
 .Os
 .Sh NAME
@@ -73,6 +73,7 @@
 .Op Fl K Ar keywords
 .Op Fl k Ar keywords
 .Op Fl N Ar dbdir
+.Op Fl O Ar onlyfile
 .Op Fl p Ar path
 .Op Fl R Ar keywords
 .Op Fl s Ar seed



CVS commit: src/usr.sbin/mtree

2012-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 20 16:43:17 UTC 2012

Modified Files:
src/usr.sbin/mtree: create.c extern.h mtree.8 mtree.c spec.c

Log Message:
Implement the flavor output discussed in tech-userlevel@, by Brooks Davis


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/usr.sbin/mtree/create.c
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/mtree/extern.h
cvs rdiff -u -r1.64 -r1.65 src/usr.sbin/mtree/mtree.8
cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/mtree/mtree.c
cvs rdiff -u -r1.84 -r1.85 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.67 src/usr.sbin/mtree/create.c:1.68
--- src/usr.sbin/mtree/create.c:1.67	Fri Dec 14 20:24:40 2012
+++ src/usr.sbin/mtree/create.c	Thu Dec 20 11:43:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.67 2012/12/15 01:24:40 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.68 2012/12/20 16:43:16 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)create.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: create.c,v 1.67 2012/12/15 01:24:40 christos Exp $);
+__RCSID($NetBSD: create.c,v 1.68 2012/12/20 16:43:16 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -136,18 +136,22 @@ cwalk(void)
 		}
 		switch(p-fts_info) {
 		case FTS_D:
-			printf(\n);
+			if (!bflag)
+printf(\n);
 			if (!nflag)
 printf(# %s\n, p-fts_path);
 			statd(t, p, uid, gid, mode, flags);
 			statf(indent, p);
 			break;
 		case FTS_DP:
-			if (p-fts_level  0) {
+			if (p-fts_level  0)
 if (!nflag)
 	printf(%*s# %s\n, indent, ,
 	p-fts_path);
-printf(%*s..\n\n, indent, );
+			if (p-fts_level  0 || flavor == F_FREEBSD9) {
+printf(%*s..\n, indent, );
+if (!bflag)
+	printf(\n);
 			}
 			break;
 		case FTS_DNR:
@@ -186,7 +190,7 @@ statf(int indent, FTSENT *p)
 	else
 		offset += printf(%*s, (INDENTNAMELEN + indent) - offset, );
 
-	if (!S_ISREG(p-fts_statp-st_mode))
+	if (!S_ISREG(p-fts_statp-st_mode)  (flavor == F_NETBSD6 || !dflag))
 		output(indent, offset, type=%s,
 		inotype(p-fts_statp-st_mode));
 	if (keys  (F_UID | F_UNAME)  p-fts_statp-st_uid != uid) {
@@ -212,7 +216,8 @@ statf(int indent, FTSENT *p)
 		(long long)p-fts_statp-st_rdev);
 	if (keys  F_NLINK  p-fts_statp-st_nlink != 1)
 		output(indent, offset, nlink=%u, p-fts_statp-st_nlink);
-	if (keys  F_SIZE  S_ISREG(p-fts_statp-st_mode))
+	if (keys  F_SIZE 
+	(flavor != F_NETBSD6 || S_ISREG(p-fts_statp-st_mode)))
 		output(indent, offset, size=%lld,
 		(long long)p-fts_statp-st_size);
 	if (keys  F_TIME)
@@ -349,29 +354,32 @@ statd(FTS *t, FTSENT *parent, uid_t *pui
 
 	maxuid = maxgid = maxmode = maxflags = 0;
 	for (; p; p = p-fts_link) {
-		smode = p-fts_statp-st_mode  MBITS;
-		if (smode  MTREE_MAXMODE  ++m[smode]  maxmode) {
-			savemode = smode;
-			maxmode = m[smode];
-		}
-		sgid = p-fts_statp-st_gid;
-		if (sgid  MTREE_MAXGID  ++g[sgid]  maxgid) {
-			savegid = sgid;
-			maxgid = g[sgid];
-		}
-		suid = p-fts_statp-st_uid;
-		if (suid  MTREE_MAXUID  ++u[suid]  maxuid) {
-			saveuid = suid;
-			maxuid = u[suid];
-		}
+		if (flavor == F_NETBSD6 || !dflag ||
+		(dflag  S_ISDIR(p-fts_statp-st_mode))) {
+			smode = p-fts_statp-st_mode  MBITS;
+			if (smode  MTREE_MAXMODE  ++m[smode]  maxmode) {
+savemode = smode;
+maxmode = m[smode];
+			}
+			sgid = p-fts_statp-st_gid;
+			if (sgid  MTREE_MAXGID  ++g[sgid]  maxgid) {
+savegid = sgid;
+maxgid = g[sgid];
+			}
+			suid = p-fts_statp-st_uid;
+			if (suid  MTREE_MAXUID  ++u[suid]  maxuid) {
+saveuid = suid;
+maxuid = u[suid];
+			}
 
 #if HAVE_STRUCT_STAT_ST_FLAGS
-		sflags = FLAGS2INDEX(p-fts_statp-st_flags);
-		if (sflags  MTREE_MAXFLAGS  ++f[sflags]  maxflags) {
-			saveflags = p-fts_statp-st_flags;
-			maxflags = f[sflags];
-		}
+			sflags = FLAGS2INDEX(p-fts_statp-st_flags);
+			if (sflags  MTREE_MAXFLAGS  ++f[sflags]  maxflags) {
+saveflags = p-fts_statp-st_flags;
+maxflags = f[sflags];
+			}
 #endif
+		}
 	}
 	/*
 	 * If the /set record is the same as the last one we do not need to
@@ -384,7 +392,10 @@ statd(FTS *t, FTSENT *parent, uid_t *pui
 	((keys  F_FLAGS)  (*pflags != saveflags)) ||
 	first) {
 		first = 0;
-		printf(/set type=file);
+		if (flavor != F_NETBSD6  dflag)
+			printf(/set type=dir);
+		else
+			printf(/set type=file);
 		if (keys  (F_UID | F_UNAME)) {
 			if (keys  F_UNAME 
 			(name = user_from_uid(saveuid, 1)) != NULL)

Index: src/usr.sbin/mtree/extern.h
diff -u src/usr.sbin/mtree/extern.h:1.36 src/usr.sbin/mtree/extern.h:1.37
--- src/usr.sbin/mtree/extern.h:1.36	Thu Oct  4 21:26:56 2012
+++ src/usr.sbin/mtree/extern.h	Thu Dec 20 11:43:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.36 2012/10/05 01:26:56 christos Exp $	*/
+/*	$NetBSD: extern.h,v 1.37 2012/12/20 16:43:16 christos Exp $	*/
 

CVS commit: src/usr.sbin/mtree

2012-12-20 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Dec 20 18:58:38 UTC 2012

Modified Files:
src/usr.sbin/mtree: mtree.c

Log Message:
joerg@: just use unsigned int please


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/usr.sbin/mtree/mtree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.c
diff -u src/usr.sbin/mtree/mtree.c:1.44 src/usr.sbin/mtree/mtree.c:1.45
--- src/usr.sbin/mtree/mtree.c:1.44	Thu Dec 20 16:43:16 2012
+++ src/usr.sbin/mtree/mtree.c	Thu Dec 20 18:58:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.c,v 1.44 2012/12/20 16:43:16 christos Exp $	*/
+/*	$NetBSD: mtree.c,v 1.45 2012/12/20 18:58:37 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1990, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)mtree.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: mtree.c,v 1.44 2012/12/20 16:43:16 christos Exp $);
+__RCSID($NetBSD: mtree.c,v 1.45 2012/12/20 18:58:37 mlelstv Exp $);
 #endif
 #endif /* not lint */
 
@@ -79,7 +79,7 @@ int
 main(int argc, char **argv)
 {
 	int	ch, status;
-	uint	i;
+	unsigned int	i;
 	char	*dir, *p;
 	FILE	*spec1, *spec2;
 
@@ -311,7 +311,7 @@ main(int argc, char **argv)
 static void
 usage(void)
 {
-	uint i;
+	unsigned int i;
 
 	fprintf(stderr,
 	usage: %s [-bCcDdejLlMnPqrStUuWx] [-i|-m] [-E tags]\n



CVS commit: src/usr.sbin/mtree

2012-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 20 19:09:25 UTC 2012

Modified Files:
src/usr.sbin/mtree: misc.c mtree.c

Log Message:
move flavor to misc.c because pax needs it.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/mtree/misc.c
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/mtree/mtree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/misc.c
diff -u src/usr.sbin/mtree/misc.c:1.33 src/usr.sbin/mtree/misc.c:1.34
--- src/usr.sbin/mtree/misc.c:1.33	Wed Dec 12 10:51:04 2012
+++ src/usr.sbin/mtree/misc.c	Thu Dec 20 14:09:25 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: misc.c,v 1.33 2012/12/12 15:51:04 christos Exp $	*/
+/*	$NetBSD: misc.c,v 1.34 2012/12/20 19:09:25 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(lint)
-__RCSID($NetBSD: misc.c,v 1.33 2012/12/12 15:51:04 christos Exp $);
+__RCSID($NetBSD: misc.c,v 1.34 2012/12/20 19:09:25 christos Exp $);
 #endif /* not lint */
 
 #include sys/types.h
@@ -50,6 +50,8 @@ __RCSID($NetBSD: misc.c,v 1.33 2012/12/
 
 #include extern.h
 
+enum flavor	flavor = F_MTREE;
+
 typedef struct _key {
 	const char	*name;		/* key name */
 	u_int		val;		/* value */

Index: src/usr.sbin/mtree/mtree.c
diff -u src/usr.sbin/mtree/mtree.c:1.45 src/usr.sbin/mtree/mtree.c:1.46
--- src/usr.sbin/mtree/mtree.c:1.45	Thu Dec 20 13:58:37 2012
+++ src/usr.sbin/mtree/mtree.c	Thu Dec 20 14:09:25 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.c,v 1.45 2012/12/20 18:58:37 mlelstv Exp $	*/
+/*	$NetBSD: mtree.c,v 1.46 2012/12/20 19:09:25 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1990, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)mtree.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: mtree.c,v 1.45 2012/12/20 18:58:37 mlelstv Exp $);
+__RCSID($NetBSD: mtree.c,v 1.46 2012/12/20 19:09:25 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -62,7 +62,6 @@ int	ftsoptions = FTS_PHYSICAL;
 int	bflag, cflag, Cflag, dflag, Dflag, eflag, iflag, jflag, lflag, mflag,
 	nflag, qflag, rflag, sflag, tflag, uflag, Uflag, wflag;
 char	fullpath[MAXPATHLEN];
-enum flavor	flavor = F_MTREE;
 
 static struct {
 	enum flavor flavor;



CVS commit: src/usr.sbin/mtree

2012-12-20 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Dec 20 20:17:26 UTC 2012

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
Add missing letter and use x.y versions for Fx/Nx.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.65 src/usr.sbin/mtree/mtree.8:1.66
--- src/usr.sbin/mtree/mtree.8:1.65	Thu Dec 20 16:43:16 2012
+++ src/usr.sbin/mtree/mtree.8	Thu Dec 20 20:17:26 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.65 2012/12/20 16:43:16 christos Exp $
+.\	$NetBSD: mtree.8,v 1.66 2012/12/20 20:17:26 wiz Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -160,11 +160,11 @@ The
 .Sy freebsd9
 and
 .Sy netbsd6
-flavors attempt to preserve output compatiblity and command line optio
+flavors attempt to preserve output compatiblity and command line option
 backward compatibility with
-.Fx 9
+.Fx 9.0
 and
-.Nx 6
+.Nx 6.0
 respectively.
 .It Fl f Ar spec
 Read the specification from



CVS commit: src/usr.sbin/mtree

2012-12-20 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Dec 20 20:31:01 UTC 2012

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
Typo fix.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.66 src/usr.sbin/mtree/mtree.8:1.67
--- src/usr.sbin/mtree/mtree.8:1.66	Thu Dec 20 20:17:26 2012
+++ src/usr.sbin/mtree/mtree.8	Thu Dec 20 20:31:01 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.66 2012/12/20 20:17:26 wiz Exp $
+.\	$NetBSD: mtree.8,v 1.67 2012/12/20 20:31:01 wiz Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -144,7 +144,7 @@ and
 Don't complain about files that are in the file hierarchy, but not in the
 specification.
 .It Fl F Ar flavor
-Set the compatibilty flavor of the
+Set the compatibility flavor of the
 .Nm
 utility.
 The



CVS commit: src/usr.sbin/mtree

2012-12-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec 15 01:24:40 UTC 2012

Modified Files:
src/usr.sbin/mtree: create.c

Log Message:
make us compatible with FreeBSD (for -n) (Brooks Davies)


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/usr.sbin/mtree/create.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.66 src/usr.sbin/mtree/create.c:1.67
--- src/usr.sbin/mtree/create.c:1.66	Wed Dec 12 10:50:35 2012
+++ src/usr.sbin/mtree/create.c	Fri Dec 14 20:24:40 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.66 2012/12/12 15:50:35 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.67 2012/12/15 01:24:40 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)create.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: create.c,v 1.66 2012/12/12 15:50:35 christos Exp $);
+__RCSID($NetBSD: create.c,v 1.67 2012/12/15 01:24:40 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -136,8 +136,9 @@ cwalk(void)
 		}
 		switch(p-fts_info) {
 		case FTS_D:
+			printf(\n);
 			if (!nflag)
-printf(\n# %s\n, p-fts_path);
+printf(# %s\n, p-fts_path);
 			statd(t, p, uid, gid, mode, flags);
 			statf(indent, p);
 			break;



CVS commit: src/usr.sbin/mtree

2012-12-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 12 15:50:35 UTC 2012

Modified Files:
src/usr.sbin/mtree: create.c

Log Message:
-n is incorrectly supressing the .. lines. (Brooks Davis)


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/mtree/create.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.65 src/usr.sbin/mtree/create.c:1.66
--- src/usr.sbin/mtree/create.c:1.65	Thu Oct  4 21:21:44 2012
+++ src/usr.sbin/mtree/create.c	Wed Dec 12 10:50:35 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.65 2012/10/05 01:21:44 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.66 2012/12/12 15:50:35 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)create.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: create.c,v 1.65 2012/10/05 01:21:44 christos Exp $);
+__RCSID($NetBSD: create.c,v 1.66 2012/12/12 15:50:35 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -142,9 +142,12 @@ cwalk(void)
 			statf(indent, p);
 			break;
 		case FTS_DP:
-			if (!nflag  p-fts_level  0)
-printf(%*s# %s\n%*s..\n\n, indent, ,
-p-fts_path, indent, );
+			if (p-fts_level  0) {
+if (!nflag)
+	printf(%*s# %s\n, indent, ,
+	p-fts_path);
+printf(%*s..\n\n, indent, );
+			}
 			break;
 		case FTS_DNR:
 		case FTS_ERR:



CVS commit: src/usr.sbin/mtree

2012-12-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 12 15:51:04 UTC 2012

Modified Files:
src/usr.sbin/mtree: misc.c

Log Message:
- two entries for rmd160digest in misc.c (Brooks Davis)


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/mtree/misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/misc.c
diff -u src/usr.sbin/mtree/misc.c:1.32 src/usr.sbin/mtree/misc.c:1.33
--- src/usr.sbin/mtree/misc.c:1.32	Thu Oct  4 21:31:05 2012
+++ src/usr.sbin/mtree/misc.c	Wed Dec 12 10:51:04 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: misc.c,v 1.32 2012/10/05 01:31:05 christos Exp $	*/
+/*	$NetBSD: misc.c,v 1.33 2012/12/12 15:51:04 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(lint)
-__RCSID($NetBSD: misc.c,v 1.32 2012/10/05 01:31:05 christos Exp $);
+__RCSID($NetBSD: misc.c,v 1.33 2012/12/12 15:51:04 christos Exp $);
 #endif /* not lint */
 
 #include sys/types.h
@@ -74,7 +74,6 @@ static KEY keylist[] = {
 	{nochange,	F_NOCHANGE,	0},
 	{optional,	F_OPT,		0},
 	{ripemd160digest, F_RMD160,	NEEDVALUE},
-	{rmd160digest,F_RMD160,	NEEDVALUE},
 	{rmd160,	F_RMD160,	NEEDVALUE},
 	{rmd160digest,F_RMD160,	NEEDVALUE},
 	{sha1,	F_SHA1,		NEEDVALUE},



CVS commit: src/usr.sbin/mtree

2012-12-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 12 15:51:41 UTC 2012

Modified Files:
src/usr.sbin/mtree: mtree.c

Log Message:
- No j in the getopt string. (Brooks Davis)


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/mtree/mtree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.c
diff -u src/usr.sbin/mtree/mtree.c:1.42 src/usr.sbin/mtree/mtree.c:1.43
--- src/usr.sbin/mtree/mtree.c:1.42	Fri Oct  5 05:18:08 2012
+++ src/usr.sbin/mtree/mtree.c	Wed Dec 12 10:51:41 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.c,v 1.42 2012/10/05 09:18:08 wiz Exp $	*/
+/*	$NetBSD: mtree.c,v 1.43 2012/12/12 15:51:41 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1990, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)mtree.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: mtree.c,v 1.42 2012/10/05 09:18:08 wiz Exp $);
+__RCSID($NetBSD: mtree.c,v 1.43 2012/12/12 15:51:41 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -80,7 +80,7 @@ main(int argc, char **argv)
 	spec2 = NULL;
 
 	while ((ch = getopt(argc, argv,
-	cCdDeE:f:I:ik:K:lLmMnN:p:PqrR:s:StuUWxX:))
+	cCdDeE:f:I:ijk:K:lLmMnN:p:PqrR:s:StuUWxX:))
 	!= -1) {
 		switch((char)ch) {
 		case 'c':
@@ -257,7 +257,7 @@ usage(void)
 {
 
 	fprintf(stderr,
-	usage: %s [-CcDdejLlMnPqrSUuWx] [-i|-m] [-E tags]\n
+	usage: %s [-CcDdejLlMnPqrStUuWx] [-i|-m] [-E tags]\n
 	\t\t[-f spec] [-f spec]\n
 	\t\t[-I tags] [-K keywords] [-k keywords] [-N dbdir] [-p path]\n
 	\t\t[-R keywords] [-s seed] [-X exclude-file]\n,



CVS commit: src/usr.sbin/mtree

2012-12-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 12 15:52:11 UTC 2012

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
- No mention of -t in the usage message or the manpage SYNOPSIS (Brooks Davis)


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.63 src/usr.sbin/mtree/mtree.8:1.64
--- src/usr.sbin/mtree/mtree.8:1.63	Fri Oct  5 05:18:02 2012
+++ src/usr.sbin/mtree/mtree.8	Wed Dec 12 10:52:10 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.63 2012/10/05 09:18:02 wiz Exp $
+.\	$NetBSD: mtree.8,v 1.64 2012/12/12 15:52:10 christos Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -64,7 +64,7 @@
 .Nd map a directory hierarchy
 .Sh SYNOPSIS
 .Nm
-.Op Fl CcDdejLlMnPqrSUuWx
+.Op Fl CcDdejLlMnPqrStUuWx
 .Op Fl i | Fl m
 .Op Fl E Ar tags
 .Op Fl f Ar spec



CVS commit: src/usr.sbin/mtree

2012-10-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Oct  7 18:40:49 UTC 2012

Modified Files:
src/usr.sbin/mtree: spec.c

Log Message:
disable encoding of globbing characters for now.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.83 src/usr.sbin/mtree/spec.c:1.84
--- src/usr.sbin/mtree/spec.c:1.83	Thu Oct  4 21:28:20 2012
+++ src/usr.sbin/mtree/spec.c	Sun Oct  7 14:40:49 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.83 2012/10/05 01:28:20 christos Exp $	*/
+/*	$NetBSD: spec.c,v 1.84 2012/10/07 18:40:49 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = @(#)spec.c	8.2 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: spec.c,v 1.83 2012/10/05 01:28:20 christos Exp $);
+__RCSID($NetBSD: spec.c,v 1.84 2012/10/07 18:40:49 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -415,8 +415,15 @@ dump_nodes(const char *dir, NODE *root, 
 char *
 vispath(const char *path)
 {
-	const char extra[] = { ' ', '\t', '\n', '\\', '#', '*', '?', '[',
-	'#', '\0' };
+	const char extra[] = { ' ', '\t', '\n', '\\', '#',
+#ifdef notyet
+	/*
+	 * We don't encode the globbing characters yet, because they
+	 * get encoded as \c and strunvis fails to decode them
+	 */
+	'*', '?', '[',
+#endif
+	'\0' };
 	static char pathbuf[4*MAXPATHLEN + 1];
 
 	strsvis(pathbuf, path, VIS_CSTYLE, extra);



CVS commit: src/usr.sbin/mtree

2012-10-05 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Oct  5 09:17:30 UTC 2012

Modified Files:
src/usr.sbin/mtree: mtree.h

Log Message:
Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/mtree/mtree.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.h
diff -u src/usr.sbin/mtree/mtree.h:1.30 src/usr.sbin/mtree/mtree.h:1.31
--- src/usr.sbin/mtree/mtree.h:1.30	Fri Oct  5 01:31:05 2012
+++ src/usr.sbin/mtree/mtree.h	Fri Oct  5 09:17:29 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.h,v 1.30 2012/10/05 01:31:05 christos Exp $	*/
+/*	$NetBSD: mtree.h,v 1.31 2012/10/05 09:17:29 wiz Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -86,7 +86,7 @@ typedef struct _node {
 #define	F_UID		0x0008		/* uid */
 #define	F_UNAME		0x0010		/* user name */
 #define	F_VISIT		0x0020		/* file visited */
-#define	F_NOCHANGE	0x0040		/* check existance, but not */
+#define	F_NOCHANGE	0x0040		/* check existence, but not */
 		/* other properties */
 #define	F_SHA256	0x0080		/* SHA256 digest */
 #define	F_SHA384	0x0100		/* SHA384 digest */



CVS commit: src/usr.sbin/mtree

2012-10-05 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Oct  5 09:18:02 UTC 2012

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
Fix typos; remove trailing whitespace; add missing options to SYNOPSIS.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.62 src/usr.sbin/mtree/mtree.8:1.63
--- src/usr.sbin/mtree/mtree.8:1.62	Fri Oct  5 01:31:05 2012
+++ src/usr.sbin/mtree/mtree.8	Fri Oct  5 09:18:02 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.62 2012/10/05 01:31:05 christos Exp $
+.\	$NetBSD: mtree.8,v 1.63 2012/10/05 09:18:02 wiz Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -64,7 +64,7 @@
 .Nd map a directory hierarchy
 .Sh SYNOPSIS
 .Nm
-.Op Fl CcDdeLlMPrSUuWx
+.Op Fl CcDdejLlMnPqrSUuWx
 .Op Fl i | Fl m
 .Op Fl E Ar tags
 .Op Fl f Ar spec
@@ -149,13 +149,12 @@ If this option is specified twice, the t
 to each other rather than to the file hierarchy.
 The specifications will be sorted like output generated using
 .Fl c .
-The output format in this case is somewhat remniscent of
+The output format in this case is somewhat reminiscent of
 .Xr comm 1 ,
 having in first spec only, in second spec only, and different
 columns, prefixed by zero, one and two TAB characters respectively.
 Each entry in the different column occupies two lines, one from each
-specifica
-tion.
+specification.
 .It Fl I Ar tags
 Add the comma separated tags to the
 .Dq inclusion
@@ -168,7 +167,7 @@ If no inclusion list is provided, the de
 .It Fl i
 If specified, set the schg and/or sappnd flags.
 .It Fl j
-Indent the output 4 spaces each time a directory level is descended when  
+Indent the output 4 spaces each time a directory level is descended when
 creating a specification with the
 .Fl c
 option.
@@ -231,7 +230,7 @@ See
 for information on security levels.
 .It Fl n
 Do not emit pathname comments when creating a specification.
-Normally  
+Normally
 a comment is emitted before each directory and before the close of that
 directory when using the
 .Fl c



CVS commit: src/usr.sbin/mtree

2012-10-05 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Oct  5 09:18:08 UTC 2012

Modified Files:
src/usr.sbin/mtree: mtree.c

Log Message:
Sync usage with man page.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/mtree/mtree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.c
diff -u src/usr.sbin/mtree/mtree.c:1.41 src/usr.sbin/mtree/mtree.c:1.42
--- src/usr.sbin/mtree/mtree.c:1.41	Fri Oct  5 01:26:56 2012
+++ src/usr.sbin/mtree/mtree.c	Fri Oct  5 09:18:08 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.c,v 1.41 2012/10/05 01:26:56 christos Exp $	*/
+/*	$NetBSD: mtree.c,v 1.42 2012/10/05 09:18:08 wiz Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1990, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)mtree.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: mtree.c,v 1.41 2012/10/05 01:26:56 christos Exp $);
+__RCSID($NetBSD: mtree.c,v 1.42 2012/10/05 09:18:08 wiz Exp $);
 #endif
 #endif /* not lint */
 
@@ -257,7 +257,7 @@ usage(void)
 {
 
 	fprintf(stderr,
-	usage: %s [-CcDdeLlMnPrSUuWx] [-i|-m] [-E tags]\n
+	usage: %s [-CcDdejLlMnPqrSUuWx] [-i|-m] [-E tags]\n
 	\t\t[-f spec] [-f spec]\n
 	\t\t[-I tags] [-K keywords] [-k keywords] [-N dbdir] [-p path]\n
 	\t\t[-R keywords] [-s seed] [-X exclude-file]\n,



CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 00:40:51 UTC 2012

Modified Files:
src/usr.sbin/mtree: crc.c

Log Message:
remove dup extern (brooks)


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/mtree/crc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/crc.c
diff -u src/usr.sbin/mtree/crc.c:1.8 src/usr.sbin/mtree/crc.c:1.9
--- src/usr.sbin/mtree/crc.c:1.8	Thu Jun  2 02:04:46 2005
+++ src/usr.sbin/mtree/crc.c	Thu Oct  4 20:40:51 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: crc.c,v 1.8 2005/06/02 06:04:46 lukem Exp $	*/
+/*	$NetBSD: crc.c,v 1.9 2012/10/05 00:40:51 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = @(#)crc.c	8.1 (Berkeley) 6/17/93;
 #else
-__RCSID($NetBSD: crc.c,v 1.8 2005/06/02 06:04:46 lukem Exp $);
+__RCSID($NetBSD: crc.c,v 1.9 2012/10/05 00:40:51 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -114,7 +114,6 @@ static const u_int32_t crctab[] = {
  * locations to store the crc and the number of bytes read.  It returns 0 on
  * success and 1 on failure.  Errno is set on failure.
  */
-extern int sflag;
 u_int32_t crc_total = ~0;		/* The crc over a number of files. */
 
 int



CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 00:41:24 UTC 2012

Modified Files:
src/usr.sbin/mtree: compare.c create.c

Log Message:
more const
check if we support SHA384 before using
(brooks)


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.sbin/mtree/compare.c
cvs rdiff -u -r1.59 -r1.60 src/usr.sbin/mtree/create.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/compare.c
diff -u src/usr.sbin/mtree/compare.c:1.52 src/usr.sbin/mtree/compare.c:1.53
--- src/usr.sbin/mtree/compare.c:1.52	Sun Dec 28 14:36:30 2008
+++ src/usr.sbin/mtree/compare.c	Thu Oct  4 20:41:24 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: compare.c,v 1.52 2008/12/28 19:36:30 christos Exp $	*/
+/*	$NetBSD: compare.c,v 1.53 2012/10/05 00:41:24 christos 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.52 2008/12/28 19:36:30 christos Exp $);
+__RCSID($NetBSD: compare.c,v 1.53 2012/10/05 00:41:24 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -462,6 +462,7 @@ typeerr:		LABEL;
 			free(digestbuf);
 		}
 	}
+#ifdef SHA384_BLOCK_LENGTH
 	if (s-flags  F_SHA384) {
 		if ((digestbuf = SHA384_File(p-fts_accpath, NULL)) == NULL) {
 			LABEL;
@@ -478,6 +479,7 @@ typeerr:		LABEL;
 			free(digestbuf);
 		}
 	}
+#endif
 	if (s-flags  F_SHA512) {
 		if ((digestbuf = SHA512_File(p-fts_accpath, NULL)) == NULL) {
 			LABEL;

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.59 src/usr.sbin/mtree/create.c:1.60
--- src/usr.sbin/mtree/create.c:1.59	Sun Jul 15 05:08:29 2012
+++ src/usr.sbin/mtree/create.c	Thu Oct  4 20:41:24 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.59 2012/07/15 09:08:29 spz Exp $	*/
+/*	$NetBSD: create.c,v 1.60 2012/10/05 00:41:24 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)create.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: create.c,v 1.59 2012/07/15 09:08:29 spz Exp $);
+__RCSID($NetBSD: create.c,v 1.60 2012/10/05 00:41:24 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -83,7 +83,7 @@ static uid_t uid;
 static mode_t mode;
 static u_long flags;
 
-static int	dcmp(const FTSENT **, const FTSENT **);
+static int	dcmp(const FTSENT *const *, const FTSENT *const *);
 static void	output(int *, const char *, ...)
 	__attribute__((__format__(__printf__, 2, 3)));
 static int	statd(FTS *, FTSENT *, uid_t *, gid_t *, mode_t *, u_long *);
@@ -242,12 +242,14 @@ statf(FTSENT *p)
 		output(indent, sha256=%s, digestbuf);
 		free(digestbuf);
 	}
+#ifdef SHA384_BLOCK_LENGTH
 	if (keys  F_SHA384  S_ISREG(p-fts_statp-st_mode)) {
 		if ((digestbuf = SHA384_File(p-fts_accpath, NULL)) == NULL)
 			mtree_err(%s: SHA384_File failed: %s, p-fts_accpath, strerror(errno));
 		output(indent, sha384=%s, digestbuf);
 		free(digestbuf);
 	}
+#endif
 	if (keys  F_SHA512  S_ISREG(p-fts_statp-st_mode)) {
 		if ((digestbuf = SHA512_File(p-fts_accpath, NULL)) == NULL)
 			mtree_err(%s: SHA512_File failed: %s, p-fts_accpath, strerror(errno));
@@ -398,7 +400,7 @@ statd(FTS *t, FTSENT *parent, uid_t *pui
  * Keep this in sync with nodecmp() in spec.c.
  */
 static int
-dcmp(const FTSENT **a, const FTSENT **b)
+dcmp(const FTSENT *const *a, const FTSENT *const *b)
 {
 
 	if (S_ISDIR((*a)-fts_statp-st_mode)) {



CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 00:42:01 UTC 2012

Modified Files:
src/usr.sbin/mtree: compare.c

Log Message:
explicitly include sys/stat.h


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.sbin/mtree/compare.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/compare.c
diff -u src/usr.sbin/mtree/compare.c:1.53 src/usr.sbin/mtree/compare.c:1.54
--- src/usr.sbin/mtree/compare.c:1.53	Thu Oct  4 20:41:24 2012
+++ src/usr.sbin/mtree/compare.c	Thu Oct  4 20:42:00 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: compare.c,v 1.53 2012/10/05 00:41:24 christos Exp $	*/
+/*	$NetBSD: compare.c,v 1.54 2012/10/05 00:42:00 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,11 +38,12 @@
 #if 0
 static char sccsid[] = @(#)compare.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: compare.c,v 1.53 2012/10/05 00:41:24 christos Exp $);
+__RCSID($NetBSD: compare.c,v 1.54 2012/10/05 00:42:00 christos Exp $);
 #endif
 #endif /* not lint */
 
 #include sys/param.h
+#include sys/stat.h
 
 #include errno.h
 #include fcntl.h



CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 00:58:47 UTC 2012

Modified Files:
src/usr.sbin/mtree: create.c

Log Message:
our fts compare routine is less constified.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/usr.sbin/mtree/create.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.60 src/usr.sbin/mtree/create.c:1.61
--- src/usr.sbin/mtree/create.c:1.60	Thu Oct  4 20:41:24 2012
+++ src/usr.sbin/mtree/create.c	Thu Oct  4 20:58:46 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.60 2012/10/05 00:41:24 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.61 2012/10/05 00:58:46 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)create.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: create.c,v 1.60 2012/10/05 00:41:24 christos Exp $);
+__RCSID($NetBSD: create.c,v 1.61 2012/10/05 00:58:46 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -83,7 +83,13 @@ static uid_t uid;
 static mode_t mode;
 static u_long flags;
 
-static int	dcmp(const FTSENT *const *, const FTSENT *const *);
+#ifdef __FreeBSD__
+#define	FTS_CONST const
+#else
+#define	FTS_CONST
+#endif
+
+static int	dcmp(const FTSENT *FTS_CONST *, const FTSENT *FTS_CONST *);
 static void	output(int *, const char *, ...)
 	__attribute__((__format__(__printf__, 2, 3)));
 static int	statd(FTS *, FTSENT *, uid_t *, gid_t *, mode_t *, u_long *);
@@ -214,46 +220,52 @@ statf(FTSENT *p)
 #ifndef NO_MD5
 	if (keys  F_MD5  S_ISREG(p-fts_statp-st_mode)) {
 		if ((digestbuf = MD5File(p-fts_accpath, NULL)) == NULL)
-			mtree_err(%s: MD5File failed: %s, p-fts_accpath, strerror(errno));
-		output(indent, md5=%s, digestbuf);
+			mtree_err(%s: MD5File failed: %s, p-fts_accpath,
+			strerror(errno));
+		output(indent, %s=%s, MD5KEY, digestbuf);
 		free(digestbuf);
 	}
 #endif	/* ! NO_MD5 */
 #ifndef NO_RMD160
 	if (keys  F_RMD160  S_ISREG(p-fts_statp-st_mode)) {
 		if ((digestbuf = RMD160File(p-fts_accpath, NULL)) == NULL)
-			mtree_err(%s: RMD160File failed: %s, p-fts_accpath, strerror(errno));
-		output(indent, rmd160=%s, digestbuf);
+			mtree_err(%s: RMD160File failed: %s, p-fts_accpath,
+			strerror(errno));
+		output(indent, %s=%s, RMD160KEY, digestbuf);
 		free(digestbuf);
 	}
 #endif	/* ! NO_RMD160 */
 #ifndef NO_SHA1
 	if (keys  F_SHA1  S_ISREG(p-fts_statp-st_mode)) {
 		if ((digestbuf = SHA1File(p-fts_accpath, NULL)) == NULL)
-			mtree_err(%s: SHA1File failed: %s, p-fts_accpath, strerror(errno));
-		output(indent, sha1=%s, digestbuf);
+			mtree_err(%s: SHA1File failed: %s, p-fts_accpath,
+			strerror(errno));
+		output(indent, %s=%s, SHA1KEY, digestbuf);
 		free(digestbuf);
 	}
 #endif	/* ! NO_SHA1 */
 #ifndef NO_SHA2
 	if (keys  F_SHA256  S_ISREG(p-fts_statp-st_mode)) {
 		if ((digestbuf = SHA256_File(p-fts_accpath, NULL)) == NULL)
-			mtree_err(%s: SHA256_File failed: %s, p-fts_accpath, strerror(errno));
-		output(indent, sha256=%s, digestbuf);
+			mtree_err(%s: SHA256_File failed: %s, p-fts_accpath,
+			strerror(errno));
+		output(indent, %s=%s, SHA256KEY, digestbuf);
 		free(digestbuf);
 	}
 #ifdef SHA384_BLOCK_LENGTH
 	if (keys  F_SHA384  S_ISREG(p-fts_statp-st_mode)) {
 		if ((digestbuf = SHA384_File(p-fts_accpath, NULL)) == NULL)
-			mtree_err(%s: SHA384_File failed: %s, p-fts_accpath, strerror(errno));
-		output(indent, sha384=%s, digestbuf);
+			mtree_err(%s: SHA384_File failed: %s, p-fts_accpath,
+			strerror(errno));
+		output(indent, %s=%s, SHA384KEY, digestbuf);
 		free(digestbuf);
 	}
 #endif
 	if (keys  F_SHA512  S_ISREG(p-fts_statp-st_mode)) {
 		if ((digestbuf = SHA512_File(p-fts_accpath, NULL)) == NULL)
-			mtree_err(%s: SHA512_File failed: %s, p-fts_accpath, strerror(errno));
-		output(indent, sha512=%s, digestbuf);
+			mtree_err(%s: SHA512_File failed: %s, p-fts_accpath,
+			strerror(errno));
+		output(indent, %s=%s, SHA512KEY, digestbuf);
 		free(digestbuf);
 	}
 #endif	/* ! NO_SHA2 */
@@ -400,7 +412,7 @@ statd(FTS *t, FTSENT *parent, uid_t *pui
  * Keep this in sync with nodecmp() in spec.c.
  */
 static int
-dcmp(const FTSENT *const *a, const FTSENT *const *b)
+dcmp(const FTSENT *FTS_CONST *a, const FTSENT *FTS_CONST *b)
 {
 
 	if (S_ISDIR((*a)-fts_statp-st_mode)) {



CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 00:59:35 UTC 2012

Modified Files:
src/usr.sbin/mtree: compare.c misc.c mtree.8 mtree.h spec.c

Log Message:
account for differences in digest names


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/usr.sbin/mtree/compare.c \
src/usr.sbin/mtree/mtree.8
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/mtree/misc.c
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/mtree/mtree.h
cvs rdiff -u -r1.80 -r1.81 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/compare.c
diff -u src/usr.sbin/mtree/compare.c:1.54 src/usr.sbin/mtree/compare.c:1.55
--- src/usr.sbin/mtree/compare.c:1.54	Thu Oct  4 20:42:00 2012
+++ src/usr.sbin/mtree/compare.c	Thu Oct  4 20:59:35 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: compare.c,v 1.54 2012/10/05 00:42:00 christos Exp $	*/
+/*	$NetBSD: compare.c,v 1.55 2012/10/05 00:59:35 christos 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.54 2012/10/05 00:42:00 christos Exp $);
+__RCSID($NetBSD: compare.c,v 1.55 2012/10/05 00:59:35 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -396,14 +396,14 @@ typeerr:		LABEL;
 	if (s-flags  F_MD5) {
 		if ((digestbuf = MD5File(p-fts_accpath, NULL)) == NULL) {
 			LABEL;
-			printf(%smd5: %s: %s\n,
-			tab, p-fts_accpath, strerror(errno));
+			printf(%s%s: %s: %s\n,
+			tab, MD5KEY, p-fts_accpath, strerror(errno));
 			tab = \t;
 		} else {
 			if (strcmp(s-md5digest, digestbuf)) {
 LABEL;
-printf(%smd5 (0x%s, 0x%s)\n,
-tab, s-md5digest, digestbuf);
+printf(%s%s (0x%s, 0x%s)\n,
+tab, MD5KEY, s-md5digest, digestbuf);
 			}
 			tab = \t;
 			free(digestbuf);
@@ -414,14 +414,14 @@ typeerr:		LABEL;
 	if (s-flags  F_RMD160) {
 		if ((digestbuf = RMD160File(p-fts_accpath, NULL)) == NULL) {
 			LABEL;
-			printf(%srmd160: %s: %s\n,
-			tab, p-fts_accpath, strerror(errno));
+			printf(%s%s: %s: %s\n,
+			tab, RMD160KEY, p-fts_accpath, strerror(errno));
 			tab = \t;
 		} else {
 			if (strcmp(s-rmd160digest, digestbuf)) {
 LABEL;
-printf(%srmd160 (0x%s, 0x%s)\n,
-tab, s-rmd160digest, digestbuf);
+printf(%s%s (0x%s, 0x%s)\n,
+tab, RMD160KEY, s-rmd160digest, digestbuf);
 			}
 			tab = \t;
 			free(digestbuf);
@@ -432,14 +432,14 @@ typeerr:		LABEL;
 	if (s-flags  F_SHA1) {
 		if ((digestbuf = SHA1File(p-fts_accpath, NULL)) == NULL) {
 			LABEL;
-			printf(%ssha1: %s: %s\n,
-			tab, p-fts_accpath, strerror(errno));
+			printf(%s%s: %s: %s\n,
+			tab, SHA1KEY, p-fts_accpath, strerror(errno));
 			tab = \t;
 		} else {
 			if (strcmp(s-sha1digest, digestbuf)) {
 LABEL;
-printf(%ssha1 (0x%s, 0x%s)\n,
-tab, s-sha1digest, digestbuf);
+printf(%s%s (0x%s, 0x%s)\n,
+tab, SHA1KEY, s-sha1digest, digestbuf);
 			}
 			tab = \t;
 			free(digestbuf);
@@ -450,14 +450,14 @@ typeerr:		LABEL;
 	if (s-flags  F_SHA256) {
 		if ((digestbuf = SHA256_File(p-fts_accpath, NULL)) == NULL) {
 			LABEL;
-			printf(%ssha256: %s: %s\n,
-			tab, p-fts_accpath, strerror(errno));
+			printf(%s%s: %s: %s\n,
+			tab, SHA256KEY, p-fts_accpath, strerror(errno));
 			tab = \t;
 		} else {
 			if (strcmp(s-sha256digest, digestbuf)) {
 LABEL;
-printf(%ssha256 (0x%s, 0x%s)\n,
-tab, s-sha256digest, digestbuf);
+printf(%s%s (0x%s, 0x%s)\n,
+tab, SHA256KEY, s-sha256digest, digestbuf);
 			}
 			tab = \t;
 			free(digestbuf);
@@ -467,14 +467,14 @@ typeerr:		LABEL;
 	if (s-flags  F_SHA384) {
 		if ((digestbuf = SHA384_File(p-fts_accpath, NULL)) == NULL) {
 			LABEL;
-			printf(%ssha384: %s: %s\n,
-			tab, p-fts_accpath, strerror(errno));
+			printf(%s%s: %s: %s\n,
+			tab, SHA384KEY, p-fts_accpath, strerror(errno));
 			tab = \t;
 		} else {
 			if (strcmp(s-sha384digest, digestbuf)) {
 LABEL;
-printf(%ssha384 (0x%s, 0x%s)\n,
-tab, s-sha384digest, digestbuf);
+printf(%s%s (0x%s, 0x%s)\n,
+tab, SHA384KEY, s-sha384digest, digestbuf);
 			}
 			tab = \t;
 			free(digestbuf);
@@ -484,14 +484,14 @@ typeerr:		LABEL;
 	if (s-flags  F_SHA512) {
 		if ((digestbuf = SHA512_File(p-fts_accpath, NULL)) == NULL) {
 			LABEL;
-			printf(%ssha512: %s: %s\n,
-			tab, p-fts_accpath, strerror(errno));
+			printf(%s%s: %s: %s\n,
+			tab, SHA512KEY, p-fts_accpath, strerror(errno));
 			tab = \t;
 		} else {
 			if (strcmp(s-sha512digest, digestbuf)) {
 LABEL;
-printf(%ssha512 (0x%s, 0x%s)\n,
-tab, s-sha512digest, digestbuf);
+printf(%s%s (0x%s, 0x%s)\n,
+tab, SHA512KEY, s-sha512digest, digestbuf);
 			}
 			tab = \t;
 			free(digestbuf);
Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.54 src/usr.sbin/mtree/mtree.8:1.55
--- src/usr.sbin/mtree/mtree.8:1.54	Wed Oct  3 

CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 01:01:07 UTC 2012

Modified Files:
src/usr.sbin/mtree: create.c extern.h mtree.8 mtree.c

Log Message:
add -n flag to disable comments (brook)


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/usr.sbin/mtree/create.c
cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/mtree/extern.h
cvs rdiff -u -r1.55 -r1.56 src/usr.sbin/mtree/mtree.8
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/mtree/mtree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.61 src/usr.sbin/mtree/create.c:1.62
--- src/usr.sbin/mtree/create.c:1.61	Thu Oct  4 20:58:46 2012
+++ src/usr.sbin/mtree/create.c	Thu Oct  4 21:01:07 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.61 2012/10/05 00:58:46 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.62 2012/10/05 01:01:07 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)create.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: create.c,v 1.61 2012/10/05 00:58:46 christos Exp $);
+__RCSID($NetBSD: create.c,v 1.62 2012/10/05 01:01:07 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -118,9 +118,11 @@ cwalk(void)
 		unknown;
 	}
 
-	printf(
-	#\t   user: %s\n#\tmachine: %s\n#\t   tree: %s\n#\t   date: %s,
-	user, host, fullpath, ctime(clocktime));
+	if (!nflag)
+		printf(
+		#\t   user: %s\n#\tmachine: %s\n#\t   tree: %s\n
+		#\t   date: %s,
+		user, host, fullpath, ctime(clocktime));
 
 	if ((t = fts_open(argv, ftsoptions, dcmp)) == NULL)
 		mtree_err(fts_open: %s, strerror(errno));
@@ -131,12 +133,13 @@ cwalk(void)
 		}
 		switch(p-fts_info) {
 		case FTS_D:
-			printf(\n# %s\n, p-fts_path);
+			if (!nflag)
+printf(\n# %s\n, p-fts_path);
 			statd(t, p, uid, gid, mode, flags);
 			statf(p);
 			break;
 		case FTS_DP:
-			if (p-fts_level  0)
+			if (!nflag  p-fts_level  0)
 printf(# %s\n..\n\n, p-fts_path);
 			break;
 		case FTS_DNR:

Index: src/usr.sbin/mtree/extern.h
diff -u src/usr.sbin/mtree/extern.h:1.32 src/usr.sbin/mtree/extern.h:1.33
--- src/usr.sbin/mtree/extern.h:1.32	Mon Aug 29 16:37:43 2011
+++ src/usr.sbin/mtree/extern.h	Thu Oct  4 21:01:07 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.32 2011/08/29 20:37:43 joerg Exp $	*/
+/*	$NetBSD: extern.h,v 1.33 2012/10/05 01:01:07 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -69,7 +69,8 @@ void	 read_excludes_file(const char *);
 const char *rlink(const char *);
 int	 verify(void);
 
-extern int	dflag, eflag, iflag, lflag, mflag, rflag, sflag, tflag, uflag;
+extern int	dflag, eflag, iflag, lflag, mflag,
+		nflag, rflag, sflag, tflag, uflag;
 extern int	mtree_Mflag, mtree_Sflag, mtree_Wflag;
 extern size_t	mtree_lineno;
 extern u_int32_t crc_total;

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.55 src/usr.sbin/mtree/mtree.8:1.56
--- src/usr.sbin/mtree/mtree.8:1.55	Thu Oct  4 20:59:35 2012
+++ src/usr.sbin/mtree/mtree.8	Thu Oct  4 21:01:07 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.55 2012/10/05 00:59:35 christos Exp $
+.\	$NetBSD: mtree.8,v 1.56 2012/10/05 01:01:07 christos Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -203,6 +203,13 @@ mode).
 See
 .Xr init 8
 for information on security levels.
+.It Fl n
+Do not emit pathname comments when creating a specification.
+Normally  
+a comment is emitted before each directory and before the close of that
+directory when using the
+.Fl c
+option.
 .It Fl N Ar dbdir
 Use the user database text file
 .Pa master.passwd

Index: src/usr.sbin/mtree/mtree.c
diff -u src/usr.sbin/mtree/mtree.c:1.37 src/usr.sbin/mtree/mtree.c:1.38
--- src/usr.sbin/mtree/mtree.c:1.37	Mon Aug 29 16:37:43 2011
+++ src/usr.sbin/mtree/mtree.c	Thu Oct  4 21:01:07 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.c,v 1.37 2011/08/29 20:37:43 joerg Exp $	*/
+/*	$NetBSD: mtree.c,v 1.38 2012/10/05 01:01:07 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1990, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)mtree.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: mtree.c,v 1.37 2011/08/29 20:37:43 joerg Exp $);
+__RCSID($NetBSD: mtree.c,v 1.38 2012/10/05 01:01:07 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -60,7 +60,7 @@ __RCSID($NetBSD: mtree.c,v 1.37 2011/08
 
 int	ftsoptions = FTS_PHYSICAL;
 int	cflag, Cflag, dflag, Dflag, eflag, iflag, lflag, mflag,
-	rflag, sflag, tflag, uflag, Uflag;
+	nflag, rflag, sflag, tflag, uflag, Uflag;
 char	fullpath[MAXPATHLEN];
 
 __dead static	void	usage(void);
@@ -77,7 +77,7 @@ main(int argc, char **argv)
 	init_excludes();
 
 	while ((ch = getopt(argc, argv,
-	cCdDeE:f:I:ik:K:lLmMN:p:PrR:s:StuUWxX:))
+	cCdDeE:f:I:ik:K:lLmMnN:p:PrR:s:StuUWxX:))
 	!= -1) {
 		switch((char)ch) {
 		case 'c':
@@ -132,6 +132,9 

CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 01:05:14 UTC 2012

Modified Files:
src/usr.sbin/mtree: extern.h mtree.8 mtree.c verify.c

Log Message:
add -q flag to silence warnings about symlinks to existing dirs (from OpenBSD
via brooks)


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/mtree/extern.h
cvs rdiff -u -r1.56 -r1.57 src/usr.sbin/mtree/mtree.8
cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/mtree/mtree.c
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/mtree/verify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/extern.h
diff -u src/usr.sbin/mtree/extern.h:1.33 src/usr.sbin/mtree/extern.h:1.34
--- src/usr.sbin/mtree/extern.h:1.33	Thu Oct  4 21:01:07 2012
+++ src/usr.sbin/mtree/extern.h	Thu Oct  4 21:05:14 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.33 2012/10/05 01:01:07 christos Exp $	*/
+/*	$NetBSD: extern.h,v 1.34 2012/10/05 01:05:14 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -70,7 +70,7 @@ const char *rlink(const char *);
 int	 verify(void);
 
 extern int	dflag, eflag, iflag, lflag, mflag,
-		nflag, rflag, sflag, tflag, uflag;
+		nflag, qflag, rflag, sflag, tflag, uflag;
 extern int	mtree_Mflag, mtree_Sflag, mtree_Wflag;
 extern size_t	mtree_lineno;
 extern u_int32_t crc_total;

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.56 src/usr.sbin/mtree/mtree.8:1.57
--- src/usr.sbin/mtree/mtree.8:1.56	Thu Oct  4 21:01:07 2012
+++ src/usr.sbin/mtree/mtree.8	Thu Oct  4 21:05:14 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.56 2012/10/05 01:01:07 christos Exp $
+.\	$NetBSD: mtree.8,v 1.57 2012/10/05 01:05:14 christos Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -230,6 +230,12 @@ This is the default.
 Use the file hierarchy rooted in
 .Ar path  ,
 instead of the current directory.
+.It Fl q
+Quiet mode.
+Do not complain when a
+.Dq missing
+directory cannot be created because it already exists.
+This occurs when the directory is a symbolic link.
 .It Fl R Ar keywords
 Remove the specified (whitespace or comma separated) keywords from the current
 set of keywords.

Index: src/usr.sbin/mtree/mtree.c
diff -u src/usr.sbin/mtree/mtree.c:1.38 src/usr.sbin/mtree/mtree.c:1.39
--- src/usr.sbin/mtree/mtree.c:1.38	Thu Oct  4 21:01:07 2012
+++ src/usr.sbin/mtree/mtree.c	Thu Oct  4 21:05:14 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.c,v 1.38 2012/10/05 01:01:07 christos Exp $	*/
+/*	$NetBSD: mtree.c,v 1.39 2012/10/05 01:05:14 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1990, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)mtree.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: mtree.c,v 1.38 2012/10/05 01:01:07 christos Exp $);
+__RCSID($NetBSD: mtree.c,v 1.39 2012/10/05 01:05:14 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -60,7 +60,7 @@ __RCSID($NetBSD: mtree.c,v 1.38 2012/10
 
 int	ftsoptions = FTS_PHYSICAL;
 int	cflag, Cflag, dflag, Dflag, eflag, iflag, lflag, mflag,
-	nflag, rflag, sflag, tflag, uflag, Uflag;
+	nflag, qflag, rflag, sflag, tflag, uflag, Uflag;
 char	fullpath[MAXPATHLEN];
 
 __dead static	void	usage(void);
@@ -77,7 +77,7 @@ main(int argc, char **argv)
 	init_excludes();
 
 	while ((ch = getopt(argc, argv,
-	cCdDeE:f:I:ik:K:lLmMnN:p:PrR:s:StuUWxX:))
+	cCdDeE:f:I:ik:K:lLmMnN:p:PqrR:s:StuUWxX:))
 	!= -1) {
 		switch((char)ch) {
 		case 'c':
@@ -148,6 +148,9 @@ main(int argc, char **argv)
 			ftsoptions = ~FTS_LOGICAL;
 			ftsoptions |= FTS_PHYSICAL;
 			break;
+		case 'q':
+			qflag = 1;
+			break;
 		case 'r':
 			rflag = 1;
 			break;

Index: src/usr.sbin/mtree/verify.c
diff -u src/usr.sbin/mtree/verify.c:1.40 src/usr.sbin/mtree/verify.c:1.41
--- src/usr.sbin/mtree/verify.c:1.40	Sun Mar 25 12:07:04 2012
+++ src/usr.sbin/mtree/verify.c	Thu Oct  4 21:05:14 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: verify.c,v 1.40 2012/03/25 16:07:04 christos Exp $	*/
+/*	$NetBSD: verify.c,v 1.41 2012/10/05 01:05:14 christos 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.40 2012/03/25 16:07:04 christos Exp $);
+__RCSID($NetBSD: verify.c,v 1.41 2012/10/05 01:05:14 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -175,8 +175,17 @@ miss(NODE *p, char *tail)
 		if (p-type != F_DIR  (dflag || p-flags  F_VISIT))
 			continue;
 		strcpy(tail, p-name);
-		if (!(p-flags  F_VISIT))
-			printf(missing: %s, path);
+		if (!(p-flags  F_VISIT)) {
+			/* Don't print missing message if file exists as a 
+			   symbolic link and the -q flag is set. */
+			struct stat statbuf;
+
+			if (qflag  stat(path, statbuf) == 0 
+			S_ISDIR(statbuf.st_mode))
+p-flags |= F_VISIT;
+			else
+(void)printf(%s missing, path);
+		}
 		switch (p-type) {
 		case F_BLOCK:
 		case 

CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 01:13:51 UTC 2012

Modified Files:
src/usr.sbin/mtree: create.c extern.h mtree.8 mtree.c

Log Message:
add -j flag to indent directory blocks (from brooks)


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/usr.sbin/mtree/create.c
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/mtree/extern.h
cvs rdiff -u -r1.57 -r1.58 src/usr.sbin/mtree/mtree.8
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/mtree/mtree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.62 src/usr.sbin/mtree/create.c:1.63
--- src/usr.sbin/mtree/create.c:1.62	Thu Oct  4 21:01:07 2012
+++ src/usr.sbin/mtree/create.c	Thu Oct  4 21:13:50 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.62 2012/10/05 01:01:07 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.63 2012/10/05 01:13:50 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)create.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: create.c,v 1.62 2012/10/05 01:01:07 christos Exp $);
+__RCSID($NetBSD: create.c,v 1.63 2012/10/05 01:13:50 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -90,10 +90,10 @@ static u_long flags;
 #endif
 
 static int	dcmp(const FTSENT *FTS_CONST *, const FTSENT *FTS_CONST *);
-static void	output(int *, const char *, ...)
-	__attribute__((__format__(__printf__, 2, 3)));
+static void	output(int, int *, const char *, ...)
+	__attribute__((__format__(__printf__, 3, 4)));
 static int	statd(FTS *, FTSENT *, uid_t *, gid_t *, mode_t *, u_long *);
-static void	statf(FTSENT *);
+static void	statf(int, FTSENT *);
 
 void
 cwalk(void)
@@ -105,6 +105,7 @@ cwalk(void)
 	const char *user;
 	char *argv[2];
 	char  dot[] = .;
+	int indent = 0;
 
 	argv[0] = dot;
 	argv[1] = NULL;
@@ -127,6 +128,8 @@ cwalk(void)
 	if ((t = fts_open(argv, ftsoptions, dcmp)) == NULL)
 		mtree_err(fts_open: %s, strerror(errno));
 	while ((p = fts_read(t)) != NULL) {
+		if (jflag)
+			indent = p-fts_level * 4;
 		if (check_excludes(p-fts_name, p-fts_path)) {
 			fts_set(t, p, FTS_SKIP);
 			continue;
@@ -136,11 +139,12 @@ cwalk(void)
 			if (!nflag)
 printf(\n# %s\n, p-fts_path);
 			statd(t, p, uid, gid, mode, flags);
-			statf(p);
+			statf(indent, p);
 			break;
 		case FTS_DP:
 			if (!nflag  p-fts_level  0)
-printf(# %s\n..\n\n, p-fts_path);
+printf(%*s# %s\n%*s..\n\n, indent, ,
+p-fts_path, indent, );
 			break;
 		case FTS_DNR:
 		case FTS_ERR:
@@ -150,7 +154,7 @@ cwalk(void)
 			break;
 		default:
 			if (!dflag)
-statf(p);
+statf(indent, p);
 			break;
 
 		}
@@ -161,56 +165,59 @@ cwalk(void)
 }
 
 static void
-statf(FTSENT *p)
+statf(int indent, FTSENT *p)
 {
 	u_int32_t len, val;
-	int fd, indent;
+	int fd, offset;
 	const char *name;
 #if !defined(NO_MD5) || !defined(NO_RMD160) || !defined(NO_SHA1) || !defined(NO_SHA2)
 	char *digestbuf;
 #endif
 
-	indent = printf(%s%s,
+	offset = printf(%*s%s%s, indent, ,
 	S_ISDIR(p-fts_statp-st_mode) ?  : , vispath(p-fts_name));
 
-	if (indent  INDENTNAMELEN)
-		indent = MAXLINELEN;
+	if (offset  (INDENTNAMELEN + indent))
+		offset = MAXLINELEN;
 	else
-		indent += printf(%*s, INDENTNAMELEN - indent, );
+		offset += printf(%*s, (INDENTNAMELEN + indent) - offset, );
 
 	if (!S_ISREG(p-fts_statp-st_mode))
-		output(indent, type=%s, inotype(p-fts_statp-st_mode));
+		output(indent, offset, type=%s,
+		inotype(p-fts_statp-st_mode));
 	if (keys  (F_UID | F_UNAME)  p-fts_statp-st_uid != uid) {
 		if (keys  F_UNAME 
 		(name = user_from_uid(p-fts_statp-st_uid, 1)) != NULL)
-			output(indent, uname=%s, name);
+			output(indent, offset, uname=%s, name);
 		else /* if (keys  F_UID) */
-			output(indent, uid=%u, p-fts_statp-st_uid);
+			output(indent, offset, uid=%u, p-fts_statp-st_uid);
 	}
 	if (keys  (F_GID | F_GNAME)  p-fts_statp-st_gid != gid) {
 		if (keys  F_GNAME 
 		(name = group_from_gid(p-fts_statp-st_gid, 1)) != NULL)
-			output(indent, gname=%s, name);
+			output(indent, offset, gname=%s, name);
 		else /* if (keys  F_GID) */
-			output(indent, gid=%u, p-fts_statp-st_gid);
+			output(indent, offset, gid=%u, p-fts_statp-st_gid);
 	}
 	if (keys  F_MODE  (p-fts_statp-st_mode  MBITS) != mode)
-		output(indent, mode=%#o, p-fts_statp-st_mode  MBITS);
+		output(indent, offset, mode=%#o,
+		p-fts_statp-st_mode  MBITS);
 	if (keys  F_DEV 
 	(S_ISBLK(p-fts_statp-st_mode) || S_ISCHR(p-fts_statp-st_mode)))
-		output(indent, device=%#llx,
+		output(indent, offset, device=%#llx,
 		(long long)p-fts_statp-st_rdev);
 	if (keys  F_NLINK  p-fts_statp-st_nlink != 1)
-		output(indent, nlink=%u, p-fts_statp-st_nlink);
+		output(indent, offset, nlink=%u, p-fts_statp-st_nlink);
 	if (keys  F_SIZE  S_ISREG(p-fts_statp-st_mode))
-		output(indent, size=%lld, (long long)p-fts_statp-st_size);
+		output(indent, offset, size=%lld,
+		

CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 01:19:54 UTC 2012

Modified Files:
src/usr.sbin/mtree: create.c mtree.8 spec.c

Log Message:
clarify seconds.09nanoseconds format (brooks)


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/usr.sbin/mtree/create.c
cvs rdiff -u -r1.58 -r1.59 src/usr.sbin/mtree/mtree.8
cvs rdiff -u -r1.81 -r1.82 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.63 src/usr.sbin/mtree/create.c:1.64
--- src/usr.sbin/mtree/create.c:1.63	Thu Oct  4 21:13:50 2012
+++ src/usr.sbin/mtree/create.c	Thu Oct  4 21:19:54 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.63 2012/10/05 01:13:50 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.64 2012/10/05 01:19:54 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)create.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: create.c,v 1.63 2012/10/05 01:13:50 christos Exp $);
+__RCSID($NetBSD: create.c,v 1.64 2012/10/05 01:19:54 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -213,11 +213,11 @@ statf(int indent, FTSENT *p)
 		(long long)p-fts_statp-st_size);
 	if (keys  F_TIME)
 #if defined(BSD4_4)  !defined(HAVE_NBTOOL_CONFIG_H)
-		output(indent, offset, time=%ld.%ld,
+		output(indent, offset, time=%ld.%09ld,
 		(long)p-fts_statp-st_mtimespec.tv_sec,
 		p-fts_statp-st_mtimespec.tv_nsec);
 #else
-		output(indent, offset, time=%ld.%ld,
+		output(indent, offset, time=%ld.%09ld,
 		(long)p-fts_statp-st_mtime, (long)0);
 #endif
 	if (keys  F_CKSUM  S_ISREG(p-fts_statp-st_mode)) {

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.58 src/usr.sbin/mtree/mtree.8:1.59
--- src/usr.sbin/mtree/mtree.8:1.58	Thu Oct  4 21:13:50 2012
+++ src/usr.sbin/mtree/mtree.8	Thu Oct  4 21:19:54 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.58 2012/10/05 01:13:50 christos Exp $
+.\	$NetBSD: mtree.8,v 1.59 2012/10/05 01:19:54 christos Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -489,7 +489,10 @@ and
 These may be specified without leading or trailing commas, but will be
 stored internally with them.
 .It Sy time
-The last modification time of the file.
+The last modification time of the file,
+in second and nanoseconds.
+The value should include a period character and exactly nine digits after
+the period.
 .It Sy type
 The type of the file; may be set to any one of the following:
 .Pp

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.81 src/usr.sbin/mtree/spec.c:1.82
--- src/usr.sbin/mtree/spec.c:1.81	Thu Oct  4 20:59:35 2012
+++ src/usr.sbin/mtree/spec.c	Thu Oct  4 21:19:54 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.81 2012/10/05 00:59:35 christos Exp $	*/
+/*	$NetBSD: spec.c,v 1.82 2012/10/05 01:19:54 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = @(#)spec.c	8.2 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: spec.c,v 1.81 2012/10/05 00:59:35 christos Exp $);
+__RCSID($NetBSD: spec.c,v 1.82 2012/10/05 01:19:54 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -358,7 +358,7 @@ dump_nodes(const char *dir, NODE *root, 
 		if (MATCHFLAG(F_SIZE))
 			appendfield(pathlast, size=%lld, (long long)cur-st_size);
 		if (MATCHFLAG(F_TIME))
-			appendfield(pathlast, time=%lld.%ld,
+			appendfield(pathlast, time=%lld.%09ld,
 			(long long)cur-st_mtimespec.tv_sec,
 			cur-st_mtimespec.tv_nsec);
 		if (MATCHFLAG(F_CKSUM))



CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 01:21:44 UTC 2012

Modified Files:
src/usr.sbin/mtree: create.c

Log Message:
Allow uid and uname or gid and gname to both be printed while
preserving the behavior of falling back to [ug]id when the name is not
resolvable. (brooks)


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/usr.sbin/mtree/create.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.64 src/usr.sbin/mtree/create.c:1.65
--- src/usr.sbin/mtree/create.c:1.64	Thu Oct  4 21:19:54 2012
+++ src/usr.sbin/mtree/create.c	Thu Oct  4 21:21:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.64 2012/10/05 01:19:54 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.65 2012/10/05 01:21:44 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)create.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: create.c,v 1.64 2012/10/05 01:19:54 christos Exp $);
+__RCSID($NetBSD: create.c,v 1.65 2012/10/05 01:21:44 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -169,7 +169,7 @@ statf(int indent, FTSENT *p)
 {
 	u_int32_t len, val;
 	int fd, offset;
-	const char *name;
+	const char *name = NULL;
 #if !defined(NO_MD5) || !defined(NO_RMD160) || !defined(NO_SHA1) || !defined(NO_SHA2)
 	char *digestbuf;
 #endif
@@ -189,14 +189,14 @@ statf(int indent, FTSENT *p)
 		if (keys  F_UNAME 
 		(name = user_from_uid(p-fts_statp-st_uid, 1)) != NULL)
 			output(indent, offset, uname=%s, name);
-		else /* if (keys  F_UID) */
+		if (keys  F_UID || (keys  F_UNAME  name == NULL))
 			output(indent, offset, uid=%u, p-fts_statp-st_uid);
 	}
 	if (keys  (F_GID | F_GNAME)  p-fts_statp-st_gid != gid) {
 		if (keys  F_GNAME 
 		(name = group_from_gid(p-fts_statp-st_gid, 1)) != NULL)
 			output(indent, offset, gname=%s, name);
-		else /* if (keys  F_GID) */
+		if (keys  F_GID || (keys  F_GNAME  name == NULL))
 			output(indent, offset, gid=%u, p-fts_statp-st_gid);
 	}
 	if (keys  F_MODE  (p-fts_statp-st_mode  MBITS) != mode)
@@ -318,7 +318,7 @@ statd(FTS *t, FTSENT *parent, uid_t *pui
 	uid_t suid;
 	mode_t smode;
 	u_long sflags = 0;
-	const char *name;
+	const char *name = NULL;
 	gid_t savegid;
 	uid_t saveuid;
 	mode_t savemode;
@@ -385,14 +385,14 @@ statd(FTS *t, FTSENT *parent, uid_t *pui
 			if (keys  F_UNAME 
 			(name = user_from_uid(saveuid, 1)) != NULL)
 printf( uname=%s, name);
-			else /* if (keys  F_UID) */
+			if (keys  F_UID || (keys  F_UNAME  name == NULL))
 printf( uid=%lu, (u_long)saveuid);
 		}
 		if (keys  (F_GID | F_GNAME)) {
 			if (keys  F_GNAME 
 			(name = group_from_gid(savegid, 1)) != NULL)
 printf( gname=%s, name);
-			else /* if (keys  F_UID) */
+			if (keys  F_GID || (keys  F_GNAME  name == NULL))
 printf( gid=%lu, (u_long)savegid);
 		}
 		if (keys  F_MODE)



CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 01:26:56 UTC 2012

Modified Files:
src/usr.sbin/mtree: Makefile extern.h mtree.8 mtree.c mtree.h verify.c
Added Files:
src/usr.sbin/mtree: specspec.c

Log Message:
Implement FreeBSD's -f spec1 -f spec2 spec comparision function.  This
is more useful than -C and diff because it highlights the keys that have
changed value so for example, you can see that the size of a file has
not changed but the contents have. (brooks)


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/mtree/Makefile
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/mtree/extern.h
cvs rdiff -u -r1.59 -r1.60 src/usr.sbin/mtree/mtree.8
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/mtree/mtree.c
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/mtree/mtree.h
cvs rdiff -u -r0 -r1.1 src/usr.sbin/mtree/specspec.c
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/mtree/verify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/Makefile
diff -u src/usr.sbin/mtree/Makefile:1.32 src/usr.sbin/mtree/Makefile:1.33
--- src/usr.sbin/mtree/Makefile:1.32	Wed Apr 22 11:23:05 2009
+++ src/usr.sbin/mtree/Makefile	Thu Oct  4 21:26:56 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.32 2009/04/22 15:23:05 lukem Exp $
+#	$NetBSD: Makefile,v 1.33 2012/10/05 01:26:56 christos Exp $
 #	from: @(#)Makefile	8.2 (Berkeley) 4/27/95
 
 .include bsd.own.mk
@@ -7,8 +7,8 @@ PROG=	mtree
 #CPPFLAGS+=-DDEBUG
 CPPFLAGS+= -DMTREE
 MAN=	mtree.8
-SRCS=	compare.c crc.c create.c excludes.c misc.c mtree.c spec.c verify.c \
-	getid.c pack_dev.c
+SRCS=	compare.c crc.c create.c excludes.c misc.c mtree.c spec.c specspec.c \
+	verify.c getid.c pack_dev.c
 .if (${HOSTPROG:U} == )
 DPADD+= ${LIBUTIL}
 LDADD+= -lutil

Index: src/usr.sbin/mtree/extern.h
diff -u src/usr.sbin/mtree/extern.h:1.35 src/usr.sbin/mtree/extern.h:1.36
--- src/usr.sbin/mtree/extern.h:1.35	Thu Oct  4 21:13:50 2012
+++ src/usr.sbin/mtree/extern.h	Thu Oct  4 21:26:56 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.35 2012/10/05 01:13:50 christos Exp $	*/
+/*	$NetBSD: extern.h,v 1.36 2012/10/05 01:26:56 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -67,7 +67,7 @@ void	 parsetags(slist_t *, char *);
 u_int	 parsetype(const char *);
 void	 read_excludes_file(const char *);
 const char *rlink(const char *);
-int	 verify(void);
+int	 verify(FILE *);
 
 extern int	dflag, eflag, iflag, jflag, lflag, mflag,
 		nflag, qflag, rflag, sflag, tflag, uflag;

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.59 src/usr.sbin/mtree/mtree.8:1.60
--- src/usr.sbin/mtree/mtree.8:1.59	Thu Oct  4 21:19:54 2012
+++ src/usr.sbin/mtree/mtree.8	Thu Oct  4 21:26:56 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.59 2012/10/05 01:19:54 christos Exp $
+.\	$NetBSD: mtree.8,v 1.60 2012/10/05 01:26:56 christos Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -144,6 +144,18 @@ specification.
 Read the specification from
 .Ar file  ,
 instead of from the standard input.
+.Pp
+If this option is specified twice, the two specifications are compared
+to each other rather than to the file hierarchy.
+The specifications will be sorted like output generated using
+.Fl c .
+The output format in this case is somewhat remniscent of
+.Xr comm 1 ,
+having in first spec only, in second spec only, and different
+columns, prefixed by zero, one and two TAB characters respectively.
+Each entry in the different column occupies two lines, one from each
+specifica
+tion.
 .It Fl I Ar tags
 Add the comma separated tags to the
 .Dq inclusion

Index: src/usr.sbin/mtree/mtree.c
diff -u src/usr.sbin/mtree/mtree.c:1.40 src/usr.sbin/mtree/mtree.c:1.41
--- src/usr.sbin/mtree/mtree.c:1.40	Thu Oct  4 21:13:50 2012
+++ src/usr.sbin/mtree/mtree.c	Thu Oct  4 21:26:56 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.c,v 1.40 2012/10/05 01:13:50 christos Exp $	*/
+/*	$NetBSD: mtree.c,v 1.41 2012/10/05 01:26:56 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1990, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)mtree.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: mtree.c,v 1.40 2012/10/05 01:13:50 christos Exp $);
+__RCSID($NetBSD: mtree.c,v 1.41 2012/10/05 01:26:56 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -70,11 +70,14 @@ main(int argc, char **argv)
 {
 	int	ch, status;
 	char	*dir, *p;
+	FILE	*spec1, *spec2;
 
 	setprogname(argv[0]);
 
 	dir = NULL;
 	init_excludes();
+	spec1 = stdin;
+	spec2 = NULL;
 
 	while ((ch = getopt(argc, argv,
 	cCdDeE:f:I:ik:K:lLmMnN:p:PqrR:s:StuUWxX:))
@@ -99,8 +102,18 @@ main(int argc, char **argv)
 			eflag = 1;
 			break;
 		case 'f':
-			if (!(freopen(optarg, r, stdin)))
-mtree_err(%s: %s, optarg, strerror(errno));
+			if (spec1 == stdin) {
+spec1 = fopen(optarg, r);
+if (spec1 == NULL)
+	mtree_err(%s: %s, 

CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 01:27:29 UTC 2012

Modified Files:
src/usr.sbin/mtree: specspec.c

Log Message:
NetBSD needs time.h


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/mtree/specspec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/specspec.c
diff -u src/usr.sbin/mtree/specspec.c:1.1 src/usr.sbin/mtree/specspec.c:1.2
--- src/usr.sbin/mtree/specspec.c:1.1	Thu Oct  4 21:26:56 2012
+++ src/usr.sbin/mtree/specspec.c	Thu Oct  4 21:27:29 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: specspec.c,v 1.1 2012/10/05 01:26:56 christos Exp $	*/
+/*	$NetBSD: specspec.c,v 1.2 2012/10/05 01:27:29 christos Exp $	*/
 
 /*-
  * Copyright (c) 2003 Poul-Henning Kamp
@@ -31,11 +31,12 @@
 #endif
 
 #include sys/cdefs.h
-__RCSID($NetBSD: specspec.c,v 1.1 2012/10/05 01:26:56 christos Exp $);
+__RCSID($NetBSD: specspec.c,v 1.2 2012/10/05 01:27:29 christos Exp $);
 
 #include err.h
 #include grp.h
 #include pwd.h
+#include time.h
 #include stdio.h
 #include stdint.h
 #include stdlib.h



CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 01:28:20 UTC 2012

Modified Files:
src/usr.sbin/mtree: spec.c

Log Message:
Encode literal global characters in files.  Otherwise the results of
updating a directory using the resulting spec will be surprising.

See http://svnweb.freebsd.org/base/head/usr.sbin/mtree/test/test00.sh
for test cases.
(brooks)


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.82 src/usr.sbin/mtree/spec.c:1.83
--- src/usr.sbin/mtree/spec.c:1.82	Thu Oct  4 21:19:54 2012
+++ src/usr.sbin/mtree/spec.c	Thu Oct  4 21:28:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.82 2012/10/05 01:19:54 christos Exp $	*/
+/*	$NetBSD: spec.c,v 1.83 2012/10/05 01:28:20 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = @(#)spec.c	8.2 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: spec.c,v 1.82 2012/10/05 01:19:54 christos Exp $);
+__RCSID($NetBSD: spec.c,v 1.83 2012/10/05 01:28:20 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -415,7 +415,8 @@ dump_nodes(const char *dir, NODE *root, 
 char *
 vispath(const char *path)
 {
-	const char extra[] = { ' ', '\t', '\n', '\\', '#', '\0' };
+	const char extra[] = { ' ', '\t', '\n', '\\', '#', '*', '?', '[',
+	'#', '\0' };
 	static char pathbuf[4*MAXPATHLEN + 1];
 
 	strsvis(pathbuf, path, VIS_CSTYLE, extra);



CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 01:30:36 UTC 2012

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
Implement FreeBSD's nochange keyworld which causes the existance of a
filesystem object to be checked but none of its attributes. (brooks)


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.60 src/usr.sbin/mtree/mtree.8:1.61
--- src/usr.sbin/mtree/mtree.8:1.60	Thu Oct  4 21:26:56 2012
+++ src/usr.sbin/mtree/mtree.8	Thu Oct  4 21:30:36 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.60 2012/10/05 01:26:56 christos Exp $
+.\	$NetBSD: mtree.8,v 1.61 2012/10/05 01:30:36 christos Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -56,7 +56,7 @@
 .\
 .\ @(#)mtree.8	8.2 (Berkeley) 12/11/93
 .\
-.Dd January 20, 2010
+.Dd October 4, 2012
 .Dt MTREE 8
 .Os
 .Sh NAME



CVS commit: src/usr.sbin/mtree

2012-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  5 01:31:05 UTC 2012

Modified Files:
src/usr.sbin/mtree: misc.c mtree.8 mtree.h verify.c

Log Message:
Implement FreeBSD's nochange keyworld which causes the existance of a
filesystem object to be checked but none of its attiributes.(brooks)


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/usr.sbin/mtree/misc.c
cvs rdiff -u -r1.61 -r1.62 src/usr.sbin/mtree/mtree.8
cvs rdiff -u -r1.29 -r1.30 src/usr.sbin/mtree/mtree.h
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/mtree/verify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/misc.c
diff -u src/usr.sbin/mtree/misc.c:1.31 src/usr.sbin/mtree/misc.c:1.32
--- src/usr.sbin/mtree/misc.c:1.31	Thu Oct  4 20:59:35 2012
+++ src/usr.sbin/mtree/misc.c	Thu Oct  4 21:31:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: misc.c,v 1.31 2012/10/05 00:59:35 christos Exp $	*/
+/*	$NetBSD: misc.c,v 1.32 2012/10/05 01:31:05 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(lint)
-__RCSID($NetBSD: misc.c,v 1.31 2012/10/05 00:59:35 christos Exp $);
+__RCSID($NetBSD: misc.c,v 1.32 2012/10/05 01:31:05 christos Exp $);
 #endif /* not lint */
 
 #include sys/types.h
@@ -71,6 +71,7 @@ static KEY keylist[] = {
 	{md5digest,	F_MD5,		NEEDVALUE},
 	{mode,	F_MODE,		NEEDVALUE},
 	{nlink,	F_NLINK,	NEEDVALUE},
+	{nochange,	F_NOCHANGE,	0},
 	{optional,	F_OPT,		0},
 	{ripemd160digest, F_RMD160,	NEEDVALUE},
 	{rmd160digest,F_RMD160,	NEEDVALUE},

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.61 src/usr.sbin/mtree/mtree.8:1.62
--- src/usr.sbin/mtree/mtree.8:1.61	Thu Oct  4 21:30:36 2012
+++ src/usr.sbin/mtree/mtree.8	Thu Oct  4 21:31:05 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.61 2012/10/05 01:30:36 christos Exp $
+.\	$NetBSD: mtree.8,v 1.62 2012/10/05 01:31:05 christos Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -450,6 +450,8 @@ The current file's permissions as a nume
 value.
 .It Sy nlink
 The number of hard links the file is expected to have.
+.It Sy 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.

Index: src/usr.sbin/mtree/mtree.h
diff -u src/usr.sbin/mtree/mtree.h:1.29 src/usr.sbin/mtree/mtree.h:1.30
--- src/usr.sbin/mtree/mtree.h:1.29	Thu Oct  4 21:26:56 2012
+++ src/usr.sbin/mtree/mtree.h	Thu Oct  4 21:31:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.h,v 1.29 2012/10/05 01:26:56 christos Exp $	*/
+/*	$NetBSD: mtree.h,v 1.30 2012/10/05 01:31:05 christos Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -86,6 +86,8 @@ typedef struct _node {
 #define	F_UID		0x0008		/* uid */
 #define	F_UNAME		0x0010		/* user name */
 #define	F_VISIT		0x0020		/* file visited */
+#define	F_NOCHANGE	0x0040		/* check existance, but not */
+		/* other properties */
 #define	F_SHA256	0x0080		/* SHA256 digest */
 #define	F_SHA384	0x0100		/* SHA384 digest */
 #define	F_SHA512	0x0200		/* SHA512 digest */

Index: src/usr.sbin/mtree/verify.c
diff -u src/usr.sbin/mtree/verify.c:1.42 src/usr.sbin/mtree/verify.c:1.43
--- src/usr.sbin/mtree/verify.c:1.42	Thu Oct  4 21:26:56 2012
+++ src/usr.sbin/mtree/verify.c	Thu Oct  4 21:31:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: verify.c,v 1.42 2012/10/05 01:26:56 christos Exp $	*/
+/*	$NetBSD: verify.c,v 1.43 2012/10/05 01:31:05 christos 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.42 2012/10/05 01:26:56 christos Exp $);
+__RCSID($NetBSD: verify.c,v 1.43 2012/10/05 01:31:05 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -124,7 +124,8 @@ vwalk(void)
 			!fnmatch(ep-name, p-fts_name, FNM_PATHNAME)) ||
 			!strcmp(ep-name, p-fts_name)) {
 ep-flags |= F_VISIT;
-if (compare(ep, p))
+if ((ep-flags  F_NOCHANGE) == 0 
+compare(ep, p))
 	rval = MISMATCHEXIT;
 if (!(ep-flags  F_IGN) 
 ep-type == F_DIR 



CVS commit: src/usr.sbin/mtree

2012-10-03 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Oct  3 19:27:48 UTC 2012

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
- Sort order of options mentioned in text;
- improve wording;
- remove unneeded macros (fixes mandoc(1) warnings);
- in the `EXAMPLES' section, for `-d', mention the use of `-U'
  besides that of `-u' (as the former is a variant on the latter).

From Bug Hunting.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.53 src/usr.sbin/mtree/mtree.8:1.54
--- src/usr.sbin/mtree/mtree.8:1.53	Wed Jan 20 14:00:48 2010
+++ src/usr.sbin/mtree/mtree.8	Wed Oct  3 19:27:48 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.53 2010/01/20 14:00:48 wiz Exp $
+.\	$NetBSD: mtree.8,v 1.54 2012/10/03 19:27:48 wiz Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -104,8 +104,8 @@ The full path name
 (beginning with
 .Dq \./ )
 is always printed as the first field;
-.Fl k ,
 .Fl K ,
+.Fl k ,
 and
 .Fl R
 can be used to control which other keywords are printed;
@@ -113,6 +113,7 @@ can be used to control which other keywo
 and
 .Fl I
 can be used to control which files are printed;
+and the
 .Fl S
 option can be used to sort the output.
 .It Fl c
@@ -187,13 +188,13 @@ particular, if other bits like the stick
 set either in the specification or the file, exact checking will be
 performed.
 This option may not be set at the same time as the
-.Fl u
-or
 .Fl U
+or
+.Fl u
 option.
 .It Fl M
 Permit merging of specification entries with different types,
-with the last entry take precedence.
+with the last entry taking precedence.
 .It Fl m
 If the schg and/or sappnd flags are specified, reset these flags.
 Note that this is only possible with securelevel less than 1 (i.e.,
@@ -287,9 +288,9 @@ Don't attempt to set various file attrib
 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
+.Fl U
 or
-.Fl U .
+.Fl u .
 .It Fl X Ar exclude-file
 The specified file contains
 .Xr fnmatch 3
@@ -329,7 +330,6 @@ or
 .Sy char
 file types.
 The argument must be one of the following forms:
-.Pp
 .Bl -tag -width 4n
 .It Ar format , Ns Ar major , Ns Ar minor
 A device with
@@ -498,7 +498,6 @@ and
 .Sy uid .
 .Pp
 There are four types of lines in a specification:
-.Pp
 .Bl -enum
 .It
 Set global values for a keyword.
@@ -581,7 +580,7 @@ appropriately.
 Multiple entries for the same full path are permitted if the types
 are the same (unless
 .Fl M
-is given, and then the types may differ);
+is given, in which case the types may differ);
 in this case the settings for the last entry take precedence.
 .Pp
 A path name that does not contain a slash will be treated as a relative path.
@@ -631,10 +630,11 @@ can be used to detect which of the binar
 .Pp
 The
 .Fl d
-and
+option can be used in combination with
+.Fl U
+or
 .Fl u
-options can be used in combination to create directory hierarchies
-for distributions and other such things.
+to create directory hierarchies for, for example, distributions.
 .Sh SEE ALSO
 .Xr chflags 1 ,
 .Xr chgrp 1 ,
@@ -681,8 +681,8 @@ keywords,
 .Fl D ,
 .Fl E ,
 .Fl I ,
-.Fl l ,
 .Fl L ,
+.Fl l ,
 .Fl N ,
 .Fl P ,
 .Fl R ,



CVS commit: src/usr.sbin/mtree

2012-07-15 Thread S.P.Zeidler
Module Name:src
Committed By:   spz
Date:   Sun Jul 15 09:08:30 UTC 2012

Modified Files:
src/usr.sbin/mtree: create.c

Log Message:
resource leak (Coverity issues 274383 and 274384)


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/usr.sbin/mtree/create.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.58 src/usr.sbin/mtree/create.c:1.59
--- src/usr.sbin/mtree/create.c:1.58	Fri Apr  3 21:18:59 2009
+++ src/usr.sbin/mtree/create.c	Sun Jul 15 09:08:29 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.58 2009/04/03 21:18:59 apb Exp $	*/
+/*	$NetBSD: create.c,v 1.59 2012/07/15 09:08:29 spz Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = @(#)create.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: create.c,v 1.58 2009/04/03 21:18:59 apb Exp $);
+__RCSID($NetBSD: create.c,v 1.59 2012/07/15 09:08:29 spz Exp $);
 #endif
 #endif /* not lint */
 
@@ -259,9 +259,11 @@ statf(FTSENT *p)
 	(p-fts_info == FTS_SL || p-fts_info == FTS_SLNONE))
 		output(indent, link=%s, vispath(rlink(p-fts_accpath)));
 #if HAVE_STRUCT_STAT_ST_FLAGS
-	if (keys  F_FLAGS  p-fts_statp-st_flags != flags)
-		output(indent, flags=%s,
-		flags_to_string(p-fts_statp-st_flags, none));
+	if (keys  F_FLAGS  p-fts_statp-st_flags != flags) {
+		char *str = flags_to_string(p-fts_statp-st_flags, none);
+		output(indent, flags=%s, str);
+		free(str);
+	}
 #endif
 	putchar('\n');
 }
@@ -372,9 +374,11 @@ statd(FTS *t, FTSENT *parent, uid_t *pui
 			printf( mode=%#lo, (u_long)savemode);
 		if (keys  F_NLINK)
 			printf( nlink=1);
-		if (keys  F_FLAGS)
-			printf( flags=%s,
-			flags_to_string(saveflags, none));
+		if (keys  F_FLAGS) {
+			char *str = flags_to_string(saveflags, none);
+			printf( flags=%s, str);
+			free(str);
+		}
 		printf(\n);
 		*puid = saveuid;
 		*pgid = savegid;



CVS commit: src/usr.sbin/mtree

2012-03-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 25 16:07:04 UTC 2012

Modified Files:
src/usr.sbin/mtree: verify.c

Log Message:
PR/41061: Steven Drake: mtree -d complains about extra symlinks


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/mtree/verify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/verify.c
diff -u src/usr.sbin/mtree/verify.c:1.39 src/usr.sbin/mtree/verify.c:1.40
--- src/usr.sbin/mtree/verify.c:1.39	Sat Oct  7 11:35:51 2006
+++ src/usr.sbin/mtree/verify.c	Sun Mar 25 12:07:04 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: verify.c,v 1.39 2006/10/07 15:35:51 elad Exp $	*/
+/*	$NetBSD: verify.c,v 1.40 2012/03/25 16:07:04 christos 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.39 2006/10/07 15:35:51 elad Exp $);
+__RCSID($NetBSD: verify.c,v 1.40 2012/03/25 16:07:04 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -141,7 +141,7 @@ vwalk(void)
 		if (ep)
 			continue;
  extra:
-		if (!eflag) {
+		if (!eflag  !(dflag  p-fts_info == FTS_SL)) {
 			printf(extra: %s, RP(p));
 			if (rflag) {
 if ((S_ISDIR(p-fts_statp-st_mode)



CVS commit: src/usr.sbin/mtree

2011-08-29 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Aug 29 20:37:43 UTC 2011

Modified Files:
src/usr.sbin/mtree: extern.h mtree.c

Log Message:
Use __dead and __printflike


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/usr.sbin/mtree/extern.h
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/mtree/mtree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/extern.h
diff -u src/usr.sbin/mtree/extern.h:1.31 src/usr.sbin/mtree/extern.h:1.32
--- src/usr.sbin/mtree/extern.h:1.31	Wed Apr  8 19:03:13 2009
+++ src/usr.sbin/mtree/extern.h	Mon Aug 29 20:37:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.31 2009/04/08 19:03:13 apb Exp $	*/
+/*	$NetBSD: extern.h,v 1.32 2011/08/29 20:37:43 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -60,8 +60,7 @@
 void	 dump_nodes(const char *, NODE *, int);
 void	 init_excludes(void);
 int	 matchtags(NODE *);
-void	 mtree_err(const char *, ...)
-	__attribute__((__format__(__printf__, 1, 2)));
+__dead __printflike(1,2) void	 mtree_err(const char *, ...);
 const char *nodetype(u_int);
 u_int	 parsekey(const char *, int *);
 void	 parsetags(slist_t *, char *);

Index: src/usr.sbin/mtree/mtree.c
diff -u src/usr.sbin/mtree/mtree.c:1.36 src/usr.sbin/mtree/mtree.c:1.37
--- src/usr.sbin/mtree/mtree.c:1.36	Wed Apr  8 19:43:05 2009
+++ src/usr.sbin/mtree/mtree.c	Mon Aug 29 20:37:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.c,v 1.36 2009/04/08 19:43:05 wiz Exp $	*/
+/*	$NetBSD: mtree.c,v 1.37 2011/08/29 20:37:43 joerg 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.36 2009/04/08 19:43:05 wiz Exp $);
+__RCSID($NetBSD: mtree.c,v 1.37 2011/08/29 20:37:43 joerg Exp $);
 #endif
 #endif /* not lint */
 
@@ -63,8 +63,7 @@
 	rflag, sflag, tflag, uflag, Uflag;
 char	fullpath[MAXPATHLEN];
 
-	int	main(int, char **);
-static	void	usage(void);
+__dead static	void	usage(void);
 
 int
 main(int argc, char **argv)



CVS commit: src/usr.sbin/mtree

2011-02-14 Thread Masao Uebayashi
Module Name:src
Committed By:   uebayasi
Date:   Mon Feb 14 16:27:58 UTC 2011

Modified Files:
src/usr.sbin/mtree: spec.c

Log Message:
Suppress a superfluous whitespace after time=... in the output.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.78 src/usr.sbin/mtree/spec.c:1.79
--- src/usr.sbin/mtree/spec.c:1.78	Tue Sep 22 04:38:21 2009
+++ src/usr.sbin/mtree/spec.c	Mon Feb 14 16:27:58 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.78 2009/09/22 04:38:21 apb Exp $	*/
+/*	$NetBSD: spec.c,v 1.79 2011/02/14 16:27:58 uebayasi Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = @(#)spec.c	8.2 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: spec.c,v 1.78 2009/09/22 04:38:21 apb Exp $);
+__RCSID($NetBSD: spec.c,v 1.79 2011/02/14 16:27:58 uebayasi Exp $);
 #endif
 #endif /* not lint */
 
@@ -358,7 +358,7 @@
 		if (MATCHFLAG(F_SIZE))
 			appendfield(pathlast, size=%lld, (long long)cur-st_size);
 		if (MATCHFLAG(F_TIME))
-			appendfield(pathlast, time=%lld.%ld ,
+			appendfield(pathlast, time=%lld.%ld,
 			(long long)cur-st_mtimespec.tv_sec,
 			cur-st_mtimespec.tv_nsec);
 		if (MATCHFLAG(F_CKSUM))



CVS commit: src/usr.sbin/mtree

2010-01-20 Thread Masao Uebayashi
Module Name:src
Committed By:   uebayasi
Date:   Wed Jan 20 13:50:27 UTC 2010

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
Document -t (modify mtime).  Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.51 src/usr.sbin/mtree/mtree.8:1.52
--- src/usr.sbin/mtree/mtree.8:1.51	Thu Apr  9 09:53:37 2009
+++ src/usr.sbin/mtree/mtree.8	Wed Jan 20 13:50:27 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.51 2009/04/09 09:53:37 apb Exp $
+.\	$NetBSD: mtree.8,v 1.52 2010/01/20 13:50:27 uebayasi Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -56,7 +56,7 @@
 .\
 .\ @(#)mtree.8	8.2 (Berkeley) 12/11/93
 .\
-.Dd April 9, 2009
+.Dd Jan 20, 2010
 .Dt MTREE 8
 .Os
 .Sh NAME
@@ -258,6 +258,9 @@
 .Sy cksum
 was specified.
 The checksum is seeded with the specified value.
+.It Fl t
+Modify the modified time of existing files, the device type of devices, and
+symbolic link targets, to match the specification.
 .It Fl U
 Same as
 .Fl u



CVS commit: src/usr.sbin/mtree

2009-09-21 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Tue Sep 22 04:38:21 UTC 2009

Modified Files:
src/usr.sbin/mtree: spec.c

Log Message:
Fix errors in previous: optional and ignore keywords also need the
appendfield treatment.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.77 src/usr.sbin/mtree/spec.c:1.78
--- src/usr.sbin/mtree/spec.c:1.77	Sat Sep 19 21:41:43 2009
+++ src/usr.sbin/mtree/spec.c	Tue Sep 22 04:38:21 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.77 2009/09/19 21:41:43 apb Exp $	*/
+/*	$NetBSD: spec.c,v 1.78 2009/09/22 04:38:21 apb Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = @(#)spec.c	8.2 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: spec.c,v 1.77 2009/09/19 21:41:43 apb Exp $);
+__RCSID($NetBSD: spec.c,v 1.78 2009/09/22 04:38:21 apb Exp $);
 #endif
 #endif /* not lint */
 
@@ -381,9 +381,9 @@
 			free(str);
 		}
 		if (MATCHFLAG(F_IGN))
-			printf(ignore );
+			appendfield(pathlast, ignore);
 		if (MATCHFLAG(F_OPT))
-			printf(optional );
+			appendfield(pathlast, optional);
 		if (MATCHFLAG(F_TAGS)) {
 			/* don't output leading or trailing commas */
 			p = cur-tags;



CVS commit: src/usr.sbin/mtree

2009-09-19 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Sat Sep 19 20:42:07 UTC 2009

Modified Files:
src/usr.sbin/mtree: spec.c

Log Message:
Fix the mtree -M problem reported in PR 42031 by Geoff Wing.
The cause of the problem was that part of the code assumed that
nodecmp() on two nodes with the same name would return 0, but in
fact nodecmp() would return -1 or +1 if one of the nodes was a
directory and the other was not.  The fix is to separate the notion
of whether or not a duplicte name was found frmo the notion of
where the new node should appear in the list.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.75 src/usr.sbin/mtree/spec.c:1.76
--- src/usr.sbin/mtree/spec.c:1.75	Sat Apr 11 14:32:51 2009
+++ src/usr.sbin/mtree/spec.c	Sat Sep 19 20:42:06 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.75 2009/04/11 14:32:51 apb Exp $	*/
+/*	$NetBSD: spec.c,v 1.76 2009/09/19 20:42:06 apb Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,13 +67,14 @@
 #if 0
 static char sccsid[] = @(#)spec.c	8.2 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: spec.c,v 1.75 2009/04/11 14:32:51 apb Exp $);
+__RCSID($NetBSD: spec.c,v 1.76 2009/09/19 20:42:06 apb Exp $);
 #endif
 #endif /* not lint */
 
 #include sys/param.h
 #include sys/stat.h
 
+#include assert.h
 #include ctype.h
 #include errno.h
 #include grp.h
@@ -670,9 +671,18 @@
 static void
 addchild(NODE *pathparent, NODE *centry)
 {
-	NODE *cur, *insertpos;
+	NODE *samename;  /* node with the same name as centry */
+	NODE *replacepos;/* if non-NULL, centry should replace this node */
+	NODE *insertpos; /* if non-NULL, centry should be inserted
+			  * after this node */
+	NODE *cur;   /* for stepping through the list */
+	NODE *last;  /* the last node in the list */
 	int cmp;
 
+	samename = NULL;
+	replacepos = NULL;
+	insertpos = NULL;
+	last = NULL;
 	cur = pathparent-child;
 	if (cur == NULL) {
 		/* centry is pathparent's first and only child node so far */
@@ -684,44 +694,91 @@
 	 * pathparent already has at least one other child, so add the
 	 * centry node to the list.
 	 *
-	 * To keep the list sorted, the new centry node will be
-	 * inserted just after the existing insertpos node, if any;
-	 * otherwise it will be inserted at the start of the list.
+	 * We first scan through the list looking for an existing node
+	 * with the same name (setting samename), and also looking
+	 * for the correct position to replace or insert the new node
+	 * (setting replacepos and/or insertpos).
 	 */
-	insertpos = NULL;
-	for (; cur != NULL; cur = cur-next) {
-		cmp = nodecmp(centry, cur);
-		if (cmp == 0) {
-			/* existing entry; replace */
-			replacenode(cur, centry);
-			break;
-		} else if (cmp  0) {
-			/* centry appears after cur in sort order */
-			insertpos = cur;
+	for (; cur != NULL; last = cur, cur = cur-next) {
+		if (strcmp(centry-name, cur-name) == 0) {
+			samename = cur;
+		}
+		if (mtree_Sflag) {
+			cmp = nodecmp(centry, cur);
+			if (cmp == 0) {
+replacepos = cur;
+			} else if (cmp  0) {
+insertpos = cur;
+			}
+		}
+	}
+	if (! mtree_Sflag) {
+		if (samename != NULL) {
+			/* replace node with same name */
+			replacepos = samename;
+		} else {
+			/* add new node at end of list */
+			insertpos = last;
+		}
+	}
+
+	if (samename != NULL) {
+		/*
+		 * We found a node with the same name above.  Call
+		 * replacenode(), which will either exit with an error,
+		 * or replace the information in the samename node and
+		 * free the information in the centry node.
+		 */
+		replacenode(samename, centry);
+		if (samename == replacepos) {
+			/* The just-replaced node was in the correct position */
+			return;
 		}
-		if ((mtree_Sflag  cmp  0) || cur-next == NULL) {
+		if (samename == insertpos || samename-prev == insertpos) {
 			/*
-			 * centry appears before cur in sort order,
-			 * or we reached the end of the list; insert
-			 * centry either just after insertpos, or at the
-			 * beginning of the list.  If we are not sorting,
-			 * then always append to the list.
+			 * We thought the new node should be just before
+			 * or just after the replaced node, but that would
+			 * be equivalent to just retaining the replaced node.
 			 */
-			if (!mtree_Sflag)
-insertpos = cur;
-			if (insertpos) {
-centry-next = insertpos-next;
-insertpos-next = centry;
-centry-prev = insertpos;
-if (centry-next)
-	centry-next-prev = centry;
-			} else {
-pathparent-child-prev = centry;
-centry-next = pathparent-child;
-pathparent-child = centry;
-			}
-			break;
+			return;
 		}
+
+		/*
+		 * The just-replaced node is in the wrong position in
+		 * the list.  This can happen if sort order depends on
+		 * criteria other than the node name.
+		 *
+		 * 

CVS commit: src/usr.sbin/mtree

2009-09-19 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Sat Sep 19 21:41:43 UTC 2009

Modified Files:
src/usr.sbin/mtree: spec.c

Log Message:
Do not print a trailing space on each line with mtree -C.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.76 src/usr.sbin/mtree/spec.c:1.77
--- src/usr.sbin/mtree/spec.c:1.76	Sat Sep 19 20:42:06 2009
+++ src/usr.sbin/mtree/spec.c	Sat Sep 19 21:41:43 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.76 2009/09/19 20:42:06 apb Exp $	*/
+/*	$NetBSD: spec.c,v 1.77 2009/09/19 21:41:43 apb Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = @(#)spec.c	8.2 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: spec.c,v 1.76 2009/09/19 20:42:06 apb Exp $);
+__RCSID($NetBSD: spec.c,v 1.77 2009/09/19 21:41:43 apb Exp $);
 #endif
 #endif /* not lint */
 
@@ -79,6 +79,7 @@
 #include errno.h
 #include grp.h
 #include pwd.h
+#include stdarg.h
 #include stdio.h
 #include stdlib.h
 #include string.h
@@ -100,6 +101,7 @@
 static	void	unset(char *, NODE *);
 static	void	addchild(NODE *, NODE *);
 static	int	nodecmp(const NODE *, const NODE *);
+static	int	appendfield(int, const char *, ...);
 
 #define REPLACEPTR(x,v)	do { if ((x)) free((x)); (x) = (v); } while (0)
 
@@ -280,6 +282,27 @@
 }
 
 /*
+ * appendfield --
+ *	Like printf(), but output a space either before or after
+ *	the regular output, according to the pathlast flag.
+ */
+static int
+appendfield(int pathlast, const char *fmt, ...)
+{
+	va_list ap;
+	int result;
+
+	va_start(ap, fmt);
+	if (!pathlast)
+		printf( );
+	result = vprintf(fmt, ap);
+	if (pathlast)
+		printf( );
+	va_end(ap);
+	return result;
+}
+
+/*
  * dump_nodes --
  *	dump the NODEs from `cur', based in the directory `dir'.
  *	if pathlast is none zero, print the path last, otherwise print
@@ -304,57 +327,57 @@
 			mtree_err(Pathname too long.);
 
 		if (!pathlast)
-			printf(%s , vispath(path));
+			printf(%s, vispath(path));
 
 #define MATCHFLAG(f)	((keys  (f))  (cur-flags  (f)))
 		if (MATCHFLAG(F_TYPE))
-			printf(type=%s , nodetype(cur-type));
+			appendfield(pathlast, type=%s, nodetype(cur-type));
 		if (MATCHFLAG(F_UID | F_UNAME)) {
 			if (keys  F_UNAME 
 			(name = user_from_uid(cur-st_uid, 1)) != NULL)
-printf(uname=%s , name);
+appendfield(pathlast, uname=%s, name);
 			else
-printf(uid=%u , cur-st_uid);
+appendfield(pathlast, uid=%u, cur-st_uid);
 		}
 		if (MATCHFLAG(F_GID | F_GNAME)) {
 			if (keys  F_GNAME 
 			(name = group_from_gid(cur-st_gid, 1)) != NULL)
-printf(gname=%s , name);
+appendfield(pathlast, gname=%s, name);
 			else
-printf(gid=%u , cur-st_gid);
+appendfield(pathlast, gid=%u, cur-st_gid);
 		}
 		if (MATCHFLAG(F_MODE))
-			printf(mode=%#o , cur-st_mode);
+			appendfield(pathlast, mode=%#o, cur-st_mode);
 		if (MATCHFLAG(F_DEV) 
 		(cur-type == F_BLOCK || cur-type == F_CHAR))
-			printf(device=%#llx , (long long)cur-st_rdev);
+			appendfield(pathlast, device=%#llx, (long long)cur-st_rdev);
 		if (MATCHFLAG(F_NLINK))
-			printf(nlink=%d , cur-st_nlink);
+			appendfield(pathlast, nlink=%d, cur-st_nlink);
 		if (MATCHFLAG(F_SLINK))
-			printf(link=%s , vispath(cur-slink));
+			appendfield(pathlast, link=%s, vispath(cur-slink));
 		if (MATCHFLAG(F_SIZE))
-			printf(size=%lld , (long long)cur-st_size);
+			appendfield(pathlast, size=%lld, (long long)cur-st_size);
 		if (MATCHFLAG(F_TIME))
-			printf(time=%lld.%ld ,
+			appendfield(pathlast, time=%lld.%ld ,
 			(long long)cur-st_mtimespec.tv_sec,
 			cur-st_mtimespec.tv_nsec);
 		if (MATCHFLAG(F_CKSUM))
-			printf(cksum=%lu , cur-cksum);
+			appendfield(pathlast, cksum=%lu, cur-cksum);
 		if (MATCHFLAG(F_MD5))
-			printf(md5=%s , cur-md5digest);
+			appendfield(pathlast, md5=%s, cur-md5digest);
 		if (MATCHFLAG(F_RMD160))
-			printf(rmd160=%s , cur-rmd160digest);
+			appendfield(pathlast, rmd160=%s, cur-rmd160digest);
 		if (MATCHFLAG(F_SHA1))
-			printf(sha1=%s , cur-sha1digest);
+			appendfield(pathlast, sha1=%s, cur-sha1digest);
 		if (MATCHFLAG(F_SHA256))
-			printf(sha256=%s , cur-sha256digest);
+			appendfield(pathlast, sha256=%s, cur-sha256digest);
 		if (MATCHFLAG(F_SHA384))
-			printf(sha384=%s , cur-sha384digest);
+			appendfield(pathlast, sha384=%s, cur-sha384digest);
 		if (MATCHFLAG(F_SHA512))
-			printf(sha512=%s , cur-sha512digest);
+			appendfield(pathlast, sha512=%s, cur-sha512digest);
 		if (MATCHFLAG(F_FLAGS)) {
 			str = flags_to_string(cur-st_flags, none);
-			printf(flags=%s , str);
+			appendfield(pathlast, flags=%s, str);
 			free(str);
 		}
 		if (MATCHFLAG(F_IGN))
@@ -369,7 +392,7 @@
 			q = p + strlen(p);
 			while(q  p  q[-1] == ',')
 q--;
-			printf(tags=%.*s , (int)(q - p), p);
+			appendfield(pathlast, tags=%.*s, (int)(q - 

CVS commit: src/usr.sbin/mtree

2009-04-11 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Sat Apr 11 14:32:52 UTC 2009

Modified Files:
src/usr.sbin/mtree: spec.c

Log Message:
When an mtree spec file omits a parent directory, missing directory in
specification, instead of no such file or directory.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.74 src/usr.sbin/mtree/spec.c:1.75
--- src/usr.sbin/mtree/spec.c:1.74	Wed Apr  8 19:03:13 2009
+++ src/usr.sbin/mtree/spec.c	Sat Apr 11 14:32:51 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.74 2009/04/08 19:03:13 apb Exp $	*/
+/*	$NetBSD: spec.c,v 1.75 2009/04/11 14:32:51 apb Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = @(#)spec.c	8.2 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: spec.c,v 1.74 2009/04/08 19:03:13 apb Exp $);
+__RCSID($NetBSD: spec.c,v 1.75 2009/04/11 14:32:51 apb Exp $);
 #endif
 #endif /* not lint */
 
@@ -190,7 +190,7 @@
 }
 if (cur == NULL || cur-type != F_DIR) {
 	mtree_err(%s: %s, tname,
-	strerror(ENOENT));
+	missing directory in specification);
 }
 *e = '/';
 pathparent = cur;



CVS commit: src/usr.sbin/mtree

2009-04-09 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Thu Apr  9 09:53:37 UTC 2009

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
* Rewrite intro to mention all three things mtree can do (check directory
  tree against spec; create spec; modify spec).
* Consistently use options to refer to command line options.  flags
  is used to refer to file flags.
* Some other clarifications and changes for consistency.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/mtree/mtree.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.50 src/usr.sbin/mtree/mtree.8:1.51
--- src/usr.sbin/mtree/mtree.8:1.50	Wed Apr  8 19:39:23 2009
+++ src/usr.sbin/mtree/mtree.8	Thu Apr  9 09:53:37 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.50 2009/04/08 19:39:23 wiz Exp $
+.\	$NetBSD: mtree.8,v 1.51 2009/04/09 09:53:37 apb Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -56,7 +56,7 @@
 .\
 .\ @(#)mtree.8	8.2 (Berkeley) 12/11/93
 .\
-.Dd April 8, 2009
+.Dd April 9, 2009
 .Dt MTREE 8
 .Os
 .Sh NAME
@@ -79,7 +79,12 @@
 .Sh DESCRIPTION
 The
 .Nm
-utility compares the file hierarchy rooted in the current directory
+utility compares a file hierarchy against a specification,
+creates a specification for a file hierarchy, or modifies
+a specification.
+.Pp
+The default action, if not overridden by command line options,
+is to compare the file hierarchy rooted in the current directory
 against a specification read from the standard input.
 Messages are written to the standard output for any files whose
 characteristics do not match the specification, or which are
@@ -88,27 +93,34 @@
 The options are as follows:
 .Bl -tag -width Xxxexcludexfilexx
 .It Fl C
-Print
-.Pq Sq dump
-the specification as provided by
-.Fl f Ar spec
-in a format that's easier to parse with various tools.
-The full path name is always printed as the first field, and
+Convert a specification into
+a format that's easier to parse with various tools.
+The input specification is read from standard input or
+from the file given by
+.Fl f Ar spec .
+In the output, each file or directory is represented using a single line
+(which might be very long).
+The full path name
+(beginning with
+.Dq \./ )
+is always printed as the first field;
 .Fl k ,
 .Fl K ,
 and
 .Fl R
-can be used to control which other keywords are printed, and
+can be used to control which other keywords are printed;
 .Fl E
 and
 .Fl I
-can be used to control which files are printed.
-The
+can be used to control which files are printed;
 .Fl S
 option can be used to sort the output.
 .It Fl c
 Print a specification for the file hierarchy originating at
-the current working directory to the standard output.
+the current working directory (or the directory provided by
+.Fl p Ar path )
+to the standard output.
+The output is in a style using relative path names.
 .It Fl D
 As per
 .Fl C ,
@@ -174,11 +186,11 @@
 particular, if other bits like the sticky bit or suid/sgid bits are
 set either in the specification or the file, exact checking will be
 performed.
-This flag may not be set at the same time as the
+This option may not be set at the same time as the
 .Fl u
 or
 .Fl U
-flags.
+option.
 .It Fl M
 Permit merging of specification entries with different types,
 with the last entry take precedence.
@@ -222,13 +234,14 @@
 .It Fl S
 When reading a specification into an internal data structure,
 sort the entries.
-This will affect the order in which the
-.Fl c
-option checks entries, and the order of the output produced by the
+Sorting will affect the order of the output produced by the
 .Fl C
 or
 .Fl D
-options.
+options, and will also affect the order in which
+missing entries are created or reported when a directory tree is checked
+against a specification.
+.Pp
 The sort order is the same as that used by the
 .Fl c
 option, which is that entries within the same directory are
@@ -641,7 +654,7 @@
 .Nx 1.2 .
 The
 .Fl U
-flag appeared in
+option appeared in
 .Nx 1.3 .
 The
 .Sy flags
@@ -651,7 +664,7 @@
 .Fl i
 and
 .Fl m
-flags
+options
 appeared in
 .Nx 1.4 .
 The
@@ -673,7 +686,7 @@
 .Fl W ,
 and
 .Fl X
-flags, and support for full paths appeared in
+options, and support for full paths appeared in
 .Nx 1.6 .
 The
 .Sy sha256 ,
@@ -682,3 +695,7 @@
 .Sy sha512
 keywords appeared in
 .Nx 3.0 .
+The
+.Fl S
+option appeared in
+.Nx 6.0 .



CVS commit: src/usr.sbin/mtree

2009-04-08 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Wed Apr  8 19:03:13 UTC 2009

Modified Files:
src/usr.sbin/mtree: extern.h mtree.8 mtree.c spec.c

Log Message:
The recent addition of sorting to mtree -C broke some third party
scripts.  Now make sorting optional, controled by the -S flag.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/mtree/extern.h
cvs rdiff -u -r1.48 -r1.49 src/usr.sbin/mtree/mtree.8
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/mtree/mtree.c
cvs rdiff -u -r1.73 -r1.74 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/extern.h
diff -u src/usr.sbin/mtree/extern.h:1.30 src/usr.sbin/mtree/extern.h:1.31
--- src/usr.sbin/mtree/extern.h:1.30	Thu Dec 14 20:09:36 2006
+++ src/usr.sbin/mtree/extern.h	Wed Apr  8 19:03:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.30 2006/12/14 20:09:36 he Exp $	*/
+/*	$NetBSD: extern.h,v 1.31 2009/04/08 19:03:13 apb Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -71,7 +71,7 @@
 int	 verify(void);
 
 extern int	dflag, eflag, iflag, lflag, mflag, rflag, sflag, tflag, uflag;
-extern int	mtree_Mflag, mtree_Wflag;
+extern int	mtree_Mflag, mtree_Sflag, mtree_Wflag;
 extern size_t	mtree_lineno;
 extern u_int32_t crc_total;
 extern int	ftsoptions, keys;

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.48 src/usr.sbin/mtree/mtree.8:1.49
--- src/usr.sbin/mtree/mtree.8:1.48	Wed Mar 11 18:10:05 2009
+++ src/usr.sbin/mtree/mtree.8	Wed Apr  8 19:03:13 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: mtree.8,v 1.48 2009/03/11 18:10:05 joerg Exp $
+.\	$NetBSD: mtree.8,v 1.49 2009/04/08 19:03:13 apb Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -56,7 +56,7 @@
 .\
 .\ @(#)mtree.8	8.2 (Berkeley) 12/11/93
 .\
-.Dd February 1, 2009
+.Dd April 8, 2009
 .Dt MTREE 8
 .Os
 .Sh NAME
@@ -64,7 +64,7 @@
 .Nd map a directory hierarchy
 .Sh SYNOPSIS
 .Nm
-.Op Fl cCdDelLMPruUWx
+.Op Fl cCdDelLMPrSuUWx
 .Bk -words
 .Op Fl i | Fl m
 .Ek
@@ -131,6 +131,9 @@
 and
 .Fl I
 can be used to control which files are printed.
+The
+.Fl S
+option can be used to sort the output.
 .It Fl D
 As per
 .Fl C ,
@@ -245,6 +248,27 @@
 .Sy cksum
 was specified.
 The checksum is seeded with the specified value.
+.It Fl S
+When reading a specification into an internal data structure,
+sort the entries.
+This will affect the order in which the
+.Fl c
+option checks entries, and the order of the output produced by the
+.Fl C
+or
+.Fl D
+options.
+It will
+The sort order is the same as that used by the
+.Fl c
+option, which is that entries within the same directory are
+sorted in the order used by
+.Xr strcmp 3 ,
+except that entries for subdirectories sort after other entries.
+By default, if the
+.Fl S
+option is not used, entries within the same directory are collected
+together (separated from entries for other directories), but not sorted.
 .It Fl u
 Modify the owner, group, permissions, and flags of existing files,
 the device type of devices, and symbolic link targets,

Index: src/usr.sbin/mtree/mtree.c
diff -u src/usr.sbin/mtree/mtree.c:1.34 src/usr.sbin/mtree/mtree.c:1.35
--- src/usr.sbin/mtree/mtree.c:1.34	Mon Jul 21 13:36:59 2008
+++ src/usr.sbin/mtree/mtree.c	Wed Apr  8 19:03:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.c,v 1.34 2008/07/21 13:36:59 lukem Exp $	*/
+/*	$NetBSD: mtree.c,v 1.35 2009/04/08 19:03:13 apb 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.34 2008/07/21 13:36:59 lukem Exp $);
+__RCSID($NetBSD: mtree.c,v 1.35 2009/04/08 19:03:13 apb Exp $);
 #endif
 #endif /* not lint */
 
@@ -77,7 +77,8 @@
 	dir = NULL;
 	init_excludes();
 
-	while ((ch = getopt(argc, argv, cCdDeE:f:I:ik:K:lLmMN:p:PrR:s:tuUWxX:))
+	while ((ch = getopt(argc, argv,
+	cCdDeE:f:I:ik:K:lLmMN:p:PrR:s:StuUWxX:))
 	!= -1) {
 		switch((char)ch) {
 		case 'c':
@@ -159,6 +160,9 @@
 			if (*p)
 mtree_err(illegal seed value -- %s, optarg);
 			break;
+		case 'S':
+			mtree_Sflag = 1;
+			break;
 		case 't':
 			tflag = 1;
 			break;

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.73 src/usr.sbin/mtree/spec.c:1.74
--- src/usr.sbin/mtree/spec.c:1.73	Tue Apr  7 18:06:41 2009
+++ src/usr.sbin/mtree/spec.c	Wed Apr  8 19:03:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.73 2009/04/07 18:06:41 apb Exp $	*/
+/*	$NetBSD: spec.c,v 1.74 2009/04/08 19:03:13 apb Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = @(#)spec.c	8.2 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: spec.c,v 1.73 2009/04/07 18:06:41 apb Exp $);
+__RCSID($NetBSD: spec.c,v 1.74 2009/04/08 19:03:13 apb Exp $);
 #endif
 #endif /* not lint */
 
@@ -91,6 +91,7 @@
 size_t	mtree_lineno;			/* Current spec line number */
 int	

CVS commit: src/usr.sbin/mtree

2009-04-08 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Apr  8 19:43:05 UTC 2009

Modified Files:
src/usr.sbin/mtree: mtree.c

Log Message:
Sync usage with man page.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/mtree/mtree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/mtree.c
diff -u src/usr.sbin/mtree/mtree.c:1.35 src/usr.sbin/mtree/mtree.c:1.36
--- src/usr.sbin/mtree/mtree.c:1.35	Wed Apr  8 19:03:13 2009
+++ src/usr.sbin/mtree/mtree.c	Wed Apr  8 19:43:05 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtree.c,v 1.35 2009/04/08 19:03:13 apb Exp $	*/
+/*	$NetBSD: mtree.c,v 1.36 2009/04/08 19:43:05 wiz 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.35 2009/04/08 19:03:13 apb Exp $);
+__RCSID($NetBSD: mtree.c,v 1.36 2009/04/08 19:43:05 wiz Exp $);
 #endif
 #endif /* not lint */
 
@@ -226,9 +226,9 @@
 {
 
 	fprintf(stderr,
-	usage: %s [-cCdDelLMPruUWx] [-i|-m] [-f spec] [-k key]\n
-	\t\t[-K addkey] [-R removekey] [-I inctags] [-E exctags]\n
-	\t\t[-N userdbdir] [-X exclude-file] [-p path] [-s seed]\n,
+	usage: %s [-CcDdeLlMPrSUuWx] [-i|-m] [-E tags] [-f spec]\n
+	\t\t[-I tags] [-K keywords] [-k keywords] [-N dbdir] [-p path]\n
+	\t\t[-R keywords] [-s seed] [-X exclude-file]\n,
 	getprogname());
 	exit(1);
 }



CVS commit: src/usr.sbin/mtree

2009-04-05 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Sun Apr  5 15:47:03 UTC 2009

Modified Files:
src/usr.sbin/mtree: spec.c

Log Message:
Fix broken prev pointer in one case.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/usr.sbin/mtree/spec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.71 src/usr.sbin/mtree/spec.c:1.72
--- src/usr.sbin/mtree/spec.c:1.71	Sun Apr  5 12:15:07 2009
+++ src/usr.sbin/mtree/spec.c	Sun Apr  5 15:47:03 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.71 2009/04/05 12:15:07 dogcow Exp $	*/
+/*	$NetBSD: spec.c,v 1.72 2009/04/05 15:47:03 apb Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = @(#)spec.c	8.2 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: spec.c,v 1.71 2009/04/05 12:15:07 dogcow Exp $);
+__RCSID($NetBSD: spec.c,v 1.72 2009/04/05 15:47:03 apb Exp $);
 #endif
 #endif /* not lint */
 
@@ -711,6 +711,7 @@
 if (centry-next)
 	centry-next-prev = centry;
 			} else {
+pathparent-child-prev = centry;
 centry-next = pathparent-child;
 pathparent-child = centry;
 			}