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.
51 _require_scratch_nocheck
53 _scratch_mkfs >/dev/null 2>&1
56 # create the test file
57 echo "make a file with data so it has an extent" > $SCRATCH_MNT/file
59 # find the inode for the test file
60 FILE_INO=`ls -i $SCRATCH_MNT |awk '{print $1}'`
64 # test bit length constants
65 BMBT_EXNTFLAG_BITLEN=1
66 BMBT_STARTOFF_BITLEN=54
67 BMBT_STARTBLOCK_BITLEN=52
68 BMBT_BLOCKCOUNT_BITLEN=21
70 prefix=$(_scratch_get_bmx_prefix $FILE_INO)
71 test -n "$prefix" || _fail "could not find bmx prefix from inode $FILE_INO"
74 sed -e "s/${prefix}/u.bmx/g"
77 # test setting the BMBT entries from 0 to past the valid number.
78 _do_bit_test "${prefix}[0].extentflag" $BMBT_EXNTFLAG_BITLEN | filter_output
79 _do_bit_test "${prefix}[0].startoff" $BMBT_STARTOFF_BITLEN | filter_output
80 _do_bit_test "${prefix}[0].startblock" $BMBT_STARTBLOCK_BITLEN | filter_output
81 _do_bit_test "${prefix}[0].blockcount" $BMBT_BLOCKCOUNT_BITLEN | filter_output
82 # test setting the 32 bit generation number
83 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0x5a"
84 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0xa5"
85 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0"
86 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen #5a5a"
87 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen #a5a5"