blob: 443c3757595fc367ee54497989a85400d5212f1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2016 Red Hat. All Rights Reserved.
#
# FS QA Test 284
#
# Do xfs_metadump, xfs_mdrestore, xfs_copy, xfs_db, xfs_repair and mkfs.xfs
# on mounted XFS to make sure they refuse to proceed.
#
. ./common/preamble
_begin_fstest auto quick dump copy db mkfs repair metadump
# Override the default cleanup function.
_cleanup()
{
cd /
rm -f $tmp.*
rm -f $METADUMP_FILE 2>/dev/null
rm -f $COPY_FILE 2>/dev/null
}
# Import common functions.
. ./common/filter
# real QA test starts here
_supported_fs xfs
_require_command "$XFS_MDRESTORE_PROG" "xfs_mdrestore"
_require_xfs_copy
_require_test
_require_scratch
_require_no_large_scratch_dev
function filter_mounted()
{
grep "mounted" | _filter_scratch | head -1
}
METADUMP_FILE="${TEST_DIR}/${seq}_metadump"
COPY_FILE="${TEST_DIR}/${seq}_copyfile"
# Test dump a mounted device
# xfs_metadump should refuse to dump a mounted device
_scratch_mkfs >> $seqres.full 2>&1
_scratch_mount
_scratch_xfs_metadump $METADUMP_FILE -a -o 2>&1 | filter_mounted
_scratch_unmount
# Test restore to a mounted device
# xfs_mdrestore should refuse to restore to a mounted device
_scratch_xfs_metadump $METADUMP_FILE -a -o
_scratch_mount
_scratch_xfs_mdrestore $METADUMP_FILE 2>&1 | filter_mounted
_scratch_unmount
# Test xfs_copy to a mounted device
# If source is mounted, xfs_copy will print a warning, but still
# keep on copying. If target is mounted, xfs_copy should fail.
$XFS_COPY_PROG $SCRATCH_DEV $COPY_FILE >/dev/null
_scratch_mount
$XFS_COPY_PROG $COPY_FILE $SCRATCH_DEV 2>&1 | filter_mounted
_scratch_unmount
# Test xfs_db a mounted device
# xfs_db a mounted device without readonly (-r) option should fail
_scratch_mount
$XFS_DB_PROG -c sb $SCRATCH_DEV 2>&1 | filter_mounted
_scratch_unmount
# Test mkfs.xfs a mounted device
# Generally mkfs will report device is mounted, but if it can't find
# device is mounted, it'll report device busy.
_scratch_mount
_scratch_mkfs 2>&1 | filter_mounted
_scratch_unmount
# Test xfs_repair (with/without modify flag) a mounted device
# xfs_repair (with/without modify flag) a mounted device should fail(don't
# test -d option at here)
_scratch_mount
_scratch_xfs_repair -n 2>&1 | filter_mounted
_scratch_xfs_repair 2>&1 | filter_mounted
_scratch_unmount
# success, all done
status=0
exit
|