From 1a4808d05741d0446dba685066a3dd7cb26dab99 Mon Sep 17 00:00:00 2001
From: grev <grev>
Date: Tue, 15 Jan 2008 19:10:46 +0000
Subject: [PATCH] b=14394 i=Adilger

fix MOUNT clobber
---
 lustre/tests/lfscktest.sh | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/lustre/tests/lfscktest.sh b/lustre/tests/lfscktest.sh
index 55d635d2e3..b10190ac45 100755
--- a/lustre/tests/lfscktest.sh
+++ b/lustre/tests/lfscktest.sh
@@ -25,8 +25,16 @@ LUSTRE=${LUSTRE:-`dirname $0`/..}
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
 
-WAS_MOUNTED=`mount | grep $MOUNT || true`
-[ -z "$WAS_MOUNTED" ] && sh llmount.sh
+# if nothing mounted, don't nuke MOUNT variable needed in llmount.sh
+WAS_MOUNTED=$(mounted_lustre_filesystems | head -1)
+if [ -z "$WAS_MOUNTED" ]; then
+       # This code doesn't handle multiple mounts well, so nuke MOUNT2 variable
+        MOUNT2="" sh llmount.sh
+        MOUNT=$(mounted_lustre_filesystems)
+        [ -z "$MOUNT" ] && echo "NAME=$NAME not mounted" && exit 2
+else
+        MOUNT=${WAS_MOUNTED}
+fi
 
 DIR=$DIR/$TESTNAME
 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 3
@@ -48,7 +56,8 @@ get_mnt_devs() {
 
 if [ "$LFSCK_SETUP" != "no" ]; then
 	#Create test directory 
-	rm -rf $DIR
+	# -- can't remove the mountpoint...
+	[ -z "$DIR" ] && rm -rf $DIR/*
 	mkdir -p $DIR
 	OSTCOUNT=`$GETSTRIPE $MOUNT | grep -c "^[0-9]*: " || true`
 
@@ -186,7 +195,7 @@ done
 # lfsck will return 1 if the filesystem had errors fixed
 echo "LFSCK TEST 1"
 echo "lfsck -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
-lfsck -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT
+echo y | lfsck -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT
 RET=$?
 [ $RET -eq 0 ] && echo "clean after first check" && exit 0
 echo "LFSCK TEST 1 - finished with rc=$RET"
-- 
GitLab