2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 SGI. All Rights Reserved.
7 # Test the xfs_db write of the XFS BMBT entries. For each XFS BMBT field,
8 # write the value 0, each bit and finally the entry beyond the maximum legal
9 # value. Also makes sure a core write and hex input still work.
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
31 echo "testing $field with $bits bits"
32 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write $field 0"
34 for n in `seq 0 1 $bits`; do
35 _scratch_xfs_db -x -c "inode $FILE_INO" \
36 -c "write $field $num"
42 # get standard environment, filters and checks
46 # real QA test starts here
48 # Modify as appropriate.
50 _require_scratch_nocheck
52 _scratch_mkfs >/dev/null 2>&1
55 # create the test file
56 echo "make a file with data so it has an extent" > $SCRATCH_MNT/file
58 # find the inode for the test file
59 FILE_INO=`ls -i $SCRATCH_MNT |awk '{print $1}'`
63 # test bit length constants
64 BMBT_EXNTFLAG_BITLEN=1
65 BMBT_STARTOFF_BITLEN=54
66 BMBT_STARTBLOCK_BITLEN=52
67 BMBT_BLOCKCOUNT_BITLEN=21
69 prefix=$(_scratch_get_bmx_prefix $FILE_INO)
70 test -n "$prefix" || _fail "could not find bmx prefix from inode $FILE_INO"
73 sed -e "s/${prefix}/u.bmx/g"
76 # test setting the BMBT entries from 0 to past the valid number.
77 _do_bit_test "${prefix}[0].extentflag" $BMBT_EXNTFLAG_BITLEN | filter_output
78 _do_bit_test "${prefix}[0].startoff" $BMBT_STARTOFF_BITLEN | filter_output
79 _do_bit_test "${prefix}[0].startblock" $BMBT_STARTBLOCK_BITLEN | filter_output
80 _do_bit_test "${prefix}[0].blockcount" $BMBT_BLOCKCOUNT_BITLEN | filter_output
81 # test setting the 32 bit generation number
82 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0x5a"
83 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0xa5"
84 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0"
85 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen #5a5a"
86 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen #a5a5"