linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: fdmanana@kernel.org
To: fstests@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, Filipe Manana <fdmanana@suse.com>
Subject: [PATCH 1/3] common: open files in ro mode for extent and hole count helpers
Date: Tue,  5 Nov 2019 14:56:22 +0000	[thread overview]
Message-ID: <20191105145622.11181-1-fdmanana@kernel.org> (raw)

From: Filipe Manana <fdmanana@suse.com>

The helper functions _count_extents() and _count_holes() open their input
file in RW mode to call fiemap, however opening it in RO mode is enough.
By opening them in RW mode it also makes it not possible to use them
against files residing in btrfs readonly snapshots for example.

So just open the files in RO mode in these functions.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 common/rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/rc b/common/rc
index ef0c2509..238ffef9 100644
--- a/common/rc
+++ b/common/rc
@@ -3199,12 +3199,12 @@ _require_metadata_journaling()
 
 _count_extents()
 {
-	$XFS_IO_PROG -c "fiemap" $1 | tail -n +2 | grep -v hole | wc -l
+	$XFS_IO_PROG -r -c "fiemap" $1 | tail -n +2 | grep -v hole | wc -l
 }
 
 _count_holes()
 {
-	$XFS_IO_PROG -c "fiemap" $1 | tail -n +2 | grep hole | wc -l
+	$XFS_IO_PROG -r -c "fiemap" $1 | tail -n +2 | grep hole | wc -l
 }
 
 _count_attr_extents()
-- 
2.11.0


                 reply	other threads:[~2019-11-05 14:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191105145622.11181-1-fdmanana@kernel.org \
    --to=fdmanana@kernel.org \
    --cc=fdmanana@suse.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).