Linux-BTRFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/3] common: open files in ro mode for extent and hole count helpers
@ 2019-11-05 14:56 fdmanana
  0 siblings, 0 replies; only message in thread
From: fdmanana @ 2019-11-05 14:56 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-05 14:56 [PATCH 1/3] common: open files in ro mode for extent and hole count helpers fdmanana

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org
	public-inbox-index linux-btrfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git