2008-06-10 22:11:31 +04:00
|
|
|
/* $NetBSD: main.c,v 1.27 2008/06/10 18:11:31 drochner Exp $ */
|
1996-03-03 20:21:25 +03:00
|
|
|
|
1996-03-17 09:29:19 +03:00
|
|
|
/*
|
1995-04-28 10:54:58 +04:00
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This software was developed by the Computer Systems Engineering group
|
|
|
|
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
|
|
|
* contributed to Berkeley.
|
|
|
|
*
|
|
|
|
* All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Lawrence Berkeley Laboratories.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 15:25:11 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1993-03-21 12:45:37 +03:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1995-04-28 10:54:58 +04:00
|
|
|
*
|
|
|
|
* from: @(#)main.c 8.1 (Berkeley) 6/6/93
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
|
2004-06-21 02:20:14 +04:00
|
|
|
#if HAVE_NBTOOL_CONFIG_H
|
|
|
|
#include "nbtool_config.h"
|
|
|
|
#endif
|
|
|
|
|
1997-10-18 11:58:56 +04:00
|
|
|
#ifndef MAKE_BOOTSTRAP
|
|
|
|
#include <sys/cdefs.h>
|
2000-10-02 23:57:23 +04:00
|
|
|
#define COPYRIGHT(x) __COPYRIGHT(x)
|
|
|
|
#else
|
|
|
|
#define COPYRIGHT(x) static const char copyright[] = x
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef lint
|
|
|
|
COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
|
1997-10-18 11:58:56 +04:00
|
|
|
The Regents of the University of California. All rights reserved.\n");
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
1996-09-01 00:58:16 +04:00
|
|
|
#include <sys/param.h>
|
2003-04-26 16:53:43 +04:00
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <paths.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <ctype.h>
|
2006-10-05 00:34:48 +04:00
|
|
|
#include <err.h>
|
1995-04-28 10:54:58 +04:00
|
|
|
#include <errno.h>
|
2003-04-26 16:53:43 +04:00
|
|
|
#include <fcntl.h>
|
1995-04-28 10:54:58 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2006-08-26 22:17:13 +04:00
|
|
|
#include <vis.h>
|
|
|
|
#include <util.h>
|
|
|
|
|
2002-01-29 13:20:28 +03:00
|
|
|
#include "defs.h"
|
1997-05-25 22:42:54 +04:00
|
|
|
#include "sem.h"
|
2002-01-29 13:20:28 +03:00
|
|
|
|
2003-04-26 16:53:43 +04:00
|
|
|
#ifndef LINE_MAX
|
|
|
|
#define LINE_MAX 1024
|
|
|
|
#endif
|
|
|
|
|
1998-06-28 08:41:36 +04:00
|
|
|
int vflag; /* verbose output */
|
2001-07-01 06:46:47 +04:00
|
|
|
int Pflag; /* pack locators */
|
2007-01-08 19:08:08 +03:00
|
|
|
int Lflag; /* lint config generation */
|
1998-06-28 08:41:36 +04:00
|
|
|
|
2000-10-02 23:48:34 +04:00
|
|
|
int yyparse(void);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2000-10-08 15:33:40 +04:00
|
|
|
#ifndef MAKE_BOOTSTRAP
|
1997-10-10 14:27:53 +04:00
|
|
|
extern int yydebug;
|
2000-10-08 15:33:40 +04:00
|
|
|
#endif
|
1995-04-28 10:54:58 +04:00
|
|
|
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
static struct hashtab *obsopttab;
|
1995-04-28 10:54:58 +04:00
|
|
|
static struct hashtab *mkopttab;
|
|
|
|
static struct nvlist **nextopt;
|
|
|
|
static struct nvlist **nextmkopt;
|
2004-06-04 08:38:27 +04:00
|
|
|
static struct nvlist **nextappmkopt;
|
1997-01-31 06:12:30 +03:00
|
|
|
static struct nvlist **nextfsopt;
|
1995-04-28 10:54:58 +04:00
|
|
|
|
2007-12-15 22:44:37 +03:00
|
|
|
static void usage(void) __dead;
|
2000-10-02 23:48:34 +04:00
|
|
|
static void dependopts(void);
|
|
|
|
static void do_depend(struct nvlist *);
|
|
|
|
static void stop(void);
|
|
|
|
static int do_option(struct hashtab *, struct nvlist ***,
|
|
|
|
const char *, const char *, const char *);
|
2002-06-05 14:56:17 +04:00
|
|
|
static int undo_option(struct hashtab *, struct nvlist **,
|
2003-06-25 10:42:40 +04:00
|
|
|
struct nvlist ***, const char *, const char *);
|
2000-10-02 23:48:34 +04:00
|
|
|
static int crosscheck(void);
|
|
|
|
static int badstar(void);
|
|
|
|
int main(int, char **);
|
|
|
|
static int mksymlinks(void);
|
|
|
|
static int mkident(void);
|
2005-10-02 03:30:37 +04:00
|
|
|
static int devbase_has_dead_instances(const char *, void *, void *);
|
2005-10-05 00:13:39 +04:00
|
|
|
static int devbase_has_any_instance(struct devbase *, int, int, int);
|
2005-10-02 03:30:37 +04:00
|
|
|
static int check_dead_devi(const char *, void *, void *);
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
static void kill_orphans(void);
|
2005-10-02 03:30:37 +04:00
|
|
|
static void do_kill_orphans(struct devbase *, struct attr *,
|
|
|
|
struct devbase *, int);
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
static int kill_orphans_cb(const char *, void *, void *);
|
2000-10-02 23:48:34 +04:00
|
|
|
static int cfcrosscheck(struct config *, const char *, struct nvlist *);
|
2002-06-05 14:56:17 +04:00
|
|
|
static const char *strtolower(const char *);
|
2000-10-02 23:48:34 +04:00
|
|
|
void defopt(struct hashtab *ht, const char *fname,
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
struct nvlist *opts, struct nvlist *deps, int obs);
|
2000-10-02 23:48:34 +04:00
|
|
|
|
2001-12-17 18:39:43 +03:00
|
|
|
#define LOGCONFIG_LARGE "INCLUDE_CONFIG_FILE"
|
|
|
|
#define LOGCONFIG_SMALL "INCLUDE_JUST_CONFIG"
|
|
|
|
|
|
|
|
static void logconfig_start(void);
|
|
|
|
static void logconfig_end(void);
|
|
|
|
static FILE *cfg;
|
2002-01-29 13:20:28 +03:00
|
|
|
static time_t cfgtime;
|
2001-12-17 18:39:43 +03:00
|
|
|
|
2003-04-26 16:53:43 +04:00
|
|
|
static int is_elf(const char *);
|
|
|
|
static int extract_config(const char *, const char *, int);
|
|
|
|
|
2000-10-02 23:48:34 +04:00
|
|
|
int badfilename(const char *fname);
|
1995-04-28 10:54:58 +04:00
|
|
|
|
2001-02-21 02:51:59 +03:00
|
|
|
const char *progname;
|
1999-04-02 10:36:30 +04:00
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
int
|
2000-10-02 23:48:34 +04:00
|
|
|
main(int argc, char **argv)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2003-04-26 16:53:43 +04:00
|
|
|
char *p, cname[20];
|
1996-09-01 00:58:16 +04:00
|
|
|
const char *last_component;
|
2003-04-26 16:53:43 +04:00
|
|
|
int pflag, xflag, ch, removeit;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2001-02-21 02:51:59 +03:00
|
|
|
setprogname(argv[0]);
|
1999-04-02 10:36:30 +04:00
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
pflag = 0;
|
2003-04-26 16:53:43 +04:00
|
|
|
xflag = 0;
|
2007-01-08 19:08:08 +03:00
|
|
|
while ((ch = getopt(argc, argv, "DLPgpvb:s:x")) != -1) {
|
1993-03-21 12:45:37 +03:00
|
|
|
switch (ch) {
|
1995-04-28 10:54:58 +04:00
|
|
|
|
2000-10-08 15:33:40 +04:00
|
|
|
#ifndef MAKE_BOOTSTRAP
|
1997-10-10 14:27:53 +04:00
|
|
|
case 'D':
|
|
|
|
yydebug = 1;
|
|
|
|
break;
|
2000-10-08 15:33:40 +04:00
|
|
|
#endif
|
1997-10-10 14:27:53 +04:00
|
|
|
|
2007-01-08 19:08:08 +03:00
|
|
|
case 'L':
|
|
|
|
Lflag = 1;
|
|
|
|
break;
|
|
|
|
|
2001-07-01 06:46:47 +04:00
|
|
|
case 'P':
|
|
|
|
Pflag = 1;
|
|
|
|
break;
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
case 'g':
|
1995-04-28 10:54:58 +04:00
|
|
|
/*
|
|
|
|
* In addition to DEBUG, you probably wanted to
|
|
|
|
* set "options KGDB" and maybe others. We could
|
|
|
|
* do that for you, but you really should just
|
|
|
|
* put them in the config file.
|
|
|
|
*/
|
2007-01-14 02:47:36 +03:00
|
|
|
warnx("-g is obsolete (use makeoptions DEBUG=\"-g\")");
|
2003-07-02 20:47:53 +04:00
|
|
|
usage();
|
2007-01-14 02:47:36 +03:00
|
|
|
/*NOTREACHED*/
|
1995-04-28 10:54:58 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
case 'p':
|
1995-04-28 10:54:58 +04:00
|
|
|
/*
|
|
|
|
* Essentially the same as makeoptions PROF="-pg",
|
|
|
|
* but also changes the path from ../../compile/FOO
|
1996-11-02 04:02:56 +03:00
|
|
|
* to ../../compile/FOO.PROF; i.e., compile a
|
1995-04-28 10:54:58 +04:00
|
|
|
* profiling kernel based on a typical "regular"
|
|
|
|
* kernel.
|
|
|
|
*
|
|
|
|
* Note that if you always want profiling, you
|
|
|
|
* can (and should) use a "makeoptions" line.
|
|
|
|
*/
|
|
|
|
pflag = 1;
|
1993-04-10 16:11:55 +04:00
|
|
|
break;
|
1995-04-28 10:54:58 +04:00
|
|
|
|
1998-06-28 08:41:36 +04:00
|
|
|
case 'v':
|
|
|
|
vflag = 1;
|
|
|
|
break;
|
|
|
|
|
1996-09-01 00:58:16 +04:00
|
|
|
case 'b':
|
|
|
|
builddir = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 's':
|
|
|
|
srcdir = optarg;
|
|
|
|
break;
|
|
|
|
|
2003-04-26 16:53:43 +04:00
|
|
|
case 'x':
|
|
|
|
xflag = 1;
|
|
|
|
break;
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
case '?':
|
|
|
|
default:
|
2003-07-02 20:47:53 +04:00
|
|
|
usage();
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1995-04-28 10:54:58 +04:00
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
1996-09-01 00:58:16 +04:00
|
|
|
if (argc > 1) {
|
2003-07-02 20:47:53 +04:00
|
|
|
usage();
|
2003-04-26 16:53:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (xflag && (builddir != NULL || srcdir != NULL || Pflag || pflag ||
|
2007-01-14 02:47:36 +03:00
|
|
|
vflag || Lflag))
|
|
|
|
errx(EXIT_FAILURE, "-x must be used alone");
|
|
|
|
if (Lflag && (builddir != NULL || Pflag || pflag))
|
|
|
|
errx(EXIT_FAILURE, "-L can only be used with -s and -v");
|
2003-04-26 16:53:43 +04:00
|
|
|
|
|
|
|
if (xflag) {
|
2003-11-12 04:24:15 +03:00
|
|
|
#ifdef __NetBSD__
|
2003-04-26 16:53:43 +04:00
|
|
|
conffile = (argc == 1) ? argv[0] : _PATH_UNIX;
|
2003-11-12 04:24:15 +03:00
|
|
|
#else
|
2007-01-14 02:47:36 +03:00
|
|
|
if (argc == 0)
|
|
|
|
errx(EXIT_FAILURE, "no kernel supplied");
|
2003-11-12 04:24:15 +03:00
|
|
|
#endif
|
2007-01-14 02:47:36 +03:00
|
|
|
if (!is_elf(conffile))
|
|
|
|
errx(EXIT_FAILURE, "%s: not a binary kernel",
|
2003-04-26 16:53:43 +04:00
|
|
|
conffile);
|
2007-01-14 02:47:36 +03:00
|
|
|
if (!extract_config(conffile, "stdout", STDOUT_FILENO))
|
|
|
|
errx(EXIT_FAILURE, "%s does not contain embedded "
|
|
|
|
"configuration data", conffile);
|
2003-04-26 16:53:43 +04:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
1996-09-01 00:58:16 +04:00
|
|
|
conffile = (argc == 1) ? argv[0] : "CONFIG";
|
1995-04-28 10:54:58 +04:00
|
|
|
if (firstfile(conffile)) {
|
2007-01-14 02:47:36 +03:00
|
|
|
err(EXIT_FAILURE, "Cannot read `%s'", conffile);
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(2);
|
|
|
|
}
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Init variables.
|
|
|
|
*/
|
|
|
|
minmaxusers = 1;
|
|
|
|
maxmaxusers = 10000;
|
|
|
|
initintern();
|
|
|
|
initfiles();
|
|
|
|
initsem();
|
2000-01-25 04:16:00 +03:00
|
|
|
ident = NULL;
|
1995-04-28 10:54:58 +04:00
|
|
|
devbasetab = ht_new();
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
devroottab = ht_new();
|
1996-03-17 05:08:22 +03:00
|
|
|
devatab = ht_new();
|
2003-01-27 08:00:54 +03:00
|
|
|
devitab = ht_new();
|
2005-10-02 03:30:37 +04:00
|
|
|
deaddevitab = ht_new();
|
1995-04-28 10:54:58 +04:00
|
|
|
selecttab = ht_new();
|
|
|
|
needcnttab = ht_new();
|
|
|
|
opttab = ht_new();
|
|
|
|
mkopttab = ht_new();
|
2004-06-04 11:28:26 +04:00
|
|
|
condmkopttab = ht_new();
|
1997-01-31 06:12:30 +03:00
|
|
|
fsopttab = ht_new();
|
1998-02-19 03:27:00 +03:00
|
|
|
deffstab = ht_new();
|
1997-02-03 00:12:30 +03:00
|
|
|
defopttab = ht_new();
|
1998-06-24 15:20:54 +04:00
|
|
|
defparamtab = ht_new();
|
2007-01-09 16:03:47 +03:00
|
|
|
defoptlint = ht_new();
|
1998-06-24 15:20:54 +04:00
|
|
|
defflagtab = ht_new();
|
1998-01-12 10:37:40 +03:00
|
|
|
optfiletab = ht_new();
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
obsopttab = ht_new();
|
2002-09-06 17:18:43 +04:00
|
|
|
bdevmtab = ht_new();
|
|
|
|
maxbdevm = 0;
|
|
|
|
cdevmtab = ht_new();
|
|
|
|
maxcdevm = 0;
|
1995-04-28 10:54:58 +04:00
|
|
|
nextopt = &options;
|
|
|
|
nextmkopt = &mkoptions;
|
2004-06-04 08:38:27 +04:00
|
|
|
nextappmkopt = &appmkoptions;
|
1997-01-31 06:12:30 +03:00
|
|
|
nextfsopt = &fsoptions;
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle profiling (must do this before we try to create any
|
|
|
|
* files).
|
|
|
|
*/
|
1996-09-01 00:58:16 +04:00
|
|
|
last_component = strrchr(conffile, '/');
|
|
|
|
last_component = (last_component) ? last_component + 1 : conffile;
|
1995-04-28 10:54:58 +04:00
|
|
|
if (pflag) {
|
2003-07-13 16:29:20 +04:00
|
|
|
p = emalloc(strlen(last_component) + 17);
|
1996-09-01 00:58:16 +04:00
|
|
|
(void)sprintf(p, "../compile/%s.PROF", last_component);
|
1995-04-28 10:54:58 +04:00
|
|
|
(void)addmkoption(intern("PROF"), "-pg");
|
|
|
|
(void)addoption(intern("GPROF"), NULL);
|
1996-09-01 00:58:16 +04:00
|
|
|
} else {
|
|
|
|
p = emalloc(strlen(last_component) + 13);
|
|
|
|
(void)sprintf(p, "../compile/%s", last_component);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1996-09-01 00:58:16 +04:00
|
|
|
defbuilddir = (argc == 0) ? "." : p;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2007-01-08 19:08:08 +03:00
|
|
|
if (Lflag) {
|
|
|
|
char resolvedname[MAXPATHLEN];
|
|
|
|
|
|
|
|
if (realpath(conffile, resolvedname) == NULL)
|
|
|
|
err(EXIT_FAILURE, "realpath(%s)", conffile);
|
|
|
|
|
|
|
|
if (yyparse())
|
|
|
|
stop();
|
|
|
|
|
2007-01-08 20:50:43 +03:00
|
|
|
printf("include \"%s\"\n", resolvedname);
|
2007-01-08 19:08:08 +03:00
|
|
|
|
|
|
|
emit_params();
|
|
|
|
emit_options();
|
|
|
|
emit_instances();
|
|
|
|
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2003-04-26 16:53:43 +04:00
|
|
|
removeit = 0;
|
|
|
|
if (is_elf(conffile)) {
|
2003-09-14 16:33:05 +04:00
|
|
|
const char *tmpdir;
|
2003-04-26 16:53:43 +04:00
|
|
|
int cfd;
|
|
|
|
|
2007-01-14 02:47:36 +03:00
|
|
|
if (builddir == NULL)
|
|
|
|
errx(EXIT_FAILURE, "Build directory must be specified "
|
|
|
|
"with binary kernels");
|
2003-04-26 16:53:43 +04:00
|
|
|
|
|
|
|
/* Open temporary configuration file */
|
|
|
|
tmpdir = getenv("TMPDIR");
|
|
|
|
if (tmpdir == NULL)
|
|
|
|
tmpdir = "/tmp";
|
|
|
|
snprintf(cname, sizeof(cname), "%s/config.tmp.XXXXXX", tmpdir);
|
|
|
|
cfd = mkstemp(cname);
|
2007-01-14 02:47:36 +03:00
|
|
|
if (cfd == -1)
|
|
|
|
err(EXIT_FAILURE, "Cannot create `%s'", cname);
|
2003-04-26 16:53:43 +04:00
|
|
|
|
|
|
|
printf("Using configuration data embedded in kernel...\n");
|
2007-01-14 02:47:36 +03:00
|
|
|
if (!extract_config(conffile, cname, cfd))
|
|
|
|
errx(EXIT_FAILURE, "%s does not contain embedded "
|
|
|
|
"configuration data", conffile);
|
2003-04-26 16:53:43 +04:00
|
|
|
|
|
|
|
removeit = 1;
|
|
|
|
close(cfd);
|
|
|
|
firstfile(cname);
|
|
|
|
}
|
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
/*
|
|
|
|
* Parse config file (including machine definitions).
|
|
|
|
*/
|
2001-12-17 18:39:43 +03:00
|
|
|
logconfig_start();
|
1993-03-21 12:45:37 +03:00
|
|
|
if (yyparse())
|
1995-04-28 10:54:58 +04:00
|
|
|
stop();
|
2001-12-17 18:39:43 +03:00
|
|
|
logconfig_end();
|
1995-04-28 10:54:58 +04:00
|
|
|
|
2003-04-26 16:53:43 +04:00
|
|
|
if (removeit)
|
|
|
|
unlink(cname);
|
|
|
|
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
/*
|
|
|
|
* Detect and properly ignore orphaned devices
|
|
|
|
*/
|
|
|
|
kill_orphans();
|
|
|
|
|
2002-06-05 14:56:17 +04:00
|
|
|
/*
|
|
|
|
* Select devices and pseudo devices and their attributes
|
|
|
|
*/
|
2005-10-02 03:30:37 +04:00
|
|
|
if (fixdevis())
|
|
|
|
stop();
|
2002-06-05 14:56:17 +04:00
|
|
|
|
1998-06-10 08:33:31 +04:00
|
|
|
/*
|
|
|
|
* Deal with option dependencies.
|
|
|
|
*/
|
|
|
|
dependopts();
|
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
/*
|
|
|
|
* Fix (as in `set firmly in place') files.
|
|
|
|
*/
|
|
|
|
if (fixfiles())
|
|
|
|
stop();
|
|
|
|
|
1997-10-10 14:27:53 +04:00
|
|
|
/*
|
|
|
|
* Fix objects and libraries.
|
|
|
|
*/
|
|
|
|
if (fixobjects())
|
|
|
|
stop();
|
|
|
|
|
2002-09-06 17:18:43 +04:00
|
|
|
/*
|
|
|
|
* Fix device-majors.
|
|
|
|
*/
|
|
|
|
if (fixdevsw())
|
|
|
|
stop();
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1995-04-28 10:54:58 +04:00
|
|
|
* Perform cross-checking.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1995-04-28 10:54:58 +04:00
|
|
|
if (maxusers == 0) {
|
|
|
|
if (defmaxusers) {
|
|
|
|
(void)printf("maxusers not specified; %d assumed\n",
|
|
|
|
defmaxusers);
|
|
|
|
maxusers = defmaxusers;
|
|
|
|
} else {
|
2007-01-14 02:47:36 +03:00
|
|
|
warnx("need \"maxusers\" line");
|
1995-04-28 10:54:58 +04:00
|
|
|
errors++;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-01-31 06:12:30 +03:00
|
|
|
if (fsoptions == NULL) {
|
2007-01-14 02:47:36 +03:00
|
|
|
warnx( "need at least one \"file-system\" line");
|
1997-01-31 06:12:30 +03:00
|
|
|
errors++;
|
|
|
|
}
|
1995-04-28 10:54:58 +04:00
|
|
|
if (crosscheck() || errors)
|
|
|
|
stop();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Squeeze things down and finish cross-checks (STAR checks must
|
|
|
|
* run after packing).
|
|
|
|
*/
|
|
|
|
pack();
|
|
|
|
if (badstar())
|
|
|
|
stop();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ready to go. Build all the various files.
|
|
|
|
*/
|
|
|
|
if (mksymlinks() || mkmakefile() || mkheaders() || mkswap() ||
|
2002-09-11 10:20:09 +04:00
|
|
|
mkioconf() || (do_devsw ? mkdevsw() : 0) || mkident())
|
1995-04-28 10:54:58 +04:00
|
|
|
stop();
|
2003-07-02 20:47:53 +04:00
|
|
|
(void)printf("Build directory is %s\n", builddir);
|
1995-04-28 10:54:58 +04:00
|
|
|
(void)printf("Don't forget to run \"make depend\"\n");
|
2007-01-14 02:47:36 +03:00
|
|
|
return 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2003-07-02 20:47:53 +04:00
|
|
|
static void
|
|
|
|
usage(void)
|
|
|
|
{
|
2007-01-14 02:47:36 +03:00
|
|
|
(void)fprintf(stderr, "Usage: %s [-Ppv] [-s srcdir] [-b builddir] "
|
|
|
|
"[config-file]\n\t%s -x [kernel-file]\n"
|
|
|
|
"\t%s -L [-v] [-s srcdir] [config-file]\n",
|
|
|
|
getprogname(), getprogname(), getprogname());
|
2003-07-02 20:47:53 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
1998-06-10 08:33:31 +04:00
|
|
|
/*
|
|
|
|
* Set any options that are implied by other options.
|
|
|
|
*/
|
|
|
|
static void
|
2000-10-02 23:48:34 +04:00
|
|
|
dependopts(void)
|
1998-06-10 08:33:31 +04:00
|
|
|
{
|
|
|
|
struct nvlist *nv, *opt;
|
|
|
|
|
|
|
|
for (nv = options; nv != NULL; nv = nv->nv_next) {
|
1998-06-30 07:30:56 +04:00
|
|
|
if ((opt = find_declared_option(nv->nv_name)) != NULL) {
|
1998-06-10 08:33:31 +04:00
|
|
|
for (opt = opt->nv_ptr; opt != NULL;
|
|
|
|
opt = opt->nv_next) {
|
|
|
|
do_depend(opt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-08-30 14:12:25 +04:00
|
|
|
|
|
|
|
for (nv = fsoptions; nv != NULL; nv = nv->nv_next) {
|
|
|
|
if ((opt = find_declared_option(nv->nv_name)) != NULL) {
|
|
|
|
for (opt = opt->nv_ptr; opt != NULL;
|
|
|
|
opt = opt->nv_next) {
|
|
|
|
do_depend(opt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-06-10 08:33:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-10-02 23:48:34 +04:00
|
|
|
do_depend(struct nvlist *nv)
|
1998-06-10 08:33:31 +04:00
|
|
|
{
|
|
|
|
struct nvlist *nextnv;
|
2002-10-11 05:48:25 +04:00
|
|
|
struct attr *a;
|
1998-06-10 08:33:31 +04:00
|
|
|
|
2002-10-11 05:48:25 +04:00
|
|
|
if (nv != NULL && (nv->nv_flags & NV_DEPENDED) == 0) {
|
1999-09-22 18:23:03 +04:00
|
|
|
nv->nv_flags |= NV_DEPENDED;
|
2002-10-11 05:48:25 +04:00
|
|
|
/*
|
|
|
|
* If the dependency is an attribute, then just add
|
|
|
|
* it to the selecttab.
|
|
|
|
*/
|
|
|
|
if ((a = ht_lookup(attrtab, nv->nv_name)) != NULL) {
|
|
|
|
if (a->a_iattr)
|
|
|
|
panic("do_depend(%s): dep `%s' is an iattr",
|
|
|
|
nv->nv_name, a->a_name);
|
|
|
|
expandattr(a, selectattr);
|
|
|
|
} else {
|
|
|
|
if (ht_lookup(opttab, nv->nv_name) == NULL)
|
|
|
|
addoption(nv->nv_name, NULL);
|
|
|
|
if ((nextnv =
|
|
|
|
find_declared_option(nv->nv_name)) != NULL)
|
|
|
|
do_depend(nextnv->nv_ptr);
|
|
|
|
}
|
1998-06-10 08:33:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-14 02:47:36 +03:00
|
|
|
static int
|
|
|
|
recreate(const char *p, const char *q)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if ((ret = unlink(q)) == -1 && errno != ENOENT)
|
|
|
|
warn("unlink(%s)\n", q);
|
|
|
|
if ((ret = symlink(p, q)) == -1)
|
|
|
|
warn("symlink(%s -> %s)", q, p);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1995-04-28 10:54:58 +04:00
|
|
|
* Make a symlink for "machine" so that "#include <machine/foo.h>" works,
|
|
|
|
* and for the machine's CPU architecture, so that works as well.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1995-04-28 10:54:58 +04:00
|
|
|
static int
|
2000-10-02 23:48:34 +04:00
|
|
|
mksymlinks(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1995-04-28 10:54:58 +04:00
|
|
|
int ret;
|
1996-09-01 00:58:16 +04:00
|
|
|
char *p, buf[MAXPATHLEN];
|
|
|
|
const char *q;
|
2001-06-08 16:47:06 +04:00
|
|
|
struct nvlist *nv;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2003-07-13 16:29:20 +04:00
|
|
|
snprintf(buf, sizeof(buf), "arch/%s/include", machine);
|
1996-09-01 00:58:16 +04:00
|
|
|
p = sourcepath(buf);
|
2007-01-14 02:47:36 +03:00
|
|
|
ret = recreate(p, "machine");
|
1998-10-05 23:50:40 +04:00
|
|
|
free(p);
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
if (machinearch != NULL) {
|
2003-07-13 16:29:20 +04:00
|
|
|
snprintf(buf, sizeof(buf), "arch/%s/include", machinearch);
|
1996-09-01 00:58:16 +04:00
|
|
|
p = sourcepath(buf);
|
|
|
|
q = machinearch;
|
1995-04-28 10:54:58 +04:00
|
|
|
} else {
|
1999-07-09 10:44:58 +04:00
|
|
|
p = estrdup("machine");
|
1996-09-01 00:58:16 +04:00
|
|
|
q = machine;
|
1993-04-10 16:11:55 +04:00
|
|
|
}
|
2007-01-14 02:47:36 +03:00
|
|
|
|
|
|
|
ret = recreate(p, q);
|
1995-04-28 10:54:58 +04:00
|
|
|
free(p);
|
|
|
|
|
2001-06-08 16:47:06 +04:00
|
|
|
for (nv = machinesubarches; nv != NULL; nv = nv->nv_next) {
|
|
|
|
q = nv->nv_name;
|
2003-07-13 16:29:20 +04:00
|
|
|
snprintf(buf, sizeof(buf), "arch/%s/include", q);
|
2001-06-08 16:47:06 +04:00
|
|
|
p = sourcepath(buf);
|
2007-01-14 02:47:36 +03:00
|
|
|
ret = recreate(p, q);
|
2001-06-08 16:47:06 +04:00
|
|
|
free(p);
|
|
|
|
}
|
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __dead void
|
2000-10-02 23:48:34 +04:00
|
|
|
stop(void)
|
1995-04-28 10:54:58 +04:00
|
|
|
{
|
|
|
|
(void)fprintf(stderr, "*** Stop.\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2006-08-30 14:12:25 +04:00
|
|
|
static void
|
|
|
|
add_dependencies(struct nvlist *nv, struct nvlist *deps)
|
|
|
|
{
|
|
|
|
struct nvlist *dep;
|
|
|
|
struct attr *a;
|
|
|
|
|
|
|
|
/* Use nv_ptr to link any other options that are implied. */
|
|
|
|
nv->nv_ptr = deps;
|
|
|
|
for (dep = deps; dep != NULL; dep = dep->nv_next) {
|
|
|
|
/*
|
|
|
|
* If the dependency is an attribute, it must not
|
|
|
|
* be an interface attribute. Otherwise, it must
|
|
|
|
* be a previously declared option.
|
|
|
|
*/
|
|
|
|
if ((a = ht_lookup(attrtab, dep->nv_name)) != NULL) {
|
|
|
|
if (a->a_iattr)
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("option `%s' dependency `%s' "
|
2006-08-30 14:12:25 +04:00
|
|
|
"is an interface attribute",
|
|
|
|
nv->nv_name, a->a_name);
|
|
|
|
} else if (OPT_OBSOLETE(dep->nv_name)) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("option `%s' dependency `%s' "
|
2006-08-30 14:12:25 +04:00
|
|
|
"is obsolete", nv->nv_name, dep->nv_name);
|
|
|
|
} else if (find_declared_option(dep->nv_name) == NULL) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("option `%s' dependency `%s' "
|
2006-08-30 14:12:25 +04:00
|
|
|
"is an unknown option",
|
|
|
|
nv->nv_name, dep->nv_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-02-19 03:27:00 +03:00
|
|
|
/*
|
|
|
|
* Define one or more file systems. If file system options file name is
|
|
|
|
* specified, a preprocessor #define for that file system will be placed
|
|
|
|
* in that file. In this case, only one file system may be specified.
|
|
|
|
* Otherwise, no preprocessor #defines will be generated.
|
|
|
|
*/
|
|
|
|
void
|
2006-08-30 14:12:25 +04:00
|
|
|
deffilesystem(const char *fname, struct nvlist *fses, struct nvlist *deps)
|
1998-02-19 03:27:00 +03:00
|
|
|
{
|
|
|
|
struct nvlist *nv;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Mark these options as ones to skip when creating the Makefile.
|
|
|
|
*/
|
|
|
|
for (nv = fses; nv != NULL; nv = nv->nv_next) {
|
2007-01-06 21:54:32 +03:00
|
|
|
if (DEFINED_OPTION(nv->nv_name)) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("file system or option `%s' already defined",
|
1998-02-19 03:27:00 +03:00
|
|
|
nv->nv_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Also mark it as a valid file system, which may be
|
|
|
|
* used in "file-system" directives in the config
|
|
|
|
* file.
|
|
|
|
*/
|
|
|
|
if (ht_insert(deffstab, nv->nv_name, nv))
|
|
|
|
panic("file system `%s' already in table?!",
|
|
|
|
nv->nv_name);
|
|
|
|
|
|
|
|
if (fname != NULL) {
|
|
|
|
/*
|
|
|
|
* Only one file system allowed in this case.
|
|
|
|
*/
|
|
|
|
if (nv->nv_next != NULL) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("only one file system per option "
|
1998-02-19 03:27:00 +03:00
|
|
|
"file may be specified");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ht_insert(optfiletab, fname, nv)) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("option file `%s' already exists",
|
1998-02-19 03:27:00 +03:00
|
|
|
fname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2006-08-30 14:12:25 +04:00
|
|
|
|
|
|
|
add_dependencies(nv, deps);
|
1998-02-19 03:27:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-06-24 15:20:54 +04:00
|
|
|
/*
|
|
|
|
* Sanity check a file name.
|
|
|
|
*/
|
|
|
|
int
|
2000-10-02 23:48:34 +04:00
|
|
|
badfilename(const char *fname)
|
1998-06-24 15:20:54 +04:00
|
|
|
{
|
|
|
|
const char *n;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We're putting multiple options into one file. Sanity
|
|
|
|
* check the file name.
|
|
|
|
*/
|
|
|
|
if (strchr(fname, '/') != NULL) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("option file name contains a `/'");
|
1998-06-24 15:20:54 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if ((n = strrchr(fname, '.')) == NULL || strcmp(n, ".h") != 0) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("option file name does not end in `.h'");
|
1998-06-24 15:20:54 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-06-30 07:30:56 +04:00
|
|
|
/*
|
|
|
|
* Search for a defined option (defopt, filesystem, etc), and if found,
|
2002-10-11 05:48:25 +04:00
|
|
|
* return the option's struct nvlist.
|
1998-06-30 07:30:56 +04:00
|
|
|
*/
|
|
|
|
struct nvlist *
|
2000-10-02 23:48:34 +04:00
|
|
|
find_declared_option(const char *name)
|
1998-06-30 07:30:56 +04:00
|
|
|
{
|
|
|
|
struct nvlist *option = NULL;
|
|
|
|
|
|
|
|
if ((option = ht_lookup(defopttab, name)) != NULL ||
|
|
|
|
(option = ht_lookup(defparamtab, name)) != NULL ||
|
|
|
|
(option = ht_lookup(defflagtab, name)) != NULL ||
|
|
|
|
(option = ht_lookup(fsopttab, name)) != NULL) {
|
|
|
|
return (option);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-02-03 00:12:30 +03:00
|
|
|
/*
|
1998-01-12 10:37:40 +03:00
|
|
|
* Define one or more standard options. If an option file name is specified,
|
|
|
|
* place all options in one file with the specified name. Otherwise, create
|
|
|
|
* an option file for each option.
|
1998-06-24 15:20:54 +04:00
|
|
|
* record the option information in the specified table.
|
1997-02-03 00:12:30 +03:00
|
|
|
*/
|
|
|
|
void
|
2000-10-02 23:48:34 +04:00
|
|
|
defopt(struct hashtab *ht, const char *fname, struct nvlist *opts,
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
struct nvlist *deps, int obs)
|
1997-02-03 00:12:30 +03:00
|
|
|
{
|
2006-08-30 14:12:25 +04:00
|
|
|
struct nvlist *nv, *nextnv, *oldnv;
|
2004-06-05 09:07:02 +04:00
|
|
|
const char *name;
|
2004-06-05 03:41:14 +04:00
|
|
|
char buf[500];
|
1997-02-03 00:12:30 +03:00
|
|
|
|
1998-06-24 15:20:54 +04:00
|
|
|
if (fname != NULL && badfilename(fname)) {
|
|
|
|
return;
|
1998-06-10 08:33:31 +04:00
|
|
|
}
|
|
|
|
|
1997-02-03 00:12:30 +03:00
|
|
|
/*
|
1998-01-12 10:37:40 +03:00
|
|
|
* Mark these options as ones to skip when creating the Makefile.
|
1997-02-03 00:12:30 +03:00
|
|
|
*/
|
1998-01-12 10:37:40 +03:00
|
|
|
for (nv = opts; nv != NULL; nv = nextnv) {
|
|
|
|
nextnv = nv->nv_next;
|
1998-06-30 07:30:56 +04:00
|
|
|
|
2007-01-09 16:03:47 +03:00
|
|
|
if (*(nv->nv_name) == '\0') {
|
|
|
|
if (nextnv == NULL)
|
|
|
|
panic("invalid option chain");
|
|
|
|
/*
|
|
|
|
* If an entry already exists, then we are about to
|
|
|
|
* complain, so no worry.
|
|
|
|
*/
|
|
|
|
(void) ht_insert(defoptlint, nextnv->nv_name,
|
|
|
|
nv);
|
|
|
|
nv = nextnv;
|
|
|
|
nextnv = nextnv->nv_next;
|
|
|
|
}
|
|
|
|
|
1998-06-30 07:30:56 +04:00
|
|
|
/* An option name can be declared at most once. */
|
|
|
|
if (DEFINED_OPTION(nv->nv_name)) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("file system or option `%s' already defined",
|
1998-06-30 07:30:56 +04:00
|
|
|
nv->nv_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-06-24 15:20:54 +04:00
|
|
|
if (ht_insert(ht, nv->nv_name, nv)) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("file system or option `%s' already defined",
|
1998-02-19 03:27:00 +03:00
|
|
|
nv->nv_name);
|
1998-01-12 10:37:40 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fname == NULL) {
|
|
|
|
/*
|
|
|
|
* Each option will be going into its own file.
|
|
|
|
* Convert the option name to lower case. This
|
|
|
|
* lower case name will be used as the option
|
|
|
|
* file name.
|
|
|
|
*/
|
2004-06-05 03:41:14 +04:00
|
|
|
(void) snprintf(buf, sizeof(buf), "opt_%s.h",
|
|
|
|
strtolower(nv->nv_name));
|
|
|
|
name = intern(buf);
|
1998-06-10 08:33:31 +04:00
|
|
|
} else {
|
|
|
|
name = fname;
|
1998-01-12 10:37:40 +03:00
|
|
|
}
|
1997-02-03 00:12:30 +03:00
|
|
|
|
2006-08-30 14:12:25 +04:00
|
|
|
add_dependencies(nv, deps);
|
1998-01-12 10:37:40 +03:00
|
|
|
|
1998-06-10 08:33:31 +04:00
|
|
|
/*
|
|
|
|
* Remove this option from the parameter list before adding
|
|
|
|
* it to the list associated with this option file.
|
|
|
|
*/
|
|
|
|
nv->nv_next = NULL;
|
1998-01-12 10:37:40 +03:00
|
|
|
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
/*
|
|
|
|
* Flag as obsolete, if requested.
|
|
|
|
*/
|
|
|
|
if (obs) {
|
|
|
|
nv->nv_flags |= NV_OBSOLETE;
|
|
|
|
(void)ht_insert(obsopttab, nv->nv_name, nv);
|
|
|
|
}
|
|
|
|
|
1998-06-10 08:33:31 +04:00
|
|
|
/*
|
|
|
|
* Add this option file if we haven't seen it yet.
|
|
|
|
* Otherwise, append to the list of options already
|
|
|
|
* associated with this file.
|
|
|
|
*/
|
|
|
|
if ((oldnv = ht_lookup(optfiletab, name)) == NULL) {
|
|
|
|
(void)ht_insert(optfiletab, name, nv);
|
|
|
|
} else {
|
|
|
|
while (oldnv->nv_next != NULL)
|
|
|
|
oldnv = oldnv->nv_next;
|
|
|
|
oldnv->nv_next = nv;
|
|
|
|
}
|
1998-01-12 10:37:40 +03:00
|
|
|
}
|
1997-02-03 00:12:30 +03:00
|
|
|
}
|
|
|
|
|
1998-06-24 15:20:54 +04:00
|
|
|
/*
|
|
|
|
* Define one or more standard options. If an option file name is specified,
|
|
|
|
* place all options in one file with the specified name. Otherwise, create
|
|
|
|
* an option file for each option.
|
|
|
|
*/
|
|
|
|
void
|
2000-10-02 23:48:34 +04:00
|
|
|
defoption(const char *fname, struct nvlist *opts, struct nvlist *deps)
|
1998-06-24 15:20:54 +04:00
|
|
|
{
|
2000-10-02 23:48:34 +04:00
|
|
|
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgwarn("The use of `defopt' is deprecated");
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
defopt(defopttab, fname, opts, deps, 0);
|
1998-06-24 15:20:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Define an option for which a value is required.
|
|
|
|
*/
|
|
|
|
void
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
defparam(const char *fname, struct nvlist *opts, struct nvlist *deps, int obs)
|
1998-06-24 15:20:54 +04:00
|
|
|
{
|
2000-10-02 23:48:34 +04:00
|
|
|
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
defopt(defparamtab, fname, opts, deps, obs);
|
1998-06-24 15:20:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2005-11-13 20:24:31 +03:00
|
|
|
* Define an option which must not have a value, and which
|
|
|
|
* emits a "needs-flag" style output.
|
1998-06-24 15:20:54 +04:00
|
|
|
*/
|
|
|
|
void
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
defflag(const char *fname, struct nvlist *opts, struct nvlist *deps, int obs)
|
1998-06-24 15:20:54 +04:00
|
|
|
{
|
2000-10-02 23:48:34 +04:00
|
|
|
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
defopt(defflagtab, fname, opts, deps, obs);
|
1998-06-24 15:20:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
/*
|
|
|
|
* Add an option from "options FOO". Note that this selects things that
|
|
|
|
* are "optional foo".
|
|
|
|
*/
|
|
|
|
void
|
2000-10-02 23:48:34 +04:00
|
|
|
addoption(const char *name, const char *value)
|
1995-04-28 10:54:58 +04:00
|
|
|
{
|
1997-10-18 11:58:56 +04:00
|
|
|
const char *n;
|
2007-01-14 02:47:36 +03:00
|
|
|
int is_fs, is_param, is_flag, is_undecl, is_obs;
|
1998-06-24 15:20:54 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Figure out how this option was declared (if at all.)
|
|
|
|
* XXX should use "params" and "flags" in config.
|
|
|
|
* XXX crying out for a type field in a unified hashtab.
|
|
|
|
*/
|
1998-06-30 07:30:56 +04:00
|
|
|
is_fs = OPT_FSOPT(name);
|
|
|
|
is_param = OPT_DEFPARAM(name);
|
|
|
|
is_flag = OPT_DEFFLAG(name);
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
is_obs = OPT_OBSOLETE(name);
|
1998-06-30 07:30:56 +04:00
|
|
|
is_undecl = !DEFINED_OPTION(name);
|
1995-04-28 10:54:58 +04:00
|
|
|
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
/* Warn and pretend the user had not selected the option */
|
|
|
|
if (is_obs) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgwarn("obsolete option `%s' will be ignored", name);
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-02-19 09:13:51 +03:00
|
|
|
/* Make sure this is not a defined file system. */
|
1998-06-24 15:20:54 +04:00
|
|
|
if (is_fs) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("`%s' is a defined file system", name);
|
1998-02-19 09:13:51 +03:00
|
|
|
return;
|
|
|
|
}
|
1998-06-24 15:20:54 +04:00
|
|
|
/* A defparam must have a value */
|
|
|
|
if (is_param && value == NULL) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("option `%s' must have a value", name);
|
1998-06-24 15:20:54 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* A defflag must not have a value */
|
|
|
|
if (is_flag && value != NULL) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("option `%s' must not have a value", name);
|
1998-06-24 15:20:54 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-06-28 08:41:36 +04:00
|
|
|
if (is_undecl && vflag) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgwarn("undeclared option `%s' added to IDENT", name);
|
1998-06-24 15:20:54 +04:00
|
|
|
}
|
1998-02-19 09:13:51 +03:00
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
if (do_option(opttab, &nextopt, name, value, "options"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* make lowercase, then add to select table */
|
2004-06-05 03:36:50 +04:00
|
|
|
n = strtolower(name);
|
2007-01-14 02:47:36 +03:00
|
|
|
(void)ht_insert(selecttab, n, (void *)__UNCONST(n));
|
1995-04-28 10:54:58 +04:00
|
|
|
}
|
|
|
|
|
2002-06-05 14:56:17 +04:00
|
|
|
void
|
|
|
|
deloption(const char *name)
|
|
|
|
{
|
|
|
|
|
2003-06-25 10:42:40 +04:00
|
|
|
if (undo_option(opttab, &options, &nextopt, name, "options"))
|
2002-06-05 14:56:17 +04:00
|
|
|
return;
|
2003-06-25 10:42:40 +04:00
|
|
|
if (undo_option(selecttab, NULL, NULL, strtolower(name), "options"))
|
2002-06-05 14:56:17 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1997-01-31 06:12:30 +03:00
|
|
|
/*
|
|
|
|
* Add a file system option. This routine simply inserts the name into
|
|
|
|
* a list of valid file systems, which is used to validate the root
|
|
|
|
* file system type. The name is then treated like a standard option.
|
|
|
|
*/
|
|
|
|
void
|
2000-10-02 23:48:34 +04:00
|
|
|
addfsoption(const char *name)
|
1997-01-31 06:12:30 +03:00
|
|
|
{
|
1997-10-18 11:58:56 +04:00
|
|
|
const char *n;
|
1997-01-31 06:12:30 +03:00
|
|
|
|
1998-02-19 03:27:00 +03:00
|
|
|
/* Make sure this is a defined file system. */
|
1998-06-30 07:30:56 +04:00
|
|
|
if (!OPT_FSOPT(name)) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("`%s' is not a defined file system", name);
|
1998-02-19 03:27:00 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-02-19 09:13:51 +03:00
|
|
|
/*
|
|
|
|
* Convert to lower case. This will be used in the select
|
2007-11-09 08:21:30 +03:00
|
|
|
* table, to verify root file systems.
|
1998-02-19 09:13:51 +03:00
|
|
|
*/
|
2004-06-05 03:36:50 +04:00
|
|
|
n = strtolower(name);
|
1997-01-31 06:12:30 +03:00
|
|
|
|
1998-02-19 09:13:51 +03:00
|
|
|
if (do_option(fsopttab, &nextfsopt, name, n, "file-system"))
|
1997-01-31 06:12:30 +03:00
|
|
|
return;
|
|
|
|
|
1998-02-19 09:13:51 +03:00
|
|
|
/* Add to select table. */
|
2007-01-14 02:47:36 +03:00
|
|
|
(void)ht_insert(selecttab, n, __UNCONST(n));
|
1997-01-31 06:12:30 +03:00
|
|
|
}
|
|
|
|
|
2002-06-05 14:56:17 +04:00
|
|
|
void
|
|
|
|
delfsoption(const char *name)
|
|
|
|
{
|
|
|
|
const char *n;
|
|
|
|
|
|
|
|
n = strtolower(name);
|
2003-06-25 10:42:40 +04:00
|
|
|
if (undo_option(fsopttab, &fsoptions, &nextfsopt, name, "file-system"))
|
2002-06-05 14:56:17 +04:00
|
|
|
return;
|
2003-06-25 10:42:40 +04:00
|
|
|
if (undo_option(selecttab, NULL, NULL, n, "file-system"))
|
2002-06-05 14:56:17 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
/*
|
|
|
|
* Add a "make" option.
|
|
|
|
*/
|
|
|
|
void
|
2000-10-02 23:48:34 +04:00
|
|
|
addmkoption(const char *name, const char *value)
|
1995-04-28 10:54:58 +04:00
|
|
|
{
|
|
|
|
|
2003-06-25 11:02:04 +04:00
|
|
|
(void)do_option(mkopttab, &nextmkopt, name, value, "makeoptions");
|
1995-04-28 10:54:58 +04:00
|
|
|
}
|
|
|
|
|
2002-06-05 14:56:17 +04:00
|
|
|
void
|
|
|
|
delmkoption(const char *name)
|
|
|
|
{
|
|
|
|
|
2003-06-25 11:02:04 +04:00
|
|
|
(void)undo_option(mkopttab, &mkoptions, &nextmkopt, name,
|
|
|
|
"makeoptions");
|
2002-06-05 14:56:17 +04:00
|
|
|
}
|
|
|
|
|
2004-06-04 08:38:27 +04:00
|
|
|
/*
|
|
|
|
* Add an appending "make" option.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
appendmkoption(const char *name, const char *value)
|
|
|
|
{
|
|
|
|
struct nvlist *nv;
|
|
|
|
|
|
|
|
nv = newnv(name, value, NULL, 0, NULL);
|
|
|
|
*nextappmkopt = nv;
|
|
|
|
nextappmkopt = &nv->nv_next;
|
|
|
|
}
|
|
|
|
|
2004-06-04 11:28:26 +04:00
|
|
|
/*
|
|
|
|
* Add a conditional appending "make" option.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
appendcondmkoption(const char *selname, const char *name, const char *value)
|
|
|
|
{
|
|
|
|
struct nvlist *nv, *lnv;
|
|
|
|
const char *n;
|
|
|
|
|
|
|
|
n = strtolower(selname);
|
|
|
|
nv = newnv(name, value, NULL, 0, NULL);
|
|
|
|
if (ht_insert(condmkopttab, n, nv) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((lnv = ht_lookup(condmkopttab, n)) == NULL)
|
|
|
|
panic("appendcondmkoption");
|
|
|
|
for (; lnv->nv_next != NULL; lnv = lnv->nv_next)
|
|
|
|
/* search for the last list element */;
|
|
|
|
lnv->nv_next = nv;
|
|
|
|
}
|
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
/*
|
|
|
|
* Add a name=value pair to an option list. The value may be NULL.
|
|
|
|
*/
|
|
|
|
static int
|
2000-10-02 23:48:34 +04:00
|
|
|
do_option(struct hashtab *ht, struct nvlist ***nppp, const char *name,
|
|
|
|
const char *value, const char *type)
|
1995-04-28 10:54:58 +04:00
|
|
|
{
|
1997-10-18 11:58:56 +04:00
|
|
|
struct nvlist *nv;
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
/* assume it will work */
|
1996-03-17 14:50:09 +03:00
|
|
|
nv = newnv(name, value, NULL, 0, NULL);
|
1995-04-28 10:54:58 +04:00
|
|
|
if (ht_insert(ht, name, nv) == 0) {
|
|
|
|
**nppp = nv;
|
|
|
|
*nppp = &nv->nv_next;
|
|
|
|
return (0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
/* oops, already got that option */
|
|
|
|
nvfree(nv);
|
|
|
|
if ((nv = ht_lookup(ht, name)) == NULL)
|
|
|
|
panic("do_option");
|
1998-06-30 07:30:56 +04:00
|
|
|
if (nv->nv_str != NULL && !OPT_FSOPT(name))
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("already have %s `%s=%s'", type, name, nv->nv_str);
|
1995-04-28 10:54:58 +04:00
|
|
|
else
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("already have %s `%s'", type, name);
|
1995-04-28 10:54:58 +04:00
|
|
|
return (1);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2002-06-05 14:56:17 +04:00
|
|
|
/*
|
|
|
|
* Remove a name from a hash table,
|
|
|
|
* and optionally, a name=value pair from an option list.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
undo_option(struct hashtab *ht, struct nvlist **npp,
|
2003-06-25 10:42:40 +04:00
|
|
|
struct nvlist ***next, const char *name, const char *type)
|
2002-06-05 14:56:17 +04:00
|
|
|
{
|
|
|
|
struct nvlist *nv;
|
|
|
|
|
|
|
|
if (ht_remove(ht, name)) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("%s `%s' is not defined", type, name);
|
2002-06-05 14:56:17 +04:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
if (npp == NULL)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
for ( ; *npp != NULL; npp = &(*npp)->nv_next) {
|
|
|
|
if ((*npp)->nv_name != name)
|
|
|
|
continue;
|
2003-06-27 22:42:11 +04:00
|
|
|
if (next != NULL && *next == &(*npp)->nv_next)
|
2003-06-25 10:42:40 +04:00
|
|
|
*next = npp;
|
2002-06-05 14:56:17 +04:00
|
|
|
nv = (*npp)->nv_next;
|
|
|
|
nvfree(*npp);
|
|
|
|
*npp = nv;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
panic("%s `%s' is not defined in nvlist", type, name);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
1993-04-10 16:11:55 +04:00
|
|
|
/*
|
1995-04-28 10:54:58 +04:00
|
|
|
* Return true if there is at least one instance of the given unit
|
1996-03-17 05:08:22 +03:00
|
|
|
* on the given device attachment (or any units, if unit == WILD).
|
1993-04-10 16:11:55 +04:00
|
|
|
*/
|
1996-03-17 05:08:22 +03:00
|
|
|
int
|
2000-10-02 23:48:34 +04:00
|
|
|
deva_has_instances(struct deva *deva, int unit)
|
1993-04-10 16:11:55 +04:00
|
|
|
{
|
1997-10-18 11:58:56 +04:00
|
|
|
struct devi *i;
|
1993-04-10 16:11:55 +04:00
|
|
|
|
1996-03-17 05:08:22 +03:00
|
|
|
for (i = deva->d_ihead; i != NULL; i = i->i_asame)
|
2005-10-02 03:30:37 +04:00
|
|
|
if (i->i_active == DEVI_ACTIVE &&
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
(unit == WILD || unit == i->i_unit || i->i_unit == STAR))
|
1995-04-28 10:54:58 +04:00
|
|
|
return (1);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1996-03-17 05:08:22 +03:00
|
|
|
/*
|
|
|
|
* Return true if there is at least one instance of the given unit
|
|
|
|
* on the given base (or any units, if unit == WILD).
|
|
|
|
*/
|
|
|
|
int
|
2000-10-02 23:48:34 +04:00
|
|
|
devbase_has_instances(struct devbase *dev, int unit)
|
1996-03-17 05:08:22 +03:00
|
|
|
{
|
1997-10-18 11:58:56 +04:00
|
|
|
struct deva *da;
|
1996-03-17 05:08:22 +03:00
|
|
|
|
2003-01-27 08:00:54 +03:00
|
|
|
/*
|
|
|
|
* Pseudo-devices are a little special. We consider them
|
|
|
|
* to have instances only if they are both:
|
|
|
|
*
|
|
|
|
* 1. Included in this kernel configuration.
|
|
|
|
*
|
2008-06-10 22:11:31 +04:00
|
|
|
* 2. Be declared "defpseudodev".
|
2003-01-27 08:00:54 +03:00
|
|
|
*/
|
|
|
|
if (dev->d_ispseudo) {
|
2008-06-10 22:11:31 +04:00
|
|
|
return ((ht_lookup(devitab, dev->d_name) != NULL)
|
|
|
|
&& (dev->d_ispseudo > 1));
|
2003-01-27 08:00:54 +03:00
|
|
|
}
|
|
|
|
|
1996-03-17 05:08:22 +03:00
|
|
|
for (da = dev->d_ahead; da != NULL; da = da->d_bsame)
|
|
|
|
if (deva_has_instances(da, unit))
|
|
|
|
return (1);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
static int
|
2000-10-02 23:48:34 +04:00
|
|
|
cfcrosscheck(struct config *cf, const char *what, struct nvlist *nv)
|
1995-04-28 10:54:58 +04:00
|
|
|
{
|
1997-10-18 11:58:56 +04:00
|
|
|
struct devbase *dev;
|
|
|
|
struct devi *pd;
|
1997-05-25 22:42:54 +04:00
|
|
|
int errs, devunit;
|
1995-04-28 10:54:58 +04:00
|
|
|
|
1996-11-12 02:41:54 +03:00
|
|
|
if (maxpartitions <= 0)
|
|
|
|
panic("cfcrosscheck");
|
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
for (errs = 0; nv != NULL; nv = nv->nv_next) {
|
|
|
|
if (nv->nv_name == NULL)
|
|
|
|
continue;
|
|
|
|
dev = ht_lookup(devbasetab, nv->nv_name);
|
|
|
|
if (dev == NULL)
|
|
|
|
panic("cfcrosscheck(%s)", nv->nv_name);
|
1997-05-25 22:42:54 +04:00
|
|
|
if (has_attr(dev->d_attrs, s_ifnet))
|
|
|
|
devunit = nv->nv_ifunit; /* XXX XXX XXX */
|
|
|
|
else
|
2007-01-14 02:47:36 +03:00
|
|
|
devunit = minor((uint32_t)nv->nv_int) / maxpartitions;
|
1997-05-25 22:42:54 +04:00
|
|
|
if (devbase_has_instances(dev, devunit))
|
1996-03-17 05:08:22 +03:00
|
|
|
continue;
|
|
|
|
if (devbase_has_instances(dev, STAR) &&
|
1997-05-25 22:42:54 +04:00
|
|
|
devunit >= dev->d_umax)
|
1995-04-28 10:54:58 +04:00
|
|
|
continue;
|
2002-06-05 14:56:17 +04:00
|
|
|
TAILQ_FOREACH(pd, &allpseudo, i_next) {
|
1997-05-25 22:42:54 +04:00
|
|
|
if (pd->i_base == dev && devunit < dev->d_umax &&
|
|
|
|
devunit >= 0)
|
1995-04-28 10:54:58 +04:00
|
|
|
goto loop;
|
2002-06-05 14:56:17 +04:00
|
|
|
}
|
1995-04-28 10:54:58 +04:00
|
|
|
(void)fprintf(stderr,
|
1998-05-22 23:29:00 +04:00
|
|
|
"%s:%d: %s says %s on %s, but there's no %s\n",
|
1995-04-28 10:54:58 +04:00
|
|
|
conffile, cf->cf_lineno,
|
|
|
|
cf->cf_name, what, nv->nv_str, nv->nv_str);
|
|
|
|
errs++;
|
2002-06-05 14:56:17 +04:00
|
|
|
loop:
|
2001-01-16 05:43:37 +03:00
|
|
|
;
|
1993-04-10 16:11:55 +04:00
|
|
|
}
|
1995-04-28 10:54:58 +04:00
|
|
|
return (errs);
|
1993-04-10 16:11:55 +04:00
|
|
|
}
|
1995-04-28 10:54:58 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1995-04-28 10:54:58 +04:00
|
|
|
* Cross-check the configuration: make sure that each target device
|
|
|
|
* or attribute (`at foo[0*?]') names at least one real device. Also
|
1997-06-12 19:03:09 +04:00
|
|
|
* see that the root and dump devices for all configurations are there.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1995-04-28 10:54:58 +04:00
|
|
|
int
|
2000-10-02 23:48:34 +04:00
|
|
|
crosscheck(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-18 11:58:56 +04:00
|
|
|
struct config *cf;
|
1995-04-28 10:54:58 +04:00
|
|
|
int errs;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
errs = 0;
|
2002-06-05 14:56:17 +04:00
|
|
|
if (TAILQ_EMPTY(&allcf)) {
|
2007-01-14 02:47:36 +03:00
|
|
|
warnx("%s has no configurations!", conffile);
|
1995-04-28 10:54:58 +04:00
|
|
|
errs++;
|
|
|
|
}
|
2002-06-05 14:56:17 +04:00
|
|
|
TAILQ_FOREACH(cf, &allcf, cf_next) {
|
1997-06-12 19:03:09 +04:00
|
|
|
if (cf->cf_root != NULL) { /* i.e., not root on ? */
|
1995-04-28 10:54:58 +04:00
|
|
|
errs += cfcrosscheck(cf, "root", cf->cf_root);
|
|
|
|
errs += cfcrosscheck(cf, "dumps", cf->cf_dump);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
1995-04-28 10:54:58 +04:00
|
|
|
return (errs);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1996-03-17 05:08:22 +03:00
|
|
|
* Check to see if there is a *'d unit with a needs-count file.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1995-04-28 10:54:58 +04:00
|
|
|
int
|
2000-10-02 23:48:34 +04:00
|
|
|
badstar(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-18 11:58:56 +04:00
|
|
|
struct devbase *d;
|
|
|
|
struct deva *da;
|
|
|
|
struct devi *i;
|
|
|
|
int errs, n;
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
errs = 0;
|
2002-06-05 14:56:17 +04:00
|
|
|
TAILQ_FOREACH(d, &allbases, d_next) {
|
1996-03-17 05:08:22 +03:00
|
|
|
for (da = d->d_ahead; da != NULL; da = da->d_bsame)
|
|
|
|
for (i = da->d_ihead; i != NULL; i = i->i_asame) {
|
|
|
|
if (i->i_unit == STAR)
|
2002-06-05 14:56:17 +04:00
|
|
|
goto aybabtu;
|
1996-03-17 05:08:22 +03:00
|
|
|
}
|
1995-04-28 10:54:58 +04:00
|
|
|
continue;
|
2002-06-05 14:56:17 +04:00
|
|
|
aybabtu:
|
1995-04-28 10:54:58 +04:00
|
|
|
if (ht_lookup(needcnttab, d->d_name)) {
|
2007-01-14 02:47:36 +03:00
|
|
|
warnx("%s's cannot be *'d until its driver is fixed",
|
1995-04-28 10:54:58 +04:00
|
|
|
d->d_name);
|
|
|
|
errs++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for (n = 0; i != NULL; i = i->i_alias)
|
|
|
|
if (!i->i_collapsed)
|
|
|
|
n++;
|
|
|
|
if (n < 1)
|
|
|
|
panic("badstar() n<1");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1995-04-28 10:54:58 +04:00
|
|
|
return (errs);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1996-11-12 02:41:54 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Verify/create builddir if necessary, change to it, and verify srcdir.
|
|
|
|
* This will be called when we see the first include.
|
|
|
|
*/
|
|
|
|
void
|
2000-10-02 23:48:34 +04:00
|
|
|
setupdirs(void)
|
1996-11-12 02:41:54 +03:00
|
|
|
{
|
2000-12-15 01:14:45 +03:00
|
|
|
struct stat st;
|
1996-11-12 02:41:54 +03:00
|
|
|
|
2000-12-15 01:14:45 +03:00
|
|
|
/* srcdir must be specified if builddir is not specified or if
|
|
|
|
* no configuration filename was specified. */
|
1996-11-12 02:41:54 +03:00
|
|
|
if ((builddir || strcmp(defbuilddir, ".") == 0) && !srcdir) {
|
2007-01-14 02:47:36 +03:00
|
|
|
cfgerror("source directory must be specified");
|
1996-11-12 02:41:54 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2007-01-08 19:08:08 +03:00
|
|
|
if (Lflag) {
|
|
|
|
if (srcdir == NULL)
|
|
|
|
srcdir = "../../..";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1996-11-12 02:41:54 +03:00
|
|
|
if (srcdir == NULL)
|
|
|
|
srcdir = "../../../..";
|
|
|
|
if (builddir == NULL)
|
|
|
|
builddir = defbuilddir;
|
|
|
|
|
2007-01-14 02:47:36 +03:00
|
|
|
if (stat(builddir, &st) == -1) {
|
|
|
|
if (mkdir(builddir, 0777) == -1)
|
|
|
|
errx(EXIT_FAILURE, "cannot create %s", builddir);
|
|
|
|
} else if (!S_ISDIR(st.st_mode))
|
|
|
|
errx(EXIT_FAILURE, "%s is not a directory", builddir);
|
|
|
|
if (chdir(builddir) == -1)
|
|
|
|
err(EXIT_FAILURE, "cannot change to %s", builddir);
|
|
|
|
if (stat(srcdir, &st) == -1)
|
|
|
|
err(EXIT_FAILURE, "cannot stat %s", srcdir);
|
|
|
|
if (!S_ISDIR(st.st_mode))
|
|
|
|
errx(EXIT_FAILURE, "%s is not a directory", srcdir);
|
1996-11-12 02:41:54 +03:00
|
|
|
}
|
2000-01-24 02:37:42 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Write identifier from "ident" directive into file, for
|
|
|
|
* newvers.sh to pick it up.
|
|
|
|
*/
|
|
|
|
int
|
2000-10-02 23:48:34 +04:00
|
|
|
mkident(void)
|
2000-01-24 02:37:42 +03:00
|
|
|
{
|
|
|
|
FILE *fp;
|
2006-03-20 01:34:44 +03:00
|
|
|
int error = 0;
|
2000-01-24 02:37:42 +03:00
|
|
|
|
|
|
|
(void)unlink("ident");
|
|
|
|
|
|
|
|
if (ident == NULL)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
if ((fp = fopen("ident", "w")) == NULL) {
|
2007-01-14 02:47:36 +03:00
|
|
|
warn("cannot write ident");
|
2000-01-24 02:37:42 +03:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
if (vflag)
|
|
|
|
(void)printf("using ident '%s'\n", ident);
|
2006-10-05 00:34:48 +04:00
|
|
|
fprintf(fp, "%s\n", ident);
|
|
|
|
fflush(fp);
|
|
|
|
if (ferror(fp))
|
2006-03-20 01:34:44 +03:00
|
|
|
error = 1;
|
2000-01-24 02:37:42 +03:00
|
|
|
(void)fclose(fp);
|
|
|
|
|
2006-03-20 01:34:44 +03:00
|
|
|
return error;
|
2000-01-24 02:37:42 +03:00
|
|
|
}
|
2001-12-17 18:39:43 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
logconfig_start(void)
|
|
|
|
{
|
|
|
|
extern FILE *yyin;
|
2003-09-14 16:33:05 +04:00
|
|
|
char line[1024];
|
|
|
|
const char *tmpdir;
|
2001-12-17 18:39:43 +03:00
|
|
|
struct stat st;
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
if (yyin == NULL || fstat(fileno(yyin), &st) == -1)
|
|
|
|
return;
|
2002-01-29 13:20:28 +03:00
|
|
|
cfgtime = st.st_mtime;
|
2001-12-17 18:39:43 +03:00
|
|
|
|
2001-12-21 22:09:43 +03:00
|
|
|
tmpdir = getenv("TMPDIR");
|
|
|
|
if (tmpdir == NULL)
|
|
|
|
tmpdir = "/tmp";
|
2007-01-14 02:47:36 +03:00
|
|
|
(void)snprintf(line, sizeof(line), "%s/config.tmp.XXXXXX", tmpdir);
|
2001-12-17 18:39:43 +03:00
|
|
|
if ((fd = mkstemp(line)) == -1 ||
|
|
|
|
(cfg = fdopen(fd, "r+")) == NULL) {
|
|
|
|
if (fd != -1) {
|
2007-01-14 02:47:36 +03:00
|
|
|
(void)unlink(line);
|
|
|
|
(void)close(fd);
|
2001-12-17 18:39:43 +03:00
|
|
|
}
|
|
|
|
cfg = NULL;
|
|
|
|
return;
|
|
|
|
}
|
2007-01-14 02:47:36 +03:00
|
|
|
(void)unlink(line);
|
2001-12-17 18:39:43 +03:00
|
|
|
|
2006-10-30 02:00:44 +03:00
|
|
|
(void)fprintf(cfg, "#include <sys/cdefs.h>\n\n");
|
2001-12-17 18:39:43 +03:00
|
|
|
(void)fprintf(cfg, "#include \"opt_config.h\"\n");
|
|
|
|
(void)fprintf(cfg, "\n");
|
|
|
|
(void)fprintf(cfg, "/*\n");
|
|
|
|
(void)fprintf(cfg, " * Add either (or both) of\n");
|
|
|
|
(void)fprintf(cfg, " *\n");
|
|
|
|
(void)fprintf(cfg, " *\toptions %s\n", LOGCONFIG_LARGE);
|
|
|
|
(void)fprintf(cfg, " *\toptions %s\n", LOGCONFIG_SMALL);
|
|
|
|
(void)fprintf(cfg, " *\n");
|
|
|
|
(void)fprintf(cfg,
|
|
|
|
" * to your kernel config file to embed it in the resulting\n");
|
|
|
|
(void)fprintf(cfg,
|
|
|
|
" * kernel. The latter option does not include files that are\n");
|
|
|
|
(void)fprintf(cfg,
|
|
|
|
" * included (recursively) by your config file. The embedded\n");
|
|
|
|
(void)fprintf(cfg,
|
|
|
|
" * data be extracted by using the command:\n");
|
|
|
|
(void)fprintf(cfg, " *\n");
|
|
|
|
(void)fprintf(cfg,
|
|
|
|
" *\tstrings netbsd | sed -n 's/^_CFG_//p' | unvis\n");
|
|
|
|
(void)fprintf(cfg, " */\n");
|
|
|
|
(void)fprintf(cfg, "\n");
|
|
|
|
(void)fprintf(cfg, "#ifdef CONFIG_FILE\n");
|
|
|
|
(void)fprintf(cfg, "#if defined(%s) || defined(%s)\n\n",
|
|
|
|
LOGCONFIG_LARGE, LOGCONFIG_SMALL);
|
2006-10-30 02:00:44 +03:00
|
|
|
(void)fprintf(cfg, "static const char config[] __used =\n\n");
|
2001-12-17 18:39:43 +03:00
|
|
|
|
|
|
|
(void)fprintf(cfg, "#ifdef %s\n\n", LOGCONFIG_LARGE);
|
|
|
|
(void)fprintf(cfg, "\"_CFG_### START CONFIG FILE \\\"%s\\\"\\n\"\n\n",
|
|
|
|
conffile);
|
|
|
|
(void)fprintf(cfg, "#endif /* %s */\n\n", LOGCONFIG_LARGE);
|
|
|
|
|
|
|
|
logconfig_include(yyin, NULL);
|
|
|
|
|
|
|
|
(void)fprintf(cfg, "#ifdef %s\n\n", LOGCONFIG_LARGE);
|
2001-12-24 01:41:27 +03:00
|
|
|
(void)fprintf(cfg, "\"_CFG_### END CONFIG FILE \\\"%s\\\"\\n\"\n",
|
|
|
|
conffile);
|
2001-12-17 18:39:43 +03:00
|
|
|
|
|
|
|
rewind(yyin);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
logconfig_include(FILE *cf, const char *filename)
|
|
|
|
{
|
|
|
|
char line[1024], in[2048], *out;
|
|
|
|
struct stat st;
|
2003-06-18 08:19:49 +04:00
|
|
|
int missingeol;
|
2001-12-17 18:39:43 +03:00
|
|
|
|
|
|
|
if (!cfg)
|
|
|
|
return;
|
|
|
|
|
2005-06-02 09:12:41 +04:00
|
|
|
missingeol = 0;
|
2001-12-17 18:39:43 +03:00
|
|
|
if (fstat(fileno(cf), &st) == -1)
|
|
|
|
return;
|
2002-01-29 13:20:28 +03:00
|
|
|
if (cfgtime < st.st_mtime)
|
|
|
|
cfgtime = st.st_mtime;
|
2001-12-17 18:39:43 +03:00
|
|
|
|
|
|
|
if (filename)
|
2001-12-24 01:41:27 +03:00
|
|
|
(void)fprintf(cfg,
|
|
|
|
"\"_CFG_### (included from \\\"%s\\\")\\n\"\n",
|
2001-12-17 18:39:43 +03:00
|
|
|
filename);
|
|
|
|
while (fgets(line, sizeof(line), cf) != NULL) {
|
2003-06-18 08:19:49 +04:00
|
|
|
missingeol = 1;
|
2001-12-24 01:41:27 +03:00
|
|
|
(void)fprintf(cfg, "\"_CFG_");
|
2001-12-17 18:39:43 +03:00
|
|
|
if (filename)
|
|
|
|
(void)fprintf(cfg, "###> ");
|
|
|
|
strvis(in, line, VIS_TAB);
|
|
|
|
for (out = in; *out; out++)
|
|
|
|
switch (*out) {
|
2001-12-24 01:41:27 +03:00
|
|
|
case '\n':
|
|
|
|
(void)fprintf(cfg, "\\n\"\n");
|
2003-06-18 08:19:49 +04:00
|
|
|
missingeol = 0;
|
2001-12-24 01:41:27 +03:00
|
|
|
break;
|
2001-12-17 18:39:43 +03:00
|
|
|
case '"': case '\\':
|
|
|
|
(void)fputc('\\', cfg);
|
2001-12-24 01:41:27 +03:00
|
|
|
/* FALLTHROUGH */
|
2001-12-17 18:39:43 +03:00
|
|
|
default:
|
|
|
|
(void)fputc(*out, cfg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-06-18 08:19:49 +04:00
|
|
|
if (missingeol) {
|
|
|
|
(void)fprintf(cfg, "\\n\"\n");
|
2007-01-14 02:47:36 +03:00
|
|
|
warnx("%s: newline missing at EOF",
|
2003-06-18 08:19:49 +04:00
|
|
|
filename != NULL ? filename : conffile);
|
|
|
|
}
|
2001-12-17 18:39:43 +03:00
|
|
|
if (filename)
|
2001-12-24 01:41:27 +03:00
|
|
|
(void)fprintf(cfg, "\"_CFG_### (end include \\\"%s\\\")\\n\"\n",
|
2001-12-17 18:39:43 +03:00
|
|
|
filename);
|
|
|
|
|
|
|
|
rewind(cf);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
logconfig_end(void)
|
|
|
|
{
|
|
|
|
char line[1024];
|
|
|
|
FILE *fp;
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
if (!cfg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
(void)fprintf(cfg, "#endif /* %s */\n", LOGCONFIG_LARGE);
|
|
|
|
(void)fprintf(cfg, ";\n");
|
|
|
|
(void)fprintf(cfg, "#endif /* %s || %s */\n",
|
|
|
|
LOGCONFIG_LARGE, LOGCONFIG_SMALL);
|
|
|
|
(void)fprintf(cfg, "#endif /* CONFIG_FILE */\n");
|
2006-10-05 00:34:48 +04:00
|
|
|
fflush(cfg);
|
|
|
|
if (ferror(cfg))
|
|
|
|
err(EXIT_FAILURE, "write to temporary file for config.h failed");
|
2001-12-17 18:39:43 +03:00
|
|
|
rewind(cfg);
|
|
|
|
|
|
|
|
if (stat("config_file.h", &st) != -1) {
|
2002-01-29 13:20:28 +03:00
|
|
|
if (cfgtime < st.st_mtime) {
|
2001-12-17 18:39:43 +03:00
|
|
|
fclose(cfg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fp = fopen("config_file.h", "w");
|
2006-10-05 00:34:48 +04:00
|
|
|
if (!fp)
|
|
|
|
err(EXIT_FAILURE, "cannot open \"config.h\"");
|
2002-01-19 09:10:13 +03:00
|
|
|
|
2001-12-17 18:39:43 +03:00
|
|
|
while (fgets(line, sizeof(line), cfg) != NULL)
|
|
|
|
fputs(line, fp);
|
2006-10-05 00:34:48 +04:00
|
|
|
fflush(fp);
|
|
|
|
if (ferror(fp))
|
|
|
|
err(EXIT_FAILURE, "write to \"config.h\" failed");
|
2001-12-17 18:39:43 +03:00
|
|
|
fclose(fp);
|
|
|
|
fclose(cfg);
|
|
|
|
}
|
2002-06-05 14:56:17 +04:00
|
|
|
|
|
|
|
static const char *
|
|
|
|
strtolower(const char *name)
|
|
|
|
{
|
|
|
|
const char *n;
|
2004-10-30 00:33:06 +04:00
|
|
|
char *p, low[500];
|
|
|
|
unsigned char c;
|
2002-06-05 14:56:17 +04:00
|
|
|
|
|
|
|
for (n = name, p = low; (c = *n) != '\0'; n++)
|
|
|
|
*p++ = isupper(c) ? tolower(c) : c;
|
|
|
|
*p = 0;
|
|
|
|
return (intern(low));
|
|
|
|
}
|
|
|
|
|
2003-04-26 16:53:43 +04:00
|
|
|
static int
|
|
|
|
is_elf(const char *file)
|
|
|
|
{
|
|
|
|
int kernel;
|
|
|
|
char hdr[4];
|
|
|
|
|
|
|
|
kernel = open(file, O_RDONLY);
|
2007-01-14 02:47:36 +03:00
|
|
|
if (kernel == -1)
|
|
|
|
err(EXIT_FAILURE, "cannot open %s", file);
|
|
|
|
if (read(kernel, hdr, 4) != 4)
|
|
|
|
err(EXIT_FAILURE, "Cannot read from %s", file);
|
|
|
|
(void)close(kernel);
|
2003-04-26 16:53:43 +04:00
|
|
|
|
|
|
|
return memcmp("\177ELF", hdr, 4) == 0 ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
extract_config(const char *kname, const char *cname, int cfd)
|
|
|
|
{
|
|
|
|
char *ptr;
|
|
|
|
int found, kfd, i;
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
found = 0;
|
|
|
|
|
|
|
|
/* mmap(2) binary kernel */
|
|
|
|
kfd = open(conffile, O_RDONLY);
|
2007-01-14 02:47:36 +03:00
|
|
|
if (kfd == -1)
|
|
|
|
err(EXIT_FAILURE, "cannot open %s", kname);
|
|
|
|
if (fstat(kfd, &st) == -1)
|
|
|
|
err(EXIT_FAILURE, "cannot stat %s", kname);
|
|
|
|
ptr = mmap(0, st.st_size, PROT_READ, MAP_FILE | MAP_SHARED,
|
2003-04-26 16:53:43 +04:00
|
|
|
kfd, 0);
|
2007-01-14 02:47:36 +03:00
|
|
|
if (ptr == MAP_FAILED)
|
|
|
|
err(EXIT_FAILURE, "cannot mmap %s", kname);
|
2003-04-26 16:53:43 +04:00
|
|
|
|
|
|
|
/* Scan mmap(2)'ed region, extracting kernel configuration */
|
|
|
|
for (i = 0; i < st.st_size; i++) {
|
|
|
|
if ((*ptr == '_') && (st.st_size - i > 5) && memcmp(ptr,
|
|
|
|
"_CFG_", 5) == 0) {
|
|
|
|
/* Line found */
|
|
|
|
char *oldptr, line[LINE_MAX + 1], uline[LINE_MAX + 1];
|
2003-09-14 16:33:05 +04:00
|
|
|
int j;
|
2003-04-26 16:53:43 +04:00
|
|
|
|
|
|
|
found = 1;
|
|
|
|
|
|
|
|
oldptr = (ptr += 5);
|
2007-01-14 02:47:36 +03:00
|
|
|
while (*ptr != '\n' && *ptr != '\0')
|
|
|
|
ptr++;
|
|
|
|
if (ptr - oldptr > LINE_MAX)
|
|
|
|
errx(EXIT_FAILURE, "line too long");
|
2003-09-14 16:43:04 +04:00
|
|
|
i += ptr - oldptr + 5;
|
2007-01-14 02:47:36 +03:00
|
|
|
(void)memcpy(line, oldptr, (size_t)(ptr - oldptr));
|
2003-04-26 16:53:43 +04:00
|
|
|
line[ptr - oldptr] = '\0';
|
2003-09-14 16:33:05 +04:00
|
|
|
j = strunvis(uline, line);
|
2007-01-14 02:47:36 +03:00
|
|
|
if (j == -1)
|
|
|
|
errx(EXIT_FAILURE, "unvis: invalid "
|
|
|
|
"encoded sequence");
|
2003-09-14 16:33:05 +04:00
|
|
|
uline[j] = '\n';
|
2007-01-14 02:47:36 +03:00
|
|
|
if (write(cfd, uline, (size_t)j + 1) == -1)
|
|
|
|
err(EXIT_FAILURE, "cannot write to %s", cname);
|
|
|
|
} else
|
|
|
|
ptr++;
|
2003-04-26 16:53:43 +04:00
|
|
|
}
|
|
|
|
|
2007-01-14 02:47:36 +03:00
|
|
|
(void)close(kfd);
|
2003-04-26 16:53:43 +04:00
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
|
2005-10-02 03:30:37 +04:00
|
|
|
struct dhdi_params {
|
|
|
|
struct devbase *d;
|
|
|
|
int unit;
|
2005-10-05 00:13:39 +04:00
|
|
|
int level;
|
2005-10-02 03:30:37 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
devbase_has_dead_instances(const char *key, void *value, void *aux)
|
|
|
|
{
|
2005-10-05 00:13:39 +04:00
|
|
|
struct devi *i;
|
2005-10-02 03:30:37 +04:00
|
|
|
struct dhdi_params *dhdi = aux;
|
|
|
|
|
2005-10-05 00:13:39 +04:00
|
|
|
for (i = value; i != NULL; i = i->i_alias)
|
|
|
|
if (i->i_base == dhdi->d &&
|
|
|
|
(dhdi->unit == WILD || dhdi->unit == i->i_unit ||
|
|
|
|
i->i_unit == STAR) &&
|
|
|
|
i->i_level >= dhdi->level)
|
|
|
|
return 1;
|
2005-10-02 03:30:37 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is almost the same as devbase_has_instances, except it
|
|
|
|
* may have special considerations regarding ignored instances.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
2005-10-05 00:13:39 +04:00
|
|
|
devbase_has_any_instance(struct devbase *dev, int unit, int state, int level)
|
2005-10-02 03:30:37 +04:00
|
|
|
{
|
|
|
|
struct deva *da;
|
|
|
|
struct devi *i;
|
|
|
|
|
|
|
|
if (dev->d_ispseudo) {
|
|
|
|
if (dev->d_ihead != NULL)
|
|
|
|
return 1;
|
2005-10-05 00:13:39 +04:00
|
|
|
else if (state != DEVI_IGNORED)
|
|
|
|
return 0;
|
|
|
|
if ((i = ht_lookup(deaddevitab, dev->d_name)) == NULL)
|
2005-10-02 03:30:37 +04:00
|
|
|
return 0;
|
2005-10-05 00:13:39 +04:00
|
|
|
return (i->i_level >= level);
|
2005-10-02 03:30:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (da = dev->d_ahead; da != NULL; da = da->d_bsame)
|
|
|
|
for (i = da->d_ihead; i != NULL; i = i->i_asame)
|
|
|
|
if ((i->i_active == DEVI_ACTIVE ||
|
|
|
|
i->i_active == state) &&
|
|
|
|
(unit == WILD || unit == i->i_unit ||
|
|
|
|
i->i_unit == STAR))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (state == DEVI_IGNORED) {
|
2005-10-05 00:13:39 +04:00
|
|
|
struct dhdi_params dhdi = { dev, unit, level };
|
2005-10-02 03:30:37 +04:00
|
|
|
/* also check dead devices */
|
|
|
|
return ht_enumerate(deaddevitab, devbase_has_dead_instances,
|
|
|
|
&dhdi);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check_dead_devi(), used with ht_enumerate, checks if any of the removed
|
|
|
|
* device instances would have been a valid instance considering the devbase,
|
|
|
|
* the parent device and the interface attribute.
|
|
|
|
*
|
|
|
|
* In other words, for a non-active device, it checks if children would be
|
|
|
|
* actual orphans or the result of a negative statement in the config file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct cdd_params {
|
|
|
|
struct devbase *d;
|
|
|
|
struct attr *at;
|
|
|
|
struct devbase *parent;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
check_dead_devi(const char *key, void *value, void *aux)
|
|
|
|
{
|
|
|
|
struct cdd_params *cdd = aux;
|
|
|
|
struct devi *i = value;
|
2005-10-05 00:13:39 +04:00
|
|
|
struct pspec *p;
|
2005-10-02 03:30:37 +04:00
|
|
|
|
|
|
|
if (i->i_base != cdd->d)
|
|
|
|
return 0;
|
|
|
|
|
2005-10-05 00:13:39 +04:00
|
|
|
for (; i != NULL; i = i->i_alias) {
|
|
|
|
p = i->i_pspec;
|
|
|
|
if ((p == NULL && cdd->at == NULL) ||
|
|
|
|
(p != NULL && p->p_iattr == cdd->at &&
|
|
|
|
(p->p_atdev == NULL || p->p_atdev == cdd->parent))) {
|
|
|
|
if (p != NULL &&
|
|
|
|
!devbase_has_any_instance(cdd->parent, p->p_atunit,
|
|
|
|
DEVI_IGNORED, i->i_level))
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
2005-10-02 03:30:37 +04:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
static void
|
2005-10-02 03:30:37 +04:00
|
|
|
do_kill_orphans(struct devbase *d, struct attr *at, struct devbase *parent,
|
|
|
|
int state)
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
{
|
|
|
|
struct nvlist *nv, *nv1;
|
|
|
|
struct attr *a;
|
|
|
|
struct devi *i, *j = NULL;
|
|
|
|
struct pspec *p;
|
2005-10-02 03:30:37 +04:00
|
|
|
int active = 0;
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A pseudo-device will always attach at root, and if it has an
|
|
|
|
* instance (it cannot have more than one), it is enough to consider
|
|
|
|
* it active, as there is no real attachment.
|
2005-10-02 03:30:37 +04:00
|
|
|
*
|
|
|
|
* A pseudo device can never be marked DEVI_IGNORED.
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
*/
|
|
|
|
if (d->d_ispseudo) {
|
2005-10-02 03:30:37 +04:00
|
|
|
if (d->d_ihead != NULL)
|
|
|
|
d->d_ihead->i_active = active = DEVI_ACTIVE;
|
|
|
|
else {
|
|
|
|
if (ht_lookup(deaddevitab, d->d_name) != NULL)
|
|
|
|
active = DEVI_IGNORED;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
} else {
|
2005-10-03 01:22:56 +04:00
|
|
|
int seen = 0;
|
|
|
|
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
for (i = d->d_ihead; i != NULL; i = i->i_bsame) {
|
|
|
|
for (j = i; j != NULL; j = j->i_alias) {
|
|
|
|
p = j->i_pspec;
|
|
|
|
if ((p == NULL && at == NULL) ||
|
|
|
|
(p != NULL && p->p_iattr == at &&
|
|
|
|
(p->p_atdev == NULL ||
|
|
|
|
p->p_atdev == parent))) {
|
|
|
|
if (p != NULL &&
|
2005-10-02 03:30:37 +04:00
|
|
|
!devbase_has_any_instance(parent,
|
2005-10-05 00:13:39 +04:00
|
|
|
p->p_atunit, state, j->i_level))
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
continue;
|
|
|
|
/*
|
|
|
|
* There are Fry-like devices which can
|
|
|
|
* be their own grand-parent (or even
|
|
|
|
* parent, like uhub). We don't want
|
|
|
|
* to loop, so if we've already reached
|
|
|
|
* an instance for one reason or
|
|
|
|
* another, stop there.
|
|
|
|
*/
|
2005-10-02 03:30:37 +04:00
|
|
|
if (j->i_active == DEVI_ACTIVE ||
|
2005-10-03 01:22:56 +04:00
|
|
|
j->i_active == state) {
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
/*
|
|
|
|
* Device has already been
|
2005-10-03 01:22:56 +04:00
|
|
|
* seen. However it might
|
|
|
|
* have siblings who still
|
|
|
|
* have to be activated or
|
|
|
|
* orphaned.
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
*/
|
2005-10-03 01:22:56 +04:00
|
|
|
seen = 1;
|
|
|
|
continue;
|
|
|
|
}
|
2005-10-02 03:30:37 +04:00
|
|
|
j->i_active = active = state;
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
if (p != NULL)
|
2005-10-02 03:30:37 +04:00
|
|
|
p->p_active = state;
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-10-05 03:00:34 +04:00
|
|
|
/*
|
|
|
|
* If we've been there but have made no change, stop.
|
|
|
|
*/
|
|
|
|
if (seen && !active)
|
2005-10-03 01:22:56 +04:00
|
|
|
return;
|
2005-10-02 03:30:37 +04:00
|
|
|
if (!active) {
|
|
|
|
struct cdd_params cdd = { d, at, parent };
|
|
|
|
/* Look for a matching dead devi */
|
2005-12-10 16:39:47 +03:00
|
|
|
if (ht_enumerate(deaddevitab, check_dead_devi, &cdd) &&
|
|
|
|
d != parent)
|
2005-10-02 03:30:37 +04:00
|
|
|
/*
|
|
|
|
* That device had its instances removed.
|
|
|
|
* Continue the loop marking descendants
|
|
|
|
* with DEVI_IGNORED instead of DEVI_ACTIVE.
|
2005-12-10 16:39:47 +03:00
|
|
|
*
|
|
|
|
* There is one special case for devices that
|
|
|
|
* are their own parent: if that instance is
|
|
|
|
* removed (e.g., no uhub* at uhub?), we don't
|
|
|
|
* have to continue looping.
|
2005-10-02 03:30:37 +04:00
|
|
|
*/
|
|
|
|
active = DEVI_IGNORED;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (nv = d->d_attrs; nv != NULL; nv = nv->nv_next) {
|
|
|
|
a = nv->nv_ptr;
|
|
|
|
for (nv1 = a->a_devs; nv1 != NULL; nv1 = nv1->nv_next)
|
2005-10-02 03:30:37 +04:00
|
|
|
do_kill_orphans(nv1->nv_ptr, a, d, active);
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-01-14 02:47:36 +03:00
|
|
|
/*ARGSUSED*/
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
kill_orphans_cb(const char *key, void *value, void *aux)
|
|
|
|
{
|
2005-10-02 03:30:37 +04:00
|
|
|
do_kill_orphans((struct devbase *)value, NULL, NULL, DEVI_ACTIVE);
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-01-14 02:47:36 +03:00
|
|
|
kill_orphans(void)
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
{
|
|
|
|
ht_enumerate(devroottab, kill_orphans_cb, NULL);
|
|
|
|
}
|