10 // XXX What to do here?
11 VtMaxLumpSize = 65535,
20 fprint(2, "usage: venti/dump [-h host] score\n");
21 threadexitsall("usage");
28 dump(int indent, uchar *score, int type)
36 memset(spaces, ' ', sizeof spaces-1);
38 buf = vtmallocz(VtMaxLumpSize);
39 if(memcmp(score, vtzeroscore, VtScoreSize) == 0)
42 n = vtread(z, score, type, buf, VtMaxLumpSize);
44 Bprint(&bout, "%.*serror reading %V: %r\n", indent*4, spaces, score);
49 if(vtrootunpack(&root, buf) < 0){
50 Bprint(&bout, "%.*serror unpacking root %V: %r\n", indent*4, spaces, score);
53 Bprint(&bout, "%.*s%V root name=%s type=%s prev=%V bsize=%ld\n",
54 indent*4, spaces, score, root.name, root.type, root.prev, root.blocksize);
55 dump(indent+1, root.score, VtDirType);
59 Bprint(&bout, "%.*s%V dir n=%d\n", indent*4, spaces, score, n);
60 for(i=0; i*VtEntrySize<n; i++){
61 if(vtentryunpack(&e, buf, i) < 0){
62 Bprint(&bout, "%.*s%d: cannot unpack\n", indent+1, spaces, i);
65 Bprint(&bout, "%.*s%d: gen=%#lux psize=%ld dsize=%ld type=%d flags=%#x size=%llud score=%V\n",
66 (indent+1)*4, spaces, i, e.gen, e.psize, e.dsize, e.type, e.flags, e.size, e.score);
67 dump(indent+2, e.score, e.type);
72 Bprint(&bout, "%.*s%V data n=%d", indent*4, spaces, score, n);
75 Bprint(&bout, "\n%.*s", (indent+1)*4, spaces);
76 Bprint(&bout, " %02x", buf[i]);
83 Bprint(&bout, "%.*s%V dir+%d\n", indent*4, spaces, score, type-VtDirType);
85 Bprint(&bout, "%.*s%V data+%d\n", indent*4, spaces, score, type-VtDirType);
86 for(i=0; i<n; i+=VtScoreSize)
87 dump(indent+1, buf+i, type-1);
96 threadmain(int argc, char *argv[])
99 uchar score[VtScoreSize];
103 fmtinstall('F', vtfcallfmt);
104 fmtinstall('V', vtscorefmt);
108 host = EARGF(usage());
117 if(vtparsescore(argv[0], &prefix, score) < 0)
118 sysfatal("could not parse score: %r");
120 buf = vtmallocz(VtMaxLumpSize);
123 sysfatal("dialing venti: %r");
125 sysfatal("vtconnect src: %r");
127 for(type=0; type<VtMaxType; type++){
128 n = vtread(z, score, type, buf, VtMaxLumpSize);
132 sysfatal("cannot find block %V", score);
135 Binit(&bout, 1, OWRITE);
136 dump(0, score, type);