From patchwork Tue May 9 17:56: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: 9718833 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 9170B603F8 for ; Tue, 9 May 2017 18:57:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86DF628459 for ; Tue, 9 May 2017 18:57:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B8B12845C; Tue, 9 May 2017 18:57:59 +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 38FE32845E for ; Tue, 9 May 2017 18:57:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753617AbdEIS5z (ORCPT ); Tue, 9 May 2017 14:57:55 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:42182 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751471AbdEIS5y (ORCPT ); Tue, 9 May 2017 14:57:54 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v49IvpWL025823 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 May 2017 18:57:51 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v49IvpuB004150 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 May 2017 18:57:51 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v49IvpxF031390; Tue, 9 May 2017 18:57:51 GMT Received: from localhost.us.oracle.com (/10.211.47.181) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 09 May 2017 11:57:50 -0700 From: Liu Bo To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana , Eryu Guan Subject: [PATCH 1/6] fstests: add _filter_filefrag Date: Tue, 9 May 2017 11:56:06 -0600 Message-Id: <1494352571-17199-2-git-send-email-bo.li.liu@oracle.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1494352571-17199-1-git-send-email-bo.li.liu@oracle.com> References: <1494352571-17199-1-git-send-email-bo.li.liu@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] 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