public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Arkadiusz Miskiewicz <arekm@maven.pl>
To: xfs@oss.sgi.com
Subject: Re: [PATCH] Validate string -> number conversion.
Date: Wed, 25 Aug 2010 11:01:26 +0200	[thread overview]
Message-ID: <201008251101.27106.arekm@maven.pl> (raw)
In-Reply-To: <201008251045.54899.arekm@maven.pl>

On Wednesday 25 of August 2010, Arkadiusz Miskiewicz wrote:
> On Wednesday 25 of August 2010, Arkadiusz Miśkiewicz wrote:
> > Make sure that numbers passed as string will fit into proper
> > types when doing string->uid_t/gid_t/prid_t conversion.
> > 
> > Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
> > ---
> > 
> >  libxcmd/input.c |   18 +++++++++++++++---
> >  quota/project.c |    2 +-
> >  2 files changed, 16 insertions(+), 4 deletions(-)
> 
> On the kernel side something like below is needed (compile tested only).
> The true fix is to extend on disk di_projid to 32bit (there is room for
> that).

template of test suite for this problem
(likely needs some small amount of work)

#! /bin/bash
# FS QA Test No. xxx
#
# test to verify that correct project quota id is set
#
# creator
owner=arekm@maven.pl

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()
{
	cd /
	umount $SCRATCH_MNT 2>/dev/null
	rm -f $tmp.*
}
#trap "_cleanup; exit \$status" 0 1 2 3 15


# real QA test starts here
_supported_fs xfs
_supported_os Linux IRIX

_require_xfs_quota

dir=$SCRATCH_MNT/project

_require_scratch
_scratch_mkfs_xfs >/dev/null 2>&1

#if pquota's already in mount options then we dont need to enable

# we can't run with group quotas
if ( `echo $MOUNT_OPTIONS | grep -q gquota` || `echo $MOUNT_OPTIONS | grep -q grpquota` )
then
    _notrun "Can't run with group quotas enabled"
fi
EXTRA_MOUNT_OPTIONS="-o pquota"

if ! _scratch_mount "$EXTRA_MOUNT_OPTIONS" >$tmp.out 2>&1
then
    cat $tmp.out
    echo "!!! mount failed"
    exit
fi

src/feature -p $SCRATCH_DEV
[ $? -ne 0 ] && _notrun "Installed kernel does not support project quotas"

mkdir $dir
touch $dir/below16bit
# below 16bit value
xfs_quota -x -c "project -s -p $dir/below16bit 3422" $SCRATCH_DEV
projid=$($XFS_IO_PROG -r -c "lsproj" $dir/below16bit)
if [ "projid = 3422" != "$projid" ]; then
	echo "FAIL: returned projid value ($projid) doesn't match set one (3422)"
fi

# over 16bit value
touch $dir/over16bit
xfs_quota -x -c "project -s -p $dir/over16bit 108545" $SCRATCH_DEV
projid=$($XFS_IO_PROG -r -c "lsproj" $dir)
if [ "projid = 108545" != "$projid" ]; then
	echo "FAIL: returned projid value ($projid) doesn't match set one (108545)"
fi

# over 32bit value, should fail
touch $dir/over32bit
if ! xfs_quota -x -c "project -s -p $dir/over32bit 5344967296" $SCRATCH_DEV; then
	echo "FAIL: setting over 32bit projid succeeded while it should fail"
fi

# success, all done
status=0
exit


-- 
Arkadiusz Miśkiewicz        PLD/Linux Team
arekm / maven.pl            http://ftp.pld-linux.org/

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2010-08-25  9:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-25  8:22 [PATCH] Validate string -> number conversion Arkadiusz Miśkiewicz
2010-08-25  8:45 ` Arkadiusz Miskiewicz
2010-08-25  9:01   ` Arkadiusz Miskiewicz [this message]
2010-08-26  8:42     ` Dave Chinner
2010-08-27 22:31       ` [PATCH] xfstests: Quota project id setting overflow Arkadiusz Miśkiewicz
2010-08-26  7:30 ` [PATCH] Validate string -> number conversion Arkadiusz Miśkiewicz
2010-08-26  8:26   ` Dave Chinner
2010-08-27 20:54     ` [PATCH] Validate string -> number conversion. [version 3] Arkadiusz Miśkiewicz
2010-08-27 21:32       ` Alex Elder
2010-09-01 10:19       ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201008251101.27106.arekm@maven.pl \
    --to=arekm@maven.pl \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox