summaryrefslogtreecommitdiff
path: root/sbin/savecore/savecore.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1998-09-05 16:33:26 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1998-09-05 16:33:26 +0000
commitb03bfdb01feeb5763528442fb49195835e6b46db (patch)
tree848e0177a1d697053bbfe9e4a25125ee915a3b51 /sbin/savecore/savecore.c
parent99e19ba6e6b41eb5e7401c8e0b474312932fa2b6 (diff)
We can now savecore with a gzipped kernel:
o Use new gzip-aware nlist o If kernel cannot be found, use kernel.gz if it exists
Diffstat (limited to 'sbin/savecore/savecore.c')
-rw-r--r--sbin/savecore/savecore.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index b8c464a5bcd..5e324dfef34 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: savecore.c,v 1.13 1998/08/10 20:57:46 mickey Exp $ */
+/* $OpenBSD: savecore.c,v 1.14 1998/09/05 16:33:25 millert Exp $ */
/* $NetBSD: savecore.c,v 1.26 1996/03/18 21:16:05 leo Exp $ */
/*-
@@ -214,6 +214,7 @@ kmem_setup()
kvm_t *kd_kern;
char errbuf[_POSIX2_LINE_MAX];
int i, hdrsz;
+ struct stat st;
/*
* Some names we need for the currently running system, others for
@@ -265,6 +266,18 @@ kmem_setup()
dump_sys = kernel ? kernel : _PATH_UNIX;
+ /* If no dumpsys, check for dumpsys.gz */
+ if (stat(dump_sys, &st) == -1) {
+ char *gzpath;
+
+ asprintf(&gzpath, "%s.gz", dump_sys);
+ if (stat(gzpath, &st) == -1) {
+ syslog(LOG_ERR, "%s: %m", dump_sys);
+ exit(1);
+ }
+ kernel = dump_sys = gzpath;
+ }
+
kd_dump = kvm_openfiles(dump_sys, ddname, NULL, O_RDWR, errbuf);
if (kd_dump == NULL) {
syslog(LOG_ERR, "%s: kvm_openfiles: %s", dump_sys, errbuf);