8 fprint(2, "usage: printarena arenafile [offset]\n");
9 threadexitsall("usage");
13 rdarena(Arena *arena, u64int offset)
18 uchar score[VtScoreSize];
24 e = arena->base + arena->size;
25 if(offset != ~(u64int)0) {
27 sysfatal("bad offset %llud >= %llud\n",
33 for(; aa < e; aa += ClumpSize+cl.info.size) {
34 magic = clumpmagic(arena, aa);
35 if(magic == ClumpFreeMagic)
37 if(magic != arena->clumpmagic) {
38 fprint(2, "illegal clump magic number %#8.8ux offset %llud\n",
42 lump = loadclump(arena, aa, 0, &cl, score, 0);
44 fprint(2, "clump %llud failed to read: %r\n", aa);
47 if(cl.info.type != VtCorruptType) {
48 scoremem(score, lump->data, cl.info.uncsize);
49 if(scorecmp(cl.info.score, score) != 0) {
50 fprint(2, "clump %llud has mismatched score\n", aa);
53 if(vttypevalid(cl.info.type) < 0) {
54 fprint(2, "clump %llud has bad type %d\n", aa, cl.info.type);
58 print("%22llud %V %3d %5d\n", aa, score, cl.info.type, cl.info.uncsize);
61 print("end offset %llud\n", aa);
65 threadmain(int argc, char *argv[])
69 u64int offset, aoffset;
74 readonly = 1; /* for part.c */
78 aoffset = strtoull(EARGF(usage()), 0, 0);
90 offset = strtoull(argv[1], 0, 0);
100 part = initpart(file, OREAD|ODIRECT);
102 sysfatal("can't open file %s: %r", file);
103 if(readpart(part, aoffset, buf, sizeof buf) < 0)
104 sysfatal("can't read file %s: %r", file);
106 if(unpackarenahead(&head, buf) < 0)
107 sysfatal("corrupted arena header: %r");
109 print("# arena head version=%d name=%.*s blocksize=%d size=%lld clumpmagic=0x%.8ux\n",
110 head.version, ANameSize, head.name, head.blocksize,
111 head.size, head.clumpmagic);
113 if(aoffset+head.size > part->size)
114 sysfatal("arena is truncated: want %llud bytes have %llud\n",
115 head.size, part->size);
117 partblocksize(part, head.blocksize);
118 initdcache(8 * MaxDiskBlock);
120 arena = initarena(part, aoffset, head.size, head.blocksize);
122 sysfatal("initarena: %r");
124 rdarena(arena, offset);