Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 May 2018 10:48:21 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r334254 - head/etc/rc.d
Message-ID:  <201805271048.w4RAmLcQ028266@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Sun May 27 10:48:21 2018
New Revision: 334254
URL: https://svnweb.freebsd.org/changeset/base/334254

Log:
  Make the cfumass rc script support USB template 10.
  
  MFC after:	2 weeks
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/etc/rc.d/cfumass

Modified: head/etc/rc.d/cfumass
==============================================================================
--- head/etc/rc.d/cfumass	Sun May 27 06:47:09 2018	(r334253)
+++ head/etc/rc.d/cfumass	Sun May 27 10:48:21 2018	(r334254)
@@ -45,7 +45,7 @@ remove_luns()
 
 cfumass_start()
 {
-	local err _files _template
+	local err _files _template _new_template
 
 	if [ ! -d "${cfumass_dir}" ]; then
 		warn "${cfumass_dir} does not exist"
@@ -90,36 +90,59 @@ cfumass_start()
 		fi
 	fi
 
+	# Set the template number based on the current one.
 	_template=`sysctl -n hw.usb.template`
-	if [ "${_template}" -lt 0 ]; then
-		sysctl hw.usb.template=0 > /dev/null
+	case "${_template}" in
+	-1)
+		_new_template="0"
+		;;
+	8)
+		_new_template="10"
+		;;
+	*)
+		warn "hw.usb.template sysctl set to neither -1 nor 8; not changing"
+		_new_template=""
+		;;
+	esac
+		
+	if [ -n "${_new_template}" ]; then
+		sysctl hw.usb.template="${_new_template}" > /dev/null
 		err=$?
 		if [ "${err}" -ne 0 ]; then
-			warn "unable to set hw.usb.template sysctl"
+			warn "unable to set hw.usb.template sysctl to ${_new_template}"
 			return "${err}"
 		fi
-	else
-		# Otherwise don't touch the sysctl - we could lock the user
-		# out of the machine otherwise.
-		warn "hw.usb.template sysctl set to neither -1 nor 0"
 	fi
 }
 
 cfumass_stop()
 {
-	local err _template
+	local err _template _new_template
 
+	remove_luns
+
 	_template=`sysctl -n hw.usb.template`
-	if [ "${_template}" -eq 0 ]; then
-		sysctl hw.usb.template=-1 > /dev/null
+	case "${_template}" in
+	0)
+		_new_template="-1"
+		;;
+	10)
+		_new_template="8"
+		;;
+	*)
+		warn "hw.usb.template sysctl set to neither 0 nor 10; not changing"
+		_new_template=""
+		;;
+	esac
+		
+	if [ -n "${_new_template}" ]; then
+		sysctl hw.usb.template="${_new_template}" > /dev/null
 		err=$?
 		if [ "${err}" -ne 0 ]; then
-			warn "unable to set hw.usb.template sysctl"
+			warn "unable to set hw.usb.template sysctl to ${_new_template}"
 			return "${err}"
 		fi
 	fi
-
-	remove_luns
 }
 
 load_rc_config $name



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805271048.w4RAmLcQ028266>