bmap: scripts: Added on-disk bmap traversal to dbgbmap and friends
And yes, dbgbmapsvg.py's parents are working, thanks to a hacky blocks @property (Python to the rescue!)
This commit is contained in:
@@ -2693,6 +2693,11 @@ class Gstate:
|
|||||||
fillvalue=0))
|
fillvalue=0))
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
|
@property
|
||||||
|
def blocks(self):
|
||||||
|
return tuple(it.chain.from_iterable(
|
||||||
|
gdelta.blocks for _, gdelta in self.gdeltas))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def size(self):
|
def size(self):
|
||||||
return len(self.data)
|
return len(self.data)
|
||||||
@@ -3224,6 +3229,7 @@ class Lfs3:
|
|||||||
# traverse the filesystem
|
# traverse the filesystem
|
||||||
def traverse(self, *,
|
def traverse(self, *,
|
||||||
mtree_only=False,
|
mtree_only=False,
|
||||||
|
gstate=True,
|
||||||
shrubs=False,
|
shrubs=False,
|
||||||
fragments=False,
|
fragments=False,
|
||||||
path=False):
|
path=False):
|
||||||
@@ -3285,6 +3291,24 @@ class Lfs3:
|
|||||||
else:
|
else:
|
||||||
yield data
|
yield data
|
||||||
|
|
||||||
|
# traverse any gstate
|
||||||
|
if not mtree_only and gstate:
|
||||||
|
for gstate_ in self.gstate:
|
||||||
|
if getattr(gstate_, 'btree', None) is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
for r in gstate_.btree.traverse(
|
||||||
|
path=path):
|
||||||
|
if path:
|
||||||
|
bid, rbyd, path_ = r
|
||||||
|
else:
|
||||||
|
bid, rbyd = r
|
||||||
|
|
||||||
|
if path:
|
||||||
|
yield rbyd, [(self.mid(-1), gstate_)]+path_
|
||||||
|
else:
|
||||||
|
yield rbyd
|
||||||
|
|
||||||
# common file operations, note Reg extends this for regular files
|
# common file operations, note Reg extends this for regular files
|
||||||
class File:
|
class File:
|
||||||
tag = None
|
tag = None
|
||||||
|
|||||||
@@ -2723,6 +2723,11 @@ class Gstate:
|
|||||||
fillvalue=0))
|
fillvalue=0))
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
|
@property
|
||||||
|
def blocks(self):
|
||||||
|
return tuple(it.chain.from_iterable(
|
||||||
|
gdelta.blocks for _, gdelta in self.gdeltas))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def size(self):
|
def size(self):
|
||||||
return len(self.data)
|
return len(self.data)
|
||||||
@@ -3254,6 +3259,7 @@ class Lfs3:
|
|||||||
# traverse the filesystem
|
# traverse the filesystem
|
||||||
def traverse(self, *,
|
def traverse(self, *,
|
||||||
mtree_only=False,
|
mtree_only=False,
|
||||||
|
gstate=True,
|
||||||
shrubs=False,
|
shrubs=False,
|
||||||
fragments=False,
|
fragments=False,
|
||||||
path=False):
|
path=False):
|
||||||
@@ -3315,6 +3321,24 @@ class Lfs3:
|
|||||||
else:
|
else:
|
||||||
yield data
|
yield data
|
||||||
|
|
||||||
|
# traverse any gstate
|
||||||
|
if not mtree_only and gstate:
|
||||||
|
for gstate_ in self.gstate:
|
||||||
|
if getattr(gstate_, 'btree', None) is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
for r in gstate_.btree.traverse(
|
||||||
|
path=path):
|
||||||
|
if path:
|
||||||
|
bid, rbyd, path_ = r
|
||||||
|
else:
|
||||||
|
bid, rbyd = r
|
||||||
|
|
||||||
|
if path:
|
||||||
|
yield rbyd, [(self.mid(-1), gstate_)]+path_
|
||||||
|
else:
|
||||||
|
yield rbyd
|
||||||
|
|
||||||
# common file operations, note Reg extends this for regular files
|
# common file operations, note Reg extends this for regular files
|
||||||
class File:
|
class File:
|
||||||
tag = None
|
tag = None
|
||||||
|
|||||||
@@ -2650,6 +2650,11 @@ class Gstate:
|
|||||||
fillvalue=0))
|
fillvalue=0))
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
|
@property
|
||||||
|
def blocks(self):
|
||||||
|
return tuple(it.chain.from_iterable(
|
||||||
|
gdelta.blocks for _, gdelta in self.gdeltas))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def size(self):
|
def size(self):
|
||||||
return len(self.data)
|
return len(self.data)
|
||||||
@@ -3181,6 +3186,7 @@ class Lfs3:
|
|||||||
# traverse the filesystem
|
# traverse the filesystem
|
||||||
def traverse(self, *,
|
def traverse(self, *,
|
||||||
mtree_only=False,
|
mtree_only=False,
|
||||||
|
gstate=True,
|
||||||
shrubs=False,
|
shrubs=False,
|
||||||
fragments=False,
|
fragments=False,
|
||||||
path=False):
|
path=False):
|
||||||
@@ -3242,6 +3248,24 @@ class Lfs3:
|
|||||||
else:
|
else:
|
||||||
yield data
|
yield data
|
||||||
|
|
||||||
|
# traverse any gstate
|
||||||
|
if not mtree_only and gstate:
|
||||||
|
for gstate_ in self.gstate:
|
||||||
|
if getattr(gstate_, 'btree', None) is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
for r in gstate_.btree.traverse(
|
||||||
|
path=path):
|
||||||
|
if path:
|
||||||
|
bid, rbyd, path_ = r
|
||||||
|
else:
|
||||||
|
bid, rbyd = r
|
||||||
|
|
||||||
|
if path:
|
||||||
|
yield rbyd, [(self.mid(-1), gstate_)]+path_
|
||||||
|
else:
|
||||||
|
yield rbyd
|
||||||
|
|
||||||
# common file operations, note Reg extends this for regular files
|
# common file operations, note Reg extends this for regular files
|
||||||
class File:
|
class File:
|
||||||
tag = None
|
tag = None
|
||||||
|
|||||||
Reference in New Issue
Block a user