#include #include #include #include #include #include enum { // XXX What to do here? VtMaxLumpSize = 65535, }; VtConn *z; char *host; void usage(void) { fprint(2, "usage: venti/dump [-h host] score\n"); threadexitsall("usage"); } Biobuf bout; char spaces[256]; void dump(int indent, uchar *score, int type) { int i, n; uchar *buf; VtEntry e; VtRoot root; if(spaces[0] == 0) memset(spaces, ' ', sizeof spaces-1); buf = vtmallocz(VtMaxLumpSize); if(memcmp(score, vtzeroscore, VtScoreSize) == 0) n = 0; else n = vtread(z, score, type, buf, VtMaxLumpSize); if(n < 0){ Bprint(&bout, "%.*serror reading %V: %r\n", indent*4, spaces, score); goto out; } switch(type){ case VtRootType: if(vtrootunpack(&root, buf) < 0){ Bprint(&bout, "%.*serror unpacking root %V: %r\n", indent*4, spaces, score); goto out; } Bprint(&bout, "%.*s%V root name=%s type=%s prev=%V bsize=%ld\n", indent*4, spaces, score, root.name, root.type, root.prev, root.blocksize); dump(indent+1, root.score, VtDirType); break; case VtDirType: Bprint(&bout, "%.*s%V dir n=%d\n", indent*4, spaces, score, n); for(i=0; i*VtEntrySize= VtDirType) Bprint(&bout, "%.*s%V dir+%d\n", indent*4, spaces, score, type-VtDirType); else Bprint(&bout, "%.*s%V data+%d\n", indent*4, spaces, score, type-VtDirType); for(i=0; i= 0) goto havetype; } sysfatal("cannot find block %V", score); havetype: Binit(&bout, 1, OWRITE); dump(0, score, type); Bflush(&bout); threadexitsall(nil); }