aur/lio-utils: add rc-arch.patch

This commit is contained in:
Kevin Mihelich 2012-04-15 12:49:11 -04:00
parent c552589933
commit 2b1fd8e3f3

149
aur/lio-utils/rc-arch.patch Normal file
View file

@ -0,0 +1,149 @@
diff -aur lio-utils/scripts/rc.target lio-utils.new/scripts/rc.target
--- lio-utils/scripts/rc.target 2011-05-06 23:16:58.000000000 +0200
+++ lio-utils.new/scripts/rc.target 2012-02-29 02:48:36.032877118 +0100
@@ -27,10 +27,13 @@
# Source function library.
#. /etc/init.d/functions
+. /etc/rc.conf
+. /etc/rc.d/functions
#########################################################################
# Our product file definitions
+daemon_name=target
MODNAME="target_core_mod"
TCM_CFS_DIR="/sys/kernel/config/target/core"
@@ -112,11 +115,22 @@
continue
fi
- if [[ $i =~ ".rpmsave" ]]; then
+ # files from arch package manager
+ if [[ $i =~ ".pacsave" ]]; then
+ continue
+ fi
+ if [[ $i =~ ".pacnew" ]]; then
+ continue
+ fi
+ if [[ $i =~ ".pacorig" ]]; then
continue
fi
- if [[ $i =~ ".dpkg-dist" ]]; then
+ # files from the free branch
+ if [[ $i =~ ".json" ]]; then
+ continue
+ fi
+ if [[ $i =~ ".backup" ]]; then
continue
fi
@@ -259,7 +273,7 @@
function shutdown_fabrics() {
- echo -n $"Unloading fabric/configfs: "
+ echo "Unloading fabric/configfs: "
${TCM_FABRIC} --unloadall
RETVAL=$?
if [ $RETVAL == 0 ]; then
@@ -274,7 +288,7 @@
return 0
fi
- echo -n $"Unloading LIO-Target/ConfigFS fabric: "
+ echo "Unloading LIO-Target/ConfigFS fabric: "
${LIO_NODE} --unload
RETVAL=$?
if [ $RETVAL == 0 ]; then
@@ -285,7 +299,10 @@
}
function unload_tcm_mod() {
-
+ if [ ! -d /sys/kernel/config/target/ ]; then
+ return 0
+ fi
+
shutdown_fabrics
shutdown_lio_mod
@@ -446,28 +463,57 @@
case "$1" in
start)
+ stat_busy "Starting LIO targets"
start 0
+ if [ $? != 0 ]; then
+ stat_fail
+ exit 1
+ else
+ add_daemon $daemon_name
+ stat_done
+ fi
;;
startbak)
if [ "$ARGS_COUNT" -ne "$ARGS_CHECK" ]; then
echo "Usage: /etc/init.d/target startbak <DATE_TIME>"
exit 1
fi
+ stat_busy "Starting LIO target backup $2"
start $2
+ if [ $? != 0 ]; then
+ stat_fail
+ exit 1
+ else
+ add_daemon $daemon_name
+ stat_done
+ fi
;;
stop)
+ stat_busy "Stopping LIO targets"
stop 1
+ if [ $? != 0 ]; then
+ stat_fail
+ exit 1
+ else
+ rm_daemon $daemon_name
+ stat_done
+ fi
;;
status)
- tcm_status
- RETVAL=$?
+ stat_busy "Checking status of LIO targets"
+ ck_status $daemon_name
+ # targetcli might have mounted configfs/target
+ if [ -d /sys/kernel/config/target/ ]; then
+ tcm_status
+ fi
;;
restart|reload)
- restart 1
+ $0 stop
+ sleep 3
+ $0 start
;;
*)
- echo $"Usage: $0 {start|startbak|stop|status|restart}"
- exit 1
+ echo "Usage: $0 {start|startbak|stop|status|restart}"
esac
exit $?
diff -aur lio-utils/tcm-py/tcm_node.py lio-utils.new/tcm-py/tcm_node.py
--- lio-utils/tcm-py/tcm_node.py 2011-05-06 23:16:58.000000000 +0200
+++ lio-utils.new/tcm-py/tcm_node.py 2012-02-29 02:48:24.306210014 +0100
@@ -591,7 +591,9 @@
# Unload TCM subsystem plugin modules
for module in ("iblock", "file", "pscsi", "stgt"):
- os.system("rmmod target_core_%s" % module)
+ module_name = "target_core_%s" % module
+ if not os.system("lsmod | grep %s > /dev/null" % module_name):
+ os.system("rmmod %s" % module_name)
# Unload TCM Core
rmmod_op = "rmmod target_core_mod"