From owner-freebsd-current@FreeBSD.ORG Mon Jun 3 07:06:46 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 7B2861F5 for ; Mon, 3 Jun 2013 07:06:46 +0000 (UTC) (envelope-from crodr001@gmail.com) Received: from mail-la0-x232.google.com (mail-la0-x232.google.com [IPv6:2a00:1450:4010:c03::232]) by mx1.freebsd.org (Postfix) with ESMTP id DF2291B0C for ; Mon, 3 Jun 2013 07:06:45 +0000 (UTC) Received: by mail-la0-f50.google.com with SMTP id ed20so3048590lab.23 for ; Mon, 03 Jun 2013 00:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=e5KSYvirBgZf9iAYZKRIiTOKDcHoNZoH2BixpJl/n8E=; b=nxkspFN+BtM0mt3NZJOY9iilerxlLNdKdVwtdc92HrGu4Z+C/KFdQekQ34PEM3XQ3/ idWbO3AqdQwqIFyCli6RIsKnFnPr7cB8PHUvg0f1GxB2WPx48cSrwwpk4Yowc6dOrnb7 WwBJqjeD04XYuDZpoTEkaNqtrrTrnwWcfjkdN9jCoLyNHkW6F9OCfYuz8alxFe9/W0zD zvnb7cev/jWj9Y6h5VfUwFjiwJadE9qkSLG1h6pC0xrsP5JRq1PMa/yJ2LEJa/tm0GeT 9RkExcDGaTAJv6rkUzKg2Fx5GVXQtn8NEkVS1Y0YEK1H18i4/O77P58K5VwYtV0dwxCB jg4A== MIME-Version: 1.0 X-Received: by 10.112.201.102 with SMTP id jz6mr6753949lbc.42.1370243204824; Mon, 03 Jun 2013 00:06:44 -0700 (PDT) Sender: crodr001@gmail.com Received: by 10.112.53.231 with HTTP; Mon, 3 Jun 2013 00:06:44 -0700 (PDT) In-Reply-To: <375AA8A5-E385-4528-A460-D4B8FCB9497B@netapp.com> References: <1435656219.2547176.1359645941027.JavaMail.root@erie.cs.uoguelph.ca> <375AA8A5-E385-4528-A460-D4B8FCB9497B@netapp.com> Date: Mon, 3 Jun 2013 00:06:44 -0700 X-Google-Sender-Auth: _4wXI6L5kVq69gG4kVmjhsI25gI Message-ID: Subject: Re: mounting root from NFS via ROOTDEVNAME From: Craig Rodrigues To: "Eggert, Lars" Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: Rick Macklem , "" X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 07:06:46 -0000 On Tue, May 28, 2013 at 8:13 AM, Eggert, Lars wrote: > Hi, > > to conclude this thread, the patch below allows one to specify an nfs > rootfs 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$"); > > #include "opt_bootp.h" > #include "opt_nfs.h" > +#include "opt_rootdevname.h" > > #include > #include > @@ -870,8 +871,20 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct > thread *td) > rtimo = 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 = 1; > + rtimo = time_second + > + BOOTP_SETTLE_DELAY; > + printf(" (ROOTDEVNAME)"); > +#endif > + } > printf("\n"); > } > } /* while secs */ > @@ -1440,6 +1453,16 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, > struct bootpc_ifcontext *ifctx, > > p = 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 == NULL) { > + p = strdup(ROOTDEVNAME, M_TEMP); > + if (strcmp(strsep(&p, ":"), "nfs") != 0) > + panic("ROOTDEVNAME is not an NFS mount point"); > + } > +#endif > if (p != NULL) { > if (gctx->setrootfs != NULL) { > printf("rootfs %s (ignored) ", p); > Sorry for not responding, I've been busy for the past few days. Thank you for persisting with this, and trying to clean this up. This is relatively old code that hasn't been touched in about 15 years, so not that many people have worked on it. I don't like things like ROOTDEVNAME which need to be specified in the kernel config and are not part of the GENERIC kernel. This usually ends up where code which is behind #ifdef ROOTDEVNAME will bitrot because not everyone uses it. I would like to see the ROOTDEVNAME kernel option go away, in favor of a variable that can be specified in loader.conf. If I search the code via Opengrok, I with this: http://bxr.su/s?n=25&start=25&sort=relevancy&q=ROOTDEVNAME&project=FreeBSD there already seems to be a variable "rootdev" that is checked in a bunch of places in the loader, so it would be nice if we could use that. My personal preference would be to delete ROOTDEVNAME from all the kernel configs and deprecate the kernel option, and instead use a tunable variable which could be set in loader.conf. This may not be practical. Do you think it would be doable if we can have something like this in the kernel code: const char *rootdevname = #ifdef ROOTDEVNAME rootdevname = ROOTDEVNAME; #else rootdevname = NULL #endif if (rootdevname == NULL) { rootdevname = getenv("rootdev"); } or something like that? -- Craig