Vendor import of NetBSD's mtree at 2013-11-21

This commit is contained in:
Brooks Davis 2013-11-21 19:16:52 +00:00
parent 675e2c61fa
commit a90dc36c0d
3 changed files with 99 additions and 49 deletions

128
compare.c
View File

@ -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 */
@ -48,6 +48,7 @@ __RCSID("$NetBSD: compare.c,v 1.56 2013/09/09 23:27:43 christos Exp $");
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@ -71,6 +72,10 @@ __RCSID("$NetBSD: compare.c,v 1.56 2013/09/09 23:27:43 christos Exp $");
#define INDENTNAMELEN 8
#define MARK \
do { \
if (flavor == F_FREEBSD9) { \
len = printf("%s changed\n", RP(p)); \
tab = "\t"; \
} else { \
len = printf("%s: ", RP(p)); \
if (len > INDENTNAMELEN) { \
tab = "\t"; \
@ -79,6 +84,7 @@ do { \
tab = ""; \
printf("%*s", INDENTNAMELEN - (int)len, ""); \
} \
} \
} while (0)
#define LABEL if (!label++) MARK
@ -170,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);
}
@ -192,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) {
@ -202,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";
@ -213,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");
@ -259,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");
@ -277,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";
@ -318,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";
}
}
@ -346,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);
@ -360,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 */
@ -386,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";
@ -402,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";
@ -420,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";
@ -438,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";
@ -456,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";
@ -473,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";
@ -490,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";
@ -501,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);
}

View File

@ -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/10/16 17:24:20 christos Exp $");
#include <pwd.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

5
spec.c
View File

@ -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/16 17:26:14 christos Exp $");
#include <pwd.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>