common/xfs: refactor commands to select a particular xfs backing device
[xfstests-dev.git] / tests / xfs / 431
index ed1a69e32c2aa0b2fb18c422699cee3bb71e3767..797b8fcdcb84385042cb683cd72283c327e601c4 100755 (executable)
@@ -1,4 +1,7 @@
 #! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2017 Facebook, Inc.  All Rights Reserved.
+#
 # FS QA Test 431
 #
 # Verify kernel doesn't panic when user attempts to set realtime flags
@@ -8,24 +11,6 @@
 #
 # See CVE-2017-14340 for more information.
 #
-#-----------------------------------------------------------------------
-# Copyright (c) 2017 Facebook, Inc.  All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write the Free Software Foundation,
-# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-#-----------------------------------------------------------------------
-#
-
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
 echo "QA output created by $seq"
@@ -52,8 +37,7 @@ rm -f $seqres.full
 
 # Modify as appropriate.
 _supported_fs xfs
-_supported_os Linux
-_require_xfs_io_command "chattr"
+_require_xfs_io_command "chattr" "t"
 _require_xfs_io_command "fsync"
 _require_xfs_io_command "pwrite"
 _require_scratch
@@ -63,7 +47,7 @@ _scratch_mount
 
 # Set realtime inherit flag on scratch mount, suppress output
 # as this may simply error out on future kernels
-$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT &> /dev/null
+_xfs_force_bdev realtime $SCRATCH_MNT &> /dev/null
 
 # Check if 't' is actually set, as xfs_io returns 0 even when it fails to set
 # an attribute. And erroring out here is fine, this would be desired behavior
@@ -76,7 +60,7 @@ if $XFS_IO_PROG -c 'lsattr' $SCRATCH_MNT | grep -q 't'; then
        # Remove the testfile and rt inherit flag after we are done or
        # xfs_repair will fail.
        rm -f $SCRATCH_MNT/testfile
-       $XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT | tee -a $seqres.full 2>&1
+       _xfs_force_bdev data $SCRATCH_MNT | tee -a $seqres.full 2>&1
 fi
 
 # success, all done