5 # Ensure that quota(1) displays blocksizes matching ondisk dquots.
7 # MOUNT_OPTIONS can be set to grpquota to test group quota,
8 # defaults to usrquota if MOUNT_OPTIONS is not set.
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
32 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
33 # Mountain View, CA 94043, or:
37 # For further information regarding this notice, see:
39 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
40 #-----------------------------------------------------------------------
46 echo "QA output created by $seq"
50 status=1 # failure is the default!
52 # get standard environment, filters and checks
59 umount $SCRATCH_MNT 2>/dev/null
62 trap "_cleanup; exit \$status" 0 1 2 3 15
69 if [ -z "$MOUNT_OPTIONS" ]; then
70 MOUNT_OPTIONS="-o usrquota"; export MOUNT_OPTIONS
73 # real QA test starts here
74 mkfs_xfs $SCRATCH_DEV | _filter_mkfs 2>$tmp.mkfs
75 cat $tmp.mkfs >>$seq.full
76 chmod a+w $seq.full # arbitrary users will write here
78 # keep the blocksize from mkfs ($dbsize)
83 # setup user/group to test
84 if src/feature -U $SCRATCH_DEV ; then
85 type=u ; eval `_choose_uid`
86 elif src/feature -G $SCRATCH_DEV ; then
87 type=g ; eval `_choose_gid`
89 _notrun "No quota support at mount time"
92 # create 100 (fs-blocksize) blocks
93 _file_as_id $SCRATCH_MNT/foo $id $type $dbsize 220
96 # set limit at 1001 (1k) blocks
97 setquota -$type $id 1001 1001 10 10 $SCRATCH_DEV
99 # cross check blks, softblks, hardblks <-> quota, xfs_db
100 quota -$type $id | tee -a $seq.full | perl -ne '
101 if (m,^\s*'$SCRATCH_DEV'\s+(\d+)\s+(\d+)\s+(\d+), ||
102 ($next == 1 && m,^\s+(\d+)\s+(\d+)\s+(\d+),)) {
103 print "used_blocks=", $1, "\n";
104 print "soft_blocks=", $2, "\n";
105 print "hard_blocks=", $3, "\n";
108 elsif (m,^\s*'$SCRATCH_DEV',) { # devfs (long) names
110 }' | LC_COLLATE=POSIX sort >$tmp.quota
112 echo ===quota output >> $seq.full
113 cat $tmp.quota >> $seq.full
114 [ ! -s $tmp.quota ] && echo "warning: quota output file is empty"
118 # note - does (insitu) conversion from fs blocks to 1K blocks
119 xfs_db -rc "dquot -$type $id" -c p $SCRATCH_DEV | tee -a $seq.full | perl -ne '
120 if (/^diskdq.bcount = (\d+)$/) {
121 print "used_blocks=", $1 * '$dbsize' / 1024, "\n";
123 elsif (/^diskdq.blk_hardlimit = (\d+)$/) {
124 print "hard_blocks=", $1 * '$dbsize' / 1024, "\n";
126 elsif (/^diskdq.blk_softlimit = (\d+)$/) {
127 print "soft_blocks=", $1 * '$dbsize' / 1024, "\n";
128 }' | LC_COLLATE=POSIX sort >$tmp.xfs_db
130 echo ===xfs_db output >> $seq.full
131 cat $tmp.xfs_db >> $seq.full
132 [ ! -s $tmp.xfs_db ] && echo "warning: xfs_db output file is empty"
134 echo Comparing out of quota and xfs_db
135 diff $tmp.quota $tmp.xfs_db
136 [ $? -eq 0 ] && echo OK.