2001-03-20 07:17:52 +00:00
|
|
|
#! /bin/sh
|
2004-06-15 07:32:36 +00:00
|
|
|
# FS QA Test No. 052
|
2001-03-20 07:17:52 +00:00
|
|
|
#
|
|
|
|
|
# Ensure that quota(1) displays blocksizes matching ondisk dquots.
|
|
|
|
|
#
|
2004-07-30 05:28:14 +00:00
|
|
|
# MOUNT_OPTIONS can be set to gquota to test group quota,
|
|
|
|
|
# defaults to uquota if MOUNT_OPTIONS is not set.
|
2001-03-20 07:17:52 +00:00
|
|
|
#
|
|
|
|
|
#-----------------------------------------------------------------------
|
2002-06-04 23:07:56 +00:00
|
|
|
# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
|
2001-03-20 07:17:52 +00:00
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
# under the terms of version 2 of the GNU General Public License as
|
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it would be useful, but
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
#
|
|
|
|
|
# Further, this software is distributed without any warranty that it is
|
|
|
|
|
# free of the rightful claim of any third person regarding infringement
|
|
|
|
|
# or the like. Any license provided herein, whether implied or
|
|
|
|
|
# otherwise, applies only to this software file. Patent licenses, if
|
|
|
|
|
# any, provided herein do not apply to combinations of this program with
|
|
|
|
|
# other software, or any other product whatsoever.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
|
# with this program; if not, write the Free Software Foundation, Inc., 59
|
|
|
|
|
# Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
|
|
|
|
#
|
|
|
|
|
# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
|
|
|
|
# Mountain View, CA 94043, or:
|
|
|
|
|
#
|
|
|
|
|
# http://www.sgi.com
|
|
|
|
|
#
|
|
|
|
|
# For further information regarding this notice, see:
|
|
|
|
|
#
|
|
|
|
|
# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# creator
|
|
|
|
|
owner=nathans@sgi.com
|
|
|
|
|
|
|
|
|
|
seq=`basename $0`
|
|
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
|
|
|
|
. ./common.rc
|
|
|
|
|
. ./common.filter
|
|
|
|
|
. ./common.quota
|
|
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
2004-06-15 07:32:36 +00:00
|
|
|
cd /
|
2001-03-20 07:17:52 +00:00
|
|
|
umount $SCRATCH_MNT 2>/dev/null
|
|
|
|
|
rm -f $tmp.*
|
|
|
|
|
}
|
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
2004-06-15 07:32:36 +00:00
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
_supported_fs xfs
|
|
|
|
|
_supported_os IRIX Linux
|
|
|
|
|
|
2001-04-11 06:10:08 +00:00
|
|
|
rm -f $seq.full
|
2001-03-20 07:17:52 +00:00
|
|
|
|
|
|
|
|
_require_scratch
|
|
|
|
|
_require_quota
|
2005-07-08 15:05:17 +00:00
|
|
|
_require_nobody
|
2001-03-20 07:17:52 +00:00
|
|
|
|
|
|
|
|
# setup a default run
|
|
|
|
|
if [ -z "$MOUNT_OPTIONS" ]; then
|
2004-07-30 05:28:14 +00:00
|
|
|
export MOUNT_OPTIONS="-o uquota"
|
2001-03-20 07:17:52 +00:00
|
|
|
fi
|
|
|
|
|
|
2003-05-22 04:16:45 +00:00
|
|
|
_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
|
2001-03-20 07:17:52 +00:00
|
|
|
cat $tmp.mkfs >>$seq.full
|
|
|
|
|
chmod a+w $seq.full # arbitrary users will write here
|
|
|
|
|
|
|
|
|
|
# keep the blocksize from mkfs ($dbsize)
|
|
|
|
|
. $tmp.mkfs
|
|
|
|
|
|
|
|
|
|
_qmount
|
|
|
|
|
|
|
|
|
|
# setup user/group to test
|
|
|
|
|
if src/feature -U $SCRATCH_DEV ; then
|
2004-07-30 05:28:14 +00:00
|
|
|
type=u; eval `_choose_uid`
|
2001-03-20 07:17:52 +00:00
|
|
|
elif src/feature -G $SCRATCH_DEV ; then
|
2004-07-30 05:28:14 +00:00
|
|
|
type=g; eval `_choose_gid`
|
2001-03-20 07:17:52 +00:00
|
|
|
else
|
|
|
|
|
_notrun "No quota support at mount time"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# create 100 (fs-blocksize) blocks
|
|
|
|
|
_file_as_id $SCRATCH_MNT/foo $id $type $dbsize 220
|
|
|
|
|
sync
|
|
|
|
|
|
2004-07-30 05:28:14 +00:00
|
|
|
# Irix uses filesystem name and Linux uses device of filesystem
|
|
|
|
|
if [ $HOSTOS = "Linux" ]; then
|
|
|
|
|
QUOTA_FS=$SCRATCH_DEV
|
|
|
|
|
else
|
|
|
|
|
QUOTA_FS=$SCRATCH_MNT
|
|
|
|
|
fi
|
2001-03-20 07:17:52 +00:00
|
|
|
|
2004-07-30 05:28:14 +00:00
|
|
|
# set limit at 1001 (1k) blocks
|
|
|
|
|
bsoft=1001
|
|
|
|
|
bhard=1001
|
|
|
|
|
isoft=10
|
|
|
|
|
ihard=10
|
|
|
|
|
_setquota -$type $id $bsoft $bhard $isoft $ihard $QUOTA_FS
|
|
|
|
|
|
|
|
|
|
_filter_quota()
|
|
|
|
|
{
|
|
|
|
|
perl -ne '
|
|
|
|
|
if (m[^\s*'$QUOTA_FS'\s+(\d+)\s+(\d+)\s+(\d+)] ||
|
2001-04-11 06:10:08 +00:00
|
|
|
($next == 1 && m,^\s+(\d+)\s+(\d+)\s+(\d+),)) {
|
2001-03-20 07:17:52 +00:00
|
|
|
print "used_blocks=", $1, "\n";
|
|
|
|
|
print "soft_blocks=", $2, "\n";
|
|
|
|
|
print "hard_blocks=", $3, "\n";
|
2001-04-11 06:10:08 +00:00
|
|
|
$next = 0;
|
|
|
|
|
}
|
2004-07-30 05:28:14 +00:00
|
|
|
elsif (m[^\s*'$QUOTA_FS']) { # devfs (long) names
|
2001-04-11 06:10:08 +00:00
|
|
|
$next = 1;
|
2004-07-30 05:28:14 +00:00
|
|
|
}' | LC_COLLATE=POSIX sort
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# cross check blks, softblks, hardblks <-> quota, xfs_db
|
|
|
|
|
_quota -$type $id | tee -a $seq.full | _filter_quota >$tmp.quota
|
2001-03-20 07:17:52 +00:00
|
|
|
|
|
|
|
|
echo ===quota output >> $seq.full
|
|
|
|
|
cat $tmp.quota >> $seq.full
|
|
|
|
|
[ ! -s $tmp.quota ] && echo "warning: quota output file is empty"
|
|
|
|
|
|
|
|
|
|
umount $SCRATCH_MNT
|
|
|
|
|
|
|
|
|
|
# note - does (insitu) conversion from fs blocks to 1K blocks
|
|
|
|
|
xfs_db -rc "dquot -$type $id" -c p $SCRATCH_DEV | tee -a $seq.full | perl -ne '
|
|
|
|
|
if (/^diskdq.bcount = (\d+)$/) {
|
|
|
|
|
print "used_blocks=", $1 * '$dbsize' / 1024, "\n";
|
|
|
|
|
}
|
|
|
|
|
elsif (/^diskdq.blk_hardlimit = (\d+)$/) {
|
|
|
|
|
print "hard_blocks=", $1 * '$dbsize' / 1024, "\n";
|
|
|
|
|
}
|
|
|
|
|
elsif (/^diskdq.blk_softlimit = (\d+)$/) {
|
|
|
|
|
print "soft_blocks=", $1 * '$dbsize' / 1024, "\n";
|
|
|
|
|
}' | LC_COLLATE=POSIX sort >$tmp.xfs_db
|
|
|
|
|
|
|
|
|
|
echo ===xfs_db output >> $seq.full
|
|
|
|
|
cat $tmp.xfs_db >> $seq.full
|
|
|
|
|
[ ! -s $tmp.xfs_db ] && echo "warning: xfs_db output file is empty"
|
|
|
|
|
|
|
|
|
|
echo Comparing out of quota and xfs_db
|
|
|
|
|
diff $tmp.quota $tmp.xfs_db
|
|
|
|
|
[ $? -eq 0 ] && echo OK.
|
|
|
|
|
|
|
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|