From: Filipe Manana Date: Tue, 5 Nov 2019 14:56:22 +0000 (+0000) Subject: common: open files in ro mode for extent and hole count helpers X-Git-Tag: v2022.05.01~960 X-Git-Url: http://git.apps.os.sepia.ceph.com/?p=xfstests-dev.git;a=commitdiff_plain;h=e1670cce6af9284c58ca8bb8ee7ea84cb255f5dd;ds=sidebyside common: open files in ro mode for extent and hole count helpers 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 Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- 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()