4 # Do xfs_metadump, xfs_mdrestore, xfs_copy, xfs_db, xfs_repair and mkfs.xfs
5 # on mounted XFS to make sure they refuse to proceed.
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2016 Red Hat. All Rights Reserved.
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
38 rm -f $METADUMP_FILE 2>/dev/null
39 rm -f $COPY_FILE 2>/dev/null
42 # get standard environment, filters and checks
46 # remove previous $seqres.full before test
49 # real QA test starts here
55 function filter_mounted()
57 grep "mounted" | _filter_scratch | head -1
60 METADUMP_FILE="${TEST_DIR}/${seq}_metadump"
61 COPY_FILE="${TEST_DIR}/${seq}_copyfile"
63 # Test dump a mounted device
64 # xfs_metadump should refuse to dump a mounted device
66 _scratch_metadump $METADUMP_FILE 2>&1 | filter_mounted
69 # Test restore to a mounted device
70 # xfs_mdrestore should refuse to restore to a mounted device
71 _scratch_metadump $METADUMP_FILE
73 xfs_mdrestore $METADUMP_FILE $SCRATCH_DEV 2>&1 | filter_mounted
76 # Test xfs_copy to a mounted device
77 # If source is mounted, xfs_copy will print a warning, but still
78 # keep on copying. If target is mounted, xfs_copy should fail.
79 $XFS_COPY_PROG $SCRATCH_DEV $COPY_FILE >/dev/null
81 $XFS_COPY_PROG $COPY_FILE $SCRATCH_DEV 2>&1 | filter_mounted
84 # Test xfs_db a mounted device
85 # xfs_db a mounted device without readonly (-r) option should fail
87 $XFS_DB_PROG -c sb $SCRATCH_DEV 2>&1 | filter_mounted
90 # Test mkfs.xfs a mounted device
91 # Generally mkfs will report device is mounted, but if it can't find
92 # device is mounted, it'll report device busy.
94 _scratch_mkfs 2>&1 | filter_mounted
97 # Test xfs_repair (with/without modify flag) a mounted device
98 # xfs_repair (with/without modify flag) a mounted device should fail(don't
99 # test -d option at here)
101 _scratch_xfs_repair -n 2>&1 | filter_mounted
102 _scratch_xfs_repair 2>&1 | filter_mounted