Merge branch 'master' of github.com:haraldh/dracut

master
Vasiliy Tolstov 2014-10-29 15:56:00 +03:00
commit f95b78f3eb
4 changed files with 92 additions and 24 deletions

View File

@ -743,6 +743,8 @@ fi

if ! [[ $DRACUT_INSTALL ]] && [[ -x $dracutbasedir/dracut-install ]]; then
DRACUT_INSTALL=$dracutbasedir/dracut-install
elif ! [[ $DRACUT_INSTALL ]] && [[ -x $dracutbasedir/install/dracut-install ]]; then
DRACUT_INSTALL=$dracutbasedir/install/dracut-install
fi

if ! [[ -x $DRACUT_INSTALL ]]; then

View File

@ -551,7 +551,19 @@ find_iface_with_link() {
}

is_persistent_ethernet_name() {
case "$1" in
local _netif="$1"
local _name_assign_type="0"

[ -f "/sys/class/net/$_netif/name_assign_type" ] \
&& _name_assign_type=$(cat "/sys/class/net/$_netif/name_assign_type")

# NET_NAME_ENUM 1
[ "$_name_assign_type" = "1" ] && return 1

# NET_NAME_PREDICTABLE 2
[ "$_name_assign_type" = "2" ] && return 0

case "$_netif" in
# udev persistent interface names
eno[0-9]|eno[0-9][0-9]|eno[0-9][0-9][0-9]*)
;;
@ -571,3 +583,35 @@ is_persistent_ethernet_name() {
esac
return 0
}

is_kernel_ethernet_name() {
local _netif="$1"
local _name_assign_type="1"

if [ -e "/sys/class/net/$_netif/name_assign_type" ]; then
_name_assign_type=$(cat "/sys/class/net/$_netif/name_assign_type")

case "$_name_assign_type" in
2|3|4)
# NET_NAME_PREDICTABLE 2
# NET_NAME_USER 3
# NET_NAME_RENAMED 4
return 1
;;
1|*)
# NET_NAME_ENUM 1
return 0
;;
esac
fi

# fallback to error prone manual name check
case "$_netif" in
eth[0-9]|eth[0-9][0-9]|eth[0-9][0-9][0-9]*)
return 0
;;
*)
return 1
esac

}

View File

@ -80,18 +80,41 @@ print_s390() {
return 0
}

hw_bind() {
local _netif="$1"
local _macaddr="$2"

[ -n "$_macaddr" ] \
&& echo "MACADDR=\"$_macaddr\""

print_s390 "$_netif" \
&& return 0

[ -n "$_macaddr" ] && return 0

is_persistent_ethernet_name "$_netif" && return 0

[ -f "/sys/class/net/$_netif/addr_assign_type" ] \
&& [ "$(cat "/sys/class/net/$_netif/addr_assign_type")" != "0" ] \
&& return 1

[ -f "/sys/class/net/$_netif/address" ] \
|| return 1

echo "HWADDR=\"$(cat /sys/class/net/$_netif/address)\""
}

interface_bind() {
local netif="$1"
local macaddr="$2"
if ! print_s390 $netif; then
if [ -z "$macaddr" ] && \
! is_persistent_ethernet_name "$netif" && \
[ -f /sys/class/net/$netif/addr_assign_type ] && \
[ "$(cat /sys/class/net/$netif/addr_assign_type)" = "0" ] && \
[ -f /sys/class/net/$netif/address ]; then
echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
fi
local _netif="$1"
local _macaddr="$2"

# see, if we can bind it to some hw parms
if hw_bind "$_netif" "$_macaddr"; then
# only print out DEVICE, if it's user assigned
is_kernel_ethernet_name "$_netif" && return 0
fi

echo "DEVICE=\"$_netif\""
}

for netup in /tmp/net.*.did-setup ; do
@ -129,7 +152,8 @@ for netup in /tmp/net.*.did-setup ; do

{
echo "# Generated by dracut initrd"
echo "DEVICE=\"$netif\""
echo "NAME=\"$netif\""
interface_bind "$netif" "$macaddr"
echo "ONBOOT=yes"
echo "NETBOOT=yes"
echo "UUID=\"$uuid\""
@ -175,10 +199,7 @@ for netup in /tmp/net.*.did-setup ; do
if [ -z "$bridge" ] && [ -z "$bond" ] && [ -z "$vlan" ]; then
# standard interface
{
[ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
interface_bind "$netif" "$macaddr"
echo "TYPE=Ethernet"
echo "NAME=\"$netif\""
[ -n "$mtu" ] && echo "MTU=\"$mtu\""
} >> /tmp/ifcfg/ifcfg-$netif
fi
@ -205,16 +226,15 @@ for netup in /tmp/net.*.did-setup ; do
# write separate ifcfg file for the raw eth interface
(
echo "# Generated by dracut initrd"
echo "DEVICE=\"$slave\""
echo "NAME=\"$slave\""
echo "TYPE=Ethernet"
echo "ONBOOT=yes"
echo "NETBOOT=yes"
echo "SLAVE=yes"
echo "MASTER=\"$netif\""
echo "NAME=\"$slave\""
echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
unset macaddr
[ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
[ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
interface_bind "$slave" "$macaddr"
) >> /tmp/ifcfg/ifcfg-$slave
done
@ -230,15 +250,14 @@ for netup in /tmp/net.*.did-setup ; do
# write separate ifcfg file for the raw eth interface
(
echo "# Generated by dracut initrd"
echo "DEVICE=\"$slave\""
echo "NAME=\"$slave\""
echo "TYPE=Ethernet"
echo "ONBOOT=yes"
echo "NETBOOT=yes"
echo "BRIDGE=\"$bridgename\""
echo "NAME=\"$slave\""
echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
unset macaddr
[ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
[ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
interface_bind "$slave" "$macaddr"
) >> /tmp/ifcfg/ifcfg-$slave
done

View File

@ -90,16 +90,19 @@ _check_shutdown() {
( . "$__f" $1 )
if [ $? -eq 0 ]; then
rm -f -- $__f
else
__s=0
fi
done
return $__s
}

while _check_shutdown; do
:
_cnt=0
while [ $_cnt -le 40 ]; do
_check_shutdown || break
_cnt=$(($_cnt+1))
done
_check_shutdown final
[ $_cnt -ge 40 ] && _check_shutdown final

getarg 'rd.break=shutdown' && emergency_shell --shutdown shutdown "Break before shutdown"