2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2007 Silicon Graphics, Inc. All Rights Reserved.
8 # Test if mkfs.xfs wipes old AG headers when using -f option
11 _begin_fstest mkfs other auto
14 _filter_repair | sed \
15 -e '/unable to verify superblock, continuing/d' \
16 -e '/found candidate secondary superblock/d' \
17 -e '/error reading superblock.*-- seek to offset/d'
20 # dd the 1st sector then repair
24 dd if=/dev/zero of=$1 bs=$2 count=1 2>&1 | _filter_dd
26 _scratch_xfs_repair 2>&1 | filter_repair
28 if _check_scratch_fs; then
35 # Import common functions.
39 # real QA test starts here
41 # Modify as appropriate.
45 # o Summary of testing:
46 # 1. mkfs.xfs a default filesystem, note agcount value.
47 # 2. dd zero first sector and repair and verify.
48 # 3. mkfs.xfs overriding agcount to a smaller value
49 # (ie. each AG is bigger)
50 # 4. dd zero first sector, repair and verify.
51 # -> old mkfs.xfs will cause repair to incorrectly
52 # fix filesystem, new mkfs.xfs will be fine.
55 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
56 test "${PIPESTATUS[0]}" -eq 0 || _fail "mkfs failed!"
58 # By executing the followint tmp file, will get on the mkfs options stored in
62 # if the default agcount is too small, bump it up and re-mkfs before testing
63 if [ $agcount -lt 8 ]; then
65 _scratch_mkfs_xfs -dagcount=$agcount >/dev/null 2>&1 \
66 || _notrun "Test requires at least 8 AGs."
69 _dd_repair_check $SCRATCH_DEV $sectsz
72 let "agcount=$agcount-2"
73 _scratch_mkfs_xfs -dagcount=$agcount >/dev/null 2>&1 \
74 || _fail "mkfs failed!"
76 _dd_repair_check $SCRATCH_DEV $sectsz