common: always pass -f to $DUMP_COMPRESSOR
[xfstests-dev.git] / common / xfs
index 5cd7b35c9ec9a468c9ee31294bb0f69cd8849b61..725819bd66acef33af9fca82605a393337c40b38 100644 (file)
@@ -478,7 +478,7 @@ _xfs_metadump() {
        $XFS_METADUMP_PROG $options "$device" "$metadump"
        res=$?
        [ "$compressopt" = "compress" ] && [ -n "$DUMP_COMPRESSOR" ] &&
-               $DUMP_COMPRESSOR "$metadump" &> /dev/null
+               $DUMP_COMPRESSOR -f "$metadump" &> /dev/null
        return $res
 }
 
@@ -786,6 +786,26 @@ _require_xfs_mkfs_without_validation()
        fi
 }
 
+_require_scratch_xfs_shrink()
+{
+       _require_scratch
+       _require_command "$XFS_GROWFS_PROG" xfs_growfs
+
+       _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
+       . $tmp.mkfs
+       _scratch_mount
+       # here just to check if kernel supports, no need do more extra work
+       local errmsg=$($XFS_GROWFS_PROG -D$((dblocks-1)) "$SCRATCH_MNT" 2>&1)
+       if [ "$?" -ne 0 ]; then
+               echo "$errmsg" | grep 'XFS_IOC_FSGROWFSDATA xfsctl failed: Invalid argument' > /dev/null && \
+                       _notrun "kernel does not support shrinking"
+               echo "$errmsg" | grep 'data size .* too small, old size is ' > /dev/null && \
+                       _notrun "xfsprogs does not support shrinking"
+               _fail "$XFS_GROWFS_PROG failed unexpectedly: $errmsg"
+       fi
+       _scratch_unmount
+}
+
 # XFS ability to change UUIDs on V5/CRC filesystems
 #
 _require_meta_uuid()