From: Brian Warner Date: Wed, 7 Nov 2007 02:46:31 +0000 (-0700) Subject: dump-share: emit SDMF information too X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/install.html?a=commitdiff_plain;h=cc5d35cc07b64742e8b4ef4d43b1a99ecd40caa2;p=tahoe-lafs%2Ftahoe-lafs.git dump-share: emit SDMF information too --- diff --git a/src/allmydata/scripts/debug.py b/src/allmydata/scripts/debug.py index 92ea94b8..936e84a6 100644 --- a/src/allmydata/scripts/debug.py +++ b/src/allmydata/scripts/debug.py @@ -137,10 +137,17 @@ def dump_mutable_share(config, out, err): extra_lease_offset = m._read_extra_lease_offset(f) container_size = extra_lease_offset - m.DATA_OFFSET leases = list(m._enumerate_leases(f)) + + share_type = "unknown" + f.seek(m.DATA_OFFSET) + if f.read(1) == "\x00": + # this slot contains an SMDF share + share_type = "SDMF" f.close() print >>out print >>out, "Mutable slot found:" + print >>out, " share_type: %s" % share_type print >>out, " write_enabler: %s" % idlib.b2a(WE) print >>out, " WE for nodeid: %s" % idlib.nodeid_b2a(nodeid) print >>out, " num_extra_leases: %d" % num_extra_leases @@ -159,8 +166,41 @@ def dump_mutable_share(config, out, err): else: print >>out, "No leases." print >>out + + if share_type == "SDMF": + dump_SDMF_share(m.DATA_OFFSET, data_length, config, out, err) + return 0 +def dump_SDMF_share(offset, length, config, out, err): + from allmydata import mutable + from allmydata.util import idlib + + f = open(config['filename'], "rb") + f.seek(offset) + data = f.read(min(length, 2000)) + f.close() + + pieces = mutable.unpack_share(data) + + (seqnum, root_hash, IV, k, N, segsize, datalen, + pubkey, signature, share_hash_chain, block_hash_tree, + share_data, enc_privkey) = pieces + + print >>out, " SDMF contents:" + print >>out, " seqnum: %d" % seqnum + print >>out, " root_hash: %s" % idlib.b2a(root_hash) + print >>out, " IV: %s" % idlib.b2a(IV) + print >>out, " required_shares: %d" % k + print >>out, " total_shares: %d" % N + print >>out, " segsize: %d" % segsize + print >>out, " datalen: %d" % datalen + share_hash_ids = ",".join([str(hid) for (hid,hash) in share_hash_chain]) + print >>out, " share_hash_chain: %s" % share_hash_ids + print >>out, " block_hash_tree: %d nodes" % len(block_hash_tree) + + print >>out + def dump_root_dirnode(config, out=sys.stdout, err=sys.stderr): from allmydata import uri diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 384dc3ce..c0628cc7 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -287,12 +287,23 @@ class SystemTest(testutil.SignalMixin, unittest.TestCase): output = out.getvalue() self.failUnlessEqual(rc, 0) self.failUnless("Mutable slot found:\n" in output) + self.failUnless("share_type: SDMF\n" in output) peerid = idlib.nodeid_b2a(self.clients[client_num].nodeid) self.failUnless(" WE for nodeid: %s\n" % peerid in output) self.failUnless(" num_extra_leases: 0\n" in output) self.failUnless(" container_size: 381\n" in output) self.failUnless(" data_length: 381\n" in output) self.failUnless(" secrets are for nodeid: %s\n" % peerid in output) + self.failUnless(" SDMF contents:\n" in output) + self.failUnless(" seqnum: 1\n" in output) + self.failUnless(" required_shares: 3\n" in output) + self.failUnless(" total_shares: 10\n" in output) + self.failUnless(" segsize: 24\n" in output) + self.failUnless(" datalen: 24\n" in output) + # the exact share_hash_chain nodes depends upon the sharenum, and + # is more of a hassle to compute than I want to deal with now + self.failUnless(" share_hash_chain: " in output) + self.failUnless(" block_hash_tree: 1 nodes\n" in output) d.addCallback(_test_debug) return d