We have two instances of reading the btrfs fsid by using the command
'btrfs filesystem show <mnt>' turn this into an easy-to-use helper
function and also use it.
Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
return 1
}
-_require_btrfs_sysfs_fsid()
+_btrfs_get_fsid()
{
local fsid
+ local mnt=$1
- fsid=$($BTRFS_UTIL_PROG filesystem show $TEST_DIR |grep uuid: |\
+ fsid=$($BTRFS_UTIL_PROG filesystem show $mnt |grep uuid: |\
$AWK_PROG '{print $NF}')
+ echo $fsid
+}
+
+_require_btrfs_sysfs_fsid()
+{
+ local fsid
+
+ fsid=$(_btrfs_get_fsid $TEST_DIR)
+
# Check if the kernel has sysfs fsid support.
# Following kernel patch adds it:
# btrfs: sysfs add devinfo/fsid to retrieve fsid from the device
_fs_sysfs_dname()
{
local dev=$1
- local fsid
if [ ! -b "$dev" ]; then
_fail "Usage: _fs_sysfs_dname <mounted_device>"
case "$FSTYP" in
btrfs)
- fsid=$($BTRFS_UTIL_PROG filesystem show ${dev} | grep uuid: | \
- $AWK_PROG '{print $NF}')
- echo $fsid ;;
+ _btrfs_get_fsid $dev ;;
*)
_short_dev $dev ;;
esac