diff options
author | Anand Jain <anand.jain@oracle.com> | 2023-11-08 12:28:57 +0800 |
---|---|---|
committer | Zorro Lang <zlang@kernel.org> | 2023-11-16 10:52:12 +0800 |
commit | 59372e8d3f961eb20d911e715777af06de921891 (patch) | |
tree | 2d0fc9c9488b268b13a899690108341d4338f6c3 | |
parent | 47737bd3decfb4ee63ca6ae2cc053af816c68df2 (diff) | |
download | xfstests-dev-59372e8d3f961eb20d911e715777af06de921891.tar.gz |
common/btrfs: add _btrfs_get_fsid() helper
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>
-rw-r--r-- | common/btrfs | 14 | ||||
-rw-r--r-- | common/rc | 5 |
2 files changed, 13 insertions, 6 deletions
diff --git a/common/btrfs b/common/btrfs index fbc26181f7..f91f8dd869 100644 --- a/common/btrfs +++ b/common/btrfs @@ -457,13 +457,23 @@ _scratch_btrfs_is_zoned() 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 @@ -4721,7 +4721,6 @@ _require_statx() _fs_sysfs_dname() { local dev=$1 - local fsid if [ ! -b "$dev" ]; then _fail "Usage: _fs_sysfs_dname <mounted_device>" @@ -4729,9 +4728,7 @@ _fs_sysfs_dname() 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 |