2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat. All Rights Reserved.
7 # Do xfs_metadump, xfs_mdrestore, xfs_copy, xfs_db, xfs_repair and mkfs.xfs
8 # on mounted XFS to make sure they refuse to proceed.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
23 rm -f $METADUMP_FILE 2>/dev/null
24 rm -f $COPY_FILE 2>/dev/null
27 # get standard environment, filters and checks
31 # remove previous $seqres.full before test
34 # real QA test starts here
37 # xfs_copy does not support realtime devices
41 _require_no_large_scratch_dev
43 function filter_mounted()
45 grep "mounted" | _filter_scratch | head -1
48 METADUMP_FILE="${TEST_DIR}/${seq}_metadump"
49 COPY_FILE="${TEST_DIR}/${seq}_copyfile"
51 # Test dump a mounted device
52 # xfs_metadump should refuse to dump a mounted device
53 _scratch_mkfs >> $seqres.full 2>&1
55 _scratch_metadump $METADUMP_FILE 2>&1 | filter_mounted
58 # Test restore to a mounted device
59 # xfs_mdrestore should refuse to restore to a mounted device
60 _scratch_metadump $METADUMP_FILE
62 xfs_mdrestore $METADUMP_FILE $SCRATCH_DEV 2>&1 | filter_mounted
65 # Test xfs_copy to a mounted device
66 # If source is mounted, xfs_copy will print a warning, but still
67 # keep on copying. If target is mounted, xfs_copy should fail.
68 $XFS_COPY_PROG $SCRATCH_DEV $COPY_FILE >/dev/null
70 $XFS_COPY_PROG $COPY_FILE $SCRATCH_DEV 2>&1 | filter_mounted
73 # Test xfs_db a mounted device
74 # xfs_db a mounted device without readonly (-r) option should fail
76 $XFS_DB_PROG -c sb $SCRATCH_DEV 2>&1 | filter_mounted
79 # Test mkfs.xfs a mounted device
80 # Generally mkfs will report device is mounted, but if it can't find
81 # device is mounted, it'll report device busy.
83 _scratch_mkfs 2>&1 | filter_mounted
86 # Test xfs_repair (with/without modify flag) a mounted device
87 # xfs_repair (with/without modify flag) a mounted device should fail(don't
88 # test -d option at here)
90 _scratch_xfs_repair -n 2>&1 | filter_mounted
91 _scratch_xfs_repair 2>&1 | filter_mounted