btrfs-progs: tests: return metadata_uuid or fsid as per METADATA_UUID flag

Previous commit "btrfs-progs: dump-super: print actual metadata_uuid
value" changed the value of the super_block::metadata_uuid to be printed
as it is, without tweaking it depending on the METADATA_UUID flag.

Apply similar tweak in the common helper functions used to read the
metadata_uuid so that test-cases still be successful.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Anand Jain 2023-08-03 07:29:38 +08:00 committed by David Sterba
parent 1d988f3638
commit 57cd29c895

View file

@ -15,6 +15,19 @@ if [ ! -f /sys/fs/btrfs/features/metadata_uuid ] ; then
_not_run "METADATA_UUID feature not supported"
fi
has_metadata_uuid_flag() {
local dev="$1"
run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \
dump-super "$dev" | grep -E -q METADATA_UUID
if [ $? -eq 0 ]; then
echo true
else
echo false
fi
}
read_fsid() {
local dev="$1"
@ -24,9 +37,14 @@ read_fsid() {
read_metadata_uuid() {
local dev="$1"
local flag=$(has_metadata_uuid_flag "$dev")
echo $(run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \
dump-super "$dev" | awk '/metadata_uuid/ {print $2}')
if [ "$flag" == "true" ]; then
echo $(run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \
dump-super "$dev" | awk '/metadata_uuid/ {print $2}')
else
read_fsid $dev
fi
}
check_btrfstune() {