summaryrefslogtreecommitdiffstats
path: root/contrib/mtree
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2013-11-26 16:12:40 +0000
committerbrooks <brooks@FreeBSD.org>2013-11-26 16:12:40 +0000
commitc545463f87891b7cabcb279987652b0665a4135c (patch)
tree96ca18958b5e248a85dc780cb4ac8f74ae94b81c /contrib/mtree
parent67681dff483bad8dc076fb5caa649e0ce4944257 (diff)
downloadFreeBSD-src-c545463f87891b7cabcb279987652b0665a4135c.zip
FreeBSD-src-c545463f87891b7cabcb279987652b0665a4135c.tar.gz
MFC r258437:
Sync with NetBSD. The functional change is to make the output when comparing a directory to an mtree file more compatible with fmtree when FreeBSD 9 compatiblity mode is on. This output is clearly intended for humans not computers, but some tools such as mergemaster's -U option rely on it. Approved by: re (glebius)
Diffstat (limited to 'contrib/mtree')
-rw-r--r--contrib/mtree/compare.c139
-rw-r--r--contrib/mtree/create.c6
-rw-r--r--contrib/mtree/spec.c6
3 files changed, 99 insertions, 52 deletions
diff --git a/contrib/mtree/compare.c b/contrib/mtree/compare.c
index af2fd31..e3639ce 100644
--- a/contrib/mtree/compare.c
+++ b/contrib/mtree/compare.c
@@ -1,4 +1,4 @@
-/* $NetBSD: compare.c,v 1.56 2013/09/09 23:27:43 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.56 2013/09/09 23:27:43 christos Exp $");
+__RCSID("$NetBSD: compare.c,v 1.58 2013/11/21 18:39:50 christos Exp $");
#endif
#endif /* not lint */
@@ -47,8 +47,8 @@ __RCSID("$NetBSD: compare.c,v 1.56 2013/09/09 23:27:43 christos Exp $");
#include <errno.h>
#include <fcntl.h>
-#include <stdint.h>
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -72,13 +72,18 @@ __RCSID("$NetBSD: compare.c,v 1.56 2013/09/09 23:27:43 christos Exp $");
#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, %#lo",
+ printf(flavor == F_FREEBSD9 ?
+ "%spermissions expcted %#lo found %#lo" :
+ "%spermissions (%#lo, %#lo",
tab, (u_long)s->st_mode,
(u_long)p->fts_statp->st_mode & MBITS);
if (uflag) {
if (lchmod(p->fts_accpath, s->st_mode))
- 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");
@@ -278,13 +298,16 @@ typeerr: LABEL;
if (s->flags & F_NLINK && s->type != F_DIR &&
s->st_nlink != p->fts_statp->st_nlink) {
LABEL;
- printf("%slink count (%lu, %lu)\n",
+ printf(flavor == F_FREEBSD9 ?
+ "%slink count expected %lu found %lu\n" :
+ "%slink count (%lu, %lu)\n",
tab, (u_long)s->st_nlink, (u_long)p->fts_statp->st_nlink);
tab = "\t";
}
if (s->flags & F_SIZE && s->st_size != p->fts_statp->st_size) {
LABEL;
- printf("%ssize (%ju, %ju)\n",
+ printf(flavor == F_FREEBSD9 ?
+ "%ssize expected %ju found %ju\n" : "%ssize (%ju, %ju)\n",
tab, (uintmax_t)s->st_size,
(uintmax_t)p->fts_statp->st_size);
tab = "\t";
@@ -319,18 +342,22 @@ typeerr: LABEL;
if (tv[0].tv_sec != tv[1].tv_sec ||
tv[0].tv_usec != tv[1].tv_usec) {
LABEL;
- printf("%smodification time (%.24s, ",
+ printf(flavor == F_FREEBSD9 ?
+ "%smodification time expected %.24s found " :
+ "%smodification time (%.24s, ",
tab, ctime(&smtime));
printf("%.24s", ctime(&pmtime));
if (tflag) {
tv[1] = tv[0];
if (utimes(p->fts_accpath, tv))
- 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");
+ printf("%s\n", flavor == F_FREEBSD9 ? "" : ")");
tab = "\t";
}
}
@@ -347,7 +374,9 @@ typeerr: LABEL;
char *f_s;
LABEL;
f_s = flags_to_string(s->st_flags, "none");
- printf("%sflags (\"%s\" is not ", tab, f_s);
+ printf(flavor == F_FREEBSD9 ?
+ "%sflags expected \"%s\" found " :
+ "%sflags (\"%s\" is not ", tab, f_s);
free(f_s);
f_s = flags_to_string(p->fts_statp->st_flags, "none");
printf("\"%s\"", f_s);
@@ -361,7 +390,7 @@ typeerr: LABEL;
else
SETFLAGS(0, (~SP_FLGS & CH_MASK));
} else
- printf(")\n");
+ printf("%s\n", flavor == F_FREEBSD9 ? "" : ")");
tab = "\t";
}
#endif /* HAVE_STRUCT_STAT_ST_FLAGS */
@@ -387,7 +416,9 @@ typeerr: LABEL;
close(fd);
if (s->cksum != val) {
LABEL;
- printf("%scksum (%lu, %lu)\n",
+ printf(flavor == F_FREEBSD9 ?
+ "%scksum expected %lu found %lu\n" :
+ "%scksum (%lu, %lu)\n",
tab, s->cksum, (unsigned long)val);
}
tab = "\t";
@@ -403,7 +434,9 @@ typeerr: LABEL;
} else {
if (strcmp(s->md5digest, digestbuf)) {
LABEL;
- printf("%s%s (0x%s, 0x%s)\n",
+ printf(flavor == F_FREEBSD9 ?
+ "%s%s expected %s found %s\n" :
+ "%s%s (0x%s, 0x%s)\n",
tab, MD5KEY, s->md5digest, digestbuf);
}
tab = "\t";
@@ -421,7 +454,9 @@ typeerr: LABEL;
} else {
if (strcmp(s->rmd160digest, digestbuf)) {
LABEL;
- printf("%s%s (0x%s, 0x%s)\n",
+ printf(flavor == F_FREEBSD9 ?
+ "%s%s expected %s found %s\n" :
+ "%s%s (0x%s, 0x%s)\n",
tab, RMD160KEY, s->rmd160digest, digestbuf);
}
tab = "\t";
@@ -439,7 +474,9 @@ typeerr: LABEL;
} else {
if (strcmp(s->sha1digest, digestbuf)) {
LABEL;
- printf("%s%s (0x%s, 0x%s)\n",
+ printf(flavor == F_FREEBSD9 ?
+ "%s%s expected %s found %s\n" :
+ "%s%s (0x%s, 0x%s)\n",
tab, SHA1KEY, s->sha1digest, digestbuf);
}
tab = "\t";
@@ -457,7 +494,9 @@ typeerr: LABEL;
} else {
if (strcmp(s->sha256digest, digestbuf)) {
LABEL;
- printf("%s%s (0x%s, 0x%s)\n",
+ printf(flavor == F_FREEBSD9 ?
+ "%s%s expected %s found %s\n" :
+ "%s%s (0x%s, 0x%s)\n",
tab, SHA256KEY, s->sha256digest, digestbuf);
}
tab = "\t";
@@ -474,7 +513,9 @@ typeerr: LABEL;
} else {
if (strcmp(s->sha384digest, digestbuf)) {
LABEL;
- printf("%s%s (0x%s, 0x%s)\n",
+ printf(flavor == F_FREEBSD9 ?
+ "%s%s expected %s found %s\n" :
+ "%s%s (0x%s, 0x%s)\n",
tab, SHA384KEY, s->sha384digest, digestbuf);
}
tab = "\t";
@@ -491,7 +532,9 @@ typeerr: LABEL;
} else {
if (strcmp(s->sha512digest, digestbuf)) {
LABEL;
- printf("%s%s (0x%s, 0x%s)\n",
+ printf(flavor == F_FREEBSD9 ?
+ "%s%s expected %s found %s\n" :
+ "%s%s (0x%s, 0x%s)\n",
tab, SHA512KEY, s->sha512digest, digestbuf);
}
tab = "\t";
@@ -502,16 +545,20 @@ typeerr: LABEL;
if (s->flags & F_SLINK &&
strcmp(cp = rlink(p->fts_accpath), s->slink)) {
LABEL;
- printf("%slink ref (%s, %s", tab, cp, s->slink);
+ printf(flavor == F_FREEBSD9 ?
+ "%slink ref expected %s found %s" :
+ "%slink ref (%s, %s", tab, cp, s->slink);
if (uflag) {
if ((unlink(p->fts_accpath) == -1) ||
(symlink(s->slink, p->fts_accpath) == -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");
+ printf("%s\n", flavor == F_FREEBSD9 ? "" : ")");
}
return (label);
}
diff --git a/contrib/mtree/create.c b/contrib/mtree/create.c
index 516977e..1e44661 100644
--- a/contrib/mtree/create.c
+++ b/contrib/mtree/create.c
@@ -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 */
@@ -53,9 +53,9 @@ __RCSID("$NetBSD: create.c,v 1.71 2013/10/16 17:24:20 christos Exp $");
#include <fcntl.h>
#include <grp.h>
#include <pwd.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
diff --git a/contrib/mtree/spec.c b/contrib/mtree/spec.c
index e6fe741..ba39180 100644
--- a/contrib/mtree/spec.c
+++ b/contrib/mtree/spec.c
@@ -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 */
@@ -80,8 +80,8 @@ __RCSID("$NetBSD: spec.c,v 1.87 2013/10/16 17:26:14 christos Exp $");
#include <grp.h>
#include <pwd.h>
#include <stdarg.h>
-#include <stdint.h>
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
OpenPOWER on IntegriCloud