[PATCH] check: check SCRATCH_MNT before calling _scratch_mkfs

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



On NFS or Overlayfs, "mkfs" turns into rm -rf $SCRATCH_MNT/*

There is no warning/error in check if SCRATCH_MNT is unset.

Also add the checks to _scratch_cleanup_files.

Signed-off-by: Jeff Mahoney <jeffm@xxxxxxxx>
---
 check     | 12 ++++++++++++
 common/rc |  8 ++++++++
 2 files changed, 20 insertions(+)

diff --git a/check b/check
index 69341d8..b22d2df 100755
--- a/check
+++ b/check
@@ -512,6 +512,18 @@ for section in $HOST_OPTIONS_SECTIONS; do
 	needwrap=true
 
 	if [ ! -z "$SCRATCH_DEV" ]; then
+	   if [ -z "$SCRATCH_MNT" ]
+	    then
+		echo "\$SCRATCH_MNT is unset"
+		status=1
+		exit
+	    fi
+	   if [ ! -d "$SCRATCH_MNT" ]
+	    then
+		echo "\$SCRATCH_MNT is not a dir"
+		status=1
+		exit
+	    fi
 	  _scratch_unmount 2> /dev/null
 	  # call the overridden mkfs - make sure the FS is built
 	  # the same as we'll create it later.
diff --git a/common/rc b/common/rc
index 13afc6a..4266c18 100644
--- a/common/rc
+++ b/common/rc
@@ -764,10 +764,18 @@ _scratch_cleanup_files()
 {
 	case $FSTYP in
 	overlay)
+		if [ -z "$SCRATCH_DEV" ]; then
+			echo "\$SCRATCH_DEV is unset."
+			return 1
+		fi
 		# $SCRATCH_DEV is a valid directory in overlay case
 		rm -rf $SCRATCH_DEV/*
 		;;
 	*)
+		if [ -z "$SCRATCH_MNT" ]; then
+			echo "\$SCRATCH_MNT is unset."
+			return 1
+		fi
 		_scratch_mount
 		rm -rf $SCRATCH_MNT/*
 		_scratch_unmount
-- 
1.7.12.4

--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux