Spray randomly created/checksummed extended attributes across a filesystem.
[xfstests-dev.git] / 050
1 #! /bin/sh
2 # XFS QA Test No. 050
3 # $Id: 1.1 $
4 #
5 # Exercises basic XFS quota functionality
6 #       MOUNT_OPTIONS env var switches the test type (uid/gid/acct/enfd)
7 #       options are:  (-o) usrquota, grpquota, uqnoenforce, gqnoenforce
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
11
12 # This program is free software; you can redistribute it and/or modify it
13 # under the terms of version 2 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, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20 # Further, this software is distributed without any warranty that it is
21 # free of the rightful claim of any third person regarding infringement
22 # or the like.  Any license provided herein, whether implied or
23 # otherwise, applies only to this software file.  Patent licenses, if
24 # any, provided herein do not apply to combinations of this program with
25 # other software, or any other product whatsoever.
26
27 # You should have received a copy of the GNU General Public License along
28 # with this program; if not, write the Free Software Foundation, Inc., 59
29 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
30
31 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
32 # Mountain View, CA  94043, or:
33
34 # http://www.sgi.com 
35
36 # For further information regarding this notice, see: 
37
38 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
39 #-----------------------------------------------------------------------
40 #
41 # creator
42 owner=nathans@sgi.com
43
44 seq=`basename $0`
45 echo "QA output created by $seq"
46
47 here=`pwd`
48 tmp=/tmp/$$
49 status=1        # failure is the default!
50
51 # get standard environment, filters and checks
52 . ./common.rc
53 . ./common.quota
54 . ./common.filter
55
56 _cleanup()
57 {
58     echo; echo "*** unmount"
59     umount $SCRATCH_MNT 2>/dev/null
60     rm -f $tmp.*
61 }
62 trap "_cleanup; exit \$status" 0 1 2 3 15
63 rm -f $seq.full $seq.out
64
65 _require_quota
66 _require_scratch
67
68 _mymount()
69 {
70     umount $SCRATCH_DEV >/dev/null 2>&1
71     mount -t xfs $SCRATCH_DEV $SCRATCH_MNT || _fail "mount failed"
72     chmod ugo+rwx $SCRATCH_MNT
73     misc/quot $SCRATCH_DEV >>$seq.full 2>&1
74 }
75
76 # real QA test starts here
77 mkfs -t xfs -f $SCRATCH_DEV | _filter_mkfs 2>$tmp.mkfs
78 cat $tmp.mkfs >>$seq.full
79 chmod a+w $seq.full     # arbitrary users will write here
80
81 # keep the blocksize and data size for dd later
82 . $tmp.mkfs
83
84 _mymount
85
86 # setup exactly what it is we'll be testing
87 if ! src/feature -q $SCRATCH_DEV
88 then
89         _notrun "XFS quota not enabled"
90 elif src/feature -u $SCRATCH_DEV
91 then
92         type=u ; id=`_choose_uid`; ln $seq.usrquota $seq.out
93 elif src/feature -g $SCRATCH_DEV
94 then
95         type=g ; id=`_choose_gid`; ln $seq.grpquota $seq.out
96 elif src/feature -U $SCRATCH_DEV
97 then
98         type=u ; id=`_choose_uid`; ln $seq.uqnoenforce $seq.out
99 elif src/feature -G $SCRATCH_DEV
100 then
101         type=g ; id=`_choose_gid`; ln $seq.gqnoenforce $seq.out
102 else
103         _notrun "No quota support at mount time"
104 fi
105
106 echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
107 echo "and using type=$type id=$id" >>$seq.full
108
109 echo
110 echo "*** report no quota settings" | tee -a $seq.full
111 repquota -m -$type $SCRATCH_DEV | _filter_repquota
112
113 echo
114 echo "*** report initial settings" | tee -a $seq.full
115 setquota -n -$type $id $SCRATCH_DEV 100 500 4 10
116 _file_as_id $SCRATCH_MNT/initme $id $type $dbsize 0
117 repquota -m -$type $SCRATCH_DEV | _filter_repquota
118
119 echo
120 echo "*** push past the soft inode limit" | tee -a $seq.full
121 _file_as_id $SCRATCH_MNT/softie1 $id $type $dbsize 0
122 _file_as_id $SCRATCH_MNT/softie2 $id $type $dbsize 0
123 _mymount
124 repquota -m -$type $SCRATCH_DEV | _filter_repquota
125
126 echo
127 echo "*** push past the soft block limit" | tee -a $seq.full
128 _file_as_id $SCRATCH_MNT/softie $id $type $dbsize 140
129 _mymount
130 repquota -m -$type $SCRATCH_DEV | _filter_repquota
131
132 echo
133 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seq.full
134 for i in 1 2 3 4 5 6 7 8 9 10 11 12
135 do
136         _file_as_id $SCRATCH_MNT/hard$i $id $type $dbsize 0
137 done
138 _mymount
139 repquota -m -$type $SCRATCH_DEV | _filter_repquota
140
141 echo
142 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seq.full
143 _file_as_id $SCRATCH_MNT/softie $id $type $dbsize 540
144 _mymount
145 repquota -m -$type $SCRATCH_DEV | _filter_repquota
146
147 # success, all done
148 status=0
149 exit