13 clumpinfoeq(ClumpInfo *c, ClumpInfo *d)
15 return c->type == d->type
17 && c->uncsize == d->uncsize
18 && scorecmp(c->score, d->score)==0;
22 * synchronize the clump info directory with
23 * with the clumps actually stored in the arena.
24 * the directory should be at least as up to date
25 * as the arena's trailer.
27 * checks/updates at most n clumps.
29 * returns 1 if ok, -1 if an error occured, 0 if blocks were updated
32 findscore(Arena *arena, uchar *score)
42 fprint(2, "reading directory for arena=%s with %d entries\n", arena->name, arena->clumps);
44 cis = MKN(ClumpInfo, ClumpChunks);
47 memset(&ie, 0, sizeof(IEntry));
48 for(clump = 0; clump < arena->clumps; clump += n){
50 if(n > arena->clumps - clump)
51 n = arena->clumps - clump;
52 if(readclumpinfos(arena, clump, cis, n) != n){
53 seterr(EOk, "arena directory read failed: %r");
57 for(i = 0; i < n; i++){
59 if(scorecmp(score, ci->score)==0){
60 fprint(2, "found at clump=%d with type=%d size=%d csize=%d position=%lld\n",
61 clump + i, ci->type, ci->uncsize, ci->size, a);
64 a += ci->size + ClumpSize;
74 fprint(2, "usage: findscore [-v] arenafile score\n");
79 threadmain(int argc, char *argv[])
84 u8int score[VtScoreSize];
87 fmtinstall('V', vtscorefmt);
105 if(strscore(argv[1], score) < 0)
106 sysfatal("bad score %s\n", argv[1]);
108 part = initpart(file, 0);
110 sysfatal("can't open partition %s: %r", file);
112 ap = initarenapart(part);
114 sysfatal("can't initialize arena partition in %s: %r", file);
117 printarenapart(2, ap);
121 initdcache(8 * MaxDiskBlock);
124 for(i = 0; i < ap->narenas; i++)
125 found += findscore(ap->arenas[i], score);
127 print("found %d occurances of %V\n", found, score);