summaryrefslogtreecommitdiff
path: root/tests/xfs/493
blob: 58091ad7d1658186195992f9efcc7a96e1290900 (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle.  All Rights Reserved.
#
# FS QA Test No. 493
#
# Test detection & fixing of bad summary block counts at mount time.
# Corrupt the AGFs to test mount failure when mount-fixing fails.
#
. ./common/preamble
_begin_fstest auto quick fuzzers

# Import common functions.
. ./common/filter

# real QA test starts here

# Modify as appropriate.
_supported_fs xfs
_require_scratch_nocheck

echo "Format and mount"
_scratch_mkfs > $seqres.full 2>&1
_scratch_mount >> $seqres.full 2>&1
echo "test file" > $SCRATCH_MNT/testfile

echo "Fuzz fdblocks and btreeblks"
_scratch_unmount
dblocks=$(_scratch_xfs_get_metadata_field dblocks 'sb 0')
_scratch_xfs_set_metadata_field fdblocks $((dblocks * 2)) 'sb 0' > $seqres.full 2>&1

aglen=$(_scratch_xfs_get_metadata_field length 'agf 0')
_scratch_xfs_set_metadata_field btreeblks $aglen 'agf 0' > $seqres.full 2>&1

echo "Detection and Correction"
if _try_scratch_mount >> $seqres.full 2>&1; then
	echo "mount should have failed"
	avail=$(stat -c '%a' -f $SCRATCH_MNT)
	total=$(stat -c '%b' -f $SCRATCH_MNT)
	echo "avail: $avail" >> $seqres.full
	echo "total: $total" >> $seqres.full
	test "$avail" -gt "$total" && echo "free space bad: $avail > $total"
	_scratch_unmount
fi
_scratch_xfs_repair -n >> $seqres.full 2>&1 && echo "repair didn't find fuzz?"

# success, all done
status=0
exit