Cleanup parse-nfsroot and NFS tests.

TODO: root=/dev/nfs is still broken.
master
Warren Togami 2009-06-30 17:48:56 -04:00
parent 798d950651
commit 297cb80bab
2 changed files with 19 additions and 29 deletions

View File

@ -72,7 +72,16 @@ netroot_to_var() {
[ -z "$netroot" ] && netroot=$(getarg netroot=)
[ -z "$nfsroot" ] && nfsroot=$(getarg nfsroot=)

# Netroot cmdline argument must be ignored, but must be used if
# nfsroot= is valid only if root=/dev/nfs
if [ -n "$nfsroot" ] ; then
# @deprecated
warn "Argument nfsroot is deprecated and might be removed in a future release. See http://apps.sourceforge.net/trac/dracut/wiki/commandline for more information."
if [ "$(getarg root=)" != "/dev/nfs" ]; then
die "Argument nfsroot only accepted for legacy root=/dev/nfs"
fi
fi

# netroot= cmdline argument must be ignored, but must be used if
# we're inside netroot to parse dhcp root-path
if [ -n "$netroot" ] ; then
if [ "$netroot" = "$(getarg netroot=)" ] ; then
@ -84,31 +93,12 @@ else
fi

# Handle old style <server-ip>:/<path
# FIXME: root= is not handled by this yet.
case "$netroot" in
[0-9]*:/*|[0-9]*\.[0-9]*\.[0-9]*[!:]|/*)
netroot=nfs:$netroot;;
esac

# Continue if nfs or blank prefix
case "${netroot%%:*}" in
''|nfs|nfs4|/dev/nfs);;
*) return;;
esac

if [ -n "$nfsroot" ] ; then
[ -z "$netroot" ] && netroot=$root

# @deprecated
warn "Argument nfsroot is deprecated and might be removed in a future release. See http://apps.sourceforge.net/trac/dracut/wiki/commandline for more information."

case "$netroot" in
/dev/nfs) netroot=${netroot:-nfs}:$nfsroot;;
*) die "Argument nfsroot only accepted for legacy root=/dev/nfs"
esac
fi

# Continue if nfs prefix
# Continue if nfs
case "${netroot%%:*}" in
nfs|nfs4|/dev/nfs);;
*) return;;

View File

@ -105,14 +105,14 @@ test_nfsv3() {
"root=dhcp" 192.168.50.1 -wsize=4096 || return 1

# XXX: Temporarily not supported during refactoring
# client_test "NFSv3 Legacy root=/dev/nfs DHCP path only" 52:54:00:12:34:00 \
# "root=/dev/nfs" 192.168.50.1 -wsize=4096 || return 1

# client_test "NFSv3 Legacy root=/dev/nfs DHCP IP:path" 52:54:00:12:34:01 \
# "root=/dev/nfs" 192.168.50.2 -wsize=4096 || return 1

# client_test "NFSv3 Legacy root=/dev/nfs nfsroot=IP:path" 52:54:00:12:34:01 \
# "root=/dev/nfs nfsroot=192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
#
# client_test "NFSv3 Legacy root=/dev/nfs DHCP path only" 52:54:00:12:34:00 \
# "root=/dev/nfs" 192.168.50.1 -wsize=4096 || return 1
#
# client_test "NFSv3 Legacy root=/dev/nfs DHCP IP:path" 52:54:00:12:34:01 \
# "root=/dev/nfs" 192.168.50.2 -wsize=4096 || return 1

client_test "NFSv3 root=dhcp DHCP IP:path" 52:54:00:12:34:01 \
"root=dhcp" 192.168.50.2 -wsize=4096 || return 1
@ -129,8 +129,8 @@ test_nfsv3() {
client_test "NFSv3 Legacy root=IP:path" 52:54:00:12:34:04 \
"root=192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1

# This test must fail: root=dhcp must ignore other arguments
client_test "NFSv3 root=dhcp nfsroot=/nfs/client" 52:54:00:12:34:04 \
# This test must fail: nfsroot= requires root=/dev/nfs
client_test "NFSv3 Invalid root=dhcp nfsroot=/nfs/client" 52:54:00:12:34:04 \
"root=dhcp nfsroot=/nfs/client" 192.168.50.1 -wsize=4096 && return 1

client_test "NFSv3 root=dhcp DHCP path,options" \