From 02abda66c904ea2231085391b87ff646ed995a2f Mon Sep 17 00:00:00 2001 From: simonb Date: Mon, 17 Aug 2020 06:23:01 +0000 Subject: [PATCH] Handle using "octeth" as root device by converting "octethN" to "cnmacN" for any N < 100. This allows booting for u-boot to use root=$(ethact) on the command line and the kernel can use the ethernet interface the kernel was loaded on as the NFS root device. --- sys/arch/evbmips/cavium/autoconf.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/arch/evbmips/cavium/autoconf.c b/sys/arch/evbmips/cavium/autoconf.c index f5a9524d573f..d09e6ce029a4 100644 --- a/sys/arch/evbmips/cavium/autoconf.c +++ b/sys/arch/evbmips/cavium/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.8 2020/06/23 05:19:12 simonb Exp $ */ +/* $NetBSD: autoconf.c,v 1.9 2020/08/17 06:23:01 simonb Exp $ */ /* * Copyright 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.8 2020/06/23 05:19:12 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.9 2020/08/17 06:23:01 simonb Exp $"); #include #include @@ -95,12 +95,24 @@ findroot(void) return; if (rootspec && *rootspec) { + /* if we get passed root=octethN, convert to cnmacN */ + if (strncmp(rootspec, "octeth", 6) == 0) { + /* allow for up to 100 interfaces */ + static char buf[sizeof("cnmacXX")]; + const char *cp = &rootspec[strlen("octeth")]; + + KASSERT(strlen(cp) < sizeof("XX")); + snprintf(buf, sizeof(buf), "cnmac%s", cp); + rootspec = buf; + } + /* XXX hard coded "cnmac" for network boot */ if (strncmp(rootspec, "cnmac", 5) == 0) { rootfstype = "nfs"; netboot = 1; return; } + /* * XXX * Assume that if the root spec is not a cnmac, it'll