Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 May 2013 15:13:02 +0000
From:      "Eggert, Lars" <lars@netapp.com>
To:        Rick Macklem <rmacklem@uoguelph.ca>
Cc:        Craig Rodrigues <rodrigc@crodrigues.org>, "<freebsd-current@freebsd.org>" <freebsd-current@freebsd.org>
Subject:   Re: mounting root from NFS via ROOTDEVNAME
Message-ID:  <375AA8A5-E385-4528-A460-D4B8FCB9497B@netapp.com>
In-Reply-To: <1435656219.2547176.1359645941027.JavaMail.root@erie.cs.uoguelph.ca>
References:  <1435656219.2547176.1359645941027.JavaMail.root@erie.cs.uoguelph.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

to conclude this thread, the patch below allows one to specify an nfs rootf=
s via the ROOTDEVNAME kernel option, which will be mounted when BOOTP does =
not return a root-path option.

Lars


diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c
index 2c57a91..972fb12 100644
--- a/sys/nfs/bootp_subr.c
+++ b/sys/nfs/bootp_subr.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
=20
 #include "opt_bootp.h"
 #include "opt_nfs.h"
+#include "opt_rootdevname.h"
=20
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -870,8 +871,20 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct =
thread *td)
 					rtimo =3D time_second +
 						BOOTP_SETTLE_DELAY;
 					printf(" (got root path)");
-				} else
+				} else {
 					printf(" (no root path)");
+#ifdef ROOTDEVNAME
+					/*
+					 * If we'll mount rootfs from
+					 * ROOTDEVNAME, we can accept
+					 * offers without root paths.
+					 */
+					gotrootpath =3D 1;
+					rtimo =3D time_second +
+						BOOTP_SETTLE_DELAY;
+					printf(" (ROOTDEVNAME)");
+#endif
+				}
 				printf("\n");
 			}
 		} /* while secs */
@@ -1440,6 +1453,16 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struc=
t bootpc_ifcontext *ifctx,
=20
 	p =3D bootpc_tag(&gctx->tag, &ifctx->reply, ifctx->replylen,
 		       TAG_ROOT);
+#ifdef ROOTDEVNAME
+	/*
+	 * If there was no root path in BOOTP, use the one in ROOTDEVNAME.
+	 */
+	if (p =3D=3D NULL) {
+		p =3D strdup(ROOTDEVNAME, M_TEMP);
+		if (strcmp(strsep(&p, ":"), "nfs") !=3D 0)
+			panic("ROOTDEVNAME is not an NFS mount point");
+	}
+#endif
 	if (p !=3D NULL) {
 		if (gctx->setrootfs !=3D NULL) {
 			printf("rootfs %s (ignored) ", p);




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?375AA8A5-E385-4528-A460-D4B8FCB9497B>