initrd.scripts: improve findnfsmount(), simplify code and branches

master
Fabio Erculiani 12 years ago
parent 7a7e01c47e
commit f4b4d6d0d6

@ -404,18 +404,18 @@ mount_sysfs() {
findnfsmount() { findnfsmount() {
if [ -z "${IP}" ]; then if [ -z "${IP}" ]; then
# IP is not set, return straight away # IP is not set, return straight away
return 0 return 1
fi fi
if ! busybox udhcpc -n -T 15 -q; then if ! busybox udhcpc -n -T 15 -q; then
bad_msg "udhcpc returned error, skipping nfs setup..." bad_msg "udhcpc returned error, skipping nfs setup..."
return 0 return 1
fi fi
local options= local options=
[ -e /rootpath ] && NFSROOT=$(cat /rootpath) [ -e /rootpath ] && NFSROOT=$(cat /rootpath)
if [ "${NFSROOT}" = "" ]; then if [ -z "${NFSROOT}" ]; then
# Obtain NFSIP # Obtain NFSIP
# TODO: this is bogus, because dmesg is a circular buffer... # TODO: this is bogus, because dmesg is a circular buffer...
# TODO: provide dmesg as symlink (see gen_initramfs.sh) # TODO: provide dmesg as symlink (see gen_initramfs.sh)
@ -443,15 +443,16 @@ findnfsmount() {
done done
# Setup NFSROOT # Setup NFSROOT
if [ "${NFSIP}" != "" ] && [ "$NFSPATH" != "" ]; then if [ -n "${NFSIP}" ] && [ -n "$NFSPATH" ]; then
NFSROOT="${NFSIP}:${NFSPATH}" NFSROOT="${NFSIP}:${NFSPATH}"
else else
bad_msg "The DHCP Server did not send a valid root-path." bad_msg "The DHCP Server did not send a valid root-path."
bad_msg "Please check your DHCP setup, or set nfsroot=<...>" bad_msg "Please check your DHCP setup, or set nfsroot=<...>"
return 1
fi fi
fi fi
if [ "${NFSROOT}" != "" ]; then # expecting a valid NFSROOT here, or the code should have returned
NFSOPTIONS=${NFSROOT#*,} NFSOPTIONS=${NFSROOT#*,}
NFSROOT=${NFSROOT%%,*} NFSROOT=${NFSROOT%%,*}
if [ "${NFSOPTIONS}" = "${NFSROOT}" ]; then if [ "${NFSOPTIONS}" = "${NFSROOT}" ]; then
@ -474,9 +475,10 @@ findnfsmount() {
mount -t nfs -o ${NFSOPTIONS} "${NFSROOT}" "${path}" mount -t nfs -o ${NFSOPTIONS} "${NFSROOT}" "${path}"
if [ "${?}" = "0" ]; then if [ "${?}" = "0" ]; then
REAL_ROOT="/dev/nfs" REAL_ROOT="/dev/nfs"
return 0
else else
bad_msg "NFS Mounting failed. Is the path corrent ?" bad_msg "NFS Mounting failed. Is the path corrent ?"
fi return 1
fi fi
} }

Loading…
Cancel
Save