Commit 34ec01b2 authored by Mike Hibler's avatar Mike Hibler
Browse files

Make imagehash create the .sig file with the same modtime as the image.

This is a cheap verification mechanism.  Also install imagehash now with
all the other image tools, it will be used soon.
parent a423c0e6
......@@ -164,7 +164,7 @@ imagehash.o: imagehdr.h
version.c: imagezip.c imageunzip.c imagedump.c
echo >$@ "char build_info[] = \"Built `date +%d-%b-%Y` by `id -nu`@`hostname | sed 's/\..*//'`:`pwd`\";"
install: $(INSTALL_BINDIR)/imagezip $(INSTALL_BINDIR)/imageunzip $(INSTALL_BINDIR)/imagedump
install: $(INSTALL_BINDIR)/imagezip $(INSTALL_BINDIR)/imageunzip $(INSTALL_BINDIR)/imagedump $(INSTALL_BINDIR)/imagehash
client: all
client-install: client
......
......@@ -208,8 +208,8 @@ or Linux zero blocks that get freed nor do they chain free blocks together
using part of the block as a link field. So I think still hashing the
blocks might pay off, but we'll have to do some tests.
Another issue is how does imagezip know how much of the file it should look
at when creating a delta. If a users only loads FreeBSD in partition 1,
Another issue is how does imagezip know how much of the disk it should look
at when creating a delta. If a user only loads FreeBSD in partition 1,
but then puts data in the other partitions, how do we know that we should
save that in the delta? In a sense, the mechanism will just work. If the
signature used for comparison only covers partition 1, and imagezip is
......
......@@ -428,6 +428,8 @@ createhash(char *name, struct hashinfo **hinfop)
int ofd, cc;
int count;
struct hashinfo *hinfo;
struct stat sb;
struct timeval tm[2];
hfile = signame(name);
ofd = open(hfile, O_RDWR|O_CREAT, 0666);
......@@ -466,6 +468,21 @@ createhash(char *name, struct hashinfo **hinfop)
}
free(hfile);
/*
* Set the modtime of the hash file to match that of the image.
* This is a crude (but fast!) method for matching images with
* signatures.
*/
cc = stat(name, &sb);
if (cc >= 0) {
TIMESPEC_TO_TIMEVAL(&tm[0], &sb.st_atimespec);
TIMESPEC_TO_TIMEVAL(&tm[1], &sb.st_mtimespec);
cc = utimes(hfile, tm);
}
if (cc < 0)
fprintf(stderr, "%s: WARNING: could not set mtime\n", hfile);
nhregions = hinfo->nregions;
printf("%s: %lu chunks, %lu regions, %lu hashregions, %llu data bytes\n",
name, nchunks, nregions, nhregions, ndatabytes);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment