Use larger files in test - makes it easier to expose problem.
[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 #
11 # creator
12 owner=allanr@sgi.com
13
14 seq=`basename $0`
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20
21 # get standard environment, filters and checks
22 . ./common.rc
23 . ./common.filter
24 . ./common.quota
25
26 _cleanup()
27 {
28         cd /
29         umount $SCRATCH_MNT 2>/dev/null
30         rm -f $tmp.*
31 }
32 #trap "_cleanup; exit \$status" 0 1 2 3 15
33
34
35 # real QA test starts here
36 _supported_fs xfs
37 _supported_os Linux IRIX
38
39 dir=$SCRATCH_MNT/project
40
41 #project quota files
42 cat >$tmp.projects <<EOF
43 1:$dir
44 EOF
45
46 cat >$tmp.projid <<EOF
47 test:1
48 EOF
49
50 cp /dev/null $seq.full
51 chmod a+rwx $seq.full   # arbitrary users will write here
52
53 _require_scratch
54 _scratch_mkfs_xfs >/dev/null 2>&1
55
56 #if pquota's already in mount options then we dont need to enable
57 [ `echo $MOUNT_OPTIONS | grep -c gquota` -eq 0 -a `echo $MOUNT_OPTIONS | grep -c gquota` -eq 0 ] &&\
58     EXTRA_MOUNT_OPTIONS="-o pquota"
59 [ `echo $MOUNT_OPTIONS | grep -c gquota` -gt 0 -o `echo $MOUNT_OPTIONS | grep -c gquota` -gt 0 ] &&\
60     _notrun "Can't run with group quotas enabled"
61
62 if ! _scratch_mount "$EXTRA_MOUNT_OPTIONS" >$tmp.out 2>&1
63 then
64     cat $tmp.out
65     echo "!!! mount failed"
66     exit
67 fi
68
69 src/feature -p $SCRATCH_DEV
70 [ $? -ne 0 ] && _notrun "Installed kernel does not support project quotas"
71
72
73 mkdir $dir
74 $XFS_IO_PROG -r -c "chproj -R 1" -c "chattr -R +P" $dir
75
76 xfs_quota -D $tmp.projects -P $tmp.projid -x \
77     -c "limit -p bsoft=100m bhard=100m 1" $SCRATCH_DEV
78 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -inN -p" $SCRATCH_DEV | tr -s '[:space:]'
79 touch $dir/1
80 touch $dir/2
81 cp $dir/2 $dir/3
82
83 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -inN -p" $SCRATCH_DEV | tr -s '[:space:]'
84
85 if [ "$HOSTOS" == "IRIX" ] ; then
86     mkfile 1M $TEST_DIR/6
87 else
88     xfs_mkfile 1M $TEST_DIR/6
89 fi
90
91 #try cp to dir
92 cp $TEST_DIR/6 $dir/6
93 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -inN -p" $SCRATCH_DEV | tr -s '[:space:]'
94
95 #try mv to dir
96 mv $TEST_DIR/6 $dir/7
97
98 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -inN -p" $SCRATCH_DEV | tr -s '[:space:]'
99
100 # success, all done
101 status=0
102 exit