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
54 _scratch_mkfs -m crc=0 >/dev/null 2>&1
57 # create the test file
58 echo "make a file with data so it has an extent" > $SCRATCH_MNT/file
60 # find the inode for the test file
61 FILE_INO=`ls -i $SCRATCH_MNT |awk '{print $1}'`
65 # test bit length constants
66 BMBT_EXNTFLAG_BITLEN=1
67 BMBT_STARTOFF_BITLEN=54
68 BMBT_STARTBLOCK_BITLEN=52
69 BMBT_BLOCKCOUNT_BITLEN=21
71 # test setting the BMBT entries from 0 to past the valid number.
72 _do_bit_test "u.bmx[0].extentflag" $BMBT_EXNTFLAG_BITLEN
73 _do_bit_test "u.bmx[0].startoff" $BMBT_STARTOFF_BITLEN
74 _do_bit_test "u.bmx[0].startblock" $BMBT_STARTBLOCK_BITLEN
75 _do_bit_test "u.bmx[0].blockcount" $BMBT_BLOCKCOUNT_BITLEN
76 # test setting the 32 bit generation number
77 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0x5a"
78 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0xa5"
79 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0"
80 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen #5a5a"
81 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen #a5a5"