diff options
author | wkoszek <wkoszek@FreeBSD.org> | 2007-05-12 19:38:18 +0000 |
---|---|---|
committer | wkoszek <wkoszek@FreeBSD.org> | 2007-05-12 19:38:18 +0000 |
commit | 2e673327ec1ac7c1b4a99f2bfe326756e0547067 (patch) | |
tree | 7df0bae947c0e7aa57e02e7373440d236848d9d0 /usr.sbin/config/lang.l | |
parent | a0d76ca625afcd4dd4e8a520e6855ba3b9bc2c96 (diff) | |
download | FreeBSD-src-2e673327ec1ac7c1b4a99f2bfe326756e0547067.zip FreeBSD-src-2e673327ec1ac7c1b4a99f2bfe326756e0547067.tar.gz |
Improve INCLUDE_CONFIG_FILE support.
This change will let us to have full configuration of a running kernel
available in sysctl:
sysctl -b kern.conftxt
The same configuration is also contained within the kernel image. It can be
obtained with:
config -x <kernelfile>
Current functionality lets you to quickly recover kernel configuration, by
simply redirecting output from commands presented above and starting kernel
build procedure. "include" statements are also honored, which means options
and devices from included files are also included.
Please note that comments from configuration files are not preserved by
default. In order to preserve them, you can use -C flag for config(8). This
will bring configuration file and included files literally; however,
redirection to a file no longer works directly.
This commit was followed by discussion, that took place on freebsd-current@.
For more details, look here:
http://lists.freebsd.org/pipermail/freebsd-current/2007-March/069994.html
http://lists.freebsd.org/pipermail/freebsd-current/2007-May/071844.html
Development of this patch took place in Perforce, hierarchy:
//depot/user/wkoszek/wkoszek_kconftxt/
Support from: freebsd-current@ (links above)
Reviewed by: imp@
Approved by: imp@
Diffstat (limited to 'usr.sbin/config/lang.l')
-rw-r--r-- | usr.sbin/config/lang.l | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l index 4eb0de7..2f2886e 100644 --- a/usr.sbin/config/lang.l +++ b/usr.sbin/config/lang.l @@ -207,6 +207,30 @@ hex(const char *str) return num; } +void +cfgfile_add(const char *fname) +{ + struct cfgfile *cf; + + cf = calloc(1, sizeof(*cf)); + assert(cf != NULL); + asprintf(&cf->cfg_path, "%s", fname); + STAILQ_INSERT_TAIL(&cfgfiles, cf, cfg_next); +} + +void +cfgfile_removeall(void) +{ + struct cfgfile *cf; + + while (!STAILQ_EMPTY(&cfgfiles)) { + cf = STAILQ_FIRST(&cfgfiles); + STAILQ_REMOVE_HEAD(&cfgfiles, cfg_next); + if (cf->cfg_path != NULL) + free(cf->cfg_path); + free(cf); + } +} /* * Open the named file for inclusion at the current point. Returns 0 on @@ -222,6 +246,7 @@ include(const char *fname, int ateof) struct incl *in; char *fnamebuf; + fnamebuf = NULL; fp = fopen(fname, "r"); if (fp == NULL && fname[0] != '.' && fname[0] != '/') { asprintf(&fnamebuf, "../../conf/%s", fname); @@ -234,6 +259,7 @@ include(const char *fname, int ateof) yyerror("cannot open included file"); return (-1); } + cfgfile_add(fnamebuf == NULL ? fname : fnamebuf); in = malloc(sizeof(*in)); assert(in != NULL); in->in_prev = inclp; |