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
This commit is contained in:
Kyle Evans 2018-07-17 14:14:53 +00:00
parent e47edf50dd
commit 8e62839eb1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=336415
4 changed files with 22 additions and 4 deletions

View File

@ -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 */

View File

@ -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

View File

@ -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);
}

View File

@ -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) {