Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Oct 2013 17:59:17 +0000 (UTC)
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r256996 - stable/10/contrib/mtree
Message-ID:  <201310231759.r9NHxH40079900@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brooks
Date: Wed Oct 23 17:59:17 2013
New Revision: 256996
URL: http://svnweb.freebsd.org/changeset/base/256996

Log:
  MFC r256687:
  
  Upgrade to the latest version of mtree from NetBSD.  This revision
  re-removes the printing of size for non-regular files, supports
  type-less root (.) entries as seen in a couple ports, and corrects a bug
  in -N that caused expanded Subversion $FreeBSD$ strings in comments to
  be processed as /etc/group entries.
  
  Includes one trivial portability fix (including <stdint.h> in three
  files) that has been committed upstream.
  
  Approved by:	re (glebius)

Modified:
  stable/10/contrib/mtree/compare.c
  stable/10/contrib/mtree/create.c
  stable/10/contrib/mtree/getid.c
  stable/10/contrib/mtree/spec.c
Directory Properties:
  stable/10/contrib/mtree/   (props changed)

Modified: stable/10/contrib/mtree/compare.c
==============================================================================
--- stable/10/contrib/mtree/compare.c	Wed Oct 23 17:55:35 2013	(r256995)
+++ stable/10/contrib/mtree/compare.c	Wed Oct 23 17:59:17 2013	(r256996)
@@ -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 */
 
@@ -47,6 +47,7 @@ __RCSID("$NetBSD: compare.c,v 1.55 2012/
 
 #include <errno.h>
 #include <fcntl.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -192,9 +193,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 +284,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";
 	}
 	/*

Modified: stable/10/contrib/mtree/create.c
==============================================================================
--- stable/10/contrib/mtree/create.c	Wed Oct 23 17:55:35 2013	(r256995)
+++ stable/10/contrib/mtree/create.c	Wed Oct 23 17:59:17 2013	(r256996)
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.69 2013/02/03 19:15:17 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.69 2013/02/03 19:15:17 christos Exp $");
+__RCSID("$NetBSD: create.c,v 1.71 2013/10/16 17:24:20 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -53,6 +53,7 @@ __RCSID("$NetBSD: create.c,v 1.69 2013/0
 #include <fcntl.h>
 #include <grp.h>
 #include <pwd.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -216,22 +217,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);
+	    (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)
 #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 ||

Modified: stable/10/contrib/mtree/getid.c
==============================================================================
--- stable/10/contrib/mtree/getid.c	Wed Oct 23 17:55:35 2013	(r256995)
+++ stable/10/contrib/mtree/getid.c	Wed Oct 23 17:59:17 2013	(r256996)
@@ -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;
 	}

Modified: stable/10/contrib/mtree/spec.c
==============================================================================
--- stable/10/contrib/mtree/spec.c	Wed Oct 23 17:55:35 2013	(r256995)
+++ stable/10/contrib/mtree/spec.c	Wed Oct 23 17:59:17 2013	(r256996)
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.85 2012/12/20 16:43:16 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.85 2012/12/20 16:43:16 christos Exp $");
+__RCSID("$NetBSD: spec.c,v 1.87 2013/10/16 17:26:14 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -80,6 +80,7 @@ __RCSID("$NetBSD: spec.c,v 1.85 2012/12/
 #include <grp.h>
 #include <pwd.h>
 #include <stdarg.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -217,6 +218,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(
@@ -350,16 +357,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 (MATCHFLAG(F_NLINK))
 			appendfield(pathlast, "nlink=%d", cur->st_nlink);
 		if (MATCHFLAG(F_SLINK))
 			appendfield(pathlast, "link=%s", vispath(cur->slink));
 		if (MATCHFLAG(F_SIZE))
-			appendfield(pathlast, "size=%lld", (long long)cur->st_size);
+			appendfield(pathlast, "size=%ju",
+			    (uintmax_t)cur->st_size);
 		if (MATCHFLAG(F_TIME))
-			appendfield(pathlast, "time=%lld.%09ld",
-			    (long long)cur->st_mtimespec.tv_sec,
+			appendfield(pathlast, "time=%jd.%09ld",
+			    (intmax_t)cur->st_mtimespec.tv_sec,
 			    cur->st_mtimespec.tv_nsec);
 		if (MATCHFLAG(F_CKSUM))
 			appendfield(pathlast, "cksum=%lu", cur->cksum);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310231759.r9NHxH40079900>