14 fprint(2, "usage: venti/dump [-h host] score\n");
15 threadexitsall("usage");
22 dump(int indent, uchar *score, int type)
30 memset(spaces, ' ', sizeof spaces-1);
32 buf = vtmallocz(VtMaxLumpSize);
33 if(memcmp(score, vtzeroscore, VtScoreSize) == 0)
36 n = vtread(z, score, type, buf, VtMaxLumpSize);
38 Bprint(&bout, "%.*serror reading %V: %r\n", indent*4, spaces, score);
43 if(vtrootunpack(&root, buf) < 0){
44 Bprint(&bout, "%.*serror unpacking root %V: %r\n", indent*4, spaces, score);
47 Bprint(&bout, "%.*s%V root name=%s type=%s prev=%V bsize=%d\n",
48 indent*4, spaces, score, root.name, root.type, root.prev, root.blocksize);
49 dump(indent+1, root.score, VtDirType);
53 Bprint(&bout, "%.*s%V dir n=%d\n", indent*4, spaces, score, n);
54 for(i=0; i*VtEntrySize<n; i++){
55 if(vtentryunpack(&e, buf, i) < 0){
56 Bprint(&bout, "%.*s%d: cannot unpack\n", indent+1, spaces, i);
59 Bprint(&bout, "%.*s%d: gen=%#lux psize=%d dsize=%d type=%d flags=%#x size=%llud score=%V\n",
60 (indent+1)*4, spaces, i, e.gen, e.psize, e.dsize, e.type, e.flags, e.size, e.score);
61 dump(indent+2, e.score, e.type);
66 Bprint(&bout, "%.*s%V data n=%d", indent*4, spaces, score, n);
69 Bprint(&bout, "\n%.*s", (indent+1)*4, spaces);
70 Bprint(&bout, " %02x", buf[i]);
77 Bprint(&bout, "%.*s%V dir+%d\n", indent*4, spaces, score, type-VtDirType);
79 Bprint(&bout, "%.*s%V data+%d\n", indent*4, spaces, score, type-VtDirType);
80 for(i=0; i<n; i+=VtScoreSize)
81 dump(indent+1, buf+i, type-1);
90 threadmain(int argc, char *argv[])
93 uchar score[VtScoreSize];
97 fmtinstall('F', vtfcallfmt);
98 fmtinstall('V', vtscorefmt);
103 host = EARGF(usage());
112 if(vtparsescore(argv[0], &prefix, score) < 0)
113 sysfatal("could not parse score: %r");
115 buf = vtmallocz(VtMaxLumpSize);
118 sysfatal("dialing venti: %r");
120 sysfatal("vtconnect src: %r");
122 for(type=0; type<VtMaxType; type++){
123 n = vtread(z, score, type, buf, VtMaxLumpSize);
127 sysfatal("cannot find block %V", score);
130 Binit(&bout, 1, OWRITE);
131 dump(0, score, type);