Browse Source

removed all direct references to /proc/cmdline

use getarg() and getargs() from /lib/dracut-lib.sh instead of
reinventing the wheel
master
Harald Hoyer 16 years ago
parent
commit
3e6d2b31ea
  1. 6
      modules.d/40network/ifup
  2. 24
      modules.d/40network/parse-ip-opts.sh
  3. 11
      modules.d/99base/parse-blacklist.sh

6
modules.d/40network/ifup

@ -100,10 +100,8 @@ ip=$(getarg ip)


# Specific configuration, spin through the kernel command line # Specific configuration, spin through the kernel command line
# looking for ip= lines # looking for ip= lines
[ "$CMDLINE" ] || read CMDLINE </proc/cmdline; for p in $(getargs ip=); do
for p in $CMDLINE; do ip_to_var $p
[ -n "${p%ip=*}" ] && continue
ip_to_var ${p#ip=}
# If this option isn't directed at our interface, skip it # If this option isn't directed at our interface, skip it
[ -n "$dev" ] && [ "$dev" != "$netif" ] && continue [ -n "$dev" ] && [ "$dev" != "$netif" ] && continue

24
modules.d/40network/parse-ip-opts.sh

@ -52,10 +52,9 @@ fi


# Count ip= lines to decide whether we need bootdev= or not # Count ip= lines to decide whether we need bootdev= or not
if [ -z "$NEEDBOOTDEV" ] ; then if [ -z "$NEEDBOOTDEV" ] ; then
[ "$CMDLINE" ] || read CMDLINE < /proc/cmdline
local count=0 local count=0
for p in $CMDLINE; do for p in $(getargs ip=); do
[ "${p%%=*}" = "ip" ] && count=$(( $count + 1 )) count=$(( $count + 1 ))
done done
[ $count -gt 1 ] && NEEDBOOTDEV=1 [ $count -gt 1 ] && NEEDBOOTDEV=1
fi fi
@ -68,11 +67,8 @@ fi


# Check ip= lines # Check ip= lines
# XXX Would be nice if we could errorcheck ip addresses here as well # XXX Would be nice if we could errorcheck ip addresses here as well
[ "$CMDLINE" ] || read CMDLINE < /proc/cmdline for p in $(getargs ip=); do
for p in $CMDLINE; do ip_to_var $p
[ -n "${p%ip=*}" ] && continue

ip_to_var ${p#ip=}


# We need to have an ip= line for the specified bootdev # We need to have an ip= line for the specified bootdev
[ -n "$NEEDBOOTDEV" ] && [ "$dev" = "$BOOTDEV" ] && BOOTDEVOK=1 [ -n "$NEEDBOOTDEV" ] && [ "$dev" = "$BOOTDEV" ] && BOOTDEVOK=1
@ -85,28 +81,28 @@ for p in $CMDLINE; do


# Error checking for autoconf in combination with other values # Error checking for autoconf in combination with other values
case $autoconf in case $autoconf in
error) die "Error parsing option '$p'";; error) die "Error parsing option 'ip=$p'";;
bootp|rarp|both) die "Sorry, ip=$autoconf is currenty unsupported";; bootp|rarp|both) die "Sorry, ip=$autoconf is currenty unsupported";;
none|off) \ none|off) \
[ -z "$ip" ] && \ [ -z "$ip" ] && \
die "For argument '$p'\nValue '$autoconf' without static configuration does not make sense" die "For argument 'ip=$p'\nValue '$autoconf' without static configuration does not make sense"
[ -z "$mask" ] && \ [ -z "$mask" ] && \
die "Sorry, automatic calculation of netmask is not yet supported" die "Sorry, automatic calculation of netmask is not yet supported"
;; ;;
dhcp|on|any) \ dhcp|on|any) \
[ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \ [ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \
die "Sorry, '$p' does not make sense for multiple interface configurations" die "Sorry, 'ip=$p' does not make sense for multiple interface configurations"
[ -n "$ip" ] && \ [ -n "$ip" ] && \
die "For argument '$p'\nSorry, setting client-ip does not make sense for '$autoconf'" die "For argument 'ip=$p'\nSorry, setting client-ip does not make sense for '$autoconf'"
;; ;;
*) die "For argument '$p'\nSorry, unknown value '$autoconf'";; *) die "For argument 'ip=$p'\nSorry, unknown value '$autoconf'";;
esac esac


if [ -n "$dev" ] ; then if [ -n "$dev" ] ; then
# We don't like duplicate device configs # We don't like duplicate device configs
if [ -n "$IFACES" ] ; then if [ -n "$IFACES" ] ; then
for i in $IFACES ; do for i in $IFACES ; do
[ "$dev" = "$i" ] && die "For argument '$p'\nDuplication configurations for '$dev'" [ "$dev" = "$i" ] && die "For argument 'ip=$p'\nDuplication configurations for '$dev'"
done done
fi fi
# IFACES list for later use # IFACES list for later use

11
modules.d/99base/parse-blacklist.sh

@ -1,10 +1,5 @@
#!/bin/sh #!/bin/sh


if getarg rdblacklist= >/dev/null ; then for p in $(getargs rdblacklist=); do
[ "$CMDLINE" ] || read CMDLINE < /proc/cmdline echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf
for p in $CMDLINE; do done
[ -n "${p%rdblacklist=*}" ] && continue

echo "blacklist ${p#rdblacklist=}" >> /etc/modprobe.d/initramfsblacklist.conf
done
fi

Loading…
Cancel
Save