diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 941a65f60216..ead56b95303e 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -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 */ diff --git a/usr.sbin/config/configvers.h b/usr.sbin/config/configvers.h index 993fb9403cf0..e65986f19fcd 100644 --- a/usr.sbin/config/configvers.h +++ b/usr.sbin/config/configvers.h @@ -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 diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index e1f2aadcadbd..f52cc2f4d329 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -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); } diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c index edde07ce694a..8559c1af5060 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -307,6 +307,13 @@ makehints(void) fprintf(ofp, "#include \n"); fprintf(ofp, "#include \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 \n"); fprintf(ofp, "#include \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) {