summaryrefslogtreecommitdiff
path: root/sbin
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
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')
-rw-r--r--sbin/savecore/Makefile8
-rw-r--r--sbin/savecore/savecore.c15
-rw-r--r--sbin/savecore/savecore_old.c18
3 files changed, 36 insertions, 5 deletions
diff --git a/sbin/savecore/Makefile b/sbin/savecore/Makefile
index 80af462b0e6..0580e81bdb7 100644
--- a/sbin/savecore/Makefile
+++ b/sbin/savecore/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.8 1998/08/30 22:29:56 millert Exp $
+# $OpenBSD: Makefile,v 1.9 1998/09/05 16:33:25 millert Exp $
PROG= savecore
@@ -17,8 +17,12 @@ DPADD= ${LIBKVM}
.else
SRCS= savecore_old.c
.endif
-SRCS+= zopen.c
+SRCS+= zopen.c nlist.c
+CFLAGS+=-D_NLIST_DO_GZIP
+LDADD+= -lz
+DPADD+= ${LIBZ}
MAN= savecore.8
.PATH: ${.CURDIR}/../../usr.bin/compress
+.PATH: ${.CURDIR}/../../lib/libc/gen
.include <bsd.prog.mk>
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);
diff --git a/sbin/savecore/savecore_old.c b/sbin/savecore/savecore_old.c
index dde55d8ca46..4c9c636216b 100644
--- a/sbin/savecore/savecore_old.c
+++ b/sbin/savecore/savecore_old.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: savecore_old.c,v 1.9 1998/08/24 05:24:25 millert Exp $ */
+/* $OpenBSD: savecore_old.c,v 1.10 1998/09/05 16:33:25 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.9 1998/08/24 05:24:25 millert Exp $";
+static char rcsid[] = "$OpenBSD: savecore_old.c,v 1.10 1998/09/05 16:33:25 millert Exp $";
#endif
#endif /* not lint */
@@ -209,6 +209,7 @@ kmem_setup()
FILE *fp;
int kmem, i;
char *dump_sys, *current_sys;
+ struct stat st;
/*
* Some names we need for the currently running system, others for
@@ -234,6 +235,19 @@ 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;
+ }
+
if ((nlist(dump_sys, dump_nl)) == -1)
syslog(LOG_ERR, "%s: nlist: %s", dump_sys, strerror(errno));
for (i = 0; dumpsyms[i] != -1; i++)