All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Arkadiusz Miskiewicz <arekm@maven.pl>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] Validate string -> number conversion.
Date: Thu, 26 Aug 2010 18:42:49 +1000	[thread overview]
Message-ID: <20100826084249.GF705@dastard> (raw)
In-Reply-To: <201008251101.27106.arekm@maven.pl>

On Wed, Aug 25, 2010 at 11:01:26AM +0200, Arkadiusz Miskiewicz wrote:
> 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)

Great - thanks for doing this. A couple of comments, though.

First, I'm assuming that no output should occur if everything
succeeds?  If so, we normally put an:

echo "Silence is golden"

in the test to document that we expect no other output.

> 
> #! /bin/bash
> # FS QA Test No. xxx
> #
> # test to verify that correct project quota id is set
> #
> # creator

Can you add the GPL text and copyright here so the license is clear
and we know where it came from?

> 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

I'm not sure any will ever validate this on Irix, so maybe that
should be left out?

> 
> _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` )

if ( `echo $MOUNT_OPTIONS | egrep -q g??quota` )

> 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

	_fail "!!! failed to mount

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

This test should probably be first.

> mkdir $dir
> touch $dir/below16bit

status=0

> # 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)"

	status=1

> 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)"

	status=1

> 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"

	status=1

> fi
> 
> # success, all done
> status=0

Remove these two lines.

> exit


Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

  reply	other threads:[~2010-08-26  8:42 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
2010-08-26  8:42     ` Dave Chinner [this message]
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=20100826084249.GF705@dastard \
    --to=david@fromorbit.com \
    --cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.