summaryrefslogtreecommitdiff
path: root/usr.sbin/mtree/compare.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-12-10 08:26:11 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-12-10 08:26:11 +0000
commit84628cb508dd539bbfb3454a013111417b6ef32d (patch)
tree5ed0c9c124851c0d6d3c3fbf1571c8a157b6ec24 /usr.sbin/mtree/compare.c
parent6180e74d3e49c2032e0fa17ee8fc2430b4828248 (diff)
merge freebsd mtree diffs, plus -Wall cleanup
Diffstat (limited to 'usr.sbin/mtree/compare.c')
-rw-r--r--usr.sbin/mtree/compare.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c
index 28280aaacc9..71600548733 100644
--- a/usr.sbin/mtree/compare.c
+++ b/usr.sbin/mtree/compare.c
@@ -1,5 +1,5 @@
/* $NetBSD: compare.c,v 1.9 1995/10/22 20:12:07 pk Exp $ */
-/* $OpenBSD: compare.c,v 1.4 1996/12/08 01:13:38 niklas Exp $ */
+/* $OpenBSD: compare.c,v 1.5 1996/12/10 08:25:57 deraadt Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -50,6 +50,7 @@ static char rcsid[] = "$NetBSD: compare.c,v 1.9 1995/10/22 20:12:07 pk Exp $";
#include <stdio.h>
#include <time.h>
#include <unistd.h>
+#include <md5.h>
#include "mtree.h"
#include "extern.h"
@@ -66,7 +67,7 @@ static char *ftype __P((u_int));
(void)printf("\n"); \
} else { \
tab = ""; \
- (void)printf("%*s", INDENTNAMELEN - len, ""); \
+ (void)printf("%*s", INDENTNAMELEN - (int)len, ""); \
} \
}
@@ -79,7 +80,7 @@ compare(name, s, p)
extern int uflag;
u_int32_t len, val;
int fd, label;
- char *cp, *tab;
+ char *cp, *tab = "";
label = 0;
switch(s->type) {
@@ -176,9 +177,9 @@ typeerr: LABEL;
* XXX
* Catches nano-second differences, but doesn't display them.
*/
- if (s->flags & F_TIME &&
- (s->st_mtimespec.tv_sec != p->fts_statp->st_mtimespec.tv_sec ||
- s->st_mtimespec.tv_nsec != p->fts_statp->st_mtimespec.tv_nsec)) {
+ if ((s->flags & F_TIME) &&
+ ((s->st_mtimespec.tv_sec != p->fts_statp->st_mtimespec.tv_sec) ||
+ (s->st_mtimespec.tv_nsec != p->fts_statp->st_mtimespec.tv_nsec))) {
LABEL;
(void)printf("%smodification time (%.24s, ",
tab, ctime(&s->st_mtimespec.tv_sec));
@@ -202,11 +203,28 @@ typeerr: LABEL;
(void)close(fd);
if (s->cksum != val) {
LABEL;
- (void)printf("%scksum (%u, %u)\n",
+ (void)printf("%scksum (%u, %u)\n",
tab, s->cksum, val);
}
tab = "\t";
}
+ if (s->flags & F_MD5) {
+ char *new_digest, buf[33];
+
+ new_digest = MD5File(p->fts_accpath,buf);
+ if (!new_digest) {
+ LABEL;
+ printf("%sMD5File: %s: %s\n", tab, p->fts_accpath,
+ strerror(errno));
+ tab = "\t";
+ } else if (strcmp(new_digest, s->md5digest)) {
+ LABEL;
+ printf("%sMD5 (%s, %s)\n", tab, s->md5digest,
+ new_digest);
+ tab = "\t";
+ }
+ }
+
if (s->flags & F_SLINK && strcmp(cp = rlink(name), s->slink)) {
LABEL;
(void)printf("%slink ref (%s, %s)\n", tab, cp, s->slink);