diff options
author | Russ Cox <rsc@swtch.com> | 2008-12-06 16:14:10 -0800 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2008-12-06 16:14:10 -0800 |
commit | 286bb40b76f35ffee1e6789895782af203e0dae3 (patch) | |
tree | b9fc8b72d8699e6cb71ce680c701f365ab7b6d53 /src/cmd/vac/file.c | |
parent | 115dbcecc8d35d12b54d17dc1cba39089ad37b5f (diff) | |
download | plan9port-286bb40b76f35ffee1e6789895782af203e0dae3.tar.gz plan9port-286bb40b76f35ffee1e6789895782af203e0dae3.tar.bz2 plan9port-286bb40b76f35ffee1e6789895782af203e0dae3.zip |
unvac: add -d flag (David Swasey)
Diffstat (limited to 'src/cmd/vac/file.c')
-rw-r--r-- | src/cmd/vac/file.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/cmd/vac/file.c b/src/cmd/vac/file.c index 598dae09..faa558f3 100644 --- a/src/cmd/vac/file.c +++ b/src/cmd/vac/file.c @@ -2061,3 +2061,32 @@ vacfssync(VacFs *fs) return -1; return 0; } + +int +vacfiledsize(VacFile *f) +{ + VtEntry e; + + if(vacfilegetentries(f,&e,nil) < 0) + return -1; + return e.dsize; +} + +/* + * Does block b of f have the same SHA1 hash as the n bytes at buf? + */ +int +sha1matches(VacFile *f, ulong b, uchar *buf, int n) +{ + uchar fscore[VtScoreSize]; + uchar bufscore[VtScoreSize]; + + if(vacfileblockscore(f, b, fscore) < 0) + return 0; + n = vtzerotruncate(VtDataType, buf, n); + sha1(buf, n, bufscore, nil); + if(memcmp(bufscore, fscore, VtScoreSize) == 0) + return 1; + return 0; +} + |