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
13 # modify it under the terms 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,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 seqres=$RESULT_DIR/$seq
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
36 status=1 # failure is the default!
38 # get standard environment, filters and checks
46 umount $SCRATCH_MNT 2>/dev/null
49 trap "_cleanup; exit \$status" 0 1 2 3 15
51 # real QA test starts here
53 _supported_os IRIX Linux
64 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
65 cat $tmp.mkfs >>$seqres.full
66 chmod a+w $seqres.full # arbitrary users will write here
68 # keep the blocksize from mkfs ($dbsize)
73 # setup user/group to test
74 if src/feature -U $SCRATCH_DEV ; then
75 type=u; eval `_choose_uid`
76 elif src/feature -G $SCRATCH_DEV ; then
77 type=g; eval `_choose_gid`
78 elif src/feature -P $SCRATCH_DEV ; then
79 type=p; eval `_choose_prid`
81 _notrun "No quota support at mount time"
84 # create 100 (fs-blocksize) blocks
85 _file_as_id $SCRATCH_MNT/foo $id $type $dbsize 220
88 # set limit at 1001 (1k) blocks
94 -c "limit -$type bsoft=${bsoft}k bhard=${bhard}k $id" \
95 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
98 # cross check blks, softblks, hardblks <-> quota, xfs_db
99 xfs_quota -c "quota -$type -birnN $id" $SCRATCH_DEV |
100 tr -d '\n' | tr -s '[:space:]' | tee -a $seqres.full |
101 perl -ne 'if (m[^\s*'$SCRATCH_DEV'\s+(\d+)\s+(\d+)\s+(\d+)]) {
102 print "used_blocks=", $1, "\n";
103 print "soft_blocks=", $2, "\n";
104 print "hard_blocks=", $3, "\n";
106 }' | LC_COLLATE=POSIX sort >$tmp.quota
108 echo ===quota output >> $seqres.full
109 cat $tmp.quota >> $seqres.full
110 [ ! -s $tmp.quota ] && echo "warning: quota output file is empty"
114 # note - does (insitu) conversion from fs blocks to 1K blocks
115 xfs_db -rc "dquot -$type $id" -c p $SCRATCH_DEV | tee -a $seqres.full | perl -ne '
116 if (/^diskdq.bcount = (\d+)$/) {
117 print "used_blocks=", $1 * '$dbsize' / 1024, "\n";
119 elsif (/^diskdq.blk_hardlimit = (\d+)$/) {
120 print "hard_blocks=", $1 * '$dbsize' / 1024, "\n";
122 elsif (/^diskdq.blk_softlimit = (\d+)$/) {
123 print "soft_blocks=", $1 * '$dbsize' / 1024, "\n";
124 }' | LC_COLLATE=POSIX sort >$tmp.xfs_db
126 echo ===xfs_db output >> $seqres.full
127 cat $tmp.xfs_db >> $seqres.full
128 [ ! -s $tmp.xfs_db ] && echo "warning: xfs_db output file is empty"
130 echo Comparing out of xfs_quota and xfs_db
131 diff $tmp.quota $tmp.xfs_db
132 [ $? -eq 0 ] && echo OK.