summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1998-12-30 18:11:55 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1998-12-30 18:11:55 +0000
commit0fb8c365fd07b69a215134efdd2e31800a1e2f1f (patch)
tree2cbbc5add4cfcf23d28af4323ec7da6f308eed66
parentd694d1c6ce729f88f5d39a65ddfcbc55508cc73e (diff)
Exit if nlist fails with ENOENT. Also replace strerror(errno) in syslog with %m
-rw-r--r--sbin/savecore/savecore_old.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/sbin/savecore/savecore_old.c b/sbin/savecore/savecore_old.c
index 2414338a10a..30a745cb216 100644
--- a/sbin/savecore/savecore_old.c
+++ b/sbin/savecore/savecore_old.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: savecore_old.c,v 1.12 1998/10/04 16:36:13 millert Exp $ */
+/* $OpenBSD: savecore_old.c,v 1.13 1998/12/30 18:11:54 millert Exp $ */
/* $NetBSD: savecore_old.c,v 1.1.1.1 1996/03/16 10:25:11 leo Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)savecore.c 8.3 (Berkeley) 1/2/94";
#else
-static char rcsid[] = "$OpenBSD: savecore_old.c,v 1.12 1998/10/04 16:36:13 millert Exp $";
+static char rcsid[] = "$OpenBSD: savecore_old.c,v 1.13 1998/12/30 18:11:54 millert Exp $";
#endif
#endif /* not lint */
@@ -234,8 +234,11 @@ kmem_setup()
} else {
current_sys = _PATH_UNIX;
}
- if ((nlist(current_sys, current_nl)) == -1)
+ if ((nlist(current_sys, current_nl)) == -1) {
syslog(LOG_ERR, "%s: nlist: %m", current_sys);
+ if (errno == ENOENT)
+ exit(1);
+ }
for (i = 0; cursyms[i] != -1; i++)
if (current_nl[cursyms[i]].n_value == 0) {
syslog(LOG_ERR, "%s: %s not in namelist",
@@ -245,8 +248,11 @@ kmem_setup()
dump_sys = kernel ? kernel : _PATH_UNIX;
- if ((nlist(dump_sys, dump_nl)) == -1)
- syslog(LOG_ERR, "%s: nlist: %s", dump_sys, strerror(errno));
+ if ((nlist(dump_sys, dump_nl)) == -1) {
+ syslog(LOG_ERR, "%s: nlist: %m", dump_sys);
+ if (errno == ENOENT)
+ exit(1);
+ }
for (i = 0; dumpsyms[i] != -1; i++)
if (dump_nl[dumpsyms[i]].n_value == 0) {
syslog(LOG_ERR, "%s: %s not in namelist",
@@ -377,7 +383,7 @@ save_core()
goto err1;
if (fgets(buf, sizeof(buf), fp) == NULL) {
if (ferror(fp))
-err1: syslog(LOG_WARNING, "%s: %s", path, strerror(errno));
+err1: syslog(LOG_WARNING, "%s: %m", path);
bounds = 0;
} else
bounds = atoi(buf);
@@ -396,7 +402,7 @@ err1: syslog(LOG_WARNING, "%s: %s", path, strerror(errno));
dirname, _PATH_UNIX, bounds, compress ? ".Z" : "");
if (compress) {
if ((fp = zopen(path, "w", 0)) == NULL) {
- syslog(LOG_ERR, "%s: %s", path, strerror(errno));
+ syslog(LOG_ERR, "%s: %m", path);
exit(1);
}
} else
@@ -452,7 +458,7 @@ err2: syslog(LOG_WARNING,
dirname, _PATH_UNIX, bounds, compress ? ".Z" : "");
if (compress) {
if ((fp = zopen(path, "w", 0)) == NULL) {
- syslog(LOG_ERR, "%s: %s", path, strerror(errno));
+ syslog(LOG_ERR, "%s: %m", path);
exit(1);
}
} else
@@ -473,10 +479,8 @@ err2: syslog(LOG_WARNING,
}
}
if (nr < 0) {
- syslog(LOG_ERR, "%s: %s",
- kernel ? kernel : _PATH_UNIX, strerror(errno));
- syslog(LOG_WARNING,
- "WARNING: kernel may be incomplete");
+ syslog(LOG_ERR, "%s: %m", kernel ? kernel : _PATH_UNIX);
+ syslog(LOG_WARNING, "WARNING: kernel may be incomplete");
exit(1);
}
if (compress)
@@ -497,14 +501,14 @@ find_dev(dev, type)
char *dp, devname[MAXPATHLEN + 1];
if ((dfd = opendir(_PATH_DEV)) == NULL) {
- syslog(LOG_ERR, "%s: %s", _PATH_DEV, strerror(errno));
+ syslog(LOG_ERR, "%s: %m", _PATH_DEV);
exit(1);
}
(void)strcpy(devname, _PATH_DEV);
while ((dir = readdir(dfd))) {
(void)strcpy(devname + sizeof(_PATH_DEV) - 1, dir->d_name);
if (lstat(devname, &sb)) {
- syslog(LOG_ERR, "%s: %s", devname, strerror(errno));
+ syslog(LOG_ERR, "%s: %m", devname);
continue;
}
if ((sb.st_mode & S_IFMT) != type)
@@ -512,7 +516,7 @@ find_dev(dev, type)
if (dev == sb.st_rdev) {
closedir(dfd);
if ((dp = strdup(devname)) == NULL) {
- syslog(LOG_ERR, "%s", strerror(errno));
+ syslog(LOG_ERR, "%s", strerror(ENOMEM));
exit(1);
}
return (dp);
@@ -536,7 +540,7 @@ rawname(s)
}
(void)snprintf(name, sizeof(name), "%.*s/r%s", sl - s, s, sl + 1);
if ((sl = strdup(name)) == NULL) {
- syslog(LOG_ERR, "%s", strerror(errno));
+ syslog(LOG_ERR, "%s", strerror(ENOMEM));
exit(1);
}
return (sl);