mirror of
https://github.com/dracutdevs/dracut.git
synced 2024-10-26 07:55:28 +03:00
fix(zfcp_rules): shellcheck for modules.d/95zfcp_rules
This commit is contained in:
parent
c0efaeca11
commit
032ecd95c9
0
modules.d/95zfcp_rules/.shchkdir
Normal file
0
modules.d/95zfcp_rules/.shchkdir
Normal file
@ -4,9 +4,10 @@
|
||||
cmdline() {
|
||||
is_zfcp() {
|
||||
local _dev=$1
|
||||
local _devpath=$(
|
||||
cd -P /sys/dev/block/$_dev
|
||||
echo $PWD
|
||||
local _devpath
|
||||
_devpath=$(
|
||||
cd -P /sys/dev/block/"$_dev" || exit
|
||||
echo "$PWD"
|
||||
)
|
||||
local _sdev _scsiid _hostno _lun _wwpn _ccw _port_type
|
||||
local _allow_lun_scan _is_npiv
|
||||
@ -14,22 +15,22 @@ cmdline() {
|
||||
_allow_lun_scan=$(cat /sys/module/zfcp/parameters/allow_lun_scan)
|
||||
[ "${_devpath#*/sd}" == "$_devpath" ] && return 1
|
||||
_sdev="${_devpath%%/block/*}"
|
||||
[ -e ${_sdev}/fcp_lun ] || return 1
|
||||
[ -e "${_sdev}"/fcp_lun ] || return 1
|
||||
_scsiid="${_sdev##*/}"
|
||||
_hostno="${_scsiid%%:*}"
|
||||
[ -d /sys/class/fc_host/host${_hostno} ] || return 1
|
||||
_port_type=$(cat /sys/class/fc_host/host${_hostno}/port_type)
|
||||
[ -d /sys/class/fc_host/host"${_hostno}" ] || return 1
|
||||
_port_type=$(cat /sys/class/fc_host/host"${_hostno}"/port_type)
|
||||
case "$_port_type" in
|
||||
NPIV*)
|
||||
_is_npiv=1
|
||||
;;
|
||||
esac
|
||||
_ccw=$(cat ${_sdev}/hba_id)
|
||||
_ccw=$(cat "${_sdev}"/hba_id)
|
||||
if [ "$_is_npiv" ] && [ "$_allow_lun_scan" = "Y" ]; then
|
||||
echo "rd.zfcp=${_ccw}"
|
||||
else
|
||||
_lun=$(cat ${_sdev}/fcp_lun)
|
||||
_wwpn=$(cat ${_sdev}/wwpn)
|
||||
_lun=$(cat "${_sdev}"/fcp_lun)
|
||||
_wwpn=$(cat "${_sdev}"/wwpn)
|
||||
echo "rd.zfcp=${_ccw},${_wwpn},${_lun}"
|
||||
fi
|
||||
return 0
|
||||
|
@ -7,13 +7,13 @@ create_udev_rule() {
|
||||
local _rule=/etc/udev/rules.d/51-zfcp-${ccw}.rules
|
||||
local _cu_type _dev_type
|
||||
|
||||
if [ -x /sbin/cio_ignore ] && cio_ignore -i $ccw > /dev/null; then
|
||||
cio_ignore -r $ccw
|
||||
if [ -x /sbin/cio_ignore ] && cio_ignore -i "$ccw" > /dev/null; then
|
||||
cio_ignore -r "$ccw"
|
||||
fi
|
||||
|
||||
if [ -e /sys/bus/ccw/devices/${ccw} ]; then
|
||||
read _cu_type < /sys/bus/ccw/devices/${ccw}/cutype
|
||||
read _dev_type < /sys/bus/ccw/devices/${ccw}/devtype
|
||||
if [ -e /sys/bus/ccw/devices/"${ccw}" ]; then
|
||||
read -r _cu_type < /sys/bus/ccw/devices/"${ccw}"/cutype
|
||||
read -r _dev_type < /sys/bus/ccw/devices/"${ccw}"/devtype
|
||||
fi
|
||||
if [ "$_cu_type" != "1731/03" ]; then
|
||||
return 0
|
||||
@ -23,21 +23,21 @@ create_udev_rule() {
|
||||
fi
|
||||
|
||||
if [ ! -f "$_rule" ]; then
|
||||
cat > $_rule << EOF
|
||||
cat > "$_rule" << EOF
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$ccw", IMPORT{program}="collect $ccw %k ${ccw} zfcp"
|
||||
ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="zfcp", IMPORT{program}="collect $ccw %k ${ccw} zfcp"
|
||||
ACTION=="add", ENV{COLLECT_$ccw}=="0", ATTR{[ccw/$ccw]online}="1"
|
||||
EOF
|
||||
fi
|
||||
[ -z "$wwpn" ] || [ -z "$lun" ] && return
|
||||
m=$(sed -n "/.*${wwpn}.*${lun}.*/p" $_rule)
|
||||
m=$(sed -n "/.*${wwpn}.*${lun}.*/p" "$_rule")
|
||||
if [ -z "$m" ]; then
|
||||
cat >> $_rule << EOF
|
||||
cat >> "$_rule" << EOF
|
||||
ACTION=="add", KERNEL=="rport-*", ATTR{port_name}=="$wwpn", SUBSYSTEMS=="ccw", KERNELS=="$ccw", ATTR{[ccw/$ccw]$wwpn/unit_add}="$lun"
|
||||
EOF
|
||||
fi
|
||||
if [ -x /sbin/cio_ignore ] && ! cio_ignore -i $ccw > /dev/null; then
|
||||
cio_ignore -r $ccw
|
||||
if [ -x /sbin/cio_ignore ] && ! cio_ignore -i "$ccw" > /dev/null; then
|
||||
cio_ignore -r "$ccw"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ if [[ -f /sys/firmware/ipl/ipl_type && \
|
||||
_lun=$(cat /sys/firmware/ipl/lun)
|
||||
_ccw=$(cat /sys/firmware/ipl/device)
|
||||
|
||||
create_udev_rule $_ccw $_wwpn $_lun
|
||||
create_udev_rule "$_ccw" "$_wwpn" "$_lun"
|
||||
)
|
||||
fi
|
||||
|
||||
@ -56,9 +56,10 @@ for zfcp_arg in $(getargs rd.zfcp); do
|
||||
(
|
||||
OLDIFS="$IFS"
|
||||
IFS=","
|
||||
# shellcheck disable=SC2086
|
||||
set $zfcp_arg
|
||||
IFS="$OLDIFS"
|
||||
create_udev_rule $1 $2 $3
|
||||
create_udev_rule "$1" "$2" "$3"
|
||||
)
|
||||
done
|
||||
|
||||
@ -72,11 +73,11 @@ for zfcp_arg in $(getargs root=) $(getargs resume=); do
|
||||
if [ -n "$ccw_arg" ]; then
|
||||
OLDIFS="$IFS"
|
||||
IFS="-"
|
||||
set -- $ccw_arg
|
||||
set -- "$ccw_arg"
|
||||
IFS="$OLDIFS"
|
||||
_wwpn=${4%:*}
|
||||
_lun=${4#*:}
|
||||
create_udev_rule $2 $wwpn $lun
|
||||
create_udev_rule "$2" "$wwpn" "$lun"
|
||||
fi
|
||||
)
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user