]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
xfstests: check for valid input to _scratch_mkfs_sized
authorEric Sandeen <sandeen@redhat.com>
Tue, 17 Sep 2013 19:30:41 +0000 (19:30 +0000)
committerRich Johnston <rjohnston@sgi.com>
Tue, 15 Oct 2013 15:05:57 +0000 (10:05 -0500)
_scratch_mkfs_sized requires an integer number of bytes
as input; if it's given something else, catch it and _notrun.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
common/rc

index 4f7087358d3b821205a3cccdb2905d1b888119a7..b2539487ffc7f2cf1a6f7a50b2d514f27e91f3fb 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -569,6 +569,15 @@ _scratch_mkfs_sized()
     fssize=$1
     blocksize=$2
     [ -z "$blocksize" ] && blocksize=4096
+
+    re='^[0-9]+$'
+    if ! [[ $fssize =~ $re ]] ; then
+        _notrun "error: _scratch_mkfs_sized: fs size \"$fssize\" not an integer."
+    fi
+    if ! [[ $blocksize =~ $re ]] ; then
+        _notrun "error: _scratch_mkfs_sized: block size \"$blocksize\" not an integer."
+    fi
+
     blocks=`expr $fssize / $blocksize`
 
     if [ "$HOSTOS" == "Linux" ]; then