7
     ˆÀ¿ƒh¹¾Á      (null)
     ˆÀ¿ƒh¹¾Á      (null)
  2   	ˆl—ßi~”d
e¶¥8 ¸ÛwyLZ7ÿÀ„ZŸ_ŒuÐb&=LyYÿÀÃ ,¢    	#!/usr/bin/sh
#
# This implementation is incomplete: Discovery mode is not implemented and
# the argument handling doesn't follow currently agreed formats. This is mainly
# because rfc4173 does not say anything about iscsi_initiator but open-iscsi's
# iscsistart needs this.
#

type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
type parse_iscsi_root > /dev/null 2>&1 || . /lib/net-lib.sh
type write_fs_tab > /dev/null 2>&1 || . /lib/fs-lib.sh

PATH=/usr/sbin:/usr/bin:/sbin:/bin

# Huh? Empty $1?
[ -z "$1" ] && exit 1

# Huh? Empty $2?
[ -z "$2" ] && exit 1

# Huh? Empty $3? This isn't really necessary, since NEWROOT isn't
# used here. But let's be consistent
[ -z "$3" ] && exit 1

# root is in the form root=iscsi:[<servername>]:[<protocol>]:[<port>]:[<LUN>]:<targetname>
netif="$1"
iroot="$2"

# If it's not iscsi we don't continue
[ "${iroot%%:*}" = "iscsi" ] || exit 1

iroot=${iroot#iscsi}
iroot=${iroot#:}

# XXX modprobe crc32c should go in the cmdline parser, but I haven't yet
# figured out a way how to check whether this is built-in or not
modprobe crc32c 2> /dev/null

# start iscsiuio if needed
if [ -z "${DRACUT_SYSTEMD}" ] \
    && { [ -e /sys/module/bnx2i ] || [ -e /sys/module/qedi ]; } \
    && ! [ -e /tmp/iscsiuio-started ]; then
    iscsiuio
    : > /tmp/iscsiuio-started
fi

handle_firmware() {
    local ifaces retry _res

    # Depending on the 'ql4xdisablesysfsboot' qla4xxx
    # will be autostarting sessions without presenting
    # them via the firmware interface.
    # In these cases 'iscsiadm -m fw' will fail, but
    # the iSCSI sessions will still be present.
    if ! iscsiadm -m fw; then
        warn "iscsiadm: Could not get list of targets from firmware."
    else
        ifaces=$(
            set -- /sys/firmware/ibft/ethernet*
            echo $#
        )
        retry=$(cat /tmp/session-retry)

        if [ "$retry" -lt "$ifaces" ]; then
            retry=$((retry + 1))
            echo $retry > /tmp/session-retry
            return 1
        else
            rm /tmp/session-retry
        fi

        # check to see if we have the new iscsiadm command,
        # that supports the "no-wait" (-W) flag. If so, use it.
        iscsiadm -m fw -l -W 2> /dev/null
        _res=$?
        if [ $_res -eq 7 ]; then
            # ISCSI_ERR_INVALID (7) => "-W" not supported
            info "iscsiadm does not support no-wait firmware logins"
            iscsiadm -m fw -l
            _res=$?
        fi
        if [ $_res -ne 0 ]; then
            warn "iscsiadm: Log-in to iscsi target failed"
        else
            need_shutdown
        fi
    fi
    [ -d /sys/class/iscsi_session ] || return 1
    echo 'started' > "/tmp/iscsistarted-iscsi:"
    echo 'started' > "/tmp/iscsistarted-firmware"

    return 0
}

handle_netroot() {
    local iscsi_initiator iscsi_target_name iscsi_target_ip iscsi_target_port
    local iscsi_target_group iscsirw iscsi_lun
    local iscsi_username iscsi_password
    local iscsi_in_username iscsi_in_password
    local iscsi_iface_name iscsi_netdev_name
    local iscsi_param param
    local p found
    local login_retry_max_seen=

    # override conf settings by command line options
    arg=$(getarg rd.iscsi.initiator -d iscsi_initiator=)
    [ -n "$arg" ] && iscsi_initiator=$arg
    arg=$(getarg rd.iscsi.target.group -d iscsi_target_group=)
    [ -n "$arg" ] && iscsi_target_group=$arg
    arg=$(getarg rd.iscsi.username -d iscsi_username=)
    [ -n "$arg" ] && iscsi_username=$arg
    arg=$(getarg rd.iscsi.password -d iscsi_password)
    [ -n "$arg" ] && iscsi_password=$arg
    arg=$(getarg rd.iscsi.in.username -d iscsi_in_username=)
    [ -n "$arg" ] && iscsi_in_username=$arg
    arg=$(getarg rd.iscsi.in.password -d iscsi_in_password=)
    [ -n "$arg" ] && iscsi_in_password=$arg
    for p in $(getargs rd.iscsi.param -d iscsi_param); do
        [ "${p%=*}" = node.session.initial_login_retry_max ] \
            && login_retry_max_seen=yes
        iscsi