3 # Functions useful for quota tests
5 # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of version 2 of the GNU General Public License as
9 # published by the Free Software Foundation.
11 # This program is distributed in the hope that it would be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 # Further, this software is distributed without any warranty that it is
16 # free of the rightful claim of any third person regarding infringement
17 # or the like. Any license provided herein, whether implied or
18 # otherwise, applies only to this software file. Patent licenses, if
19 # any, provided herein do not apply to combinations of this program with
20 # other software, or any other product whatsoever.
22 # You should have received a copy of the GNU General Public License along
23 # with this program; if not, write the Free Software Foundation, Inc., 59
24 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
26 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 # Mountain View, CA 94043, or:
31 # For further information regarding this notice, see:
33 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
37 # checks that the XFS quota support in the kernel is enabled
38 # and that we have valid quota user tools installed.
42 src/feature -q $TEST_DEV
43 [ $? -ne 0 ] && _notrun "Installed kernel does not support XFS quota"
44 [ -x /usr/sbin/xfs_quota ] || _notrun "Quota user tools not installed"
48 # checks that the XFS project quota support in the kernel is enabled.
52 src/feature -p $TEST_DEV
53 [ $? -ne 0 ] && _notrun "Installed kernel does not support XFS project quotas"
57 # checks for user nobody in /etc/passwd and /etc/group.
61 grep -q '^nobody' /etc/passwd
62 [ $? -ne 0 ] && _notrun "/etc/passwd does not contain user nobody."
64 grep -q '^nobody' /etc/group
65 [ $? -ne 0 ] && _notrun "/etc/group does not contain user nobody."
68 # create a file as a specific user (uid)
69 # takes filename, id, type (u/g), blocksize, blockcount
73 [ $# != 5 ] && _notrun "broken call to _file_as_id in test $seq"
77 magik='$>' # perlspeak for effective uid
80 magik='$)' # perlspeak for effective gid
82 _notrun "broken type in call to _file_as_id in test $seq"
85 perl <<EOF >>$seq.full 2>&1
92 print "dd if=/dev/zero of=$1 bs=$4 count=$5";
93 exec "dd if=/dev/zero of=$1 bs=$4 count=$5";
96 # for debugging the above euid change, try... [need write in cwd]
97 # exec "dd if=/dev/zero of=$1 bs=$4 count=$5 >>$seq.full 2>&1";
102 grep '^nobody' /etc/passwd | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
107 grep '^nobody' /etc/group | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
112 if [ ! -f /etc/projid ]; then
116 perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[1],$a[0] }' \
121 # filter to get the guts out
122 # and make linux and irix similar
126 tee -a $seq.full | $AWK_PROG '
132 gsub(/timeleft/, "grace")
136 gsub(/1week/,"7days")
137 gsub(/NOT STARTED/,"")
145 ' | sed -e '/-----------------/d'
150 umount $SCRATCH_DEV >/dev/null 2>&1
151 _scratch_mount || _fail "qmount failed"
152 chmod ugo+rwx $SCRATCH_MNT
157 # setup exactly what it is we'll be testing
159 if src/feature -u $SCRATCH_DEV
161 type=u ; eval `_choose_uid`; ln -s $seq.usrquota $seq.out
162 elif src/feature -g $SCRATCH_DEV
164 type=g ; eval `_choose_gid`; ln -s $seq.grpquota $seq.out
165 elif src/feature -p $SCRATCH_DEV
167 type=p ; eval `_choose_prid`; ln -s $seq.prjquota $seq.out
168 elif src/feature -U $SCRATCH_DEV
170 type=u ; eval `_choose_uid`; ln -s $seq.uqnoenforce $seq.out
172 elif src/feature -G $SCRATCH_DEV
174 type=g ; eval `_choose_gid`; ln -s $seq.gqnoenforce $seq.out
176 elif src/feature -P $SCRATCH_DEV
178 type=p ; eval `_choose_prid`; ln -s $seq.pqnoenforce $seq.out
181 _notrun "No quota support at mount time"
184 echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
185 echo "and using type=$type id=$id" >>$seq.full
189 #-----------------------------------------------------------------------------------
191 # wrappers for Linux/IRIX differences
203 [ $# -eq 7 ] || _fail "_setquota failed with wrong # args: $*"
205 if [ $HOSTOS = "Linux" ]; then
206 echo "setquota $_opt_type $_id $_bsoft $_bhard $_isoft $_ihard $_fs" >>$seq.full
207 setquota $_opt_type $_id $_bsoft $_bhard $_isoft $_ihard $_fs
210 if [ $_opt_type = "-u" ]; then
216 echo "/usr/etc/edquota $_opt_type -f $_fs -l $id_param=$_id,bsoft=$_bsoft,bhard=$_bhard,isoft=$_isoft,ihard=$_ihard" >>$seq.full
217 /usr/etc/edquota $_opt_type -f $_fs -l $id_param=$_id,bsoft=$_bsoft,bhard=$_bhard,isoft=$_isoft,ihard=$_ihard
223 echo "quota $*" >>$seq.full
224 if [ $HOSTOS = "Linux" ]; then
228 args=`echo $*|sed -e 's/-u//'`
235 echo "repquota $*" >>$seq.full
236 if [ $HOSTOS = "Linux" ]; then
240 args=`echo $*|sed -e 's/-u//'`
245 #-----------------------------------------------------------------------------------
247 # make sure this script returns success