4 # Ensure that quota(1) displays blocksizes matching ondisk dquots.
6 # MOUNT_OPTIONS can be set to gquota to test group quota,
7 # defaults to uquota if MOUNT_OPTIONS is not set.
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
31 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
32 # Mountain View, CA 94043, or:
36 # For further information regarding this notice, see:
38 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
39 #-----------------------------------------------------------------------
45 echo "QA output created by $seq"
49 status=1 # failure is the default!
51 # get standard environment, filters and checks
59 umount $SCRATCH_MNT 2>/dev/null
62 trap "_cleanup; exit \$status" 0 1 2 3 15
64 # real QA test starts here
66 _supported_os IRIX Linux
74 if [ -z "$MOUNT_OPTIONS" ]; then
75 export MOUNT_OPTIONS="-o uquota"
78 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
79 cat $tmp.mkfs >>$seq.full
80 chmod a+w $seq.full # arbitrary users will write here
82 # keep the blocksize from mkfs ($dbsize)
87 # setup user/group to test
88 if src/feature -U $SCRATCH_DEV ; then
89 type=u; eval `_choose_uid`
90 elif src/feature -G $SCRATCH_DEV ; then
91 type=g; eval `_choose_gid`
93 _notrun "No quota support at mount time"
96 # create 100 (fs-blocksize) blocks
97 _file_as_id $SCRATCH_MNT/foo $id $type $dbsize 220
100 # Irix uses filesystem name and Linux uses device of filesystem
101 if [ $HOSTOS = "Linux" ]; then
102 QUOTA_FS=$SCRATCH_DEV
104 QUOTA_FS=$SCRATCH_MNT
107 # set limit at 1001 (1k) blocks
112 _setquota -$type $id $bsoft $bhard $isoft $ihard $QUOTA_FS
117 if (m[^\s*'$QUOTA_FS'\s+(\d+)\s+(\d+)\s+(\d+)] ||
118 ($next == 1 && m,^\s+(\d+)\s+(\d+)\s+(\d+),)) {
119 print "used_blocks=", $1, "\n";
120 print "soft_blocks=", $2, "\n";
121 print "hard_blocks=", $3, "\n";
124 elsif (m[^\s*'$QUOTA_FS']) { # devfs (long) names
126 }' | LC_COLLATE=POSIX sort
129 # cross check blks, softblks, hardblks <-> quota, xfs_db
130 _quota -$type $id | tee -a $seq.full | _filter_quota >$tmp.quota
132 echo ===quota output >> $seq.full
133 cat $tmp.quota >> $seq.full
134 [ ! -s $tmp.quota ] && echo "warning: quota output file is empty"
138 # note - does (insitu) conversion from fs blocks to 1K blocks
139 xfs_db -rc "dquot -$type $id" -c p $SCRATCH_DEV | tee -a $seq.full | perl -ne '
140 if (/^diskdq.bcount = (\d+)$/) {
141 print "used_blocks=", $1 * '$dbsize' / 1024, "\n";
143 elsif (/^diskdq.blk_hardlimit = (\d+)$/) {
144 print "hard_blocks=", $1 * '$dbsize' / 1024, "\n";
146 elsif (/^diskdq.blk_softlimit = (\d+)$/) {
147 print "soft_blocks=", $1 * '$dbsize' / 1024, "\n";
148 }' | LC_COLLATE=POSIX sort >$tmp.xfs_db
150 echo ===xfs_db output >> $seq.full
151 cat $tmp.xfs_db >> $seq.full
152 [ ! -s $tmp.xfs_db ] && echo "warning: xfs_db output file is empty"
154 echo Comparing out of quota and xfs_db
155 diff $tmp.quota $tmp.xfs_db
156 [ $? -eq 0 ] && echo OK.