common/rc: Add _require_{chown,chmod}()
[xfstests-dev.git] / tests / generic / 308
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 308
6 #
7 # Regression test for commit:
8 # f17722f ext4: Fix max file size and logical block counting of extent format file
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 status=1        # failure is the default!
15 trap "_cleanup; exit \$status" 0 1 2 3 15
16
17 _cleanup()
18 {
19         cd /
20         rm -f $testfile
21 }
22
23 # get standard environment, filters and checks
24 . ./common/rc
25 . ./common/filter
26
27 testfile=$TEST_DIR/testfile.$seq
28
29 # real QA test starts here
30 _supported_fs generic
31 _require_test
32
33 rm -f $seqres.full
34 echo "Silence is golden"
35
36 block_size=`_get_block_size $TEST_DIR`
37
38 # On unpatched ext4, if an extent exists which includes the block right
39 # before the maximum file offset, and the block for the maximum file offset
40 # is written, the kernel panics
41 # On patched ext4, the write would get EFBIG since we lower s_maxbytes by
42 # one fs block
43
44 # Create a sparse file with an extent lays at one block before old s_maxbytes
45 offset=$(((2**32 - 2) * $block_size))
46 $XFS_IO_PROG -f -c "pwrite $offset $block_size" -c fsync $testfile >$seqres.full 2>&1
47
48 # Write to the block after the extent just created
49 offset=$(((2**32 - 1) * $block_size))
50 $XFS_IO_PROG -f -c "pwrite $offset $block_size" -c fsync $testfile >>$seqres.full 2>&1
51
52 # Got here without hitting BUG_ON(), test passed
53 status=0
54 exit