a471affb66108b9bd6c0d25c0f6fa3d6b34ac9c3
[xfstests-dev.git] / tests / xfs / 196
1 #! /bin/bash
2 # FS QA Test No. 196
3 #
4 # Make sure renames accross project boundaries are properly rejected
5 # and that we don't use the wrong lock flags internally.
6 #
7 # Based on a report and testcase from Arkadiusz Miskiewicz <arekm@maven.pl>
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2008 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 seqres=$RESULT_DIR/$seq
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35 status=1        # failure is the default!
36
37 _cleanup()
38 {
39         cd /
40         umount $SCRATCH_MNT
41         rm -f $tmp.*
42 }
43 trap "_cleanup; exit \$status" 0 1 2 3 15
44
45 # get standard environment, filters and checks
46 . ./common/rc
47 . ./common/filter
48 . ./common/quota
49
50 # real QA test starts here
51 _supported_fs xfs
52 _supported_os Linux
53
54 _require_scratch
55 _require_xfs_quota
56
57 #
58 # Setup temporary replacements for /etc/projects and /etc/projid
59 #
60 cat >$tmp.projects <<EOF
61 42:$SCRATCH_MNT/t
62 EOF
63
64 cat >$tmp.projid <<EOF
65 answer:42
66 EOF
67
68 #
69 # And make sure we always use our replacements
70 #
71 quota_cmd="xfs_quota -D $tmp.projects -P $tmp.projid"
72
73 _scratch_mkfs_xfs >/dev/null 2>&1
74 _qmount_option "pquota"
75 _qmount
76
77 #
78 # Create the project root
79 #
80 mkdir $SCRATCH_MNT/t
81
82 $quota_cmd -x -c 'project -s answer' $SCRATCH_MNT >/dev/null 2>&1
83 $quota_cmd -x -c 'limit -p bhard=100m answer' $SCRATCH_MNT
84
85 touch $SCRATCH_MNT/test
86
87 #
88 # Try renaming a file into the project.  This should fail.
89 #
90 # We repeat this a couple thousand times as a single rename couldn't
91 # always trigger the wrong unlock flags bug we had in older kernels.
92 #
93 for i in `seq 1 2000`; do
94     src/rename test t/test
95 done
96
97 # success, all done
98 echo "*** done"
99 rm -f $seqres.full
100 status=0