Open rakeshpandit opened 7 years ago
Something like this works for me. Feel free to use if you think it is appropriate. Should work for old or new dumpe2fs. Note that I didn't do any testing for older version.
diff --git a/pyreuse/sysutils/dumpe2fsparser.py b/pyreuse/sysutils/dumpe2fsparser.py
index f4b03a7..c17f9e9 100644
--- a/pyreuse/sysutils/dumpe2fsparser.py
+++ b/pyreuse/sysutils/dumpe2fsparser.py
@@ -41,6 +41,14 @@ def parse_bitmaps(line):
return {'block-bitmap': convert_to_range(mo.group(1)),
'inode-bitmap': convert_to_range(mo.group(2))}
+def parse_block_bitmap(line):
+ mo = re.search(r'Block bitmap at (\S+) .*', line)
+ return {'block-bitmap': convert_to_range(mo.group(1))}
+
+def parse_inode_bitmap(line):
+ mo = re.search(r'Inode bitmap at (\S+) .*', line)
+ return {'inode-bitmap': convert_to_range(mo.group(1))}
+
def parse_inodetable(line):
mo = re.search(r'Inode table at (\S+) .*', line)
return {'inode-table': convert_to_range(mo.group(1))}
@@ -55,9 +63,15 @@ def parse_bg_lines(bg_lines):
elif 'Reserved GDT' in line:
d = parse_gdt(line)
results.append(d)
- elif 'Block bitmap' in line:
+ elif ('Block bitmap' in line) and ('Inode bitmap' in line):
d = parse_bitmaps(line)
results.append(d)
+ elif ('Block bitmap' in line) and ('Inode bitmap' not in line):
+ d = parse_block_bitmap(line)
+ results.append(d)
+ elif ('Block bitmap' not in line) and ('Inode bitmap' in line):
+ d = parse_inode_bitmap(line)
+ results.append(d)
elif 'Inode table' in line:
d = parse_inodetable(line)
results.append(d)
Note that I haven't been using python much since years so I would skip creating patches. :)
Thanks. I'll fix it later.
Following code:
breaks with:
This would only happen with newer tools.
With older version it works fine:
Problem is newer version breaks this line: Block bitmap at 2 (+2), Inode bitmap at 18 (+18) into two lines: Block bitmap at 2 (+2) Inode bitmap at 18 (+18)
So solutions is to fix regular expression to parse both patterns and still extract information.