Changes to config(8) to support dump configuration in the wake of the

new swap system.  The dump specification syntax is now more flexible,
and supports constructs like the following:

config netbsd root on ? type ? dumps on ?
	- wildcarded root, fstype, and dump device

config netbsd root on ? type ffs dumps on sd0b
	- wildcarded root, ffs root fs, always dump on sd0b

config netbsd root on de0 type nfs dumps on wd0b
	- mount an nfs root using de0, and write kernel crash dumps
	  to wd0b

Also, garbage-collect some now unused code, now that swap configuration
is no longer handled by config(8).
This commit is contained in:
thorpej 1997-06-14 04:25:55 +00:00
parent 70eb4a4223
commit 9fec93804a
3 changed files with 44 additions and 45 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkswap.c,v 1.7 1997/06/12 15:03:11 mrg Exp $ */ /* $NetBSD: mkswap.c,v 1.8 1997/06/14 04:25:55 thorpej Exp $ */
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -88,7 +88,7 @@ mkoneswap(cf)
register struct nvlist *nv; register struct nvlist *nv;
register FILE *fp; register FILE *fp;
char fname[200]; char fname[200];
char rootinfo[200]; char specinfo[200];
(void)sprintf(fname, "swap%s.c", cf->cf_name); (void)sprintf(fname, "swap%s.c", cf->cf_name);
if ((fp = fopen(fname, "w")) == NULL) { if ((fp = fopen(fname, "w")) == NULL) {
@ -106,12 +106,12 @@ mkoneswap(cf)
*/ */
nv = cf->cf_root; nv = cf->cf_root;
if (cf->cf_root->nv_str == s_qmark) if (cf->cf_root->nv_str == s_qmark)
strcpy(rootinfo, "NULL"); strcpy(specinfo, "NULL");
else else
sprintf(rootinfo, "\"%s\"", cf->cf_root->nv_str); sprintf(specinfo, "\"%s\"", cf->cf_root->nv_str);
if (fprintf(fp, "const char *rootspec = %s;\n", rootinfo) < 0) if (fprintf(fp, "const char *rootspec = %s;\n", specinfo) < 0)
goto wrerror; goto wrerror;
if (fprintf(fp, "dev_t\trootdev = %s;\t/* %s */\n", if (fprintf(fp, "dev_t\trootdev = %s;\t/* %s */\n\n",
mkdevstr(nv->nv_int), mkdevstr(nv->nv_int),
nv->nv_str == s_qmark ? "wildcarded" : nv->nv_str) < 0) nv->nv_str == s_qmark ? "wildcarded" : nv->nv_str) < 0)
goto wrerror; goto wrerror;
@ -120,22 +120,28 @@ mkoneswap(cf)
* Emit the dump device. * Emit the dump device.
*/ */
nv = cf->cf_dump; nv = cf->cf_dump;
if (fprintf(fp, "dev_t\tdumpdev = %s;\t/* %s */\n", if (cf->cf_dump == NULL)
strcpy(specinfo, "NULL");
else
sprintf(specinfo, "\"%s\"", cf->cf_dump->nv_str);
if (fprintf(fp, "const char *dumpspec = %s;\n", specinfo) < 0)
goto wrerror;
if (fprintf(fp, "dev_t\tdumpdev = %s;\t/* %s */\n\n",
nv ? mkdevstr(nv->nv_int) : "NODEV", nv ? mkdevstr(nv->nv_int) : "NODEV",
nv ? (nv->nv_str ? nv->nv_str : "none") : "unspecified") < 0) nv ? nv->nv_str : "unspecified") < 0)
goto wrerror; goto wrerror;
/* /*
* Emit the root file system. * Emit the root file system.
*/ */
if (cf->cf_fstype == NULL) if (cf->cf_fstype == NULL)
strcpy(rootinfo, "NULL"); strcpy(specinfo, "NULL");
else { else {
sprintf(rootinfo, "%s_mountroot", cf->cf_fstype); sprintf(specinfo, "%s_mountroot", cf->cf_fstype);
if (fprintf(fp, "extern int %s __P((void));\n", rootinfo) < 0) if (fprintf(fp, "extern int %s __P((void));\n", specinfo) < 0)
goto wrerror; goto wrerror;
} }
if (fprintf(fp, "int (*mountroot) __P((void)) = %s;\n", rootinfo) < 0) if (fprintf(fp, "int (*mountroot) __P((void)) = %s;\n", specinfo) < 0)
goto wrerror; goto wrerror;
if (fclose(fp)) { if (fclose(fp)) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: sem.c,v 1.16 1997/06/12 15:03:13 mrg Exp $ */ /* $NetBSD: sem.c,v 1.17 1997/06/14 04:25:56 thorpej Exp $ */
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -59,8 +59,8 @@
#define NAMESIZE 100 /* local name buffers */ #define NAMESIZE 100 /* local name buffers */
const char *s_ifnet; /* magic attribute */ const char *s_ifnet; /* magic attribute */
const char *s_nfs;
const char *s_qmark; const char *s_qmark;
const char *s_none;
static struct hashtab *cfhashtab; /* for config lookup */ static struct hashtab *cfhashtab; /* for config lookup */
static struct hashtab *devitab; /* etc */ static struct hashtab *devitab; /* etc */
@ -79,8 +79,6 @@ static struct nvlist *addtoattr __P((struct nvlist *, struct devbase *));
static int exclude __P((struct nvlist *, const char *, const char *)); static int exclude __P((struct nvlist *, const char *, const char *));
static int resolve __P((struct nvlist **, const char *, const char *, static int resolve __P((struct nvlist **, const char *, const char *,
struct nvlist *, int)); struct nvlist *, int));
static int lresolve __P((struct nvlist **, const char *, const char *,
struct nvlist *, int));
static struct devi *newdevi __P((const char *, int, struct devbase *d)); static struct devi *newdevi __P((const char *, int, struct devbase *d));
static struct devi *getdevi __P((const char *)); static struct devi *getdevi __P((const char *));
static const char *concat __P((const char *, int)); static const char *concat __P((const char *, int));
@ -116,8 +114,8 @@ initsem()
nextpseudo = &allpseudo; nextpseudo = &allpseudo;
s_ifnet = intern("ifnet"); s_ifnet = intern("ifnet");
s_nfs = intern("nfs");
s_qmark = intern("?"); s_qmark = intern("?");
s_none = intern("none");
} }
/* Name of include file just ended (set in scan.l) */ /* Name of include file just ended (set in scan.l) */
@ -673,21 +671,6 @@ resolve(nvp, name, what, dflt, part)
return (0); return (0);
} }
static int
lresolve(nvp, name, what, dflt, part)
register struct nvlist **nvp;
const char *name, *what;
struct nvlist *dflt;
int part;
{
int err;
while ((err = resolve(nvp, name, what, dflt, part)) == 0 &&
(*nvp)->nv_next != NULL)
nvp = &(*nvp)->nv_next;
return (err);
}
/* /*
* Add a completed configuration to the list. * Add a completed configuration to the list.
*/ */
@ -709,23 +692,33 @@ addconf(cf0)
*cf = *cf0; *cf = *cf0;
/* /*
* Check for wildcarded root device. * Resolve the root device.
*/ */
if (cf->cf_root->nv_str == s_qmark) { if (cf->cf_root->nv_str != s_qmark) {
/*
* Make sure no dump device specified.
* Note single | here (check all).
*/
if (exclude(cf->cf_dump, name, "dump device"))
goto bad;
} else {
nv = cf->cf_root; nv = cf->cf_root;
if (nv == NULL) { if (nv == NULL) {
error("%s: no root device specified", name); error("%s: no root device specified", name);
goto bad; goto bad;
} }
if (resolve(&cf->cf_root, name, "root", nv, 'a') | if (resolve(&cf->cf_root, name, "root", nv, 'a'))
resolve(&cf->cf_dump, name, "dumps", nv, 'b')) goto bad;
}
/*
* Resolve the dump device.
*/
if (cf->cf_dump == NULL || cf->cf_dump->nv_str == s_qmark) {
/*
* Wildcarded dump device is equivalent to unspecified.
*/
cf->cf_dump = NULL;
} else if (cf->cf_dump->nv_str == s_none) {
/*
* Operator has requested that no dump device should be
* configured; do nothing.
*/
} else {
if (resolve(&cf->cf_dump, name, "dumps", cf->cf_dump, 'b'))
goto bad; goto bad;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: sem.h,v 1.8 1997/05/25 18:42:57 thorpej Exp $ */ /* $NetBSD: sem.h,v 1.9 1997/06/14 04:25:57 thorpej Exp $ */
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -68,5 +68,5 @@ const char *wildref __P((const char *name));
int has_attr __P((struct nvlist *, const char *)); int has_attr __P((struct nvlist *, const char *));
extern const char *s_qmark; extern const char *s_qmark;
extern const char *s_nfs; extern const char *s_none;
extern const char *s_ifnet; extern const char *s_ifnet;