Extended dbglfs.py to show file data structures
You can now pass -s/--structs to dbglfs.py to show any file data
structures:
$ ./scripts/dbglfs.py disk -B4096 -f -s -t
littlefs v2.0 0x{0,1}.9cf, rev 3, weight 0.256
{0000,0001}: -1.1 hello reg 128, trunk 0x0.993 128
0000.0993: .-> 0-15 shrubinlined w16 16 6b 75 72 65 65 67 73 63 kureegsc
.-+-> 16-31 shrubinlined w16 16 6b 65 6a 79 68 78 6f 77 kejyhxow
| .-> 32-47 shrubinlined w16 16 65 6f 66 75 76 61 6a 73 eofuvajs
.-+-+-> 48-63 shrubinlined w16 16 6e 74 73 66 67 61 74 6a ntsfgatj
| .-> 64-79 shrubinlined w16 16 70 63 76 79 6c 6e 72 66 pcvylnrf
| .-+-> 80-95 shrubinlined w16 16 70 69 73 64 76 70 6c 6f pisdvplo
| | .-> 96-111 shrubinlined w16 16 74 73 65 69 76 7a 69 6c tseivzil
+-+-+-> 112-127 shrubinlined w16 16 7a 79 70 61 77 72 79 79 zypawryy
This supports the same -b/-t/-i options found in dbgbtree.py, with the
one exception being -z/--struct-depth which is lowercase to avoid
conflict with the -Z/--depth used to indicate the filesystem tree depth.
I think this is a surprisingly reasonable way to show the inner
structure of files without clobbering the user's console with file
contents.
Don't worry, if clobbering is desired, -T/--no-truncate still dumps all
of the file content.
Though it's still up to the user to manually apply the sprout/shrub
overlay. That step is still complex enough to not implement in this
tool yet.
I
This commit is contained in:
+6
-6
@@ -1573,7 +1573,7 @@ def main(disk, mroots=None, *,
|
||||
for tag, j, d, data in tags
|
||||
if tag & 0x7f00 != TAG_NAME]
|
||||
|
||||
# find mdir in the tags
|
||||
# found an mdir in the tags?
|
||||
mdir__ = None
|
||||
if (not args.get('depth')
|
||||
or mdepth+len(path) < args.get('depth')):
|
||||
@@ -1582,7 +1582,7 @@ def main(disk, mroots=None, *,
|
||||
if tag == TAG_MDIR),
|
||||
None)
|
||||
|
||||
# print btree entries in certain cases
|
||||
# show other btree entries in certain cases
|
||||
if args.get('inner') or not mdir__:
|
||||
dbg_branch(mbid, mw, rbyd, rid, tags, len(path)-1)
|
||||
|
||||
@@ -1656,10 +1656,6 @@ if __name__ == "__main__":
|
||||
'-T', '--no-truncate',
|
||||
action='store_true',
|
||||
help="Don't truncate, show the full contents.")
|
||||
parser.add_argument(
|
||||
'-i', '--inner',
|
||||
action='store_true',
|
||||
help="Show inner branches.")
|
||||
parser.add_argument(
|
||||
'-t', '--tree',
|
||||
action='store_true',
|
||||
@@ -1668,6 +1664,10 @@ if __name__ == "__main__":
|
||||
'-b', '--btree',
|
||||
action='store_true',
|
||||
help="Show the underlying B-tree.")
|
||||
parser.add_argument(
|
||||
'-i', '--inner',
|
||||
action='store_true',
|
||||
help="Show inner branches.")
|
||||
parser.add_argument(
|
||||
'-Z', '--depth',
|
||||
nargs='?',
|
||||
|
||||
Reference in New Issue
Block a user