SHA256
1
0
forked from pool/open-iscsi
open-iscsi/open-iscsi-umount-all-luns

62 lines
1.5 KiB
Plaintext
Raw Normal View History

diff --git a/etc/initd/initd.suse b/etc/initd/initd.suse
index 6d4cbd8..ce9fa70 100644
--- a/etc/initd/initd.suse
+++ b/etc/initd/initd.suse
@@ -77,6 +77,39 @@ iscsi_logout_all_nodes()
return ${RETVAL:-0}
}
+iscsi_umount_all_luns()
+{
+ local d m dev p s
+
+ cat /proc/mounts | sed -ne '/^\/dev\/.*/p' | while read d m t o x; do
+ if [ "$m" = "/" ] ; then
+ continue;
+ fi
+ if [ -L "$d" ] ; then
+ d=$(readlink -f $d)
+ fi
+ dev=${d##/dev}
+
+ if [ "${dev##/sd}" = "$dev" ] ; then
+ continue;
+ fi
+ p="/sys/block${dev%%[0-9]*}"
+
+ if [ ! -d ${p} ] && [ ! -d ${p}/device ] ; then
+ continue;
+ fi
+
+ s=$(cd -P ${p}/device && echo $PWD)
+
+ case "$s" in
+ */session[0-9]*/*)
+ # This is an iSCSI device
+ umount "$m"
+ ;;
+ esac
+ done
+}
+
iscsi_list_all_nodes()
{
TARGETS=$($ISCSIADM -m session | sed 's@\[[^:]*:\(.*\)\] .*@\1@g')
@@ -110,6 +143,7 @@ case "$1" in
fi
;;
stop)
+ iscsi_umount_all_luns
if iscsi_logout_all_nodes ; then
killproc -KILL $DAEMON
RETVAL=$?
diff --git a/include/iscsi_if.h b/include/iscsi_if.h
diff --git a/kernel/iscsi_tcp.c b/kernel/iscsi_tcp.c
diff --git a/kernel/libiscsi.c b/kernel/libiscsi.c
diff --git a/kernel/libiscsi.h b/kernel/libiscsi.h
diff --git a/kernel/scsi_transport_iscsi.c b/kernel/scsi_transport_iscsi.c
diff --git a/usr/discovery.c b/usr/discovery.c
diff --git a/usr/initiator.c b/usr/initiator.c
diff --git a/usr/initiator.h b/usr/initiator.h
diff --git a/usr/iscsid.c b/usr/iscsid.c