Commit Graph

142 Commits

Author SHA1 Message Date
Kyle Evans
aebda5bf06 config(8): replace opteq with a call to strcasecmp
This obscures the comparison slightly less; when option name appear in
files, they are case-insensitive.

MFC after:	1 week
2019-04-15 21:20:06 +00:00
Kyle Evans
53fb9a2475 Remove variable re-inserted during mis-application of r336973 2018-07-31 16:08:17 +00:00
Kyle Evans
2870403b53 Re-insert variable disappeared during mis-application of r336973 2018-07-31 16:04:49 +00:00
Kyle Evans
9e7178f5c7 config(8): Strip comments from env lines
Consolidates the small bits of logic required for preprocessing a line
before inclusion into a file or nvlist.
2018-07-31 16:03:30 +00:00
Kyle Evans
761d344c16 config(8): Invert checks; envmode/hintmode reflect "env provided"1 2018-07-17 15:16:34 +00:00
Kyle Evans
8e62839eb1 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
2018-07-17 14:14:53 +00:00
Kyle Evans
88171893e2 config(8): De-dupe hint/env vars within a single file
r335653 flipped the order in which hints/env files are concatenated to match
the order in which vars are processed by the kernel. This is the other
hammer to drop.

Use nv(9) to de-dupe entries within a single `hint` or `env` file, using the
latest value specified for a key. This leaves some duplicates if a variable
is specified in multiple hint/env files or via `envvar` in a kernel config,
but the reversed order of concatenation (from r335653) makes this a
non-issue as the latest-specified version will be seen first.

This change also silently rewrote hint bits to use the same sanitization
process that ian@ wrote for r335642. To the kernel, hints and env vars are
basically the same thing through early boot, then get merged into the
dynamic environment once kmem becomes available and the dynamic environment
is created. They should be subjected to the same restrictions.

libnv has been added to -legacy for the time being to support the build of
config(8) with the new cnvlist API.

Tested with:	universe (11 host & 12 host)
MFC after:	1 month
2018-07-06 01:11:06 +00:00
Kyle Evans
417d105fae Revert r336011,r336012 until I can competently test 2018-07-05 18:55:42 +00:00
Kyle Evans
f1e0a986a8 Fix build after r336011
Add libnv to bootstrap-tools, use ${SRCTOP}/sys headers.
2018-07-05 18:39:02 +00:00
Kyle Evans
51c854f028 config(8): De-dupe hint/env vars within a single file
r335653 flipped the order in which hints/env files are concatenated to match
the order in which vars are processed by the kernel. This is the other
hammer to drop.

Use nv(9) to de-dupe entries within a single `hint` or `env` file, using the
latest value specified for a key. This leaves some duplicates if a variable
is specified in multiple hint/env files or via `envvar` in a kernel config,
but the reversed order of concatenation (from r335653) makes this a
non-issue as the latest-specified version will be seen first.

This change also silently rewrote hint bits to use the same sanitization
process that ian@ wrote for r335642. To the kernel, hints and env vars are
basically the same thing through early boot, then get merged into the
dynamic environment once kmem becomes available and the dynamic environment
is created. They should be subjected to the same restrictions.

MFC after:	1 month
2018-07-05 17:53:51 +00:00
Kyle Evans
39d44f7f15 kern_environment: use any provided environments, evict hintmode/envmode
At the moment, hintmode and envmode are used to indicate whether static
hints or static env have been provided in the kernel config(5) and the
static versions are mutually exclusive with loader(8)-provided environment.
hintmode *can* be reconfigured later to pull from the dynamic environment,
thus taking advantage of the loader(8) or post-kmem environment setting.

This changeset fixes both problems at once to move us from a semi-confusing
state to a consistent state: if an environment file, hints file, or
loader(8) environment are provided, we use them in a well-known order of
precedence:

- loader(8) environment
- static environment
- static hints file

Once the dynamic environment is setup this becomes a moot point. The
loader(8) and static environments are merged (respecting the above order of
precedence), and the static hints are merged in on an as-needed basis after
the dynamic environment has been setup.

Hints lookup are changed to respect all of the above. Before the dynamic
environment is setup, lookups use the above-mentioned order and fallback to
the next environment if a matching hint is not found. Once the dynamic
environment is setup, that is used on its own since it captures all of the
above information plus any dynamic kenv settings that came up later in boot.

The following tangentially related changes were made to res_find:

- A hintp cookie is now passed in so that related searches continue using
  the chain of environments (or dynamic environment) without relying on
  global state
- All three environments will be searched if they actually have valid hints
  to use, rather than just choosing the first environment that actually had
  a hint and rolling with that only

The hintmode sysctl has been ripped out. static_{env,hints}.disabled are
still honored and will disable their respective environments from being used
for hint lookups and from being merged into the dynamic environment, as
expected.

MFC after:	1 month (maybe)
Differential Revision:	https://reviews.freebsd.org/D15953
2018-07-05 16:30:32 +00:00
Kyle Evans
e28687347f Revert r335995 due to accidental changes snuck in 2018-07-05 16:28:43 +00:00
Kyle Evans
8ef5886303 kern_environment: use any provided environments, evict hintmode/envmode
At the moment, hintmode and envmode are used to indicate whether static
hints or static env have been provided in the kernel config(5) and the
static versions are mutually exclusive with loader(8)-provided environment.
hintmode *can* be reconfigured later to pull from the dynamic environment,
thus taking advantage of the loader(8) or post-kmem environment setting.

This changeset fixes both problems at once to move us from a semi-confusing
state to a consistent state: if an environment file, hints file, or
loader(8) environment are provided, we use them in a well-known order of
precedence:

- loader(8) environment
- static environment
- static hints file

Once the dynamic environment is setup this becomes a moot point. The
loader(8) and static environments are merged (respecting the above order of
precedence), and the static hints are merged in on an as-needed basis after
the dynamic environment has been setup.

Hints lookup are changed to respect all of the above. Before the dynamic
environment is setup, lookups use the above-mentioned order and fallback to
the next environment if a matching hint is not found. Once the dynamic
environment is setup, that is used on its own since it captures all of the
above information plus any dynamic kenv settings that came up later in boot.

The following tangentially related changes were made to res_find:

- A hintp cookie is now passed in so that related searches continue using
  the chain of environments (or dynamic environment) without relying on
  global state
- All three environments will be searched if they actually have valid hints
  to use, rather than just choosing the first environment that actually had
  a hint and rolling with that only

The hintmode sysctl has been ripped out. static_{env,hints}.disabled are
still honored and will disable their respective environments from being used
for hint lookups and from being merged into the dynamic environment, as
expected.

MFC after:	1 month (maybe)
Differential Revision:	https://reviews.freebsd.org/D15953
2018-07-05 16:25:48 +00:00
Kyle Evans
67fc3f5608 config(8): part of patch disappeared, don't close ifp at the end 2018-06-26 04:06:49 +00:00
Kyle Evans
4edfa9085a config(8): Make 'env' files consistent with other file-accepting options
Previously, only one 'env' file could be specified. Later 'env' directives
would overwrite earlier 'env' directives. This is inconsistent with every
other file-accepting directives which process files in order, including
hints.

A caveat applies to both hints and env that isn't mentioned: they're
concatenated in the order of appearance, so they're not actually applied in
the way one might think by supplying:

hints x
hints y

Hints in x will take precedence over same-name hints in y due to how
the kernel processes them, stopping at the first line that matches the hint
we're searching for. Future work will flip the order of concatenation so
that later files may still properly override earlier files.

In practice, this likely doesn't matter at all due to the nature of the
beast.
2018-06-26 03:56:10 +00:00
Kyle Evans
3b31596dc8 config(8): Add envvar support
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
2018-06-25 17:17:47 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
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.
2017-11-20 19:49:47 +00:00
Bryan Drewery
1bf59a71c7 Fix 'local' to not look in the source tree for the file.
Usually 'local' is used along with other rules such as 'no-implicit-rule' or
'dependency' which avoids this problem.  It's possible to need to use 'local'
while relying on the default rules though for a file which is not in the source
tree nor generated in the kernel.

Sponsored by:	Dell
Differential Revision:	https://reviews.freebsd.org/D13125
2017-11-17 18:34:14 +00:00
Warner Losh
1cbb58886a Remove build system support for lint.
Differential Revision: https://reviews.freebsd.org/D13124
2017-11-17 18:16:46 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
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
2017-02-28 23:42:47 +00:00
Marcelo Araujo
1f3d62ab98 For pointers use NULL instead of 0.
Reviewed by:	rpaulo
MFC after:	2 weeks.
Differential Revision:	https://reviews.freebsd.org/D5946
2016-04-27 03:06:53 +00:00
Rui Paulo
8ed645520e Fix two memory leaks in config(8).
PR:		202145
Submitted by:	Kurt Lidl <lidl pix.net>
2015-10-13 20:25:03 +00:00
Ian Lepore
0fe8749f47 Fix the negation (!) operator so that it binds only to the word that
immediately follows it, which means 'not' has to be reset every time an
option word or device name is processed.
2014-11-23 23:58:47 +00:00
Warner Losh
2c32ed5e40 Fix ! by not clearing not at the bottom of the loop.
Add a blank line

Submitted by:	bde (blank line)
2014-02-05 00:26:11 +00:00
Warner Losh
ff9aeb4c47 Implement the '!' operator for files* files. It means 'include this
only if the specified option is NOT specified.' Bump version because
old config won't be able to cope with files* files that have this
construct in them.
2014-02-04 18:28:58 +00:00
Warner Losh
3de7c987c7 Convert the loop by gotos into a for loop to improve readability. I
did this only with the inner loop for the token parsing, and not the
outer loop which was understandable enough when the extra layers of
looping went away...
2014-02-03 19:14:36 +00:00
Warner Losh
6554680b51 Fix a bug introduced in r261437 that failed to honor "optional
profiling-routine" to work, since profiling-routine is not really an
option or a device, but a special case elsewhere in the code.
2014-02-03 19:10:33 +00:00
Warner Losh
2ae93551bd Slight cleanup to the error messaging to compress code vertically... 2014-02-03 18:56:41 +00:00
Warner Losh
87fbb90b99 Better error messages when EOF is hit in the middle of a phrase. 2014-02-03 18:31:51 +00:00
Warner Losh
603a40e413 Move the check for standard keyword + optional inclusion specifier to
its proper location. Otherwise you could have 'file.c standard pci'
without an error. This construct isn't in our tree, and has no well
defined meaning.
2014-02-03 16:54:53 +00:00
Warner Losh
034d9de50d Don't believe we have a requirement until after we've checked all the
known key words. This will make error messages slightly better in
weird corner cases, but should otherwise be a nop.
2014-02-03 16:47:10 +00:00
Warner Losh
5da753bc0a In the 17 years since r30796, the mandatory keyword has never been used
in any files as far as I can tell, and is currently unused. Retire it.
2014-02-03 16:46:01 +00:00
Warner Losh
c79e3e3d8b Slightly deobfuscate read_file() and likely pessimize the runtime
performance by epsilon.
(Translation: elminate bogus macros that hid 'returns' making it hard
 to read and moved a block of code inline rather than at the end of the
 fuction where it was effectively a 'gosub' kind of goto).
2014-02-03 15:10:44 +00:00
John Baldwin
c388f51ab4 - Fix the error message when a dependency string is not provided to
reference a missing dependency rather than a missing compile command.
- Don't append a newline to the auto-generated compile command.  The
  compile command has a newline appended when it is later output to the
  Makefile.

MFC after:	2 weeks
2012-10-10 14:47:46 +00:00
Kevin Lo
b1c09bd5ff Fix copyright year
Spotted by:	pluknet
2012-01-13 09:08:41 +00:00
Kevin Lo
a3a2bf4b67 fgets(3) returns a pointer, so compare against NULL, not integer 0. 2012-01-13 06:51:15 +00:00
Ed Schouten
b3608ae18f Replace index() and rindex() calls with strchr() and strrchr().
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.
2012-01-03 18:51:58 +00:00
Max Khon
d28e8f62e8 Generate ${NORMAL_CTFCONVERT} invocation without '@' modifier:
- ${NORMAL_CC} is also invoked without '@'
- Userland CTF support was changed previously to echo ctfconvert invocations too
2011-11-30 13:33:09 +00:00
Ryan Stone
2e0aa47581 The generated Makefile for the kernel was not running ctfconvert on
object files corresponding to source files that had the compile-with
option set in conf/files.  This means that any fbt probes for functions
in that object file would not have correct argument types.

The fix is to run ctfconvert on any target file that does not have the
no-obj option set in files.

PR:		bin/160275
Reported by:	Paul Ambrose (ambrosehua AT gmail DOT com)
MFC after:	1 week
2011-11-10 21:07:14 +00:00
Jeff Roberson
e4cd31dd3c - Merge changes to the base system to support OFED. These include
a wider arg2 for sysctl, updates to vlan code, IFT_INFINIBAND,
   and other miscellaneous small features.
2011-03-21 09:40:01 +00:00
Warner Losh
be1d53ac56 Generate MACHINE= and MACHINE_ARCH= lines based on the machine
directive.  Once this is MFC'd, we can move these out of the template
files where they are (incosnsitently) defined.

MFC after:	1 week
2011-02-11 06:35:53 +00:00
David E. O'Brien
a17e0dbbf8 Give the user a hint as to what config(8) is unhappy with. 2010-11-02 05:27:05 +00:00
Warner Losh
5eb0164407 Put warnings out to stderr rather than stdout.
MFC after:	3 days
2010-07-15 22:28:19 +00:00
Warner Losh
28a24ccfa9 style(9) fixes:
o make cmd scoped to the whole do_rules function, since it really is
  scoped to the whole fucnion.  Making it static was the wrong way to
  fix referencing it outside of the block in which it was declared
  (and conforms to the style of the rest of the file).
o remove a couple of meaningless blank lines
o properly wrap one line.
2010-06-13 16:54:11 +00:00
Warner Losh
90aa4f9e8c Move checking the version up from Makefile generation to just after
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
2010-04-27 05:04:32 +00:00
Alexander Leidinger
7ab4cc53fd Revert r206179 (by imp) and do something similar which is more consistent
with all other corresponding CTF places by changing the corresponding
code which is generated by config(8). Or in short, move the '@' from
the variable definition to the use of the variable. [1]

While I'm here break up a long line. [2]

Discussed with:	imp [1,2], bde [2]
2010-04-22 09:20:17 +00:00
Ruslan Ermilov
53d55e9756 - Handle calloc() allocation failures.
- Fixed a comment.
- 2 -> EXIT_FAILURE in some places.
- errx() -> err() where appropriate.

PR:		144644
Submitted by:	Garrett Cooper
2010-03-30 13:46:40 +00:00
Andrew Thompson
2880daeb77 Allow multiple makeoption lines to be used with the += operator, this permits
the following syntax in the kernel config.

 makeoptions MODULES_OVERRIDE=foo
 makeoptions MODULES_OVERRIDE+=bar
 makeoptions MODULES_OVERRIDE+=baz

Bump config minor version to 600007.
2008-11-22 21:12:47 +00:00
John Birrell
4287da9afb Revice the way the CTF conversion is done per object. Avoid creating a second
shell (which was the problem with the original implementation) and avoid
letting make see an empty definition (which was the problem with the current
implementation).
2008-06-29 07:15:57 +00:00
John Birrell
1f1fa917bd Change the CTF conversion makefile code to use a new line to avoid
spawning another shell.

Requested by: Ed Schouten

M    config/mkmakefile.c
2008-06-09 06:33:26 +00:00