common: open files in ro mode for extent and hole count helpers
authorFilipe Manana <fdmanana@suse.com>
Tue, 5 Nov 2019 14:56:22 +0000 (14:56 +0000)
committerEryu Guan <guaneryu@gmail.com>
Sun, 10 Nov 2019 13:09:13 +0000 (21:09 +0800)
commite1670cce6af9284c58ca8bb8ee7ea84cb255f5dd
treea40a501e0ee4915d41bea5f2065dbb9bc1740037
parent8947e7cacf2e036d5fcd019e040af49faa1b76fa
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 <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/rc