- rename {x,}error -> cfg{x,}error and {x,}warn -> cfg{x,}warn so that we
can use err(3) and warn(3) to display errors instead of using inconsistent fprintf's. - remove emalloc/estrdup etc. We have them in libutil.
This commit is contained in:
parent
869fc5c107
commit
c7295a4c51
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: defs.h,v 1.19 2007/01/12 21:49:51 cube Exp $ */
|
||||
/* $NetBSD: defs.h,v 1.20 2007/01/13 23:47:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -440,7 +440,7 @@ SLIST_HEAD(, prefix) prefixes, /* prefix stack */
|
|||
SLIST_HEAD(, prefix) curdirs; /* curdir stack */
|
||||
|
||||
struct devi **packed; /* arrayified table for packed devi's */
|
||||
int npacked; /* size of packed table, <= ndevi */
|
||||
size_t npacked; /* size of packed table, <= ndevi */
|
||||
|
||||
struct { /* loc[] table for config */
|
||||
const char **vec;
|
||||
|
@ -538,20 +538,16 @@ void initsem(void);
|
|||
int onlist(struct nvlist *, void *);
|
||||
|
||||
/* util.c */
|
||||
void *ecalloc(size_t, size_t);
|
||||
void *emalloc(size_t);
|
||||
void *erealloc(void *, size_t);
|
||||
char *estrdup(const char *);
|
||||
void prefix_push(const char *);
|
||||
void prefix_pop(void);
|
||||
char *sourcepath(const char *);
|
||||
void warn(const char *, ...) /* immediate warns */
|
||||
void cfgwarn(const char *, ...) /* immediate warns */
|
||||
__attribute__((__format__(__printf__, 1, 2)));
|
||||
void xwarn(const char *, int, const char *, ...) /* delayed warns */
|
||||
void cfgxwarn(const char *, int, const char *, ...) /* delayed warns */
|
||||
__attribute__((__format__(__printf__, 3, 4)));
|
||||
void error(const char *, ...) /* immediate errs */
|
||||
void cfgerror(const char *, ...) /* immediate errs */
|
||||
__attribute__((__format__(__printf__, 1, 2)));
|
||||
void xerror(const char *, int, const char *, ...) /* delayed errs */
|
||||
void cfgxerror(const char *, int, const char *, ...) /* delayed errs */
|
||||
__attribute__((__format__(__printf__, 3, 4)));
|
||||
__dead void panic(const char *, ...)
|
||||
__attribute__((__format__(__printf__, 1, 2)));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: files.c,v 1.5 2006/12/26 00:07:18 alc Exp $ */
|
||||
/* $NetBSD: files.c,v 1.6 2007/01/13 23:47:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -97,11 +97,12 @@ addfile(const char *path, struct nvlist *optx, int flags, const char *rule)
|
|||
needc = flags & FI_NEEDSCOUNT;
|
||||
needf = flags & FI_NEEDSFLAG;
|
||||
if (needc && needf) {
|
||||
error("cannot mix needs-count and needs-flag");
|
||||
cfgerror("cannot mix needs-count and needs-flag");
|
||||
goto bad;
|
||||
}
|
||||
if (optx == NULL && (needc || needf)) {
|
||||
error("nothing to %s for %s", needc ? "count" : "flag", path);
|
||||
cfgerror("nothing to %s for %s", needc ? "count" : "flag",
|
||||
path);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
|
@ -114,7 +115,7 @@ addfile(const char *path, struct nvlist *optx, int flags, const char *rule)
|
|||
dotp = strrchr(tail, '.');
|
||||
if (dotp == NULL || dotp[1] == 0 ||
|
||||
(baselen = dotp - tail) >= sizeof(base)) {
|
||||
error("invalid pathname `%s'", path);
|
||||
cfgerror("invalid pathname `%s'", path);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
|
@ -141,8 +142,8 @@ addfile(const char *path, struct nvlist *optx, int flags, const char *rule)
|
|||
fi->fi_mkrule = rule;
|
||||
return;
|
||||
}
|
||||
error("duplicate file %s", path);
|
||||
xerror(fi->fi_srcfile, fi->fi_srcline,
|
||||
cfgerror("duplicate file %s", path);
|
||||
cfgxerror(fi->fi_srcfile, fi->fi_srcline,
|
||||
"here is the original definition");
|
||||
goto bad;
|
||||
}
|
||||
|
@ -179,8 +180,8 @@ addobject(const char *path, struct nvlist *optx, int flags)
|
|||
free(oi);
|
||||
if ((oi = ht_lookup(pathtab, path)) == NULL)
|
||||
panic("addfile: ht_lookup(%s)", path);
|
||||
error("duplicate file %s", path);
|
||||
xerror(oi->oi_srcfile, oi->oi_srcline,
|
||||
cfgerror("duplicate file %s", path);
|
||||
cfgxerror(oi->oi_srcfile, oi->oi_srcline,
|
||||
"here is the original definition");
|
||||
}
|
||||
oi->oi_srcfile = yyfile;
|
||||
|
@ -226,7 +227,7 @@ checkaux(const char *name, void *context)
|
|||
struct files *fi = context;
|
||||
|
||||
if (ht_lookup(devbasetab, name) == NULL) {
|
||||
xerror(fi->fi_srcfile, fi->fi_srcline,
|
||||
cfgxerror(fi->fi_srcfile, fi->fi_srcline,
|
||||
"`%s' is not a countable device",
|
||||
name);
|
||||
/* keep fixfiles() from complaining again */
|
||||
|
@ -287,10 +288,10 @@ fixfiles(void)
|
|||
ofi->fi_flags &= ~FI_SEL;
|
||||
ofi->fi_flags |= FI_HIDDEN;
|
||||
} else {
|
||||
xerror(fi->fi_srcfile, fi->fi_srcline,
|
||||
cfgxerror(fi->fi_srcfile, fi->fi_srcline,
|
||||
"object file collision on %s.o, from %s",
|
||||
fi->fi_base, fi->fi_path);
|
||||
xerror(ofi->fi_srcfile, ofi->fi_srcline,
|
||||
cfgxerror(ofi->fi_srcfile, ofi->fi_srcline,
|
||||
"here is the previous file: %s",
|
||||
ofi->fi_path);
|
||||
err = 1;
|
||||
|
@ -352,18 +353,18 @@ fixdevsw(void)
|
|||
if (res != NULL) {
|
||||
if (res->dm_cmajor != dm->dm_cmajor ||
|
||||
res->dm_bmajor != dm->dm_bmajor) {
|
||||
xerror(res->dm_srcfile, res->dm_srcline,
|
||||
cfgxerror(res->dm_srcfile, res->dm_srcline,
|
||||
"device-major '%s' is inconsistent: "
|
||||
"block %d, char %d", res->dm_name,
|
||||
res->dm_bmajor, res->dm_cmajor);
|
||||
xerror(dm->dm_srcfile, dm->dm_srcline,
|
||||
cfgxerror(dm->dm_srcfile, dm->dm_srcline,
|
||||
"device-major '%s' is inconsistent: "
|
||||
"block %d, char %d", dm->dm_name,
|
||||
dm->dm_bmajor, dm->dm_cmajor);
|
||||
error = 1;
|
||||
goto out;
|
||||
} else {
|
||||
xerror(dm->dm_srcfile, dm->dm_srcline,
|
||||
cfgxerror(dm->dm_srcfile, dm->dm_srcline,
|
||||
"device-major '%s' is duplicated: "
|
||||
"block %d, char %d",
|
||||
dm->dm_name, dm->dm_bmajor,
|
||||
|
@ -383,7 +384,7 @@ fixdevsw(void)
|
|||
|
||||
if (dm->dm_cmajor != -1) {
|
||||
if (ht_lookup(cdevmtab, intern(dm->dm_name)) != NULL) {
|
||||
xerror(dm->dm_srcfile, dm->dm_srcline,
|
||||
cfgxerror(dm->dm_srcfile, dm->dm_srcline,
|
||||
"device-major of character device '%s' "
|
||||
"is already defined", dm->dm_name);
|
||||
error = 1;
|
||||
|
@ -391,7 +392,7 @@ fixdevsw(void)
|
|||
}
|
||||
(void)snprintf(mstr, sizeof(mstr), "%d", dm->dm_cmajor);
|
||||
if (ht_lookup(cdevmtab, intern(mstr)) != NULL) {
|
||||
xerror(dm->dm_srcfile, dm->dm_srcline,
|
||||
cfgxerror(dm->dm_srcfile, dm->dm_srcline,
|
||||
"device-major of character major '%d' "
|
||||
"is already defined", dm->dm_cmajor);
|
||||
error = 1;
|
||||
|
@ -405,7 +406,7 @@ fixdevsw(void)
|
|||
}
|
||||
if (dm->dm_bmajor != -1) {
|
||||
if (ht_lookup(bdevmtab, intern(dm->dm_name)) != NULL) {
|
||||
xerror(dm->dm_srcfile, dm->dm_srcline,
|
||||
cfgxerror(dm->dm_srcfile, dm->dm_srcline,
|
||||
"device-major of block device '%s' "
|
||||
"is already defined", dm->dm_name);
|
||||
error = 1;
|
||||
|
@ -413,7 +414,7 @@ fixdevsw(void)
|
|||
}
|
||||
(void)snprintf(mstr, sizeof(mstr), "%d", dm->dm_bmajor);
|
||||
if (ht_lookup(bdevmtab, intern(mstr)) != NULL) {
|
||||
xerror(dm->dm_srcfile, dm->dm_srcline,
|
||||
cfgxerror(dm->dm_srcfile, dm->dm_srcline,
|
||||
"device-major of block major '%d' "
|
||||
"is already defined", dm->dm_bmajor);
|
||||
error = 1;
|
||||
|
@ -480,6 +481,7 @@ fixfsel(const char *name, void *context)
|
|||
* As for fixfsel above, but we do not need the flat list.
|
||||
*/
|
||||
static int
|
||||
/*ARGSUSED*/
|
||||
fixsel(const char *name, void *context)
|
||||
{
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
%{
|
||||
/* $NetBSD: gram.y,v 1.12 2007/01/12 21:49:51 cube Exp $ */
|
||||
/* $NetBSD: gram.y,v 1.13 2007/01/13 23:47:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -54,7 +54,7 @@
|
|||
#define FORMAT(n) (((n).fmt == 8 && (n).val != 0) ? "0%llo" : \
|
||||
((n).fmt == 16) ? "0x%llx" : "%lld")
|
||||
|
||||
#define stop(s) error(s), exit(1)
|
||||
#define stop(s) cfgerror(s), exit(1)
|
||||
|
||||
static struct config conf; /* at most one active at a time */
|
||||
|
||||
|
@ -596,7 +596,7 @@ void
|
|||
yyerror(const char *s)
|
||||
{
|
||||
|
||||
error("%s", s);
|
||||
cfgerror("%s", s);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: main.c,v 1.22 2007/01/09 13:03:47 cube Exp $ */
|
||||
/* $NetBSD: main.c,v 1.23 2007/01/13 23:47:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -96,7 +96,7 @@ static struct nvlist **nextmkopt;
|
|||
static struct nvlist **nextappmkopt;
|
||||
static struct nvlist **nextfsopt;
|
||||
|
||||
static void usage(void);
|
||||
static void usage(void) __attribute__((__noreturn__));
|
||||
static void dependopts(void);
|
||||
static void do_depend(struct nvlist *);
|
||||
static void stop(void);
|
||||
|
@ -171,9 +171,9 @@ main(int argc, char **argv)
|
|||
* do that for you, but you really should just
|
||||
* put them in the config file.
|
||||
*/
|
||||
(void)fprintf(stderr,
|
||||
"config: -g is obsolete (use makeoptions DEBUG=\"-g\")\n");
|
||||
warnx("-g is obsolete (use makeoptions DEBUG=\"-g\")");
|
||||
usage();
|
||||
/*NOTREACHED*/
|
||||
|
||||
case 'p':
|
||||
/*
|
||||
|
@ -218,44 +218,30 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (xflag && (builddir != NULL || srcdir != NULL || Pflag || pflag ||
|
||||
vflag || Lflag)) {
|
||||
(void)fprintf(stderr, "config: -x must be used alone\n");
|
||||
exit(1);
|
||||
}
|
||||
if (Lflag && (builddir != NULL || Pflag || pflag)) {
|
||||
(void)fprintf(stderr,
|
||||
"config: -L can only be used with -s and -v\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
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");
|
||||
|
||||
if (xflag) {
|
||||
#ifdef __NetBSD__
|
||||
conffile = (argc == 1) ? argv[0] : _PATH_UNIX;
|
||||
#else
|
||||
if (argc == 0) {
|
||||
(void)fprintf(stderr, "config: no kernel supplied\n");
|
||||
exit(1);
|
||||
}
|
||||
if (argc == 0)
|
||||
errx(EXIT_FAILURE, "no kernel supplied");
|
||||
#endif
|
||||
if (!is_elf(conffile)) {
|
||||
(void)fprintf(stderr,
|
||||
"config: %s: not a binary kernel\n",
|
||||
if (!is_elf(conffile))
|
||||
errx(EXIT_FAILURE, "%s: not a binary kernel",
|
||||
conffile);
|
||||
exit(1);
|
||||
}
|
||||
if (!extract_config(conffile, "stdout", STDOUT_FILENO)) {
|
||||
(void)fprintf(stderr,
|
||||
"config: %s does not contain embedded "
|
||||
"configuration data\n", conffile);
|
||||
exit(2);
|
||||
}
|
||||
if (!extract_config(conffile, "stdout", STDOUT_FILENO))
|
||||
errx(EXIT_FAILURE, "%s does not contain embedded "
|
||||
"configuration data", conffile);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
conffile = (argc == 1) ? argv[0] : "CONFIG";
|
||||
if (firstfile(conffile)) {
|
||||
(void)fprintf(stderr, "config: cannot read %s: %s\n",
|
||||
conffile, strerror(errno));
|
||||
err(EXIT_FAILURE, "Cannot read `%s'", conffile);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
@ -335,12 +321,9 @@ main(int argc, char **argv)
|
|||
const char *tmpdir;
|
||||
int cfd;
|
||||
|
||||
if (builddir == NULL) {
|
||||
(void)fprintf(stderr,
|
||||
"config: build directory must be specified with "
|
||||
"binary kernels\n");
|
||||
exit(1);
|
||||
}
|
||||
if (builddir == NULL)
|
||||
errx(EXIT_FAILURE, "Build directory must be specified "
|
||||
"with binary kernels");
|
||||
|
||||
/* Open temporary configuration file */
|
||||
tmpdir = getenv("TMPDIR");
|
||||
|
@ -348,19 +331,13 @@ main(int argc, char **argv)
|
|||
tmpdir = "/tmp";
|
||||
snprintf(cname, sizeof(cname), "%s/config.tmp.XXXXXX", tmpdir);
|
||||
cfd = mkstemp(cname);
|
||||
if (cfd == -1) {
|
||||
fprintf(stderr, "config: cannot create %s: %s", cname,
|
||||
strerror(errno));
|
||||
exit(2);
|
||||
}
|
||||
if (cfd == -1)
|
||||
err(EXIT_FAILURE, "Cannot create `%s'", cname);
|
||||
|
||||
printf("Using configuration data embedded in kernel...\n");
|
||||
if (!extract_config(conffile, cname, cfd)) {
|
||||
(void)fprintf(stderr,
|
||||
"config: %s does not contain embedded "
|
||||
"configuration data\n", conffile);
|
||||
exit(2);
|
||||
}
|
||||
if (!extract_config(conffile, cname, cfd))
|
||||
errx(EXIT_FAILURE, "%s does not contain embedded "
|
||||
"configuration data", conffile);
|
||||
|
||||
removeit = 1;
|
||||
close(cfd);
|
||||
|
@ -421,14 +398,12 @@ main(int argc, char **argv)
|
|||
defmaxusers);
|
||||
maxusers = defmaxusers;
|
||||
} else {
|
||||
(void)fprintf(stderr,
|
||||
"config: need \"maxusers\" line\n");
|
||||
warnx("need \"maxusers\" line");
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
if (fsoptions == NULL) {
|
||||
(void)fprintf(stderr,
|
||||
"config: need at least one \"file-system\" line\n");
|
||||
warnx( "need at least one \"file-system\" line");
|
||||
errors++;
|
||||
}
|
||||
if (crosscheck() || errors)
|
||||
|
@ -450,15 +425,16 @@ main(int argc, char **argv)
|
|||
stop();
|
||||
(void)printf("Build directory is %s\n", builddir);
|
||||
(void)printf("Don't forget to run \"make depend\"\n");
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
(void)fputs("usage: config [-Ppv] [-s srcdir] [-b builddir] "
|
||||
"[sysname]\n", stderr);
|
||||
(void)fputs(" config -x [kernel-file]\n", stderr);
|
||||
(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());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -516,6 +492,18 @@ do_depend(struct nvlist *nv)
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a symlink for "machine" so that "#include <machine/foo.h>" works,
|
||||
* and for the machine's CPU architecture, so that works as well.
|
||||
|
@ -530,14 +518,7 @@ mksymlinks(void)
|
|||
|
||||
snprintf(buf, sizeof(buf), "arch/%s/include", machine);
|
||||
p = sourcepath(buf);
|
||||
ret = unlink("machine");
|
||||
if (ret && errno != ENOENT)
|
||||
(void)fprintf(stderr, "config: unlink(machine): %s\n",
|
||||
strerror(errno));
|
||||
ret = symlink(p, "machine");
|
||||
if (ret)
|
||||
(void)fprintf(stderr, "config: symlink(machine -> %s): %s\n",
|
||||
p, strerror(errno));
|
||||
ret = recreate(p, "machine");
|
||||
free(p);
|
||||
|
||||
if (machinearch != NULL) {
|
||||
|
@ -548,28 +529,15 @@ mksymlinks(void)
|
|||
p = estrdup("machine");
|
||||
q = machine;
|
||||
}
|
||||
ret = unlink(q);
|
||||
if (ret && errno != ENOENT)
|
||||
(void)fprintf(stderr, "config: unlink(%s): %s\n",
|
||||
q, strerror(errno));
|
||||
ret = symlink(p, q);
|
||||
if (ret)
|
||||
(void)fprintf(stderr, "config: symlink(%s -> %s): %s\n",
|
||||
q, p, strerror(errno));
|
||||
|
||||
ret = recreate(p, q);
|
||||
free(p);
|
||||
|
||||
for (nv = machinesubarches; nv != NULL; nv = nv->nv_next) {
|
||||
q = nv->nv_name;
|
||||
snprintf(buf, sizeof(buf), "arch/%s/include", q);
|
||||
p = sourcepath(buf);
|
||||
ret = unlink(q);
|
||||
if (ret && errno != ENOENT)
|
||||
(void)fprintf(stderr, "config: unlink(%s): %s\n",
|
||||
q, strerror(errno));
|
||||
ret = symlink(p, q);
|
||||
if (ret)
|
||||
(void)fprintf(stderr, "config: symlink(%s -> %s): %s\n",
|
||||
q, p, strerror(errno));
|
||||
ret = recreate(p, q);
|
||||
free(p);
|
||||
}
|
||||
|
||||
|
@ -599,14 +567,14 @@ add_dependencies(struct nvlist *nv, struct nvlist *deps)
|
|||
*/
|
||||
if ((a = ht_lookup(attrtab, dep->nv_name)) != NULL) {
|
||||
if (a->a_iattr)
|
||||
error("option `%s' dependency `%s' "
|
||||
cfgerror("option `%s' dependency `%s' "
|
||||
"is an interface attribute",
|
||||
nv->nv_name, a->a_name);
|
||||
} else if (OPT_OBSOLETE(dep->nv_name)) {
|
||||
error("option `%s' dependency `%s' "
|
||||
cfgerror("option `%s' dependency `%s' "
|
||||
"is obsolete", nv->nv_name, dep->nv_name);
|
||||
} else if (find_declared_option(dep->nv_name) == NULL) {
|
||||
error("option `%s' dependency `%s' "
|
||||
cfgerror("option `%s' dependency `%s' "
|
||||
"is an unknown option",
|
||||
nv->nv_name, dep->nv_name);
|
||||
}
|
||||
|
@ -629,7 +597,7 @@ deffilesystem(const char *fname, struct nvlist *fses, struct nvlist *deps)
|
|||
*/
|
||||
for (nv = fses; nv != NULL; nv = nv->nv_next) {
|
||||
if (DEFINED_OPTION(nv->nv_name)) {
|
||||
error("file system or option `%s' already defined",
|
||||
cfgerror("file system or option `%s' already defined",
|
||||
nv->nv_name);
|
||||
return;
|
||||
}
|
||||
|
@ -648,13 +616,13 @@ deffilesystem(const char *fname, struct nvlist *fses, struct nvlist *deps)
|
|||
* Only one file system allowed in this case.
|
||||
*/
|
||||
if (nv->nv_next != NULL) {
|
||||
error("only one file system per option "
|
||||
cfgerror("only one file system per option "
|
||||
"file may be specified");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ht_insert(optfiletab, fname, nv)) {
|
||||
error("option file `%s' already exists",
|
||||
cfgerror("option file `%s' already exists",
|
||||
fname);
|
||||
return;
|
||||
}
|
||||
|
@ -677,11 +645,11 @@ badfilename(const char *fname)
|
|||
* check the file name.
|
||||
*/
|
||||
if (strchr(fname, '/') != NULL) {
|
||||
error("option file name contains a `/'");
|
||||
cfgerror("option file name contains a `/'");
|
||||
return 1;
|
||||
}
|
||||
if ((n = strrchr(fname, '.')) == NULL || strcmp(n, ".h") != 0) {
|
||||
error("option file name does not end in `.h'");
|
||||
cfgerror("option file name does not end in `.h'");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -747,13 +715,13 @@ defopt(struct hashtab *ht, const char *fname, struct nvlist *opts,
|
|||
|
||||
/* An option name can be declared at most once. */
|
||||
if (DEFINED_OPTION(nv->nv_name)) {
|
||||
error("file system or option `%s' already defined",
|
||||
cfgerror("file system or option `%s' already defined",
|
||||
nv->nv_name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ht_insert(ht, nv->nv_name, nv)) {
|
||||
error("file system or option `%s' already defined",
|
||||
cfgerror("file system or option `%s' already defined",
|
||||
nv->nv_name);
|
||||
return;
|
||||
}
|
||||
|
@ -812,7 +780,7 @@ void
|
|||
defoption(const char *fname, struct nvlist *opts, struct nvlist *deps)
|
||||
{
|
||||
|
||||
warn("The use of `defopt' is deprecated");
|
||||
cfgwarn("The use of `defopt' is deprecated");
|
||||
defopt(defopttab, fname, opts, deps, 0);
|
||||
}
|
||||
|
||||
|
@ -847,7 +815,7 @@ void
|
|||
addoption(const char *name, const char *value)
|
||||
{
|
||||
const char *n;
|
||||
int is_fs, is_param, is_flag, is_opt, is_undecl, is_obs;
|
||||
int is_fs, is_param, is_flag, is_undecl, is_obs;
|
||||
|
||||
/*
|
||||
* Figure out how this option was declared (if at all.)
|
||||
|
@ -856,35 +824,34 @@ addoption(const char *name, const char *value)
|
|||
*/
|
||||
is_fs = OPT_FSOPT(name);
|
||||
is_param = OPT_DEFPARAM(name);
|
||||
is_opt = OPT_DEFOPT(name);
|
||||
is_flag = OPT_DEFFLAG(name);
|
||||
is_obs = OPT_OBSOLETE(name);
|
||||
is_undecl = !DEFINED_OPTION(name);
|
||||
|
||||
/* Warn and pretend the user had not selected the option */
|
||||
if (is_obs) {
|
||||
warn("obsolete option `%s' will be ignored", name);
|
||||
cfgwarn("obsolete option `%s' will be ignored", name);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Make sure this is not a defined file system. */
|
||||
if (is_fs) {
|
||||
error("`%s' is a defined file system", name);
|
||||
cfgerror("`%s' is a defined file system", name);
|
||||
return;
|
||||
}
|
||||
/* A defparam must have a value */
|
||||
if (is_param && value == NULL) {
|
||||
error("option `%s' must have a value", name);
|
||||
cfgerror("option `%s' must have a value", name);
|
||||
return;
|
||||
}
|
||||
/* A defflag must not have a value */
|
||||
if (is_flag && value != NULL) {
|
||||
error("option `%s' must not have a value", name);
|
||||
cfgerror("option `%s' must not have a value", name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_undecl && vflag) {
|
||||
warn("undeclared option `%s' added to IDENT", name);
|
||||
cfgwarn("undeclared option `%s' added to IDENT", name);
|
||||
}
|
||||
|
||||
if (do_option(opttab, &nextopt, name, value, "options"))
|
||||
|
@ -892,7 +859,7 @@ addoption(const char *name, const char *value)
|
|||
|
||||
/* make lowercase, then add to select table */
|
||||
n = strtolower(name);
|
||||
(void)ht_insert(selecttab, n, (void *)n);
|
||||
(void)ht_insert(selecttab, n, (void *)__UNCONST(n));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -917,7 +884,7 @@ addfsoption(const char *name)
|
|||
|
||||
/* Make sure this is a defined file system. */
|
||||
if (!OPT_FSOPT(name)) {
|
||||
error("`%s' is not a defined file system", name);
|
||||
cfgerror("`%s' is not a defined file system", name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -935,11 +902,11 @@ addfsoption(const char *name)
|
|||
* Add a lower-case version to the table for root file system
|
||||
* verification.
|
||||
*/
|
||||
if (ht_insert(fsopttab, n, (void *)n))
|
||||
if (ht_insert(fsopttab, n, __UNCONST(n)))
|
||||
panic("addfsoption: already in table");
|
||||
|
||||
/* Add to select table. */
|
||||
(void)ht_insert(selecttab, n, (void *)n);
|
||||
(void)ht_insert(selecttab, n, __UNCONST(n));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1039,9 +1006,9 @@ do_option(struct hashtab *ht, struct nvlist ***nppp, const char *name,
|
|||
if ((nv = ht_lookup(ht, name)) == NULL)
|
||||
panic("do_option");
|
||||
if (nv->nv_str != NULL && !OPT_FSOPT(name))
|
||||
error("already have %s `%s=%s'", type, name, nv->nv_str);
|
||||
cfgerror("already have %s `%s=%s'", type, name, nv->nv_str);
|
||||
else
|
||||
error("already have %s `%s'", type, name);
|
||||
cfgerror("already have %s `%s'", type, name);
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
@ -1056,7 +1023,7 @@ undo_option(struct hashtab *ht, struct nvlist **npp,
|
|||
struct nvlist *nv;
|
||||
|
||||
if (ht_remove(ht, name)) {
|
||||
error("%s `%s' is not defined", type, name);
|
||||
cfgerror("%s `%s' is not defined", type, name);
|
||||
return (1);
|
||||
}
|
||||
if (npp == NULL)
|
||||
|
@ -1149,7 +1116,7 @@ cfcrosscheck(struct config *cf, const char *what, struct nvlist *nv)
|
|||
if (has_attr(dev->d_attrs, s_ifnet))
|
||||
devunit = nv->nv_ifunit; /* XXX XXX XXX */
|
||||
else
|
||||
devunit = minor(nv->nv_int) / maxpartitions;
|
||||
devunit = minor((uint32_t)nv->nv_int) / maxpartitions;
|
||||
if (devbase_has_instances(dev, devunit))
|
||||
continue;
|
||||
if (devbase_has_instances(dev, STAR) &&
|
||||
|
@ -1184,8 +1151,7 @@ crosscheck(void)
|
|||
|
||||
errs = 0;
|
||||
if (TAILQ_EMPTY(&allcf)) {
|
||||
(void)fprintf(stderr, "%s has no configurations!\n",
|
||||
conffile);
|
||||
warnx("%s has no configurations!", conffile);
|
||||
errs++;
|
||||
}
|
||||
TAILQ_FOREACH(cf, &allcf, cf_next) {
|
||||
|
@ -1218,8 +1184,7 @@ badstar(void)
|
|||
continue;
|
||||
aybabtu:
|
||||
if (ht_lookup(needcnttab, d->d_name)) {
|
||||
(void)fprintf(stderr,
|
||||
"config: %s's cannot be *'d until its driver is fixed\n",
|
||||
warnx("%s's cannot be *'d until its driver is fixed",
|
||||
d->d_name);
|
||||
errs++;
|
||||
continue;
|
||||
|
@ -1245,7 +1210,7 @@ setupdirs(void)
|
|||
/* srcdir must be specified if builddir is not specified or if
|
||||
* no configuration filename was specified. */
|
||||
if ((builddir || strcmp(defbuilddir, ".") == 0) && !srcdir) {
|
||||
error("source directory must be specified");
|
||||
cfgerror("source directory must be specified");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -1260,27 +1225,17 @@ setupdirs(void)
|
|||
if (builddir == NULL)
|
||||
builddir = defbuilddir;
|
||||
|
||||
if (stat(builddir, &st) != 0) {
|
||||
if (mkdir(builddir, 0777)) {
|
||||
(void)fprintf(stderr, "config: cannot create %s: %s\n",
|
||||
builddir, strerror(errno));
|
||||
exit(2);
|
||||
}
|
||||
} else if (!S_ISDIR(st.st_mode)) {
|
||||
(void)fprintf(stderr, "config: %s is not a directory\n",
|
||||
builddir);
|
||||
exit(2);
|
||||
}
|
||||
if (chdir(builddir) != 0) {
|
||||
(void)fprintf(stderr, "config: cannot change to %s\n",
|
||||
builddir);
|
||||
exit(2);
|
||||
}
|
||||
if (stat(srcdir, &st) != 0 || !S_ISDIR(st.st_mode)) {
|
||||
(void)fprintf(stderr, "config: %s is not a directory\n",
|
||||
srcdir);
|
||||
exit(2);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1299,8 +1254,7 @@ mkident(void)
|
|||
return (0);
|
||||
|
||||
if ((fp = fopen("ident", "w")) == NULL) {
|
||||
(void)fprintf(stderr, "config: cannot write ident: %s\n",
|
||||
strerror(errno));
|
||||
warn("cannot write ident");
|
||||
return (1);
|
||||
}
|
||||
if (vflag)
|
||||
|
@ -1330,17 +1284,17 @@ logconfig_start(void)
|
|||
tmpdir = getenv("TMPDIR");
|
||||
if (tmpdir == NULL)
|
||||
tmpdir = "/tmp";
|
||||
snprintf(line, sizeof(line), "%s/config.tmp.XXXXXX", tmpdir);
|
||||
(void)snprintf(line, sizeof(line), "%s/config.tmp.XXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(line)) == -1 ||
|
||||
(cfg = fdopen(fd, "r+")) == NULL) {
|
||||
if (fd != -1) {
|
||||
unlink(line);
|
||||
close(fd);
|
||||
(void)unlink(line);
|
||||
(void)close(fd);
|
||||
}
|
||||
cfg = NULL;
|
||||
return;
|
||||
}
|
||||
unlink(line);
|
||||
(void)unlink(line);
|
||||
|
||||
(void)fprintf(cfg, "#include <sys/cdefs.h>\n\n");
|
||||
(void)fprintf(cfg, "#include \"opt_config.h\"\n");
|
||||
|
@ -1425,8 +1379,7 @@ logconfig_include(FILE *cf, const char *filename)
|
|||
}
|
||||
if (missingeol) {
|
||||
(void)fprintf(cfg, "\\n\"\n");
|
||||
(void)fprintf(stderr,
|
||||
"config: %s: newline missing at EOF\n",
|
||||
warnx("%s: newline missing at EOF",
|
||||
filename != NULL ? filename : conffile);
|
||||
}
|
||||
if (filename)
|
||||
|
@ -1496,17 +1449,11 @@ is_elf(const char *file)
|
|||
char hdr[4];
|
||||
|
||||
kernel = open(file, O_RDONLY);
|
||||
if (kernel == -1) {
|
||||
fprintf(stderr, "config: cannot open %s: %s\n", file,
|
||||
strerror(errno));
|
||||
exit(2);
|
||||
}
|
||||
if (read(kernel, hdr, 4) == -1) {
|
||||
fprintf(stderr, "config: cannot read from %s: %s\n", file,
|
||||
strerror(errno));
|
||||
exit(2);
|
||||
}
|
||||
close(kernel);
|
||||
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);
|
||||
|
||||
return memcmp("\177ELF", hdr, 4) == 0 ? 1 : 0;
|
||||
}
|
||||
|
@ -1522,23 +1469,14 @@ extract_config(const char *kname, const char *cname, int cfd)
|
|||
|
||||
/* mmap(2) binary kernel */
|
||||
kfd = open(conffile, O_RDONLY);
|
||||
if (kfd == -1) {
|
||||
fprintf(stderr, "config: cannot open %s: %s\n", kname,
|
||||
strerror(errno));
|
||||
exit(2);
|
||||
}
|
||||
if ((fstat(kfd, &st) == -1)) {
|
||||
fprintf(stderr, "config: cannot stat %s: %s\n", kname,
|
||||
strerror(errno));
|
||||
exit(2);
|
||||
}
|
||||
ptr = (char *)mmap(0, st.st_size, PROT_READ, MAP_FILE | MAP_SHARED,
|
||||
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,
|
||||
kfd, 0);
|
||||
if (ptr == MAP_FAILED) {
|
||||
fprintf(stderr, "config: cannot mmap %s: %s\n", kname,
|
||||
strerror(errno));
|
||||
exit(2);
|
||||
}
|
||||
if (ptr == MAP_FAILED)
|
||||
err(EXIT_FAILURE, "cannot mmap %s", kname);
|
||||
|
||||
/* Scan mmap(2)'ed region, extracting kernel configuration */
|
||||
for (i = 0; i < st.st_size; i++) {
|
||||
|
@ -1551,30 +1489,25 @@ extract_config(const char *kname, const char *cname, int cfd)
|
|||
found = 1;
|
||||
|
||||
oldptr = (ptr += 5);
|
||||
while (*ptr != '\n' && *ptr != '\0') ptr++;
|
||||
if (ptr - oldptr > LINE_MAX) {
|
||||
fprintf(stderr, "config: line too long\n");
|
||||
exit(2);
|
||||
}
|
||||
while (*ptr != '\n' && *ptr != '\0')
|
||||
ptr++;
|
||||
if (ptr - oldptr > LINE_MAX)
|
||||
errx(EXIT_FAILURE, "line too long");
|
||||
i += ptr - oldptr + 5;
|
||||
memcpy(line, oldptr, (ptr - oldptr));
|
||||
(void)memcpy(line, oldptr, (size_t)(ptr - oldptr));
|
||||
line[ptr - oldptr] = '\0';
|
||||
j = strunvis(uline, line);
|
||||
if (j == -1) {
|
||||
fprintf(stderr, "config: unvis: invalid "
|
||||
"encoded sequence\n");
|
||||
exit(2);
|
||||
}
|
||||
if (j == -1)
|
||||
errx(EXIT_FAILURE, "unvis: invalid "
|
||||
"encoded sequence");
|
||||
uline[j] = '\n';
|
||||
if (write(cfd, uline, j + 1) == -1) {
|
||||
fprintf(stderr, "config: cannot write to %s: "
|
||||
"%s\n", cname, strerror(errno));
|
||||
exit(2);
|
||||
}
|
||||
} else ptr++;
|
||||
if (write(cfd, uline, (size_t)j + 1) == -1)
|
||||
err(EXIT_FAILURE, "cannot write to %s", cname);
|
||||
} else
|
||||
ptr++;
|
||||
}
|
||||
|
||||
close(kfd);
|
||||
(void)close(kfd);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
@ -1780,6 +1713,7 @@ do_kill_orphans(struct devbase *d, struct attr *at, struct devbase *parent,
|
|||
}
|
||||
|
||||
static int
|
||||
/*ARGSUSED*/
|
||||
kill_orphans_cb(const char *key, void *value, void *aux)
|
||||
{
|
||||
do_kill_orphans((struct devbase *)value, NULL, NULL, DEVI_ACTIVE);
|
||||
|
@ -1787,7 +1721,7 @@ kill_orphans_cb(const char *key, void *value, void *aux)
|
|||
}
|
||||
|
||||
static void
|
||||
kill_orphans()
|
||||
kill_orphans(void)
|
||||
{
|
||||
ht_enumerate(devroottab, kill_orphans_cb, NULL);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mkdevsw.c,v 1.3 2006/10/04 20:34:48 dsl Exp $ */
|
||||
/* $NetBSD: mkdevsw.c,v 1.4 2007/01/13 23:47:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -43,6 +43,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <err.h>
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
|
@ -57,8 +58,7 @@ mkdevsw(void)
|
|||
FILE *fp;
|
||||
|
||||
if ((fp = fopen("devsw.c.tmp", "w")) == NULL) {
|
||||
(void)fprintf(stderr, "config: cannot write devsw.c: %s\n",
|
||||
strerror(errno));
|
||||
warn("cannot create devsw.c");
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,7 @@ mkdevsw(void)
|
|||
|
||||
fflush(fp);
|
||||
if (ferror(fp)) {
|
||||
(void)fprintf(stderr, "config: error writing devsw.c: %s\n",
|
||||
strerror(errno));
|
||||
warn("error writing devsw.c");
|
||||
fclose(fp);
|
||||
return 1;
|
||||
}
|
||||
|
@ -78,8 +77,7 @@ mkdevsw(void)
|
|||
(void)fclose(fp);
|
||||
|
||||
if (moveifchanged("devsw.c.tmp", "devsw.c") != 0) {
|
||||
(void)fprintf(stderr, "config: error renaming devsw.c: %s\n",
|
||||
strerror(errno));
|
||||
warn("error renaming devsw.c");
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mkheaders.c,v 1.9 2006/10/04 20:34:48 dsl Exp $ */
|
||||
/* $NetBSD: mkheaders.c,v 1.10 2007/01/13 23:47:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -52,6 +52,7 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <util.h>
|
||||
#include <err.h>
|
||||
#include "defs.h"
|
||||
|
||||
#ifdef notyet
|
||||
|
@ -174,20 +175,21 @@ static void
|
|||
fprintstr(FILE *fp, const char *str)
|
||||
{
|
||||
|
||||
if (strncmp(str, "\\\"", 2)) {
|
||||
fprintf(fp, "\t%s", str);
|
||||
if (strncmp(str, "\\\"", 2) != 0) {
|
||||
(void)fprintf(fp, "\t%s", str);
|
||||
return;
|
||||
}
|
||||
|
||||
fputc('\t', fp);
|
||||
(void)fputc('\t', fp);
|
||||
|
||||
for (; *str; str++) {
|
||||
switch (*str) {
|
||||
case '\\':
|
||||
if (!*++str) /* XXX */
|
||||
str--;
|
||||
/*FALLTHROUGH*/
|
||||
default:
|
||||
fputc(*str, fp);
|
||||
(void)fputc(*str, fp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -198,6 +200,7 @@ fprintstr(FILE *fp, const char *str)
|
|||
* the options defined for this file.
|
||||
*/
|
||||
static int
|
||||
/*ARGSUSED*/
|
||||
defopts_print(const char *name, void *value, void *arg)
|
||||
{
|
||||
char tfname[BUFSIZ];
|
||||
|
@ -484,8 +487,7 @@ static int
|
|||
herr(const char *what, const char *fname, FILE *fp)
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "%s: error %sing %s: %s\n",
|
||||
getprogname(), what, fname, strerror(errno));
|
||||
warn("error %sing %s", what, fname);
|
||||
if (fp)
|
||||
(void)fclose(fp);
|
||||
return (1);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mkioconf.c,v 1.8 2006/10/04 20:34:48 dsl Exp $ */
|
||||
/* $NetBSD: mkioconf.c,v 1.9 2007/01/13 23:47:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -85,8 +85,7 @@ mkioconf(void)
|
|||
|
||||
qsort(packed, npacked, sizeof *packed, cforder);
|
||||
if ((fp = fopen("ioconf.c.tmp", "w")) == NULL) {
|
||||
(void)fprintf(stderr, "config: cannot write ioconf.c: %s\n",
|
||||
strerror(errno));
|
||||
warn("cannot write ioconf.c");
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
@ -104,18 +103,17 @@ mkioconf(void)
|
|||
|
||||
fflush(fp);
|
||||
if (ferror(fp)) {
|
||||
(void)fprintf(stderr,
|
||||
"config: error writing ioconf.c: %s\n",
|
||||
strerror(errno));
|
||||
warn("error writing ioconf.c");
|
||||
(void)fclose(fp);
|
||||
/* (void)unlink("ioconf.c.tmp"); */
|
||||
#if 0
|
||||
(void)unlink("ioconf.c.tmp");
|
||||
#endif
|
||||
return (1);
|
||||
}
|
||||
|
||||
(void)fclose(fp);
|
||||
if (moveifchanged("ioconf.c.tmp", "ioconf.c") != 0) {
|
||||
(void)fprintf(stderr, "config: error renaming ioconf.c: %s\n",
|
||||
strerror(errno));
|
||||
warn("error renaming ioconf.c");
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
|
@ -126,8 +124,8 @@ cforder(const void *a, const void *b)
|
|||
{
|
||||
int n1, n2;
|
||||
|
||||
n1 = (*(struct devi **)a)->i_cfindex;
|
||||
n2 = (*(struct devi **)b)->i_cfindex;
|
||||
n1 = (*(const struct devi **)a)->i_cfindex;
|
||||
n2 = (*(const struct devi **)b)->i_cfindex;
|
||||
return (n1 - n2);
|
||||
}
|
||||
|
||||
|
@ -150,7 +148,7 @@ emithdr(FILE *ofp)
|
|||
ifn = sourcepath(ifnbuf);
|
||||
if ((ifp = fopen(ifn, "r")) != NULL) {
|
||||
while ((n = fread(buf, 1, sizeof(buf), ifp)) > 0)
|
||||
fwrite(buf, 1, n, ofp);
|
||||
(void)fwrite(buf, 1, n, ofp);
|
||||
if (ferror(ifp))
|
||||
err(EXIT_FAILURE, "error reading %s", ifn);
|
||||
(void)fclose(ifp);
|
||||
|
@ -449,9 +447,7 @@ emitroots(FILE *fp)
|
|||
continue;
|
||||
if (i->i_unit != 0 &&
|
||||
(i->i_unit != STAR || i->i_base->d_umax != 0))
|
||||
(void)fprintf(stderr,
|
||||
"config: warning: `%s at root' is not unit 0\n",
|
||||
i->i_name);
|
||||
warnx("warning: `%s at root' is not unit 0", i->i_name);
|
||||
fprintf(fp, "\t%2d /* %s */,\n",
|
||||
i->i_cfindex, i->i_name);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mkmakefile.c,v 1.5 2006/10/04 20:34:48 dsl Exp $ */
|
||||
/* $NetBSD: mkmakefile.c,v 1.6 2007/01/13 23:47:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -50,6 +50,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
#include "defs.h"
|
||||
#include "sem.h"
|
||||
|
||||
|
@ -98,14 +99,12 @@ mkmakefile(void)
|
|||
ifp = fopen(ifname, "r");
|
||||
}
|
||||
if (ifp == NULL) {
|
||||
(void)fprintf(stderr, "config: cannot read %s: %s\n",
|
||||
ifname, strerror(errno));
|
||||
warn("cannot read %s", ifname);
|
||||
goto bad2;
|
||||
}
|
||||
|
||||
if ((ofp = fopen("Makefile.tmp", "w")) == NULL) {
|
||||
(void)fprintf(stderr, "config: cannot write Makefile: %s\n",
|
||||
strerror(errno));
|
||||
warn("cannot write Makefile");
|
||||
goto bad1;
|
||||
}
|
||||
|
||||
|
@ -133,7 +132,7 @@ mkmakefile(void)
|
|||
else if (strcmp(line, "%MAKEOPTIONSAPPEND\n") == 0)
|
||||
fn = emitappmkoptions;
|
||||
else {
|
||||
xerror(ifname, lineno,
|
||||
cfgxerror(ifname, lineno,
|
||||
"unknown %% construct ignored: %s", line);
|
||||
continue;
|
||||
}
|
||||
|
@ -145,9 +144,7 @@ mkmakefile(void)
|
|||
goto wrerror;
|
||||
|
||||
if (ferror(ifp)) {
|
||||
(void)fprintf(stderr,
|
||||
"config: error reading %s (at line %d): %s\n",
|
||||
ifname, lineno, strerror(errno));
|
||||
warn("error reading %s (at line %d)", ifname, lineno);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
|
@ -158,17 +155,14 @@ mkmakefile(void)
|
|||
(void)fclose(ifp);
|
||||
|
||||
if (moveifchanged("Makefile.tmp", "Makefile") != 0) {
|
||||
(void)fprintf(stderr,
|
||||
"config: error renaming Makefile: %s\n",
|
||||
strerror(errno));
|
||||
warn("error renaming Makefile");
|
||||
goto bad2;
|
||||
}
|
||||
free(ifname);
|
||||
return (0);
|
||||
|
||||
wrerror:
|
||||
(void)fprintf(stderr, "config: error writing Makefile: %s\n",
|
||||
strerror(errno));
|
||||
warn("error writing Makefile");
|
||||
bad:
|
||||
if (ofp != NULL)
|
||||
(void)fclose(ofp);
|
||||
|
@ -198,7 +192,7 @@ srcpath(struct files *fi)
|
|||
if (have_source || (fi->fi_flags & FI_ALWAYSSRC) != 0)
|
||||
return (fi->fi_path);
|
||||
if (objpath == NULL) {
|
||||
error("obj-directory not set");
|
||||
cfgerror("obj-directory not set");
|
||||
return (NULL);
|
||||
}
|
||||
(void)snprintf(buf, sizeof buf, "%s/%s.o", objpath, fi->fi_base);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mkswap.c,v 1.2 2006/10/04 20:34:48 dsl Exp $ */
|
||||
/* $NetBSD: mkswap.c,v 1.3 2007/01/13 23:47:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -49,6 +49,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
#include "defs.h"
|
||||
#include "sem.h"
|
||||
|
||||
|
@ -94,8 +95,7 @@ mkoneswap(struct config *cf)
|
|||
(void)snprintf(fname, sizeof(fname), "swap%s.c", cf->cf_name);
|
||||
(void)snprintf(tname, sizeof(tname), "swap%s.c.tmp", cf->cf_name);
|
||||
if ((fp = fopen(tname, "w")) == NULL) {
|
||||
(void)fprintf(stderr, "config: cannot write %s: %s\n",
|
||||
fname, strerror(errno));
|
||||
warn("cannot open %s", fname);
|
||||
return (1);
|
||||
}
|
||||
fputs("#include <sys/param.h>\n"
|
||||
|
@ -148,17 +148,17 @@ mkoneswap(struct config *cf)
|
|||
goto wrerror;
|
||||
}
|
||||
if (moveifchanged(tname, fname) != 0) {
|
||||
(void)fprintf(stderr, "config: error renaming %s: %s\n",
|
||||
fname, strerror(errno));
|
||||
warn("error renaming %s", fname);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
|
||||
wrerror:
|
||||
(void)fprintf(stderr, "config: error writing %s: %s\n",
|
||||
fname, strerror(errno));
|
||||
warn("error writing %s", fname);
|
||||
if (fp != NULL)
|
||||
(void)fclose(fp);
|
||||
/* (void)unlink(fname); */
|
||||
#if 0
|
||||
(void)unlink(fname);
|
||||
#endif
|
||||
return (1);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pack.c,v 1.4 2006/08/26 18:17:13 christos Exp $ */
|
||||
/* $NetBSD: pack.c,v 1.5 2007/01/13 23:47:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -124,7 +124,7 @@ pack(void)
|
|||
}
|
||||
|
||||
/* Allocate and pack loc[]. */
|
||||
locators.vec = ecalloc(locspace, sizeof(*locators.vec));
|
||||
locators.vec = ecalloc((size_t)locspace, sizeof(*locators.vec));
|
||||
locators.used = 0;
|
||||
packlocs();
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ packdevi(void)
|
|||
}
|
||||
}
|
||||
|
||||
packed = ecalloc(ndevi + 1, sizeof *packed);
|
||||
packed = ecalloc((size_t)ndevi + 1, sizeof *packed);
|
||||
n = 0;
|
||||
TAILQ_FOREACH(d, &allbases, d_next) {
|
||||
/*
|
||||
|
@ -320,13 +320,13 @@ addlocs(const char **locs, int len)
|
|||
static int
|
||||
loclencmp(const void *a, const void *b)
|
||||
{
|
||||
struct pspec *p1, *p2;
|
||||
const struct pspec *p1, *p2;
|
||||
int l1, l2;
|
||||
|
||||
p1 = (*(struct devi **)a)->i_pspec;
|
||||
p1 = (*(const struct devi **)a)->i_pspec;
|
||||
l1 = p1 != NULL ? p1->p_iattr->a_loclen : 0;
|
||||
|
||||
p2 = (*(struct devi **)b)->i_pspec;
|
||||
p2 = (*(const struct devi **)b)->i_pspec;
|
||||
l2 = p2 != NULL ? p2->p_iattr->a_loclen : 0;
|
||||
|
||||
return (l2 - l1);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
%{
|
||||
/* $NetBSD: scan.l,v 1.6 2007/01/09 13:03:47 cube Exp $ */
|
||||
/* $NetBSD: scan.l,v 1.7 2007/01/13 23:47:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -178,7 +178,7 @@ package[ \t]+{FILENAME} {
|
|||
\"{QCHARS} {
|
||||
tok = input(); /* eat closing quote */
|
||||
if (tok != '"') {
|
||||
error("closing quote missing\n");
|
||||
cfgerror("closing quote missing\n");
|
||||
unput(tok);
|
||||
}
|
||||
yylval.str = intern(yytext + 1);
|
||||
|
@ -215,7 +215,7 @@ package[ \t]+{FILENAME} {
|
|||
/* Detect NUL characters in the config file and
|
||||
* error out.
|
||||
*/
|
||||
error("NUL character detected at line %i\n", yyline);
|
||||
cfgerror("NUL character detected at line %i\n", yyline);
|
||||
}
|
||||
#.* { /* ignored (comment) */; }
|
||||
[ \t]+ { /* ignored (white space) */; }
|
||||
|
@ -355,16 +355,16 @@ include(const char *fname, int ateof, int conditional, int direct)
|
|||
s = sourcepath(fname);
|
||||
if ((fp = fopen(s, "r")) == NULL) {
|
||||
if (conditional == 0)
|
||||
error("cannot open %s for reading: %s\n", s,
|
||||
cfgerror("cannot open %s for reading: %s\n", s,
|
||||
strerror(errno));
|
||||
else if (vflag)
|
||||
warn("cannot open conditional include file %s: %s",
|
||||
cfgwarn("cannot open conditional include file %s: %s",
|
||||
s, strerror(errno));
|
||||
free(s);
|
||||
return (-1);
|
||||
}
|
||||
if (curdir_push(s) == -1) {
|
||||
error("cannot record current working directory for %s\n", s);
|
||||
cfgerror("cannot record current working directory for %s\n", s);
|
||||
fclose(fp);
|
||||
free(s);
|
||||
return (-1);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sem.c,v 1.26 2007/01/08 16:08:08 cube Exp $ */
|
||||
/* $NetBSD: sem.c,v 1.27 2007/01/13 23:47:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -146,7 +146,8 @@ setdefmaxusers(int min, int def, int max)
|
|||
{
|
||||
|
||||
if (min < 1 || min > def || def > max)
|
||||
error("maxusers must have 1 <= min (%d) <= default (%d) <= max (%d)", min, def, max);
|
||||
cfgerror("maxusers must have 1 <= min (%d) <= default (%d) "
|
||||
"<= max (%d)", min, def, max);
|
||||
else {
|
||||
minmaxusers = min;
|
||||
defmaxusers = def;
|
||||
|
@ -159,18 +160,19 @@ setmaxusers(int n)
|
|||
{
|
||||
|
||||
if (maxusers == n) {
|
||||
error("duplicate maxusers parameter");
|
||||
cfgerror("duplicate maxusers parameter");
|
||||
return;
|
||||
}
|
||||
if (vflag && maxusers != 0)
|
||||
warn("maxusers already defined");
|
||||
cfgwarn("warning: maxusers already defined");
|
||||
maxusers = n;
|
||||
if (n < minmaxusers) {
|
||||
error("warning: minimum of %d maxusers assumed", minmaxusers);
|
||||
cfgerror("warning: minimum of %d maxusers assumed",
|
||||
minmaxusers);
|
||||
errors--; /* take it away */
|
||||
maxusers = minmaxusers;
|
||||
} else if (n > maxmaxusers) {
|
||||
error("warning: maxusers (%d) > %d", n, maxmaxusers);
|
||||
cfgerror("warning: maxusers (%d) > %d", n, maxmaxusers);
|
||||
errors--;
|
||||
}
|
||||
}
|
||||
|
@ -212,8 +214,8 @@ defattr(const char *name, struct nvlist *locs, struct nvlist *deps,
|
|||
for (nv = deps; nv != NULL; nv = nv->nv_next) {
|
||||
dep = nv->nv_ptr;
|
||||
if (dep->a_iattr) {
|
||||
error("`%s' dependency `%s' is an interface attribute",
|
||||
name, dep->a_name);
|
||||
cfgerror("`%s' dependency `%s' is an interface "
|
||||
"attribute", name, dep->a_name);
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
@ -221,7 +223,7 @@ defattr(const char *name, struct nvlist *locs, struct nvlist *deps,
|
|||
a = ecalloc(1, sizeof *a);
|
||||
if (ht_insert(attrtab, name, a)) {
|
||||
free(a);
|
||||
error("attribute `%s' already defined", name);
|
||||
cfgerror("attribute `%s' already defined", name);
|
||||
nvfreel(locs);
|
||||
return (1);
|
||||
}
|
||||
|
@ -244,7 +246,8 @@ defattr(const char *name, struct nvlist *locs, struct nvlist *deps,
|
|||
if (!errored &&
|
||||
(!isalnum((unsigned char)*cp) ||
|
||||
(isalpha((unsigned char)*cp) && !islower((unsigned char)*cp)))) {
|
||||
error("device class names must be lower-case alphanumeric characters");
|
||||
cfgerror("device class names must be "
|
||||
"lower-case alphanumeric characters");
|
||||
errored = 1;
|
||||
}
|
||||
*cp = toupper((unsigned char)*cp);
|
||||
|
@ -327,7 +330,7 @@ defdev(struct devbase *dev, struct nvlist *loclist, struct nvlist *attrs,
|
|||
if (dev == &errdev)
|
||||
goto bad;
|
||||
if (dev->d_isdef) {
|
||||
error("redefinition of `%s'", dev->d_name);
|
||||
cfgerror("redefinition of `%s'", dev->d_name);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
|
@ -383,7 +386,8 @@ defdev(struct devbase *dev, struct nvlist *loclist, struct nvlist *attrs,
|
|||
a->a_refs = addtoattr(a->a_refs, dev);
|
||||
if (a->a_devclass != NULL) {
|
||||
if (dev->d_classattr != NULL) {
|
||||
error("device `%s' has multiple classes (`%s' and `%s')",
|
||||
cfgerror("device `%s' has multiple classes "
|
||||
"(`%s' and `%s')",
|
||||
dev->d_name, dev->d_classattr->a_name,
|
||||
a->a_name);
|
||||
}
|
||||
|
@ -403,10 +407,10 @@ defdev(struct devbase *dev, struct nvlist *loclist, struct nvlist *attrs,
|
|||
struct devbase *
|
||||
getdevbase(const char *name)
|
||||
{
|
||||
u_char *p;
|
||||
const u_char *p;
|
||||
struct devbase *dev;
|
||||
|
||||
p = (u_char *)name;
|
||||
p = (const u_char *)name;
|
||||
if (!isalpha(*p))
|
||||
goto badname;
|
||||
while (*++p) {
|
||||
|
@ -415,7 +419,7 @@ getdevbase(const char *name)
|
|||
}
|
||||
if (isdigit(*--p)) {
|
||||
badname:
|
||||
error("bad device base name `%s'", name);
|
||||
cfgerror("bad device base name `%s'", name);
|
||||
return (&errdev);
|
||||
}
|
||||
dev = ht_lookup(devbasetab, name);
|
||||
|
@ -456,15 +460,15 @@ defdevattach(struct deva *deva, struct devbase *dev, struct nvlist *atlist,
|
|||
if (deva == &errdeva)
|
||||
goto bad;
|
||||
if (!dev->d_isdef) {
|
||||
error("attaching undefined device `%s'", dev->d_name);
|
||||
cfgerror("attaching undefined device `%s'", dev->d_name);
|
||||
goto bad;
|
||||
}
|
||||
if (deva->d_isdef) {
|
||||
error("redefinition of `%s'", deva->d_name);
|
||||
cfgerror("redefinition of `%s'", deva->d_name);
|
||||
goto bad;
|
||||
}
|
||||
if (dev->d_ispseudo) {
|
||||
error("pseudo-devices can't attach");
|
||||
cfgerror("pseudo-devices can't attach");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
|
@ -476,7 +480,7 @@ defdevattach(struct deva *deva, struct devbase *dev, struct nvlist *atlist,
|
|||
if (a == &errattr)
|
||||
continue; /* already complained */
|
||||
if (a->a_iattr || a->a_devclass != NULL)
|
||||
error("`%s' is not a plain attribute", a->a_name);
|
||||
cfgerror("`%s' is not a plain attribute", a->a_name);
|
||||
}
|
||||
|
||||
/* Committed! Set up fields. */
|
||||
|
@ -505,7 +509,7 @@ defdevattach(struct deva *deva, struct devbase *dev, struct nvlist *atlist,
|
|||
*/
|
||||
for (da = dev->d_ahead; da != NULL; da = da->d_bsame)
|
||||
if (onlist(da->d_atlist, a))
|
||||
error("attach at `%s' already done by `%s'",
|
||||
cfgerror("attach at `%s' already done by `%s'",
|
||||
a ? a->a_name : "root", da->d_name);
|
||||
|
||||
if (a == NULL) {
|
||||
|
@ -513,7 +517,7 @@ defdevattach(struct deva *deva, struct devbase *dev, struct nvlist *atlist,
|
|||
continue; /* at root; don't add */
|
||||
}
|
||||
if (!a->a_iattr)
|
||||
error("%s cannot be at plain attribute `%s'",
|
||||
cfgerror("%s cannot be at plain attribute `%s'",
|
||||
dev->d_name, a->a_name);
|
||||
else
|
||||
a->a_devs = addtoattr(a->a_devs, dev);
|
||||
|
@ -535,10 +539,10 @@ defdevattach(struct deva *deva, struct devbase *dev, struct nvlist *atlist,
|
|||
struct deva *
|
||||
getdevattach(const char *name)
|
||||
{
|
||||
u_char *p;
|
||||
const u_char *p;
|
||||
struct deva *deva;
|
||||
|
||||
p = (u_char *)name;
|
||||
p = (const u_char *)name;
|
||||
if (!isalpha(*p))
|
||||
goto badname;
|
||||
while (*++p) {
|
||||
|
@ -547,7 +551,7 @@ getdevattach(const char *name)
|
|||
}
|
||||
if (isdigit(*--p)) {
|
||||
badname:
|
||||
error("bad device attachment name `%s'", name);
|
||||
cfgerror("bad device attachment name `%s'", name);
|
||||
return (&errdeva);
|
||||
}
|
||||
deva = ht_lookup(devatab, name);
|
||||
|
@ -577,7 +581,7 @@ getattr(const char *name)
|
|||
struct attr *a;
|
||||
|
||||
if ((a = ht_lookup(attrtab, name)) == NULL) {
|
||||
error("undefined attribute `%s'", name);
|
||||
cfgerror("undefined attribute `%s'", name);
|
||||
a = &errattr;
|
||||
}
|
||||
return (a);
|
||||
|
@ -594,7 +598,7 @@ expandattr(struct attr *a, void (*callback)(struct attr *))
|
|||
struct attr *dep;
|
||||
|
||||
if (a->a_expanding) {
|
||||
error("circular dependency on attribute `%s'", a->a_name);
|
||||
cfgerror("circular dependency on attribute `%s'", a->a_name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -622,7 +626,7 @@ setmajor(struct devbase *d, int n)
|
|||
{
|
||||
|
||||
if (d != &errdev && d->d_major != NODEV)
|
||||
error("device `%s' is already major %d",
|
||||
cfgerror("device `%s' is already major %d",
|
||||
d->d_name, d->d_major);
|
||||
else
|
||||
d->d_major = n;
|
||||
|
@ -669,14 +673,14 @@ dev2major(struct devbase *dev)
|
|||
static const char *
|
||||
makedevstr(int maj, int min)
|
||||
{
|
||||
const char *devname;
|
||||
const char *devicename;
|
||||
char buf[32];
|
||||
|
||||
devname = major2name(maj);
|
||||
if (devname == NULL)
|
||||
devicename = major2name(maj);
|
||||
if (devicename == NULL)
|
||||
(void)snprintf(buf, sizeof(buf), "<%d/%d>", maj, min);
|
||||
else
|
||||
(void)snprintf(buf, sizeof(buf), "%s%d%c", devname,
|
||||
(void)snprintf(buf, sizeof(buf), "%s%d%c", devicename,
|
||||
min / maxpartitions, (min % maxpartitions) + 'a');
|
||||
|
||||
return (intern(buf));
|
||||
|
@ -747,12 +751,12 @@ resolve(struct nvlist **nvp, const char *name, const char *what,
|
|||
}
|
||||
cp = nv->nv_str;
|
||||
if (split(cp, l, buf, sizeof buf, &unit)) {
|
||||
error("%s: invalid %s device name `%s'", name, what, cp);
|
||||
cfgerror("%s: invalid %s device name `%s'", name, what, cp);
|
||||
return (1);
|
||||
}
|
||||
dev = ht_lookup(devbasetab, intern(buf));
|
||||
if (dev == NULL) {
|
||||
error("%s: device `%s' does not exist", name, buf);
|
||||
cfgerror("%s: device `%s' does not exist", name, buf);
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
@ -766,7 +770,7 @@ resolve(struct nvlist **nvp, const char *name, const char *what,
|
|||
} else {
|
||||
maj = dev2major(dev);
|
||||
if (maj == NODEV) {
|
||||
error("%s: can't make %s device from `%s'",
|
||||
cfgerror("%s: can't make %s device from `%s'",
|
||||
name, what, nv->nv_str);
|
||||
return (1);
|
||||
}
|
||||
|
@ -789,7 +793,7 @@ addconf(struct config *cf0)
|
|||
name = cf0->cf_name;
|
||||
cf = ecalloc(1, sizeof *cf);
|
||||
if (ht_insert(cfhashtab, name, cf)) {
|
||||
error("configuration `%s' already defined", name);
|
||||
cfgerror("configuration `%s' already defined", name);
|
||||
free(cf);
|
||||
goto bad;
|
||||
}
|
||||
|
@ -799,7 +803,7 @@ addconf(struct config *cf0)
|
|||
* Resolve the root device.
|
||||
*/
|
||||
if (cf->cf_root == NULL) {
|
||||
error("%s: no root device specified", name);
|
||||
cfgerror("%s: no root device specified", name);
|
||||
goto bad;
|
||||
}
|
||||
if (cf->cf_root && cf->cf_root->nv_str != s_qmark) {
|
||||
|
@ -843,7 +847,7 @@ setconf(struct nvlist **npp, const char *what, struct nvlist *v)
|
|||
{
|
||||
|
||||
if (*npp != NULL) {
|
||||
error("duplicate %s specification", what);
|
||||
cfgerror("duplicate %s specification", what);
|
||||
nvfreel(v);
|
||||
} else
|
||||
*npp = v;
|
||||
|
@ -855,7 +859,7 @@ delconf(const char *name)
|
|||
struct config *cf;
|
||||
|
||||
if (ht_lookup(cfhashtab, name) == NULL) {
|
||||
error("configuration `%s' undefined", name);
|
||||
cfgerror("configuration `%s' undefined", name);
|
||||
return;
|
||||
}
|
||||
(void)ht_remove(cfhashtab, name);
|
||||
|
@ -874,12 +878,12 @@ setfstype(const char **fstp, const char *v)
|
|||
{
|
||||
|
||||
if (*fstp != NULL) {
|
||||
error("multiple fstype specifications");
|
||||
cfgerror("multiple fstype specifications");
|
||||
return;
|
||||
}
|
||||
|
||||
if (v != s_qmark && OPT_FSOPT(v)) {
|
||||
error("\"%s\" is not a configured file system", v);
|
||||
cfgerror("\"%s\" is not a configured file system", v);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -951,14 +955,14 @@ adddev(const char *name, const char *at, struct nvlist *loclist, int flags)
|
|||
break;
|
||||
}
|
||||
if (!hit) {
|
||||
error("`%s' cannot attach to the root", ib->d_name);
|
||||
cfgerror("`%s' cannot attach to the root", ib->d_name);
|
||||
i->i_active = DEVI_BROKEN;
|
||||
goto bad;
|
||||
}
|
||||
attr = &errattr; /* a convenient "empty" attr */
|
||||
} else {
|
||||
if (split(at, strlen(at), atbuf, sizeof atbuf, &atunit)) {
|
||||
error("invalid attachment name `%s'", at);
|
||||
cfgerror("invalid attachment name `%s'", at);
|
||||
/* (void)getdevi(name); -- ??? */
|
||||
goto bad;
|
||||
}
|
||||
|
@ -1006,7 +1010,7 @@ adddev(const char *name, const char *at, struct nvlist *loclist, int flags)
|
|||
* nonesuch is not even a device).
|
||||
*/
|
||||
if (ab == NULL) {
|
||||
error("%s at %s: `%s' unknown",
|
||||
cfgerror("%s at %s: `%s' unknown",
|
||||
name, at, atbuf);
|
||||
i->i_active = DEVI_BROKEN;
|
||||
goto bad;
|
||||
|
@ -1021,7 +1025,7 @@ adddev(const char *name, const char *at, struct nvlist *loclist, int flags)
|
|||
if (onlist(attr->a_devs, ib))
|
||||
goto findattachment;
|
||||
}
|
||||
error("`%s' cannot attach to `%s'", ib->d_name, atbuf);
|
||||
cfgerror("`%s' cannot attach to `%s'", ib->d_name, atbuf);
|
||||
i->i_active = DEVI_BROKEN;
|
||||
goto bad;
|
||||
|
||||
|
@ -1070,20 +1074,20 @@ deldevi(const char *name, const char *at)
|
|||
char base[NAMESIZE];
|
||||
|
||||
if (split(name, strlen(name), base, sizeof base, &unit)) {
|
||||
error("invalid device name `%s'", name);
|
||||
cfgerror("invalid device name `%s'", name);
|
||||
return;
|
||||
}
|
||||
d = ht_lookup(devbasetab, intern(base));
|
||||
if (d == NULL) {
|
||||
error("%s: unknown device `%s'", name, base);
|
||||
cfgerror("%s: unknown device `%s'", name, base);
|
||||
return;
|
||||
}
|
||||
if (d->d_ispseudo) {
|
||||
error("%s: %s is a pseudo-device", name, base);
|
||||
cfgerror("%s: %s is a pseudo-device", name, base);
|
||||
return;
|
||||
}
|
||||
if ((firsti = ht_lookup(devitab, name)) == NULL) {
|
||||
error("`%s' not defined", name);
|
||||
cfgerror("`%s' not defined", name);
|
||||
return;
|
||||
}
|
||||
if (at == NULL && firsti->i_at == NULL) {
|
||||
|
@ -1096,7 +1100,7 @@ deldevi(const char *name, const char *at)
|
|||
remove_devi(i);
|
||||
return;
|
||||
}
|
||||
error("`%s' at `%s' not found", name, at ? at : "root");
|
||||
cfgerror("`%s' at `%s' not found", name, at ? at : "root");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1272,7 +1276,7 @@ deldeva(const char *at)
|
|||
char base[NAMESIZE];
|
||||
|
||||
if (split(at, l+1, base, sizeof base, &unit)) {
|
||||
error("invalid attachment name `%s'", at);
|
||||
cfgerror("invalid attachment name `%s'", at);
|
||||
return;
|
||||
}
|
||||
cp = intern(base);
|
||||
|
@ -1284,12 +1288,12 @@ deldeva(const char *at)
|
|||
ad = ht_lookup(devbasetab, cp);
|
||||
a = ht_lookup(attrtab, cp);
|
||||
if (a == NULL) {
|
||||
error("unknown attachment attribute or device `%s'",
|
||||
cfgerror("unknown attachment attribute or device `%s'",
|
||||
cp);
|
||||
return;
|
||||
}
|
||||
if (!a->a_iattr) {
|
||||
error("plain attribute `%s' cannot have children",
|
||||
cfgerror("plain attribute `%s' cannot have children",
|
||||
a->a_name);
|
||||
return;
|
||||
}
|
||||
|
@ -1355,7 +1359,7 @@ deldev(const char *name)
|
|||
/* `no mydev0' or `no mydev*' */
|
||||
firsti = ht_lookup(devitab, name);
|
||||
if (firsti == NULL) {
|
||||
error("unknown instance %s", name);
|
||||
cfgerror("unknown instance %s", name);
|
||||
return;
|
||||
}
|
||||
for (i = firsti; i != NULL; i = i->i_alias)
|
||||
|
@ -1364,11 +1368,11 @@ deldev(const char *name)
|
|||
struct devbase *d = ht_lookup(devbasetab, name);
|
||||
|
||||
if (d == NULL) {
|
||||
error("unknown device %s", name);
|
||||
cfgerror("unknown device %s", name);
|
||||
return;
|
||||
}
|
||||
if (d->d_ispseudo) {
|
||||
error("%s is a pseudo-device; "
|
||||
cfgerror("%s is a pseudo-device; "
|
||||
"use \"no pseudo-device %s\" instead", name,
|
||||
name);
|
||||
return;
|
||||
|
@ -1393,15 +1397,15 @@ addpseudo(const char *name, int number)
|
|||
|
||||
d = ht_lookup(devbasetab, name);
|
||||
if (d == NULL) {
|
||||
error("undefined pseudo-device %s", name);
|
||||
cfgerror("undefined pseudo-device %s", name);
|
||||
return;
|
||||
}
|
||||
if (!d->d_ispseudo) {
|
||||
error("%s is a real device, not a pseudo-device", name);
|
||||
cfgerror("%s is a real device, not a pseudo-device", name);
|
||||
return;
|
||||
}
|
||||
if (ht_lookup(devitab, name) != NULL) {
|
||||
error("`%s' already defined", name);
|
||||
cfgerror("`%s' already defined", name);
|
||||
return;
|
||||
}
|
||||
i = newdevi(name, number - 1, d); /* foo 16 => "foo0..foo15" */
|
||||
|
@ -1421,15 +1425,15 @@ delpseudo(const char *name)
|
|||
|
||||
d = ht_lookup(devbasetab, name);
|
||||
if (d == NULL) {
|
||||
error("undefined pseudo-device %s", name);
|
||||
cfgerror("undefined pseudo-device %s", name);
|
||||
return;
|
||||
}
|
||||
if (!d->d_ispseudo) {
|
||||
error("%s is a real device, not a pseudo-device", name);
|
||||
cfgerror("%s is a real device, not a pseudo-device", name);
|
||||
return;
|
||||
}
|
||||
if ((i = ht_lookup(devitab, name)) == NULL) {
|
||||
error("`%s' not defined", name);
|
||||
cfgerror("`%s' not defined", name);
|
||||
return;
|
||||
}
|
||||
d->d_umax = 0; /* clear neads-count entries */
|
||||
|
@ -1447,18 +1451,18 @@ adddevm(const char *name, int cmajor, int bmajor, struct nvlist *options)
|
|||
struct devm *dm;
|
||||
|
||||
if (cmajor < -1 || cmajor >= 4096) {
|
||||
error("character major %d is invalid", cmajor);
|
||||
cfgerror("character major %d is invalid", cmajor);
|
||||
nvfreel(options);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bmajor < -1 || bmajor >= 4096) {
|
||||
error("block major %d is invalid", bmajor);
|
||||
cfgerror("block major %d is invalid", bmajor);
|
||||
nvfreel(options);
|
||||
return;
|
||||
}
|
||||
if (cmajor == -1 && bmajor == -1) {
|
||||
error("both character/block majors are not specified");
|
||||
cfgerror("both character/block majors are not specified");
|
||||
nvfreel(options);
|
||||
return;
|
||||
}
|
||||
|
@ -1492,14 +1496,14 @@ fixdevis(void)
|
|||
* i_at or i_pspec are NULL.
|
||||
*/
|
||||
++error;
|
||||
xerror(i->i_srcfile, i->i_lineno,
|
||||
cfgxerror(i->i_srcfile, i->i_lineno,
|
||||
"`%s at %s' is orphaned (%s `%s' found)",
|
||||
i->i_name, i->i_at, i->i_pspec->p_atunit == WILD ?
|
||||
"nothing matching" : "no", i->i_at);
|
||||
} else if (vflag && i->i_active == DEVI_IGNORED)
|
||||
xwarn(i->i_srcfile, i->i_lineno, "ignoring explicitely"
|
||||
" orphaned instance `%s at %s'", i->i_name,
|
||||
i->i_at);
|
||||
cfgxwarn(i->i_srcfile, i->i_lineno, "ignoring "
|
||||
"explicitly orphaned instance `%s at %s'",
|
||||
i->i_name, i->i_at);
|
||||
|
||||
if (error)
|
||||
return error;
|
||||
|
@ -1550,16 +1554,16 @@ getdevi(const char *name)
|
|||
char base[NAMESIZE];
|
||||
|
||||
if (split(name, strlen(name), base, sizeof base, &unit)) {
|
||||
error("invalid device name `%s'", name);
|
||||
cfgerror("invalid device name `%s'", name);
|
||||
return (NULL);
|
||||
}
|
||||
d = ht_lookup(devbasetab, intern(base));
|
||||
if (d == NULL) {
|
||||
error("%s: unknown device `%s'", name, base);
|
||||
cfgerror("%s: unknown device `%s'", name, base);
|
||||
return (NULL);
|
||||
}
|
||||
if (d->d_ispseudo) {
|
||||
error("%s: %s is a pseudo-device", name, base);
|
||||
cfgerror("%s: %s is a pseudo-device", name, base);
|
||||
return (NULL);
|
||||
}
|
||||
firsti = ht_lookup(devitab, name);
|
||||
|
@ -1582,12 +1586,12 @@ getdevi(const char *name)
|
|||
static const char *
|
||||
concat(const char *name, int c)
|
||||
{
|
||||
int len;
|
||||
size_t len;
|
||||
char buf[NAMESIZE];
|
||||
|
||||
len = strlen(name);
|
||||
if (len + 2 > sizeof(buf)) {
|
||||
error("device name `%s%c' too long", name, c);
|
||||
cfgerror("device name `%s%c' too long", name, c);
|
||||
len = sizeof(buf) - 2;
|
||||
}
|
||||
memmove(buf, name, len);
|
||||
|
@ -1619,7 +1623,8 @@ static int
|
|||
split(const char *name, size_t nlen, char *base, size_t bsize, int *aunit)
|
||||
{
|
||||
const char *cp;
|
||||
int c, l;
|
||||
int c;
|
||||
size_t l;
|
||||
|
||||
l = nlen;
|
||||
if (l < 2 || l >= bsize || isdigit((unsigned char)*name))
|
||||
|
@ -1647,7 +1652,7 @@ void
|
|||
selectattr(struct attr *a)
|
||||
{
|
||||
|
||||
(void)ht_insert(selecttab, a->a_name, (char *)a->a_name);
|
||||
(void)ht_insert(selecttab, a->a_name, __UNCONST(a->a_name));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1660,13 +1665,13 @@ selectbase(struct devbase *d, struct deva *da)
|
|||
struct attr *a;
|
||||
struct nvlist *nv;
|
||||
|
||||
(void)ht_insert(selecttab, d->d_name, (char *)d->d_name);
|
||||
(void)ht_insert(selecttab, d->d_name, __UNCONST(d->d_name));
|
||||
for (nv = d->d_attrs; nv != NULL; nv = nv->nv_next) {
|
||||
a = nv->nv_ptr;
|
||||
expandattr(a, selectattr);
|
||||
}
|
||||
if (da != NULL) {
|
||||
(void)ht_insert(selecttab, da->d_name, (char *)da->d_name);
|
||||
(void)ht_insert(selecttab, da->d_name, __UNCONST(da->d_name));
|
||||
for (nv = da->d_attrs; nv != NULL; nv = nv->nv_next) {
|
||||
a = nv->nv_ptr;
|
||||
expandattr(a, selectattr);
|
||||
|
@ -1689,7 +1694,7 @@ onlist(struct nvlist *nv, void *ptr)
|
|||
static char *
|
||||
extend(char *p, const char *name)
|
||||
{
|
||||
int l;
|
||||
size_t l;
|
||||
|
||||
l = strlen(name);
|
||||
memmove(p, name, l);
|
||||
|
@ -1763,16 +1768,16 @@ fixloc(const char *name, struct attr *attr, struct nvlist *got)
|
|||
}
|
||||
if (nextra) {
|
||||
ep[-2] = 0; /* kill ", " */
|
||||
error("%s: extraneous locator%s: %s",
|
||||
cfgerror("%s: extraneous locator%s: %s",
|
||||
name, nextra > 1 ? "s" : "", extra);
|
||||
}
|
||||
if (nmissing) {
|
||||
mp[-2] = 0;
|
||||
error("%s: must specify %s", name, missing);
|
||||
cfgerror("%s: must specify %s", name, missing);
|
||||
}
|
||||
if (nnodefault) {
|
||||
ndp[-2] = 0;
|
||||
error("%s: cannot wildcard %s", name, nodefault);
|
||||
cfgerror("%s: cannot wildcard %s", name, nodefault);
|
||||
}
|
||||
if (nmissing || nnodefault) {
|
||||
free(lp);
|
||||
|
@ -1785,10 +1790,10 @@ void
|
|||
setversion(int newver)
|
||||
{
|
||||
if (newver > CONFIG_VERSION)
|
||||
error("your sources require a newer version of config(1) "
|
||||
cfgerror("your sources require a newer version of config(1) "
|
||||
"-- please rebuild it.");
|
||||
else if (newver < CONFIG_MINVERSION)
|
||||
error("your sources are out of date -- please update.");
|
||||
cfgerror("your sources are out of date -- please update.");
|
||||
else
|
||||
version = newver;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: util.c,v 1.5 2007/01/12 21:49:51 cube Exp $ */
|
||||
/* $NetBSD: util.c,v 1.6 2007/01/13 23:47:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -51,78 +51,16 @@
|
|||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <util.h>
|
||||
#include <err.h>
|
||||
#include "defs.h"
|
||||
|
||||
static void nomem(void);
|
||||
static void vxerror(const char *, int, const char *, va_list)
|
||||
static void cfgvxerror(const char *, int, const char *, va_list)
|
||||
__attribute__((__format__(__printf__, 3, 0)));
|
||||
static void vxwarn(const char *, int, const char *, va_list)
|
||||
static void cfgvxwarn(const char *, int, const char *, va_list)
|
||||
__attribute__((__format__(__printf__, 3, 0)));
|
||||
static void vxmsg(const char *fname, int line, const char *class,
|
||||
const char *fmt, va_list)
|
||||
static void cfgvxmsg(const char *, int, const char *, const char *, va_list)
|
||||
__attribute__((__format__(__printf__, 4, 0)));
|
||||
|
||||
/*
|
||||
* Calloc, with abort on error.
|
||||
*/
|
||||
void *
|
||||
ecalloc(size_t nelem, size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
if ((p = calloc(nelem, size)) == NULL)
|
||||
nomem();
|
||||
return (p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Malloc, with abort on error.
|
||||
*/
|
||||
void *
|
||||
emalloc(size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
if ((p = malloc(size)) == NULL)
|
||||
nomem();
|
||||
return (p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Realloc, with abort on error.
|
||||
*/
|
||||
void *
|
||||
erealloc(void *p, size_t size)
|
||||
{
|
||||
void *q;
|
||||
|
||||
if ((q = realloc(p, size)) == NULL)
|
||||
nomem();
|
||||
p = q;
|
||||
return (p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Strdup, with abort on error.
|
||||
*/
|
||||
char *
|
||||
estrdup(const char *p)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
if ((cp = strdup(p)) == NULL)
|
||||
nomem();
|
||||
return (cp);
|
||||
}
|
||||
|
||||
static void
|
||||
nomem(void)
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "config: out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Push a prefix onto the prefix stack.
|
||||
*/
|
||||
|
@ -156,7 +94,7 @@ prefix_pop(void)
|
|||
struct prefix *pf;
|
||||
|
||||
if ((pf = SLIST_FIRST(&prefixes)) == NULL) {
|
||||
error("no prefixes on the stack to pop");
|
||||
cfgerror("no prefixes on the stack to pop");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -250,30 +188,30 @@ nvcat(struct nvlist *nv1, struct nvlist *nv2)
|
|||
}
|
||||
|
||||
void
|
||||
warn(const char *fmt, ...)
|
||||
cfgwarn(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
extern const char *yyfile;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vxwarn(yyfile, currentline(), fmt, ap);
|
||||
cfgvxwarn(yyfile, currentline(), fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
xwarn(const char *file, int line, const char *fmt, ...)
|
||||
cfgxwarn(const char *file, int line, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vxwarn(file, line, fmt, ap);
|
||||
cfgvxwarn(file, line, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static void
|
||||
vxwarn(const char *file, int line, const char *fmt, va_list ap)
|
||||
cfgvxwarn(const char *file, int line, const char *fmt, va_list ap)
|
||||
{
|
||||
vxmsg(file, line, "warning: ", fmt, ap);
|
||||
cfgvxmsg(file, line, "warning: ", fmt, ap);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -281,13 +219,13 @@ vxwarn(const char *file, int line, const char *fmt, va_list ap)
|
|||
* and line number.
|
||||
*/
|
||||
void
|
||||
error(const char *fmt, ...)
|
||||
cfgerror(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
extern const char *yyfile;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vxerror(yyfile, currentline(), fmt, ap);
|
||||
cfgvxerror(yyfile, currentline(), fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
@ -296,12 +234,12 @@ error(const char *fmt, ...)
|
|||
* find out about it until later).
|
||||
*/
|
||||
void
|
||||
xerror(const char *file, int line, const char *fmt, ...)
|
||||
cfgxerror(const char *file, int line, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vxerror(file, line, fmt, ap);
|
||||
cfgvxerror(file, line, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
@ -309,9 +247,9 @@ xerror(const char *file, int line, const char *fmt, ...)
|
|||
* Internal form of error() and xerror().
|
||||
*/
|
||||
static void
|
||||
vxerror(const char *file, int line, const char *fmt, va_list ap)
|
||||
cfgvxerror(const char *file, int line, const char *fmt, va_list ap)
|
||||
{
|
||||
vxmsg(file, line, "", fmt, ap);
|
||||
cfgvxmsg(file, line, "", fmt, ap);
|
||||
errors++;
|
||||
}
|
||||
|
||||
|
@ -325,7 +263,7 @@ panic(const char *fmt, ...)
|
|||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
(void)fprintf(stderr, "config: panic: ");
|
||||
(void)fprintf(stderr, "%s: panic: ", getprogname());
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
(void)putc('\n', stderr);
|
||||
va_end(ap);
|
||||
|
@ -336,7 +274,7 @@ panic(const char *fmt, ...)
|
|||
* Internal form of error() and xerror().
|
||||
*/
|
||||
static void
|
||||
vxmsg(const char *file, int line, const char *msgclass, const char *fmt,
|
||||
cfgvxmsg(const char *file, int line, const char *msgclass, const char *fmt,
|
||||
va_list ap)
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in New Issue