Message ID | 20190121163316.20616-3-jeffm@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/7] btrfs/010: don't run without /sys/fs/btrfs | expand |
On Mon, Jan 21, 2019 at 11:33:12AM -0500, jeffm@suse.com wrote: > From: Jeff Mahoney <jeffm@suse.com> > > e2fsprogs versions prior to v1.42.7 had a different format for > filefrag -v that is incompatible with the regex in _filefrag_filter. > > This patch adds support for the older format to test on older releases Can you document what the two formats are in a comment just so it is somewhat easier to check the regexes are, indeed, doing the right thing? Cheers, Dave.
On 1/21/19 5:53 PM, Dave Chinner wrote: > On Mon, Jan 21, 2019 at 11:33:12AM -0500, jeffm@suse.com wrote: >> From: Jeff Mahoney <jeffm@suse.com> >> >> e2fsprogs versions prior to v1.42.7 had a different format for >> filefrag -v that is incompatible with the regex in _filefrag_filter. >> >> This patch adds support for the older format to test on older releases > > Can you document what the two formats are in a comment just so it is > somewhat easier to check the regexes are, indeed, doing the right > thing? Sure. That's easy enough. -Jeff
diff --git a/common/filter b/common/filter index b4443a34..a8ddf571 100644 --- a/common/filter +++ b/common/filter @@ -528,13 +528,27 @@ _filter_filefrag() { perl -ne ' if (/blocks? of (\d+) bytes/) { + $oldfmt = 0; $blocksize = $1; - next + next; + } elsif (/\d+ blocks, blocksize (\d+)/) { + $oldfmt = 1; + $blocksize = $1; + next; + } + if ($oldfmt) { + chomp; + ($ext, $logical, $physical, $ignore, $length1, $length2, $flags) = + (/^\s*(\d+)\s+(\d+)\s+(\d+)\s+((\d+)|\d+\s+(\d+))\s+([a-z0-9,]*)$/) + or next; + $length = "$length1$length2"; + } else { + ($ext, $logical, $physical, $length) = + (/^\s*(\d+):\s+(\d+)\.\.\s*\d+:\s+(\d+)\.\.\s*\d+:\s+(\d+):/) + or next; + ($flags) = /.*:\s*(\S*)$/; } - ($ext, $logical, $physical, $length) = - (/^\s*(\d+):\s+(\d+)\.\.\s*\d+:\s+(\d+)\.\.\s*\d+:\s+(\d+):/) - or next; - ($flags) = /.*:\s*(\S*)$/; + print $physical * $blocksize, "#", $length * $blocksize, "#", $logical * $blocksize, "#",