common: Fixes for testing NFS over IPv6

When testing NFS over IPv6, the user may set a $TEST_DEV of the form
[fe80::42]:/export.  The use of square brackets surrounding the IPv6
address is an accepted convention, but grep and awk think that our IPv6
address is actually a regex and tries to evaluate it instead.  The
result is that xfstests reports our filesystem "is busy or already
mounted".

This patch fixes the IPv6 problem by telling awk and grep to treat
$TEST_DEV as a fixed string rather than a regex.

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Anna Schumaker
2014-11-10 18:06:23 +11:00
committed by Dave Chinner
parent 155cf517b0
commit 73dfa4ae3e
+8 -4
View File
@@ -809,14 +809,16 @@ _df_device()
exit 1 exit 1
fi fi
# Note that we use "==" here so awk doesn't try to interpret an NFS over
# IPv6 server as a regular expression.
$DF_PROG 2>/dev/null | $AWK_PROG -v what=$1 ' $DF_PROG 2>/dev/null | $AWK_PROG -v what=$1 '
match($1,what) && NF==1 { ($1==what) && (NF==1) {
v=$1 v=$1
getline getline
print v, $0 print v, $0
exit exit
} }
match($1,what) { ($1==what) {
print print
exit exit
} }
@@ -1132,10 +1134,12 @@ _require_test()
esac esac
# mounted? # mounted?
if _mount | grep -q $TEST_DEV # Note that we use -F here so grep doesn't try to interpret an NFS over
# IPv6 server as a regular expression.
if _mount | grep -F -q $TEST_DEV
then then
# if it's mounted, make sure its on $TEST_DIR # if it's mounted, make sure its on $TEST_DIR
if ! _mount | grep $TEST_DEV | grep -q $TEST_DIR if ! _mount | grep -F $TEST_DEV | grep -q $TEST_DIR
then then
echo "\$TEST_DEV is mounted but not on \$TEST_DIR - aborting" echo "\$TEST_DEV is mounted but not on \$TEST_DIR - aborting"
exit 1 exit 1