Merge pull request #375 from ackalker/initramfs-iscsi-support

initramfs init: add support for iSCSI mounts, this fixes #269
This commit is contained in:
Stephan Raue
2012-03-27 11:09:48 -07:00
24 changed files with 862 additions and 50 deletions

View File

@@ -4,6 +4,7 @@
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
#      Copyright (C) 2010-2011 Roman Weber (roman@openelec.tv)
# Copyright (C) 2012 Yann Cézard (eesprit@free.fr)
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -144,6 +145,72 @@ NBD_DEVS="0"
mount_common "$CIFS_SHARE" "$2" "$3,$CIFS_OPTIONS" "cifs"
}
get_iscsistart_options() {
# Convert kernel commandline ISCSI= options to iscsistart options
IFS_SAVE="$IFS"
IFS=,
for arg in $1; do
val="${arg#*=}"
case "$arg" in
iscsi_initiator=*)
option="-i"
;;
iscsi_target_name=*)
option="-t"
;;
iscsi_target_ip=*)
option="-a"
;;
iscsi_target_port=*)
option="-p"
;;
iscsi_target_group=*)
option="-g"
;;
iscsi_username=*)
option="-u"
;;
iscsi_password=*)
option="-w"
;;
iscsi_in_username=*)
option="-U"
;;
iscsi_in_password=*)
option="-W"
;;
esac
echo "$option $val"
done
IFS="$IFS_SAVE"
}
mount_iscsi() {
# Mount iSCSI target
ISCSI_DEV="${1##*,}"
ISCSI_OPTIONS="${1%,*}"
if [ ! -f "/sbin/iscsistart" ]; then
error "iscsistart" "iSCSI support not available"
fi
if [ "$ISCSI_OPTIONS" = "auto" ]; then
progress "Network configuration based on iBFT"
/sbin/iscsistart -N >&$SILENT_OUT 2>&1 || \
error "iscsistart" "Unable to configure network"
progress "iSCSI auto connect based on iBFT"
/sbin/iscsistart -b >&$SILENT_OUT 2>&1 || \
error "iscsistart" "Unable to auto connect"
else
/sbin/iscsistart $(get_iscsistart_options "$ISCSI_OPTIONS") >&$SILENT_OUT 2>&1 || \
error "iscsistart" "Unable to connect to ISCSI target"
fi
mount_common "$ISCSI_DEV" "$2" "$3" "$4"
}
mount_nbd() {
# Mount NBD device
NBD_SERVER="${1%%:*}"
@@ -182,6 +249,9 @@ NBD_DEVS="0"
CIFS=*|SMB=*)
MOUNT_CMD="mount_cifs"
;;
ISCSI=*)
MOUNT_CMD="mount_iscsi"
;;
NBD=*)
MOUNT_CMD="mount_nbd"
;;