aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/config/main.c
Commit message (Collapse)AuthorAgeFilesLines
* config(8): remove support for -pKonstantin Belousov2021-04-021-4/+0
| | | | | | | | | and other equivalent ways to request mcount-based profiling, like 'profile N' in kernel config. Reviewed by: jhb Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D29529
* config(8): use sbuf to manage line buffersJason A. Harmening2020-04-121-42/+39
| | | | | | | | | | | PR: 245476 Reported by: kevans Reviewed by: imp, kevans MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D24373 Notes: svn path=/head/; revision=359815
* config(8): "fix" a couple of buffer overflowsKyle Evans2020-04-071-4/+24
| | | | | | | | | | | | | | | | | Recently added/changed lines in various kernel configs have caused some buffer overflows that went undetected. These were detected with a config built using -fno-common as these line buffers smashed one of our arrays, then further triaged with ASAN. Double the sizes; this is really not a great fix, but addresses the immediate need until someone rewrites config. While here, add some bounds checking so that we don't need to detect this by random bus errors or other weird failures. MFC after: 3 days Notes: svn path=/head/; revision=359689
* config(8): fixes for -fno-commonKyle Evans2020-03-281-0/+11
| | | | | | | | | | | | | Move this handful of definitions into main.c, properly declare these as extern in config.h. This fixes the config(8) build with -fno-common. Unexplained in my previous commit to gas, -fno-common will become the default in GCC10 and LLVM11, so it's worth addressing these in advance. MFC after: 3 days Notes: svn path=/head/; revision=359389
* Create ../compileWarner Losh2020-02-241-1/+10
| | | | | | | | | | | Give up the battle to keep extra files in $MACHINE/compile to keep the file in the tree. Instead, create CDIR (usually ../compile) if it doesn't exist when we're using a default build location (eg, not using -d). If it does, we do nothing. This only affects people that do old-school builds, but it's bit me a dozen times since last summer so time to fix the bug. Notes: svn path=/head/; revision=358291
* Move initializations of config earlier.Warner Losh2019-08-171-10/+10
| | | | | | | | Inizialize global variables earlier in the process. It doesn't matter today, but may in the future if we want to access these lists earlier in config's run. Notes: svn path=/head/; revision=351155
* Sort getopt(3) options and case statements per style(9)Warner Losh2019-08-151-10/+10
| | | | | | | Alphebetize the options and cases without regard for case. Notes: svn path=/head/; revision=351087
* Fix GCC 4.2 build after r336415, proper declaration and prototypeKyle Evans2018-07-171-2/+3
| | | | Notes: svn path=/head/; revision=336416
* config(8): Add compatibility shims for r335998Kyle Evans2018-07-171-3/+3
| | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=336415
* config(8): Add `envvar` supportKyle Evans2018-06-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | envvar allows adding individual environment variables to the kernel's static environment without the overhead of pulling in a full file. envvar in a config looks like: envvar some_var=5 All envvar-provided variables will be added after the env file is processed, so envvar keys that exist in the previous env will be overwritten by whatever value is set here in the kernel configuration directly. As an aside, envvar lines are intentionally tokenized differently from basically every other line. We used a named state when ENVVAR is encountered to gobble up the rest of the line, which will later be cleaned and validated in post-processing by sanitize_envline. This turns out to be the simplest and cleanest way to allow the flexibility that kenv does while not compromising on silly hacks. Reviewed by: ian (also contributor of sanitize_envline rewrite) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D15962 Notes: svn path=/head/; revision=335642
* Let -s actually work.Bryan Drewery2018-06-221-1/+1
| | | | | | | | MFC after: 2 weeks Sponsored by: Dell EMC Notes: svn path=/head/; revision=335526
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-1/+3
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* Make it clear that we're ignoring the return value fread(3). AllWarner Losh2015-08-241-1/+1
| | | | | | | | | errors that might happen here will be reported a few lines down. CID: 1295248 Notes: svn path=/head/; revision=287087
* config: remove set but unchecked variableEitan Adler2015-04-191-2/+2
| | | | | | | reported by: gcc5.1 Notes: svn path=/head/; revision=281731
* Add -s option to config.Craig Rodrigues2015-01-291-3/+11
| | | | | | | | | | | | | | | This option allows for specifying the directory to use as the location for kernel source files. This option was ported from NetBSD. GitHub Pull Request: https://github.com/freebsd/freebsd/pull/18 Submitted by: Steve Kiernan <stevek@juniper.net>, Simon Gerraty <sjg@juniper.net> Obtained from: Juniper Networks, Inc. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D1722 Relnotes: yes Notes: svn path=/head/; revision=277904
* Consider the negation operator (!) to be a word even if it is not followedIan Lepore2014-11-231-0/+5
| | | | | | | | by whitespace. This allows "optional !foo" which is what most programmers are naturally going to tend to do as opposed to "optional ! foo". Notes: svn path=/head/; revision=274924
* Fix kern/187712: config(8) does not respect KERNCONFDIR.Alan Somers2014-03-201-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | The impact of this bug is that you cannot build a kernel if both of the following are true: 1) The kernel config file is in a non-default location 2) The kernel config file uses the "include" statement from config(5). usr.sbin/config/main.c usr.sbin/config/config.8 usr.sbin/config/config.h usr.sbin/config/lang.l Added a "-I path" option to config(8). By analogy to cc(1), it adds an extra path in which the "include" statement will search for files. Makefile.inc1 Pass "-I ${KERNCONFDIR}" to config(8). PR: kern/187712 Reviewed by: will, imp (previous version) MFC after: 3 weeks Sponsored by: Spectra Logic Corporation Notes: svn path=/head/; revision=263429
* Make the internal assertion correct--only fail when '\0' is found inWojciech A. Koszek2013-05-011-10/+4
| | | | | | | | | | | | | places other than the end of the test section. Otherwise, with kernel compiled with Clang which happens to be setting ELF section alignment differently config(8) was throwing assert() failure unnecessarily Reported by: Kimmo Paasiala <kpaasial (at) gmail.com> Tested by: Kimmo Paasiala <kpaasial (at) gmail.com> MFC after: 10 days Notes: svn path=/head/; revision=250133
* Loosen restrictions for quoted strings. Now we can use more complex stringsJung-uk Kim2013-03-261-2/+10
| | | | | | | | | and "escaped" quote characters. MFC after: 1 month Notes: svn path=/head/; revision=248777
* Fix world after byacc import:Baptiste Daroussin2012-05-221-0/+1
| | | | | | | | | | | - old yacc(1) use to magicially append stdlib.h, while new one don't - new yacc(1) do declare yyparse by itself, fix redundant declaration of 'yyparse' Approved by: des (mentor) Notes: svn path=/head/; revision=235789
* Replace index() and rindex() calls with strchr() and strrchr().Ed Schouten2012-01-031-1/+1
| | | | | | | | | | | | | The index() and rindex() functions were marked LEGACY in the 2001 revision of POSIX and were subsequently removed from the 2008 revision. The strchr() and strrchr() functions are part of the C standard. This makes the source code a lot more consistent, as most of these C files also call into other str*() routines. In fact, about a dozen already perform strchr() calls. Notes: svn path=/head/; revision=229403
* Improve portability of config(8).Ed Schouten2011-07-031-4/+5
| | | | | | | | | | | | | | | - Use strlen(dp->d_name) instead of the unportable dp->d_namlen. Rename i to len to make it slightly more descriptive and prevent negative indexing of the array. - Replace index() by strchr(). This supposedly fixes compilation on GNU systems. Submitted by: Robert Millan <rmh debian org> (original patch) MFC after: 3 weeks Notes: svn path=/head/; revision=223744
* Remove support for creating the 'machine' symlink as well as creating theJohn Baldwin2010-10-291-27/+0
| | | | | | | | | | | | extra MACHINE_ARCH symlink for certain platforms (such as pc98). The support for creating these symlinks was added to sys/conf/kern.post.mk in changeset 152964. The intention of that commit was to remove this code from config(8), but config(8) was never updated. Approved by: imp Notes: svn path=/head/; revision=214523
* Enhance config to handle MACHINEs with multiple architectures:Nathan Whitehorn2010-07-131-9/+20
| | | | | | | | | | | | | | | | - Passing -m to config will now print the MACHINE and MACHINE_ARCH given in the passed kernel configuration file and then exit. - If an option is defined in options.MACHINE with the same name as the architecture of the kernel being configured, that option will be considered set. This allows conditional compilation based on CPU architecture. Config version is now 600010. Reviewed by: imp Notes: svn path=/head/; revision=209969
* sparc64, and possibly other architectures, pads the length of theWarner Losh2010-05-011-7/+11
| | | | | | | | | | | section holding the config file to sh_addralign bytes using NULs. This bogusly triggers an assert. Break out of the loop when we hit an NUL within that many bytes of the end. MFC after: 3 days Notes: svn path=/head/; revision=207461
* Move checking the version up from Makefile generation to just afterWarner Losh2010-04-271-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | we've parsed the config file. Makefile generation is too late if we've introduce changes to the syntax of the metafiles to warn about version skew, since we have to try to parse them and we get an parse error that's rather baffling to the user rather than a 'your config is too old, upgrade' which we should get. We have to defer doing it until after we've read the user's config file because we define machinename there. The version required to compile the kernel is encoded in Makefile.machinename. There's no real reason for this to be the case, but changing it now would introduce some logistical issues that I'd rather avoid for the moment. I intend to revisit this if we're still using config in FreeBSD 10. This also means that we cannot introduce any config metafile changes that result in a syntax error or other error for the user until 9.0 is released. Otherwise, we break the upgrade path, or at least reduce the usefulness of the error messages we generate. # This implies that the config file option mapping will need to be redone. MFC after: 3 days Notes: svn path=/head/; revision=207260
* - Handle calloc() allocation failures.Ruslan Ermilov2010-03-301-9/+11
| | | | | | | | | | | | - Fixed a comment. - 2 -> EXIT_FAILURE in some places. - errx() -> err() where appropriate. PR: 144644 Submitted by: Garrett Cooper Notes: svn path=/head/; revision=205880
* Move the comment to it's correct place.Wojciech A. Koszek2009-02-071-5/+5
| | | | Notes: svn path=/head/; revision=188280
* Remove leftover of alpha support for config(8)--we have MAP_FAILEDWojciech A. Koszek2009-02-071-3/+0
| | | | | | | globally defined. Notes: svn path=/head/; revision=188277
* Make config -x <kernel> only return non-zero characters,Wojciech A. Koszek2009-02-061-2/+13
| | | | | | | | | | | | | so that: config -x <kernel> | grep <something> just works. Reported by: Danny Braniss <danny@cs.huji.ac.il> Notes: svn path=/head/; revision=188214
* Fix a bug introduced by DEFAULTS feature. When the config fileWarner Losh2008-04-101-0/+2
| | | | | | | | | | doesn't exist, we make a directory and then say "oops, that file isn't there" leaving the directory behind. Add a stat for the config file so that we detect this before making the directory. This is semi-lame, but less lame than having this bug. Notes: svn path=/head/; revision=178085
* Honour the logical current working directory ($PWD) when using config'sEd Maste2008-01-081-0/+18
| | | | | | | | | | | -d destdir option. For an automounted src tree using the logical cwd in the Makefile keeps amd(8)'s mount timeout refreshed. Code to check $PWD's validity cribbed from pwd(1). Discussed on hackers@. Notes: svn path=/head/; revision=175163
* Fix some problems that affect multiple file inclusion. Bruce foundWarner Losh2007-05-171-9/+8
| | | | | | | | | | | | | | | | | this bug and submitted these patches to dunstan@. He sent them to me to test, and I discovered they were needed for the atmel kernel config files. Since we were playing with them in the terminal room after the developer's summit today, I thought I'd go ahead and commit them to allow those folks that now have atmel hardware (thanks Andre) a chance to try it out w/o my help. Since dunstan@ is asleep right now, risk stepping on his toes a little by going ahead and committing this change. Submitted by: dunstan@, bde@ Tested by: bde@ Notes: svn path=/head/; revision=169647
* This is loser's commit message:Wojciech A. Koszek2007-05-121-1/+12
| | | | | | | | | | | | | | Remember about tricky cases, where options contain unfriendly characters, from the ANSI-C string point of view ('"' in this case). The x09 build breakage was caused by SC_CUT_SEPCHARS options. I did test this patch number of times; each time unprofessionally and inappropriately. OKed by: cognet (mentor) Notes: svn path=/head/; revision=169512
* Improve INCLUDE_CONFIG_FILE support.Wojciech A. Koszek2007-05-121-46/+203
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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@ Notes: svn path=/head/; revision=169507
* End my resistance to jmg's multiple hints files and bring in supportWarner Losh2006-10-241-0/+1
| | | | | | | | for having multiple hints files generate a correct hints.c (eg, with all the specified ones catenated together). Notes: svn path=/head/; revision=163638
* Use calloc() instead of zeroing the memory our own.Xin LI2006-06-071-2/+1
| | | | Notes: svn path=/head/; revision=159362
* - Change the exit message from "make cleandepend; make depend" toFlorent Thoumie2006-01-141-1/+1
| | | | | | | | | | | | "make cleandepend && make depend". PR: bin/91765 Submitted by: Soeren Straarup <xride@x12.dk> Approved by: cpercival MFC after: 3 days Notes: svn path=/head/; revision=154338
* Clean up most of the "XXX"-tagged items:Ruslan Ermilov2005-12-301-0/+15
| | | | | | | | | | | | | | - The code that creates hints.c and env.c from the skeleton files moved into separate functions. - Sanity checks for missing "ident" and "cputype" directives moved into main(), alongside the existing check for "machine". PR: bin/90310 Submitted by: Matt Emmerton <matt@gsicomp.on.ca> Notes: svn path=/head/; revision=153888
* Style: use S_ISDIR() (submitted by bde@) and eq() where appropriate.Ruslan Ermilov2005-11-301-4/+3
| | | | Notes: svn path=/head/; revision=152963
* The DEFAULTS changes caused the user specified config file to be openedPeter Wemm2005-11-291-0/+5
| | | | | | | | | | | | | | | | | | much later than before, and it is now after we do a mkdir ../compile/FILE. As a result, if you do 'config DOESNOTEXIST', it now creates the directory ../config/DOESNOTEXIST. It did not do that before. If DEFAULTS does not exist, it still fails early before any permanent changes. This shameless hack restores the old behavior of ensuring the config file actually exists before mkdiring its counterpart directory. Now I can rmdir ../compile/D and it will stay dead, after my fingers keep sabotaging me with 'config D<tab><enter>'. (Some of my kernel names started with D, which used to be 1-character unique and my fingers knew this very well...) Notes: svn path=/head/; revision=152937
* Optionally include a DEFAULTS config file if it is present in the currentJohn Baldwin2005-10-271-3/+10
| | | | | | | | | | | | | | | | directory before the specified config file. This is implemented by opening DEFAULTS as stdin if it exists, and if so resetting stdin to the actual config file when DEFAULTS is fully parsed via yywrap(). In short, this lets us create DEFAULTS kernel configs in /sys/<arch>/conf that can enable certain options or devices by default and allow users to disable them via 'nooptions' or 'nodevice' rather than having to create kludge NO_FOO options. Requested by: scottl Reviewed by: scottl Notes: svn path=/head/; revision=151744
* Put rev. 1.65 into usage().David E. O'Brien2005-08-111-1/+1
| | | | Notes: svn path=/head/; revision=148962
* Add an option to tell what version of config(8) this is.David E. O'Brien2005-08-101-1/+5
| | | | Notes: svn path=/head/; revision=148916
* Ask that "make cleandepend" be run before "make depend", now thatRuslan Ermilov2005-04-221-1/+1
| | | | | | | | | we don't do this automatically. Suggested by: bde Notes: svn path=/head/; revision=145405
* Allow one to specify a second parameter to the machine line. ThisWarner Losh2005-04-011-0/+14
| | | | | | | | | | | | | | allows us to specify the machine_arch as well as machine. If specified then a second link will be made, similar to machine, from $MACHINE_ARCH to $S/$MACHINE_ARCH/include. This is for ports where MACHINE != MACHINE_ARCH (pc98 today, others in the future?). Reviewed by: arch@, nyan@ Notes: svn path=/head/; revision=144509
* style(9) nitsWarner Losh2005-03-301-2/+3
| | | | Notes: svn path=/head/; revision=144352
* Unstaticize config. It was being optimized away.Dag-Erling Smørgrav2005-03-271-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=144179
* Per letter dated July 22, 1999, delete clause 3 from code directlyWarner Losh2004-08-071-4/+0
| | | | | | | from Berkeley. Notes: svn path=/head/; revision=133248