From: Liu Bo Date: Wed, 17 May 2017 22:36:06 +0000 (-0600) Subject: common/filter: add _filter_filefrag X-Git-Tag: v2022.05.01~2044 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7453987aaa652c802c8265117d6ef1057ba94718;p=xfstests-dev.git common/filter: add _filter_filefrag _filter_filefrag is a helper function to filter filefrag's output and it can be used to get a file's file offset and physical offset. Signed-off-by: Liu Bo Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- diff --git a/common/filter b/common/filter index 5fd71a88..1ef342b5 100644 --- a/common/filter +++ b/common/filter @@ -418,5 +418,24 @@ _filter_ovl_dirs() -e "s,$OVL_WORK,OVL_WORK,g" } +# interpret filefrag output, +# eg. "physical 1234, length 10, logical 5678" -> "1234#10#5678" +_filter_filefrag() +{ + perl -ne ' + if (/blocks? of (\d+) bytes/) { + $blocksize = $1; + next + } + ($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, "#", + $flags, "\n"' +} + # make sure this script returns success /bin/true