Skip to content

Commit

Permalink
Making select_eth_device work with 2nd NIC linked only and FETCH assi…
Browse files Browse the repository at this point in the history
…gned.

The differences:

  1. If user uses "FETCH", "HTTPFS", or "FTPFS", select_eth_device
     should not exit since network is also required to get the
     filesystem.squashfs.

  2. Files in "/sys/class/net/" maybe not be up so quick, so it's
     better to use a while loop to wait for that.

  3. Another case is, for example, if eth0 and eth1 are linked, but
     only eth1 is able to get filesystem.squashfs, the original
     select_eth_device will try eth0 only. It's better to provide an
     alternative way to allow user to specify the device in boot
     parameter. Here in the patch live-netdev=eth1, for example, can
     be used to make it.
  • Loading branch information
stevenshiau authored and daniel-baumann committed Mar 16, 2010
1 parent 612de86 commit c78c135
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions scripts/init-premount/select_eth_device
Expand Up @@ -30,9 +30,14 @@ for ARGUMENT in $(cat /proc/cmdline); do
esac
done

if [ "$bootconf" != "BOOT=nfs" ] && [ "$NETBOOT" = "" ]; then
# Not a net boot : nothing to do
exit 0
if [ "$bootconf" != "BOOT=nfs" ] &&
[ "$NETBOOT" = "" ] &&
[ "$FETCH" = "" ] &&
[ "$FTPFS" = "" ] &&
[ "$HTTPFS" = "" ]
then
# Not a net boot : nothing to do
exit 0
fi

# be sure this has been run (*should* be done by scripts/init-premount/udev)
Expand All @@ -43,14 +48,30 @@ udevadm settle
modprobe -q af_packet

# Available Ethernet interfaces ?
l_interfaces=$(cd /sys/class/net/ && ls -d eth* 2>/dev/null)
l_interfaces=""
echo "Waiting for ethernet card(s) up... If this fails, maybe the ethernet card is not supported by the kernel `uname -r`?"
while [ -z "$l_interfaces" ]; do
l_interfaces="$(cd /sys/class/net/ && ls -d eth* 2>/dev/null)"
done

if [ $(echo $l_interfaces | wc -w) -lt 2 ]; then
# only one interface : no choice
echo "DEVICE=$l_interfaces" >> /conf/param.conf
exit 0
fi

# If user force to use specific device, write it
for ARGUMENT in $(cat /proc/cmdline); do
case "${ARGUMENT}" in
live-netdev=*)
NETDEV="${ARGUMENT#live-netdev=}"
echo "DEVICE=$NETDEV" >> /conf/param.conf
echo "Found live-netdev parameter in /proc/cmdline. Force to use network device $NETDEV."
exit 0
;;
esac
done

while true; do
echo -n "Looking for a connected Ethernet interface ..."

Expand Down

0 comments on commit c78c135

Please sign in to comment.