xfs: fix more xfs_db open-coding instances
[xfstests-dev.git] / tests / xfs / 201
1 #! /bin/bash
2 # FS QA Test No. 201
3 #
4 # Test out the infamous xfs_btree_delrec corruption.
5 #
6 # Only happens on 32-bit kernels without CONFIG_LBD, but it should be harmless
7 # to run this everywhere.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2009 Christoph Hellwig.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34
35 _cleanup()
36 {
37         _scratch_unmount
38 }
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/filter
44
45 # real QA test starts here
46 _supported_fs xfs
47 _supported_os Linux
48
49 file=$SCRATCH_MNT/f
50
51 min_align=`_min_dio_alignment $SCRATCH_DEV`
52
53 do_pwrite()
54 {
55         offset=`expr $1 \* $min_align`
56         end=`expr $2 \* $min_align`
57         length=`expr $end - $offset`
58
59         $XFS_IO_PROG -d -f $file -c "pwrite $offset $length" >/dev/null
60 }
61
62 _require_scratch
63
64 _scratch_mkfs_xfs >/dev/null 2>&1
65 _scratch_mount
66
67 # Create a fragmented file
68 do_pwrite 30792 31039
69 do_pwrite 30320 30791
70 do_pwrite 29688 30319
71 do_pwrite 29536 29687
72 do_pwrite 27216 29535
73 do_pwrite 24368 27215
74 do_pwrite 21616 24367
75 do_pwrite 20608 21615
76 do_pwrite 19680 20607
77 do_pwrite 19232 19679
78 do_pwrite 17840 19231
79 do_pwrite 16928 17839
80 do_pwrite 15168 16927
81 do_pwrite 14048 15167
82 do_pwrite 12152 14047
83 do_pwrite 11344 12151
84 do_pwrite 8792 11343
85 do_pwrite 6456 8791
86 do_pwrite 5000 6455
87 do_pwrite 1728 4999
88 do_pwrite 0 1727
89
90 sync
91 sync
92
93 # and truncate it again
94 > $SCRATCH_MNT/bigfile
95
96 # success, all done
97 echo "*** done"
98 rm -f $seqres.full
99 status=0