From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.kernel.org ([198.145.29.99]:47220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731206AbfI3VT0 (ORCPT ); Mon, 30 Sep 2019 17:19:26 -0400 From: Eric Biggers Subject: [PATCH v4 1/8] common/filter: add _filter_xfs_io_fiemap() Date: Mon, 30 Sep 2019 14:15:46 -0700 Message-Id: <20190930211553.64208-2-ebiggers@kernel.org> In-Reply-To: <20190930211553.64208-1-ebiggers@kernel.org> References: <20190930211553.64208-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-fscrypt-owner@vger.kernel.org To: fstests@vger.kernel.org Cc: linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Jaegeuk Kim , "Theodore Y . Ts'o" List-ID: From: Eric Biggers Add _filter_xfs_io_fiemap() to clean up the output of 'xfs_io -c fiemap'. This will be used by a function in common/verity. Signed-off-by: Eric Biggers --- common/filter | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/common/filter b/common/filter index 26fc2132..2477f386 100644 --- a/common/filter +++ b/common/filter @@ -541,6 +541,30 @@ _filter_filefrag() $flags, "\n"' } +# Clean up the extents list output of 'xfs_io -c fiemap', e.g. +# +# file: +# 0: [0..79]: 628365312..628365391 +# 1: [80..159]: hole +# 2: [160..319]: 628365472..628365631 +# => +# 0 79 628365312 628365391 +# 160 319 628365472 628365631 +# +# The fields are: +# +# first_logical_block last_logical_block first_physical_block last_physical_block +# +# Blocks are 512 bytes, and holes are omitted. +# +_filter_xfs_io_fiemap() +{ + grep -E '^[[:space:]]+[0-9]+:' \ + | grep -v '\' \ + | sed -E 's/^[[:space:]]+[0-9]+://' \ + | tr '][.:' ' ' +} + # We generate WARNINGs on purpose when applications mix buffered/mmap IO with # direct IO on the same file. This is a helper for _check_dmesg() to filter out # such warnings. -- 2.23.0.444.g18eeb5a265-goog