diff options
Diffstat (limited to 'usr.sbin/config')
-rw-r--r-- | usr.sbin/config/config.8 | 7 | ||||
-rw-r--r-- | usr.sbin/config/config.h | 7 | ||||
-rw-r--r-- | usr.sbin/config/lang.l | 13 | ||||
-rw-r--r-- | usr.sbin/config/main.c | 12 |
4 files changed, 38 insertions, 1 deletions
diff --git a/usr.sbin/config/config.8 b/usr.sbin/config/config.8 index 784b06b..79520a7 100644 --- a/usr.sbin/config/config.8 +++ b/usr.sbin/config/config.8 @@ -37,6 +37,7 @@ .Sh SYNOPSIS .Nm .Op Fl CVgp +.Op Fl I Ar path .Op Fl d Ar destdir .Ar SYSTEM_NAME .Nm @@ -69,6 +70,12 @@ If the INCLUDE_CONFIG_FILE is present in a configuration file, kernel image will contain full configuration files included literally (preserving comments). This flag is kept for backward compatibility. +.It Fl I Ar path +Search in +.Ar path +for any file included by the +.Ic include +directive. This option may be specified more than once. .It Fl d Ar destdir Use .Ar destdir diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index f275749..93b2086 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -144,6 +144,13 @@ struct hint { STAILQ_HEAD(hint_head, hint) hints; +struct includepath { + char *path; + SLIST_ENTRY(includepath) path_next; +}; + +SLIST_HEAD(, includepath) includepath; + /* * Tag present in the kernelconf.tmlp template file. It's mandatory for those * two strings to be the same. Otherwise you'll get into trouble. diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l index 3e4e115..14fa7da 100644 --- a/usr.sbin/config/lang.l +++ b/usr.sbin/config/lang.l @@ -34,6 +34,7 @@ #include <assert.h> #include <ctype.h> #include <err.h> +#include <stdlib.h> #include <string.h> #include "y.tab.h" #include "config.h" @@ -257,6 +258,7 @@ include(const char *fname, int ateof) { FILE *fp; struct incl *in; + struct includepath* ipath; char *fnamebuf; fnamebuf = NULL; @@ -269,6 +271,17 @@ include(const char *fname, int ateof) } } if (fp == NULL) { + SLIST_FOREACH(ipath, &includepath, path_next) { + asprintf(&fnamebuf, "%s/%s", ipath->path, fname); + if (fnamebuf != NULL) { + fp = fopen(fnamebuf, "r"); + free(fnamebuf); + } + if (fp != NULL) + break; + } + } + if (fp == NULL) { yyerror("cannot open included file"); return (-1); } diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index 78bb13d..86ecfa6 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -110,15 +110,25 @@ main(int argc, char **argv) int ch, len; char *p; char *kernfile; + struct includepath* ipath; int printmachine; printmachine = 0; kernfile = NULL; - while ((ch = getopt(argc, argv, "Cd:gmpVx:")) != -1) + SLIST_INIT(&includepath); + while ((ch = getopt(argc, argv, "CI:d:gmpVx:")) != -1) switch (ch) { case 'C': filebased = 1; break; + case 'I': + ipath = (struct includepath *) \ + calloc(1, sizeof (struct includepath)); + if (ipath == NULL) + err(EXIT_FAILURE, "calloc"); + ipath->path = optarg; + SLIST_INSERT_HEAD(&includepath, ipath, path_next); + break; case 'm': printmachine = 1; break; |