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
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
53 _scratch_metadump $METADUMP_FILE 2>&1 | filter_mounted
56 # Test restore to a mounted device
57 # xfs_mdrestore should refuse to restore to a mounted device
58 _scratch_metadump $METADUMP_FILE
60 xfs_mdrestore $METADUMP_FILE $SCRATCH_DEV 2>&1 | filter_mounted
63 # Test xfs_copy to a mounted device
64 # If source is mounted, xfs_copy will print a warning, but still
65 # keep on copying. If target is mounted, xfs_copy should fail.
66 $XFS_COPY_PROG $SCRATCH_DEV $COPY_FILE >/dev/null
68 $XFS_COPY_PROG $COPY_FILE $SCRATCH_DEV 2>&1 | filter_mounted
71 # Test xfs_db a mounted device
72 # xfs_db a mounted device without readonly (-r) option should fail
74 $XFS_DB_PROG -c sb $SCRATCH_DEV 2>&1 | filter_mounted
77 # Test mkfs.xfs a mounted device
78 # Generally mkfs will report device is mounted, but if it can't find
79 # device is mounted, it'll report device busy.
81 _scratch_mkfs 2>&1 | filter_mounted
84 # Test xfs_repair (with/without modify flag) a mounted device
85 # xfs_repair (with/without modify flag) a mounted device should fail(don't
86 # test -d option at here)
88 _scratch_xfs_repair -n 2>&1 | filter_mounted
89 _scratch_xfs_repair 2>&1 | filter_mounted