Browse Source
Parse and convert commandline options in the cmdline hook, and fill in the missing pieces in the netroot hook. This also allows root=dhcp to work as expected.master

6 changed files with 149 additions and 83 deletions
@ -1 +0,0 @@
@@ -1 +0,0 @@
|
||||
ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/nfsroot $env{INTERFACE}" |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh # for highlighting |
||||
|
||||
# If we're auto-detecting our root type from DHCP, see if this looks like |
||||
# an NFS root option. As the variety of root-path formats is large, validate |
||||
# that the number of colons match what we expect, and our glob didn't |
||||
# inadvertently match a different handler's. |
||||
# |
||||
if [ "$root" = "dhcp" -o "$root" = "nfs" -o "$root" = "nfs4" ]; then |
||||
nfsver=nfs |
||||
if [ "$root" = "nfs4" ]; then |
||||
nfsver=nfs4 |
||||
fi |
||||
case "$new_root_path" in |
||||
nfs:*|nfs4:*) root="$new_root_path" ;; |
||||
*:/*:*) |
||||
if check_occurances "$new_root_path" ':' 2; then |
||||
root="$nfsver:$new_root_path" |
||||
fi ;; |
||||
*:/*) |
||||
if check_occurances "$new_root_path" ':' 1; then |
||||
root="$nfsver:$new_root_path:" |
||||
fi ;; |
||||
/*:*) |
||||
if check_occurances "$new_root_path" ':' 1; then |
||||
root="$nfsver::$new_root_path" |
||||
fi ;; |
||||
/*) |
||||
if check_occurances "$new_root_path" ':' 0; then |
||||
root="$nfsver::$new_root_path:" |
||||
fi ;; |
||||
esac |
||||
fi |
||||
|
||||
if [ -z "${root%%nfs:*}" -o -z "${root%%nfs4:*}" ]; then |
||||
# Fill in missing information from DHCP |
||||
nfsver=${root%%:*}; root=${root#*:} |
||||
nfsserver=${root%%:*}; root=${root#*:} |
||||
nfspath=${root%%:*} |
||||
nfsflags=${root#*:} |
||||
|
||||
# XXX where does dhclient stash the next-server option? Do we care? |
||||
if [ -z "$nfsserver" -o "$nfsserver" = "$nfspath" ]; then |
||||
nfsserver=$new_dhcp_server_identifier |
||||
fi |
||||
if [ "$nfspath" = "$nfsflags" ]; then |
||||
unset nfsflags |
||||
fi |
||||
|
||||
# XXX validate we have all the required info? |
||||
root="$nfsver:$nfsserver:$nfspath:$nfsflags" |
||||
handler=/sbin/nfsroot |
||||
fi |
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash |
||||
|
||||
# We're 90-nfs.sh to catch root=/dev/nfs |
||||
# |
||||
# Preferred format: |
||||
# root=nfs[4]:[server:]path[:options] |
||||
# |
||||
# If server is unspecified it will be pulled from one of the following |
||||
# sources, in order: |
||||
# static ip= option on kernel command line |
||||
# DHCP next-server option |
||||
# DHCP server-id option |
||||
# |
||||
# Legacy formats: |
||||
# root=nfs[4] |
||||
# root=/dev/nfs[4] nfsroot=[server:]path[,options] |
||||
# |
||||
# Plain "root=nfs" interprets DHCP root-path option as [ip:]path[:options] |
||||
# |
||||
# NFSv4 is only used if explicitly listed; default is NFSv3 |
||||
# |
||||
|
||||
case "$root" in |
||||
nfs|dhcp|'') |
||||
if getarg nfsroot= > /dev/null; then |
||||
root=nfs:$(getarg nfsroot=) |
||||
fi |
||||
;; |
||||
nfs4) |
||||
if getarg nfsroot= > /dev/null; then |
||||
root=nfs4:$(getarg nfsroot=) |
||||
fi |
||||
;; |
||||
/dev/nfs|/dev/nfs4) |
||||
if getarg nfsroot= > /dev/null; then |
||||
root=${root#/dev/}:$(getarg nfsroot=) |
||||
else |
||||
root=${root#/dev/} |
||||
fi |
||||
;; |
||||
esac |
||||
|
||||
case "$root" in |
||||
nfs|nfs4|nfs:*|nfs4:*) |
||||
rootok=1 |
||||
netroot=nfs |
||||
;; |
||||
esac |
Loading…
Reference in new issue