svn commit: r336415 - head/usr.sbin/config

Kyle Evans kevans at FreeBSD.org
Tue Jul 17 14:14:55 UTC 2018


Author: kevans
Date: Tue Jul 17 14:14:53 2018
New Revision: 336415
URL: https://svnweb.freebsd.org/changeset/base/336415

Log:
  config(8): Add compatibility shims for r335998
  
  Plumb the %VERSREQ from Makefile.<arch> through to the rest of config(8).
  We've recorded the config(8) version that we're calling "the end of
  envmode and hintmode," and we'll write them out for earlier versions. Later
  kernel version bumps will remove envmode/hintmode from the kernel as needed,
  which is OK since the current kernel does not use them at all.
  
  These compatibility shims really need to go away when the major version
  rolls over...
  
  Discussed with:	imp

Modified:
  head/usr.sbin/config/config.h
  head/usr.sbin/config/configvers.h
  head/usr.sbin/config/main.c
  head/usr.sbin/config/mkmakefile.c

Modified: head/usr.sbin/config/config.h
==============================================================================
--- head/usr.sbin/config/config.h	Tue Jul 17 14:11:30 2018	(r336414)
+++ head/usr.sbin/config/config.h	Tue Jul 17 14:14:53 2018	(r336415)
@@ -212,6 +212,7 @@ extern int	debugging;
 extern int	found_defaults;
 
 extern int	maxusers;
+extern int	versreq;
 
 extern char *PREFIX;		/* Config file name - for error messages */
 extern char srcdir[];		/* root of the kernel source tree */

Modified: head/usr.sbin/config/configvers.h
==============================================================================
--- head/usr.sbin/config/configvers.h	Tue Jul 17 14:11:30 2018	(r336414)
+++ head/usr.sbin/config/configvers.h	Tue Jul 17 14:14:53 2018	(r336415)
@@ -49,5 +49,8 @@
  *
  * $FreeBSD$
  */
-#define	CONFIGVERS	600015
+#define	CONFIGVERS	600016
 #define	MAJOR_VERS(x)	((x) / 100000)
+
+/* Last config(8) version to require envmode/hintmode */
+#define	CONFIGVERS_ENVMODE_REQ	600015

Modified: head/usr.sbin/config/main.c
==============================================================================
--- head/usr.sbin/config/main.c	Tue Jul 17 14:11:30 2018	(r336414)
+++ head/usr.sbin/config/main.c	Tue Jul 17 14:14:53 2018	(r336415)
@@ -86,6 +86,7 @@ int	incignore;
  * literally).
  */
 int	filebased = 0;
+int	versreq;
 
 static void configfile(void);
 static void get_srcdir(void);
@@ -743,7 +744,7 @@ kernconfdump(const char *file)
 }
 
 static void 
-badversion(int versreq)
+badversion()
 {
 	fprintf(stderr, "ERROR: version of config(8) does not match kernel!\n");
 	fprintf(stderr, "config version = %d, ", CONFIGVERS);
@@ -763,7 +764,6 @@ checkversion(void)
 {
 	FILE *ifp;
 	char line[BUFSIZ];
-	int versreq;
 
 	ifp = open_makefile_template();
 	while (fgets(line, BUFSIZ, ifp) != 0) {
@@ -775,7 +775,7 @@ checkversion(void)
 		if (MAJOR_VERS(versreq) == MAJOR_VERS(CONFIGVERS) &&
 		    versreq <= CONFIGVERS)
 			continue;
-		badversion(versreq);
+		badversion();
 	}
 	fclose(ifp);
 }

Modified: head/usr.sbin/config/mkmakefile.c
==============================================================================
--- head/usr.sbin/config/mkmakefile.c	Tue Jul 17 14:11:30 2018	(r336414)
+++ head/usr.sbin/config/mkmakefile.c	Tue Jul 17 14:14:53 2018	(r336415)
@@ -307,6 +307,13 @@ makehints(void)
 	fprintf(ofp, "#include <sys/types.h>\n");
 	fprintf(ofp, "#include <sys/systm.h>\n");
 	fprintf(ofp, "\n");
+	/*
+	 * Write out hintmode for older kernels. Remove when config(8) major
+	 * version rolls over.
+	 */
+	if (versreq <= CONFIGVERS_ENVMODE_REQ)
+		fprintf(ofp, "int hintmode = %d;\n",
+			STAILQ_EMPTY(&hints) ? 1 : 0);
 	fprintf(ofp, "char static_hints[] = {\n");
 	nvl = nvlist_create(0);
 	STAILQ_FOREACH(hint, &hints, hint_next) {
@@ -341,6 +348,13 @@ makeenv(void)
 	fprintf(ofp, "#include <sys/types.h>\n");
 	fprintf(ofp, "#include <sys/systm.h>\n");
 	fprintf(ofp, "\n");
+	/*
+	 * Write out envmode for older kernels. Remove when config(8) major
+	 * version rolls over.
+	 */
+	if (versreq <= CONFIGVERS_ENVMODE_REQ)
+		fprintf(ofp, "int envmode = %d;\n",
+			STAILQ_EMPTY(&envvars) ? 1 : 0);
 	fprintf(ofp, "char static_env[] = {\n");
 	nvl = nvlist_create(0);
 	STAILQ_FOREACH(envvar, &envvars, envvar_next) {


More information about the svn-src-head mailing list