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
52 # xfs_copy does not support realtime devices
57 function filter_mounted()
59 grep "mounted" | _filter_scratch | head -1
62 METADUMP_FILE="${TEST_DIR}/${seq}_metadump"
63 COPY_FILE="${TEST_DIR}/${seq}_copyfile"
65 # Test dump a mounted device
66 # xfs_metadump should refuse to dump a mounted device
68 _scratch_metadump $METADUMP_FILE 2>&1 | filter_mounted
71 # Test restore to a mounted device
72 # xfs_mdrestore should refuse to restore to a mounted device
73 _scratch_metadump $METADUMP_FILE
75 xfs_mdrestore $METADUMP_FILE $SCRATCH_DEV 2>&1 | filter_mounted
78 # Test xfs_copy to a mounted device
79 # If source is mounted, xfs_copy will print a warning, but still
80 # keep on copying. If target is mounted, xfs_copy should fail.
81 $XFS_COPY_PROG $SCRATCH_DEV $COPY_FILE >/dev/null
83 $XFS_COPY_PROG $COPY_FILE $SCRATCH_DEV 2>&1 | filter_mounted
86 # Test xfs_db a mounted device
87 # xfs_db a mounted device without readonly (-r) option should fail
89 $XFS_DB_PROG -c sb $SCRATCH_DEV 2>&1 | filter_mounted
92 # Test mkfs.xfs a mounted device
93 # Generally mkfs will report device is mounted, but if it can't find
94 # device is mounted, it'll report device busy.
96 _scratch_mkfs 2>&1 | filter_mounted
99 # Test xfs_repair (with/without modify flag) a mounted device
100 # xfs_repair (with/without modify flag) a mounted device should fail(don't
101 # test -d option at here)
103 _scratch_xfs_repair -n 2>&1 | filter_mounted
104 _scratch_xfs_repair 2>&1 | filter_mounted