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
40 _require_no_large_scratch_dev
42 function filter_mounted()
44 grep "mounted" | _filter_scratch | head -1
47 METADUMP_FILE="${TEST_DIR}/${seq}_metadump"
48 COPY_FILE="${TEST_DIR}/${seq}_copyfile"
50 # Test dump a mounted device
51 # xfs_metadump should refuse to dump a mounted device
52 _scratch_mkfs >> $seqres.full 2>&1
54 _scratch_metadump $METADUMP_FILE 2>&1 | filter_mounted
57 # Test restore to a mounted device
58 # xfs_mdrestore should refuse to restore to a mounted device
59 _scratch_metadump $METADUMP_FILE
61 xfs_mdrestore $METADUMP_FILE $SCRATCH_DEV 2>&1 | filter_mounted
64 # Test xfs_copy to a mounted device
65 # If source is mounted, xfs_copy will print a warning, but still
66 # keep on copying. If target is mounted, xfs_copy should fail.
67 $XFS_COPY_PROG $SCRATCH_DEV $COPY_FILE >/dev/null
69 $XFS_COPY_PROG $COPY_FILE $SCRATCH_DEV 2>&1 | filter_mounted
72 # Test xfs_db a mounted device
73 # xfs_db a mounted device without readonly (-r) option should fail
75 $XFS_DB_PROG -c sb $SCRATCH_DEV 2>&1 | filter_mounted
78 # Test mkfs.xfs a mounted device
79 # Generally mkfs will report device is mounted, but if it can't find
80 # device is mounted, it'll report device busy.
82 _scratch_mkfs 2>&1 | filter_mounted
85 # Test xfs_repair (with/without modify flag) a mounted device
86 # xfs_repair (with/without modify flag) a mounted device should fail(don't
87 # test -d option at here)
89 _scratch_xfs_repair -n 2>&1 | filter_mounted
90 _scratch_xfs_repair 2>&1 | filter_mounted