Moved nfs_diskless setup code from autoconf.c to nfsclient/nfs_diskless.c

so that it is MI.  Allow nfs_mountroot to return an error if the nfs_diskless
struct is not valid, rather than panicing later on.  Call nfs_setup_diskless()
from nfs_mountroot if NFS_ROOT is defined, like bootpc_init().  Removed legacy
root mount support for sparc64, and enabled NFS_ROOT by default.
This commit is contained in:
Jake Burkholder 2002-09-22 00:59:02 +00:00
parent dcf0aad852
commit abc370fa85
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=103770
9 changed files with 246 additions and 390 deletions

View File

@ -61,7 +61,6 @@
#include <sys/mount.h>
#include <sys/cons.h>
#if defined(NFSCLIENT) && defined(NFS_ROOT)
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_dl.h>
@ -73,7 +72,6 @@
#include <nfs/nfsproto.h>
#include <nfsclient/nfs.h>
#include <nfsclient/nfsdiskless.h>
#endif
#include <machine/bootinfo.h>
#include <machine/md_var.h>
@ -93,10 +91,6 @@ static void configure_first(void *);
static void configure(void *);
static void configure_final(void *);
#if defined(NFSCLIENT) && defined(NFS_ROOT) && !defined(BOOTP_NFSROOT)
static void pxe_setup_nfsdiskless(void);
#endif
SYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL);
/* SI_ORDER_SECOND is hookable */
SYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL);
@ -225,184 +219,10 @@ cpu_rootconf()
#endif
#if defined(NFSCLIENT) && defined(NFS_ROOT)
#if !defined(BOOTP_NFSROOT)
pxe_setup_nfsdiskless();
nfs_setup_diskless();
if (nfs_diskless_valid)
#endif
rootdevnames[0] = "nfs:";
#endif
}
SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL)
#if defined(NFSCLIENT) && defined(NFS_ROOT) && !defined(BOOTP_NFSROOT)
static int
inaddr_to_sockaddr(char *ev, struct sockaddr_in *sa)
{
u_int32_t a[4];
char *cp;
int count;
bzero(sa, sizeof(*sa));
sa->sin_len = sizeof(*sa);
sa->sin_family = AF_INET;
if ((cp = getenv(ev)) == NULL)
return(1);
count = sscanf(cp, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]);
freeenv(cp);
if (count != 4)
return(1);
/* XXX is this ordering correct? */
sa->sin_addr.s_addr = (a[3] << 24) + (a[2] << 16) + (a[1] << 8) + a[0];
return(0);
}
static int
hwaddr_to_sockaddr(char *ev, struct sockaddr_dl *sa)
{
char *cp;
u_int32_t a[6];
int count;
bzero(sa, sizeof(*sa));
sa->sdl_len = sizeof(*sa);
sa->sdl_family = AF_LINK;
sa->sdl_type = IFT_ETHER;
sa->sdl_alen = ETHER_ADDR_LEN;
if ((cp = getenv(ev)) == NULL)
return(1);
count = sscanf(cp, "%x:%x:%x:%x:%x:%x",
&a[0], &a[1], &a[2], &a[3], &a[4], &a[5]);
freeenv(cp);
if (count != 6)
return(1);
sa->sdl_data[0] = a[0];
sa->sdl_data[1] = a[1];
sa->sdl_data[2] = a[2];
sa->sdl_data[3] = a[3];
sa->sdl_data[4] = a[4];
sa->sdl_data[5] = a[5];
return(0);
}
static int
decode_nfshandle(char *ev, u_char *fh)
{
u_char *cp, *ep;
int len, val;
ep = cp = getenv(ev);
if (cp == NULL)
return(0);
if ((strlen(cp) < 2) || (*cp != 'X')) {
freeenv(ep);
return (0);
}
len = 0;
cp++;
for (;;) {
if (*cp == 'X') {
freeenv(ep);
return(len);
}
if ((sscanf(cp, "%2x", &val) != 1) || (val > 0xff)) {
freeenv(ep);
return(0);
}
*(fh++) = val;
len++;
cp += 2;
if (len > NFSX_V2FH) {
freeenv(ep);
return(0);
}
}
}
/*
* Populate the essential fields in the nfsv3_diskless structure.
*
* The loader is expected to export the following environment variables:
*
* boot.netif.ip IP address on boot interface
* boot.netif.netmask netmask on boot interface
* boot.netif.gateway default gateway (optional)
* boot.netif.hwaddr hardware address of boot interface
* boot.nfsroot.server IP address of root filesystem server
* boot.nfsroot.path path of the root filesystem on server
* boot.nfsroot.nfshandle NFS handle for root filesystem on server
*/
static void
pxe_setup_nfsdiskless(void)
{
struct nfs_diskless *nd = &nfs_diskless;
struct ifnet *ifp;
struct ifaddr *ifa;
struct sockaddr_dl *sdl, ourdl;
struct sockaddr_in myaddr, netmask;
char *cp;
/* set up interface */
if (inaddr_to_sockaddr("boot.netif.ip", &myaddr))
return;
if (inaddr_to_sockaddr("boot.netif.netmask", &netmask)) {
printf("PXE: no netmask\n");
return;
}
bcopy(&myaddr, &nd->myif.ifra_addr, sizeof(myaddr));
bcopy(&myaddr, &nd->myif.ifra_broadaddr, sizeof(myaddr));
((struct sockaddr_in *) &nd->myif.ifra_broadaddr)->sin_addr.s_addr =
myaddr.sin_addr.s_addr | ~ netmask.sin_addr.s_addr;
bcopy(&netmask, &nd->myif.ifra_mask, sizeof(netmask));
if (hwaddr_to_sockaddr("boot.netif.hwaddr", &ourdl)) {
printf("PXE: no hardware address\n");
return;
}
ifa = NULL;
TAILQ_FOREACH(ifp, &ifnet, if_link) {
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
if ((ifa->ifa_addr->sa_family == AF_LINK) &&
(sdl = ((struct sockaddr_dl *)ifa->ifa_addr))) {
if ((sdl->sdl_type == ourdl.sdl_type) &&
(sdl->sdl_alen == ourdl.sdl_alen) &&
!bcmp(sdl->sdl_data + sdl->sdl_nlen,
ourdl.sdl_data + ourdl.sdl_nlen,
sdl->sdl_alen))
goto match_done;
}
}
}
printf("PXE: no interface\n");
return; /* no matching interface */
match_done:
sprintf(nd->myif.ifra_name, "%s%d", ifp->if_name, ifp->if_unit);
/* set up gateway */
inaddr_to_sockaddr("boot.netif.gateway", &nd->mygateway);
/* XXX set up swap? */
/* set up root mount */
nd->root_args.rsize = 8192; /* XXX tunable? */
nd->root_args.wsize = 8192;
nd->root_args.sotype = SOCK_DGRAM;
nd->root_args.flags = (NFSMNT_WSIZE | NFSMNT_RSIZE | NFSMNT_RESVPORT);
if (inaddr_to_sockaddr("boot.nfsroot.server", &nd->root_saddr)) {
printf("PXE: no server\n");
return;
}
nd->root_saddr.sin_port = htons(NFS_PORT);
if (decode_nfshandle("boot.nfsroot.nfshandle", &nd->root_fh[0]) == 0) {
printf("PXE: no NFS handle\n");
return;
}
if ((cp = getenv("boot.nfsroot.path")) != NULL) {
strncpy(nd->root_hostnam, cp, MNAMELEN - 1);
freeenv(cp);
}
nfs_diskless_valid = 1;
}
#endif

View File

@ -1324,6 +1324,7 @@ nfs/nfs_common.c optional nfsserver
nfsclient/bootp_subr.c optional bootp nfsclient
nfsclient/krpc_subr.c optional bootp nfsclient
nfsclient/nfs_bio.c optional nfsclient
nfsclient/nfs_diskless.c optional nfsclient nfs_root
nfsclient/nfs_node.c optional nfsclient
nfsclient/nfs_socket.c optional nfsclient
nfsclient/nfs_subs.c optional nfsclient

View File

@ -61,7 +61,6 @@
#include <sys/mount.h>
#include <sys/cons.h>
#if defined(NFSCLIENT) && defined(NFS_ROOT)
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_dl.h>
@ -73,7 +72,6 @@
#include <nfs/nfsproto.h>
#include <nfsclient/nfs.h>
#include <nfsclient/nfsdiskless.h>
#endif
#include <machine/bootinfo.h>
#include <machine/md_var.h>
@ -93,10 +91,6 @@ static void configure_first(void *);
static void configure(void *);
static void configure_final(void *);
#if defined(NFSCLIENT) && defined(NFS_ROOT) && !defined(BOOTP_NFSROOT)
static void pxe_setup_nfsdiskless(void);
#endif
SYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL);
/* SI_ORDER_SECOND is hookable */
SYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL);
@ -225,184 +219,10 @@ cpu_rootconf()
#endif
#if defined(NFSCLIENT) && defined(NFS_ROOT)
#if !defined(BOOTP_NFSROOT)
pxe_setup_nfsdiskless();
nfs_setup_diskless();
if (nfs_diskless_valid)
#endif
rootdevnames[0] = "nfs:";
#endif
}
SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL)
#if defined(NFSCLIENT) && defined(NFS_ROOT) && !defined(BOOTP_NFSROOT)
static int
inaddr_to_sockaddr(char *ev, struct sockaddr_in *sa)
{
u_int32_t a[4];
char *cp;
int count;
bzero(sa, sizeof(*sa));
sa->sin_len = sizeof(*sa);
sa->sin_family = AF_INET;
if ((cp = getenv(ev)) == NULL)
return(1);
count = sscanf(cp, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]);
freeenv(cp);
if (count != 4)
return(1);
/* XXX is this ordering correct? */
sa->sin_addr.s_addr = (a[3] << 24) + (a[2] << 16) + (a[1] << 8) + a[0];
return(0);
}
static int
hwaddr_to_sockaddr(char *ev, struct sockaddr_dl *sa)
{
char *cp;
u_int32_t a[6];
int count;
bzero(sa, sizeof(*sa));
sa->sdl_len = sizeof(*sa);
sa->sdl_family = AF_LINK;
sa->sdl_type = IFT_ETHER;
sa->sdl_alen = ETHER_ADDR_LEN;
if ((cp = getenv(ev)) == NULL)
return(1);
count = sscanf(cp, "%x:%x:%x:%x:%x:%x",
&a[0], &a[1], &a[2], &a[3], &a[4], &a[5]);
freeenv(cp);
if (count != 6)
return(1);
sa->sdl_data[0] = a[0];
sa->sdl_data[1] = a[1];
sa->sdl_data[2] = a[2];
sa->sdl_data[3] = a[3];
sa->sdl_data[4] = a[4];
sa->sdl_data[5] = a[5];
return(0);
}
static int
decode_nfshandle(char *ev, u_char *fh)
{
u_char *cp, *ep;
int len, val;
ep = cp = getenv(ev);
if (cp == NULL)
return(0);
if ((strlen(cp) < 2) || (*cp != 'X')) {
freeenv(ep);
return (0);
}
len = 0;
cp++;
for (;;) {
if (*cp == 'X') {
freeenv(ep);
return(len);
}
if ((sscanf(cp, "%2x", &val) != 1) || (val > 0xff)) {
freeenv(ep);
return(0);
}
*(fh++) = val;
len++;
cp += 2;
if (len > NFSX_V2FH) {
freeenv(ep);
return(0);
}
}
}
/*
* Populate the essential fields in the nfsv3_diskless structure.
*
* The loader is expected to export the following environment variables:
*
* boot.netif.ip IP address on boot interface
* boot.netif.netmask netmask on boot interface
* boot.netif.gateway default gateway (optional)
* boot.netif.hwaddr hardware address of boot interface
* boot.nfsroot.server IP address of root filesystem server
* boot.nfsroot.path path of the root filesystem on server
* boot.nfsroot.nfshandle NFS handle for root filesystem on server
*/
static void
pxe_setup_nfsdiskless(void)
{
struct nfs_diskless *nd = &nfs_diskless;
struct ifnet *ifp;
struct ifaddr *ifa;
struct sockaddr_dl *sdl, ourdl;
struct sockaddr_in myaddr, netmask;
char *cp;
/* set up interface */
if (inaddr_to_sockaddr("boot.netif.ip", &myaddr))
return;
if (inaddr_to_sockaddr("boot.netif.netmask", &netmask)) {
printf("PXE: no netmask\n");
return;
}
bcopy(&myaddr, &nd->myif.ifra_addr, sizeof(myaddr));
bcopy(&myaddr, &nd->myif.ifra_broadaddr, sizeof(myaddr));
((struct sockaddr_in *) &nd->myif.ifra_broadaddr)->sin_addr.s_addr =
myaddr.sin_addr.s_addr | ~ netmask.sin_addr.s_addr;
bcopy(&netmask, &nd->myif.ifra_mask, sizeof(netmask));
if (hwaddr_to_sockaddr("boot.netif.hwaddr", &ourdl)) {
printf("PXE: no hardware address\n");
return;
}
ifa = NULL;
TAILQ_FOREACH(ifp, &ifnet, if_link) {
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
if ((ifa->ifa_addr->sa_family == AF_LINK) &&
(sdl = ((struct sockaddr_dl *)ifa->ifa_addr))) {
if ((sdl->sdl_type == ourdl.sdl_type) &&
(sdl->sdl_alen == ourdl.sdl_alen) &&
!bcmp(sdl->sdl_data + sdl->sdl_nlen,
ourdl.sdl_data + ourdl.sdl_nlen,
sdl->sdl_alen))
goto match_done;
}
}
}
printf("PXE: no interface\n");
return; /* no matching interface */
match_done:
sprintf(nd->myif.ifra_name, "%s%d", ifp->if_name, ifp->if_unit);
/* set up gateway */
inaddr_to_sockaddr("boot.netif.gateway", &nd->mygateway);
/* XXX set up swap? */
/* set up root mount */
nd->root_args.rsize = 8192; /* XXX tunable? */
nd->root_args.wsize = 8192;
nd->root_args.sotype = SOCK_DGRAM;
nd->root_args.flags = (NFSMNT_WSIZE | NFSMNT_RSIZE | NFSMNT_RESVPORT);
if (inaddr_to_sockaddr("boot.nfsroot.server", &nd->root_saddr)) {
printf("PXE: no server\n");
return;
}
nd->root_saddr.sin_port = htons(NFS_PORT);
if (decode_nfshandle("boot.nfsroot.nfshandle", &nd->root_fh[0]) == 0) {
printf("PXE: no NFS handle\n");
return;
}
if ((cp = getenv("boot.nfsroot.path")) != NULL) {
strncpy(nd->root_hostnam, cp, MNAMELEN - 1);
freeenv(cp);
}
nfs_diskless_valid = 1;
}
#endif

View File

@ -5,7 +5,7 @@ KMOD= nfsclient
SRCS= vnode_if.h \
nfs_bio.c nfs_lock.c nfs_node.c nfs_socket.c nfs_subs.c nfs_nfsiod.c \
nfs_vfsops.c nfs_vnops.c nfs_common.c \
opt_inet.h opt_nfs.h opt_bootp.h
opt_inet.h opt_nfs.h opt_bootp.h opt_nfsroot.h
SRCS+= opt_inet6.h
NFS_INET?= 1 # 0/1 - requires INET to be configured in kernel

View File

@ -0,0 +1,232 @@
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
* $FreeBSD$
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_types.h>
#include <net/if_var.h>
#include <net/ethernet.h>
#include <netinet/in.h>
#include <nfs/rpcv2.h>
#include <nfs/nfsproto.h>
#include <nfsclient/nfs.h>
#include <nfsclient/nfsdiskless.h>
static int inaddr_to_sockaddr(char *ev, struct sockaddr_in *sa);
static int hwaddr_to_sockaddr(char *ev, struct sockaddr_dl *sa);
static int decode_nfshandle(char *ev, u_char *fh);
/*
* Populate the essential fields in the nfsv3_diskless structure.
*
* The loader is expected to export the following environment variables:
*
* boot.netif.ip IP address on boot interface
* boot.netif.netmask netmask on boot interface
* boot.netif.gateway default gateway (optional)
* boot.netif.hwaddr hardware address of boot interface
* boot.nfsroot.server IP address of root filesystem server
* boot.nfsroot.path path of the root filesystem on server
* boot.nfsroot.nfshandle NFS handle for root filesystem on server
*/
void
nfs_setup_diskless(void)
{
struct nfs_diskless *nd = &nfs_diskless;
struct ifnet *ifp;
struct ifaddr *ifa;
struct sockaddr_dl *sdl, ourdl;
struct sockaddr_in myaddr, netmask;
char *cp;
if (nfs_diskless_valid)
return;
/* set up interface */
if (inaddr_to_sockaddr("boot.netif.ip", &myaddr))
return;
if (inaddr_to_sockaddr("boot.netif.netmask", &netmask)) {
printf("nfs_diskless: no netmask\n");
return;
}
bcopy(&myaddr, &nd->myif.ifra_addr, sizeof(myaddr));
bcopy(&myaddr, &nd->myif.ifra_broadaddr, sizeof(myaddr));
((struct sockaddr_in *) &nd->myif.ifra_broadaddr)->sin_addr.s_addr =
myaddr.sin_addr.s_addr | ~ netmask.sin_addr.s_addr;
bcopy(&netmask, &nd->myif.ifra_mask, sizeof(netmask));
if (hwaddr_to_sockaddr("boot.netif.hwaddr", &ourdl)) {
printf("nfs_diskless: no hardware address\n");
return;
}
ifa = NULL;
TAILQ_FOREACH(ifp, &ifnet, if_link) {
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
if ((ifa->ifa_addr->sa_family == AF_LINK) &&
(sdl = ((struct sockaddr_dl *)ifa->ifa_addr))) {
if ((sdl->sdl_type == ourdl.sdl_type) &&
(sdl->sdl_alen == ourdl.sdl_alen) &&
!bcmp(sdl->sdl_data + sdl->sdl_nlen,
ourdl.sdl_data + ourdl.sdl_nlen,
sdl->sdl_alen))
goto match_done;
}
}
}
printf("nfs_diskless: no interface\n");
return; /* no matching interface */
match_done:
sprintf(nd->myif.ifra_name, "%s%d", ifp->if_name, ifp->if_unit);
/* set up gateway */
inaddr_to_sockaddr("boot.netif.gateway", &nd->mygateway);
/* XXX set up swap? */
/* set up root mount */
nd->root_args.rsize = 8192; /* XXX tunable? */
nd->root_args.wsize = 8192;
nd->root_args.sotype = SOCK_DGRAM;
nd->root_args.flags = (NFSMNT_WSIZE | NFSMNT_RSIZE | NFSMNT_RESVPORT);
if (inaddr_to_sockaddr("boot.nfsroot.server", &nd->root_saddr)) {
printf("nfs_diskless: no server\n");
return;
}
nd->root_saddr.sin_port = htons(NFS_PORT);
if (decode_nfshandle("boot.nfsroot.nfshandle", &nd->root_fh[0]) == 0) {
printf("nfs_diskless: no NFS handle\n");
return;
}
if ((cp = getenv("boot.nfsroot.path")) != NULL) {
strncpy(nd->root_hostnam, cp, MNAMELEN - 1);
freeenv(cp);
}
nfs_diskless_valid = 1;
}
static int
inaddr_to_sockaddr(char *ev, struct sockaddr_in *sa)
{
u_int32_t a[4];
char *cp;
int count;
bzero(sa, sizeof(*sa));
sa->sin_len = sizeof(*sa);
sa->sin_family = AF_INET;
if ((cp = getenv(ev)) == NULL)
return (1);
count = sscanf(cp, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]);
freeenv(cp);
if (count != 4)
return (1);
sa->sin_addr.s_addr =
htonl((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]);
return (0);
}
static int
hwaddr_to_sockaddr(char *ev, struct sockaddr_dl *sa)
{
char *cp;
u_int32_t a[6];
int count;
bzero(sa, sizeof(*sa));
sa->sdl_len = sizeof(*sa);
sa->sdl_family = AF_LINK;
sa->sdl_type = IFT_ETHER;
sa->sdl_alen = ETHER_ADDR_LEN;
if ((cp = getenv(ev)) == NULL)
return (1);
count = sscanf(cp, "%x:%x:%x:%x:%x:%x",
&a[0], &a[1], &a[2], &a[3], &a[4], &a[5]);
freeenv(cp);
if (count != 6)
return (1);
sa->sdl_data[0] = a[0];
sa->sdl_data[1] = a[1];
sa->sdl_data[2] = a[2];
sa->sdl_data[3] = a[3];
sa->sdl_data[4] = a[4];
sa->sdl_data[5] = a[5];
return (0);
}
static int
decode_nfshandle(char *ev, u_char *fh)
{
u_char *cp, *ep;
int len, val;
ep = cp = getenv(ev);
if (cp == NULL)
return (0);
if ((strlen(cp) < 2) || (*cp != 'X')) {
freeenv(ep);
return (0);
}
len = 0;
cp++;
for (;;) {
if (*cp == 'X') {
freeenv(ep);
return (len);
}
if ((sscanf(cp, "%2x", &val) != 1) || (val > 0xff)) {
freeenv(ep);
return (0);
}
*(fh++) = val;
len++;
cp += 2;
if (len > NFSX_V2FH) {
freeenv(ep);
return (0);
}
}
}

View File

@ -40,6 +40,7 @@
__FBSDID("$FreeBSD$");
#include "opt_bootp.h"
#include "opt_nfsroot.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -384,9 +385,13 @@ nfs_mountroot(struct mount *mp, struct thread *td)
#if defined(BOOTP_NFSROOT) && defined(BOOTP)
bootpc_init(); /* use bootp to get nfs_diskless filled in */
#elif defined(NFS_ROOT)
nfs_setup_diskless();
#endif
if (nfs_diskless_valid==1)
if (nfs_diskless_valid == 0)
return (-1);
if (nfs_diskless_valid == 1)
nfs_convert_diskless();
/*
@ -725,10 +730,8 @@ nfs_mount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp,
size_t len;
u_char nfh[NFSX_V3FHMAX];
if (path == NULL) {
nfs_mountroot(mp, td);
return (0);
}
if (path == NULL)
return (nfs_mountroot(mp, td));
error = copyin(data, (caddr_t)&args, sizeof (struct nfs_args));
if (error)
return (error);

View File

@ -125,6 +125,7 @@ extern struct nfsv3_diskless nfsv3_diskless;
extern struct nfs_diskless nfs_diskless;
extern int nfs_diskless_valid;
void bootpc_init(void);
void nfs_setup_diskless(void);
#endif
#endif

View File

@ -41,7 +41,7 @@ options UFS_DIRHASH #Improve performance on big directories
options MD_ROOT #MD is a potential root device
options NFSCLIENT #Network Filesystem Client
options NFSSERVER #Network Filesystem Server
#options NFS_ROOT #NFS usable as root device
options NFS_ROOT #NFS usable as root device
#options MSDOSFS #MSDOS Filesystem
options CD9660 #ISO 9660 Filesystem
options PROCFS #Process filesystem (requires PSEUDOFS)
@ -200,8 +200,3 @@ options KTR_ENTRIES=8192
options KTR_MASK=KTR_TRAP
options OFW_PCI_DEBUG
#options BOOTP
#options BOOTP_NFSROOT
#options BOOTP_NFSV3
#options BOOTP_COMPAT

View File

@ -47,22 +47,6 @@ static device_t nexusdev;
static void configure(void *);
SYSINIT(configure, SI_SUB_CONFIGURE, SI_ORDER_ANY, configure, NULL);
#ifdef NFS_ROOT
SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL)
#ifndef BOOTP_NFSROOT
#error "NFS_ROOT support not implemented for the non-BOOTP_NFSROOT case"
#endif
extern void bootpc_init(void);
void
cpu_rootconf()
{
bootpc_init();
rootdevnames[0] = "nfs:";
}
#endif
static void
configure(void *v)