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