xfs: test what happens when we reset the root dir and it has xattrs
[xfstests-dev.git] / tests / xfs / 332
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 332
6 #
7 # Make sure query_range returns -EINVAL if lowkey > highkey.
8 #
9 seq=`basename "$0"`
10 seqres="$RESULT_DIR/$seq"
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1    # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -rf "$tmp".*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/attr
28
29 # real QA test starts here
30 _supported_fs xfs
31 _require_xfs_scratch_rmapbt
32 _require_command "$XFS_DB_PROG" "xfs_db"
33 _require_xfs_io_command "falloc"
34 _require_xfs_io_command "fpunch"
35 _require_xfs_io_command "fzero"
36 _require_xfs_io_command "fcollapse"
37 _require_xfs_io_command "finsert"
38
39 rm -f "$seqres.full"
40
41 echo "Format and mount"
42 _scratch_mkfs > "$seqres.full" 2>&1
43 _scratch_mount
44 blksz=65536
45 blocks=16
46 len=$((blocks * blksz))
47
48 echo "Create some files"
49 $XFS_IO_PROG -f -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
50
51 echo "Manipulate file"
52 $XFS_IO_PROG -c "fpunch $blksz $blksz" \
53         -c "fzero $((3 * blksz)) $blksz" \
54         -c "pwrite -S 0x69 $((5 * blksz)) $blksz" \
55         -c "fpunch $((7 * blksz)) $blksz" \
56         -c "fsync" \
57         -c "pwrite -S 0x70 $((7 * blksz)) $blksz" \
58         -c "fcollapse $((9 * blksz)) $blksz" \
59         -c "finsert $((10 * blksz)) $blksz" $SCRATCH_MNT/f1 >> $seqres.full
60
61 echo "Check file"
62 md5sum $SCRATCH_MNT/f1 | _filter_scratch
63 od -tx1 -Ad -c $SCRATCH_MNT/f1 >> $seqres.full
64
65 echo "Unmount"
66 _scratch_unmount
67
68 echo "Try a regular fsmap"
69 _scratch_xfs_db -c 'fsmap' >> $seqres.full
70 _scratch_xfs_db -c 'fsmap 0 5' >> $seqres.full
71
72 echo "Try a bad fsmap"
73 _scratch_xfs_db -c 'fsmap 5 4'
74
75 # success, all done
76 status=0
77 exit