clean:
rm -f shredtree shredcompare shredtree.o md5.o shredcompare.o
-test:
+test-a:
shredtree -c test1 >TEST1
shredtree -c test2 >TEST2
shredcompare TEST1 TEST2
-
-testgood:
+test-b:
shredtree -c test3 >TEST1
shredtree -c test4 >TEST2
- @echo "*** Python;"
- shredcompare.py TEST1 TEST2
- @echo "*** C:"
shredcompare TEST1 TEST2
+
+goodtest:
+ shredtree -c -d ~/src/unix src5r4/src/ucbhead >src5r4.shif
+ shredtree -c -d ~/src/unix linux-2.6.0-test4/include/linux >linux-2.6.0-test4.shif
+ shredcompare src5r4.shif linux-2.6.0-test4.shif >TEST.LOG
+
+bigtest:
+ shredtree -c -d ~/src/unix src5r4 >src5r4.shif
+ shredtree -c -d ~/src/unix linux-2.6.0-test4 >linux-2.6.0-test4.shif
+ shredcompare src5r4.shif linux-2.6.0-test4.shif >TEST.LOG
int shred_size;
char *hash_method;
char *generator_program;
+ int hashcount;
};
static struct shif_t *shiflist;
stat(sp->name, &sb);
total += sb.st_size - ftell(sp->fp);
}
- fprintf(stderr, "%% %ld bytes to be read.\n", total);
init_intern(total/sizeof(struct hash_t)); /* real work done here */
/* read in all hashes */
{
u_int32_t sectcount;
+ fprintf(stderr, "Reading %s... ", sp->name);
fread(§count, sizeof(u_int32_t), 1, sp->fp);
sectcount = ntohl(sectcount);
while (sectcount--)
this.end = FROMNET(this.end);
hash_intern(&this); /* real work done here */
hashcount++;
+ sp->hashcount++;
+ if (hashcount % 10000 == 0)
+ fprintf(stderr, "\b\b\b%02.0f%%", (ftell(sp->fp) / (total * 0.01)));
}
}
+ fprintf(stderr, "\b\b\b100%%...done, %d entries\n", sp->hashcount);
}
}
self.name = name
self.fp = open(name)
self.comments = []
+ self.hashcount = 0
id = self.fp.readline()
if not id.startswith("#SHIF-A "):
sys.stderr.write("shredcompare: %s is not a SHIF-A file."%self.fp.name)
hashcount = total = 0
-def merge_hashes(fp, dict):
+def merge_hashes(shif, dict):
"Read and merge hashes corresponding to one file."
global hashcount
- file = fp.readline()
+ file = shif.fp.readline()
if not file:
return False
file = file.strip()
# Record count comes right after the filename
- (record_count,) = struct.unpack("!H", fp.read(2))
+ (record_count,) = struct.unpack("!H", shif.fp.read(2))
while record_count > 0:
record_count -= 1
# 4 bytes of start line number + 4 of end line number + 16 of MD5 hash
- (start, end, hashval) = struct.unpack("!HH16s", fp.read(20))
+ (start, end, hashval) = struct.unpack("!HH16s", shif.fp.read(20))
if dict.has_key(hashval):
oldval = dict[hashval]
else:
oldval = ""
dict[hashval] = oldval + file + "\t" + `start` + "\t" + `end` + "\n"
hashcount += 1
+ shif.hashcount += 1
if hashcount % 10000 == 0:
- sys.stderr.write("\b\b\b%02.0f%%" % (fp.tell() / (total * 0.01)))
+ sys.stderr.write("\b\b\b%02.0f%%" % (shif.fp.tell() / (total * 0.01)))
return True
def item_factory(db):
shiflist[i].compatible(shiflist[i+1])
# Compute amount of data to be read
total = sum(map(lambda x: filesize(x.name) - x.fp.tell(), shiflist))
- sys.stderr.write("%d bytes of data to be read\n" % total)
# Read in the filecounts, though this implementation won't use them.
for shif in shiflist:
shif.fp.read(struct.calcsize("!i"))
# Read in all hashes
hashdict = bsddb.hashopen(None, 'c')
for shif in shiflist:
- sys.stderr.write("Reading... ")
- while merge_hashes(shif.fp, hashdict):
+ sys.stderr.write("Reading %s... " % shif.name)
+ while merge_hashes(shif, hashdict):
continue
- sys.stderr.write("\b\b\b100%...done\n")
+ sys.stderr.write("\b\b\b100%...done, %d entries\n" % shif->hashcount)
report_time("Hash merge done, %d entries" % hashcount)
# Nuke all unique hashes
nonuniques = 0