From patchwork Wed May 17 22:36:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 9732071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C5BAB6022E for ; Wed, 17 May 2017 23:37:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BD63287D6 for ; Wed, 17 May 2017 23:37:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6074C287F5; Wed, 17 May 2017 23:37:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2867287D6 for ; Wed, 17 May 2017 23:37:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753977AbdEQXg6 (ORCPT ); Wed, 17 May 2017 19:36:58 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:22817 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753149AbdEQXgx (ORCPT ); Wed, 17 May 2017 19:36:53 -0400 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v4HNamBO024477 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 17 May 2017 23:36:49 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id v4HNamtM022606 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 17 May 2017 23:36:48 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v4HNalMm025467; Wed, 17 May 2017 23:36:48 GMT Received: from localhost.us.oracle.com (/10.211.47.181) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 May 2017 16:36:47 -0700 From: Liu Bo To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana , Eryu Guan Subject: [PATCH v2 1/5] fstests: add _filter_filefrag Date: Wed, 17 May 2017 16:36:06 -0600 Message-Id: <20170517223610.3916-2-bo.li.liu@oracle.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170517223610.3916-1-bo.li.liu@oracle.com> References: <20170517223610.3916-1-bo.li.liu@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP _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 --- common/filter | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/common/filter b/common/filter index 5fd71a8..1ef342b 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