3 # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
5 # Functions useful for quota tests
9 # checks that the XFS quota support in the kernel is enabled
10 # and that we have valid quota user tools installed.
14 src/feature -q $TEST_DEV
15 [ $? -ne 0 ] && _notrun "Installed kernel does not support XFS quota"
16 [ -x /usr/sbin/xfs_quota ] || _notrun "Quota user tools not installed"
20 # checks that the XFS project quota support in the kernel is enabled.
24 src/feature -p $TEST_DEV
25 [ $? -ne 0 ] && _notrun "Installed kernel does not support XFS project quotas"
29 # checks for user nobody in /etc/passwd and /etc/group.
33 grep -q '^nobody' /etc/passwd
34 [ $? -ne 0 ] && _notrun "/etc/passwd does not contain user nobody."
36 grep -q '^nobody' /etc/group
37 [ $? -ne 0 ] && _notrun "/etc/group does not contain user nobody."
40 # create a file as a specific user (uid)
41 # takes filename, id, type (u/g), blocksize, blockcount
45 [ $# != 5 ] && _notrun "broken call to _file_as_id in test $seq"
49 magik='$>' # perlspeak for effective uid
52 magik='$)' # perlspeak for effective gid
54 _notrun "broken type in call to _file_as_id in test $seq"
57 perl <<EOF >>$seq.full 2>&1
64 print "dd if=/dev/zero of=$1 bs=$4 count=$5";
65 exec "dd if=/dev/zero of=$1 bs=$4 count=$5";
68 # for debugging the above euid change, try... [need write in cwd]
69 # exec "dd if=/dev/zero of=$1 bs=$4 count=$5 >>$seq.full 2>&1";
74 grep '^nobody' /etc/passwd | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
79 grep '^nobody' /etc/group | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
84 if [ ! -f /etc/projid ]; then
88 perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[1],$a[0] }' \
93 # filter to get the guts out
94 # and make linux and irix similar
98 tee -a $seq.full | $AWK_PROG '
104 gsub(/timeleft/, "grace")
108 gsub(/1week/,"7days")
109 gsub(/NOT STARTED/,"")
117 ' | sed -e '/-----------------/d'
122 umount $SCRATCH_DEV >/dev/null 2>&1
123 _scratch_mount || _fail "qmount failed"
124 chmod ugo+rwx $SCRATCH_MNT
129 # setup exactly what it is we'll be testing
131 if src/feature -u $SCRATCH_DEV
133 type=u ; eval `_choose_uid`; ln -s $seq.usrquota $seq.out
134 elif src/feature -g $SCRATCH_DEV
136 type=g ; eval `_choose_gid`; ln -s $seq.grpquota $seq.out
137 elif src/feature -p $SCRATCH_DEV
139 type=p ; eval `_choose_prid`; ln -s $seq.prjquota $seq.out
140 elif src/feature -U $SCRATCH_DEV
142 type=u ; eval `_choose_uid`; ln -s $seq.uqnoenforce $seq.out
144 elif src/feature -G $SCRATCH_DEV
146 type=g ; eval `_choose_gid`; ln -s $seq.gqnoenforce $seq.out
148 elif src/feature -P $SCRATCH_DEV
150 type=p ; eval `_choose_prid`; ln -s $seq.pqnoenforce $seq.out
153 _notrun "No quota support at mount time"
156 echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
157 echo "and using type=$type id=$id" >>$seq.full
161 #-----------------------------------------------------------------------------------
163 # wrappers for Linux/IRIX differences
175 [ $# -eq 7 ] || _fail "_setquota failed with wrong # args: $*"
177 if [ $HOSTOS = "Linux" ]; then
178 echo "setquota $_opt_type $_id $_bsoft $_bhard $_isoft $_ihard $_fs" >>$seq.full
179 setquota $_opt_type $_id $_bsoft $_bhard $_isoft $_ihard $_fs
182 if [ $_opt_type = "-u" ]; then
188 echo "/usr/etc/edquota $_opt_type -f $_fs -l $id_param=$_id,bsoft=$_bsoft,bhard=$_bhard,isoft=$_isoft,ihard=$_ihard" >>$seq.full
189 /usr/etc/edquota $_opt_type -f $_fs -l $id_param=$_id,bsoft=$_bsoft,bhard=$_bhard,isoft=$_isoft,ihard=$_ihard
195 echo "quota $*" >>$seq.full
196 if [ $HOSTOS = "Linux" ]; then
200 args=`echo $*|sed -e 's/-u//'`
207 echo "repquota $*" >>$seq.full
208 if [ $HOSTOS = "Linux" ]; then
212 args=`echo $*|sed -e 's/-u//'`
217 #-----------------------------------------------------------------------------------
219 # make sure this script returns success