f00e1f0a042304728a2c128763e0a6ccfcbb1319
[xfstests-dev.git] / 134
1 #! /bin/sh
2 # FS QA Test No. 134
3 #
4 # test to reproduce PV951636:
5 #   project quotas not updated if a file is mv'd into that directory
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25 # creator
26 owner=allanr@sgi.com
27
28 seq=`basename $0`
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
38 . ./common.quota
39
40 _cleanup()
41 {
42         cd /
43         umount $SCRATCH_MNT 2>/dev/null
44         rm -f $tmp.*
45 }
46 #trap "_cleanup; exit \$status" 0 1 2 3 15
47
48
49 # real QA test starts here
50 _supported_fs xfs
51 _supported_os Linux IRIX
52
53 _require_xfs_quota
54
55 dir=$SCRATCH_MNT/project
56
57 #project quota files
58 cat >$tmp.projects <<EOF
59 1:$dir
60 EOF
61
62 cat >$tmp.projid <<EOF
63 test:1
64 EOF
65
66 cp /dev/null $seq.full
67 chmod a+rwx $seq.full   # arbitrary users will write here
68
69 _require_scratch
70 _scratch_mkfs_xfs >/dev/null 2>&1
71
72 #if pquota's already in mount options then we dont need to enable
73
74 # we can't run with group quotas
75 if ( `echo $MOUNT_OPTIONS | grep -q gquota` || `echo $MOUNT_OPTIONS | grep -q grpquota` )
76 then
77     _notrun "Can't run with group quotas enabled"
78 fi
79 EXTRA_MOUNT_OPTIONS="-o pquota"
80
81 if ! _scratch_mount "$EXTRA_MOUNT_OPTIONS" >$tmp.out 2>&1
82 then
83     cat $tmp.out
84     echo "!!! mount failed"
85     exit
86 fi
87
88 src/feature -p $SCRATCH_DEV
89 [ $? -ne 0 ] && _notrun "Installed kernel does not support project quotas"
90
91
92 mkdir $dir
93 $XFS_IO_PROG -r -c "chproj -R 1" -c "chattr -R +P" $dir
94
95 xfs_quota -D $tmp.projects -P $tmp.projid -x \
96     -c "limit -p bsoft=100m bhard=100m 1" $SCRATCH_DEV
97 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -inN -p" $SCRATCH_DEV | tr -s '[:space:]'
98 touch $dir/1
99 touch $dir/2
100 cp $dir/2 $dir/3
101
102 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -inN -p" $SCRATCH_DEV | tr -s '[:space:]'
103
104 if [ "$HOSTOS" == "IRIX" ] ; then
105     mkfile 1M $TEST_DIR/6
106 else
107     xfs_mkfile 1M $TEST_DIR/6
108 fi
109
110 #try cp to dir
111 cp $TEST_DIR/6 $dir/6
112 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -inN -p" $SCRATCH_DEV | tr -s '[:space:]'
113
114 #try mv to dir
115 mv $TEST_DIR/6 $dir/7
116
117 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -inN -p" $SCRATCH_DEV | tr -s '[:space:]'
118
119 # success, all done
120 status=0
121 exit