use gzip instead of compress
This commit is contained in:
parent
4cefdbee45
commit
7e74657e37
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.23 1998/02/19 23:43:37 thorpej Exp $
|
||||
# $NetBSD: Makefile,v 1.24 2001/01/02 21:39:37 joda Exp $
|
||||
# @(#)Makefile 8.2 (Berkeley) 4/17/94
|
||||
|
||||
PROG= savecore
|
||||
|
@ -6,8 +6,7 @@ SRCS= savecore.c zopen.c
|
|||
|
||||
MAN= savecore.8
|
||||
|
||||
LDADD= -lkvm
|
||||
LDADD= -lkvm -lz
|
||||
DPADD= ${LIBKVM}
|
||||
.PATH: ${.CURDIR}/../../usr.bin/compress
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: savecore.8,v 1.17 2000/12/07 03:18:03 wiz Exp $
|
||||
.\" $NetBSD: savecore.8,v 1.18 2001/01/02 21:39:37 joda Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1980, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -106,7 +106,7 @@ as the kernel instead of the default ``/netbsd''.
|
|||
Prints out some additional debugging information.
|
||||
.It Fl z
|
||||
Compresses the core dump and kernel (see
|
||||
.Xr compress 1 ).
|
||||
.Xr gzip 1 ).
|
||||
.El
|
||||
.Pp
|
||||
.Nm
|
||||
|
@ -117,9 +117,9 @@ If it passes these checks, it saves the core image in
|
|||
and the system in
|
||||
.Ar directory Ns Pa /netbsd.#
|
||||
(or in
|
||||
.Ar directory Ns Pa /netbsd.#.core.Z
|
||||
.Ar directory Ns Pa /netbsd.#.core.gz
|
||||
and
|
||||
.Ar directory Ns Pa /netbsd.#.Z ,
|
||||
.Ar directory Ns Pa /netbsd.#.gz ,
|
||||
respectively, if the
|
||||
.Fl z
|
||||
option is used).
|
||||
|
@ -154,10 +154,10 @@ current kernel
|
|||
.Sh BUGS
|
||||
The minfree code does not consider the effect of compression.
|
||||
.Sh SEE ALSO
|
||||
.Xr compress 1 ,
|
||||
.Xr dmesg 8 ,
|
||||
.Xr fstat 1 ,
|
||||
.Xr gdb 1 ,
|
||||
.Xr gzip 1 ,
|
||||
.Xr iostat 8 ,
|
||||
.Xr netstat 1 ,
|
||||
.Xr ps 1 ,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: savecore.c,v 1.48 2001/01/02 00:29:37 lukem Exp $ */
|
||||
/* $NetBSD: savecore.c,v 1.49 2001/01/02 21:39:37 joda Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1986, 1992, 1993
|
||||
|
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1986, 1992, 1993\n\
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)savecore.c 8.5 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: savecore.c,v 1.48 2001/01/02 00:29:37 lukem Exp $");
|
||||
__RCSID("$NetBSD: savecore.c,v 1.49 2001/01/02 21:39:37 joda Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -67,7 +67,7 @@ __RCSID("$NetBSD: savecore.c,v 1.48 2001/01/02 00:29:37 lukem Exp $");
|
|||
#include <limits.h>
|
||||
#include <kvm.h>
|
||||
|
||||
extern FILE *zopen(const char *fname, const char *mode, int bits);
|
||||
extern FILE *zopen(const char *fname, const char *mode);
|
||||
|
||||
#define KREAD(kd, addr, p)\
|
||||
(kvm_read(kd, addr, (char *)(p), sizeof(*(p))) != sizeof(*(p)))
|
||||
|
@ -427,9 +427,9 @@ err1: syslog(LOG_WARNING, "%s: %m", path);
|
|||
|
||||
/* Create the core file. */
|
||||
(void)snprintf(path, sizeof(path), "%s/netbsd.%d.core%s",
|
||||
dirname, bounds, compress ? ".Z" : "");
|
||||
dirname, bounds, compress ? ".gz" : "");
|
||||
if (compress) {
|
||||
if ((fp = zopen(path, "w", 0)) == NULL) {
|
||||
if ((fp = zopen(path, "w")) == NULL) {
|
||||
syslog(LOG_ERR, "%s: %m", path);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -489,9 +489,9 @@ err2: syslog(LOG_WARNING,
|
|||
/* Copy the kernel. */
|
||||
ifd = Open(kernel ? kernel : _PATH_UNIX, O_RDONLY);
|
||||
(void)snprintf(path, sizeof(path), "%s/netbsd.%d%s",
|
||||
dirname, bounds, compress ? ".Z" : "");
|
||||
dirname, bounds, compress ? ".gz" : "");
|
||||
if (compress) {
|
||||
if ((fp = zopen(path, "w", 0)) == NULL) {
|
||||
if ((fp = zopen(path, "w")) == NULL) {
|
||||
syslog(LOG_ERR, "%s: %m", path);
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/* $NetBSD: zopen.c,v 1.1 2001/01/02 21:39:37 joda Exp $ */
|
||||
|
||||
/*
|
||||
* Public domain stdio wrapper for libz, written by Johan Danielsson.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: zopen.c,v 1.1 2001/01/02 21:39:37 joda Exp $");
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <zlib.h>
|
||||
|
||||
FILE *zopen(const char *fname, const char *mode);
|
||||
|
||||
/* convert arguments */
|
||||
static int
|
||||
xgzread(void *cookie, char *data, int size)
|
||||
{
|
||||
return gzread(cookie, data, size);
|
||||
}
|
||||
|
||||
static int
|
||||
xgzwrite(void *cookie, const char *data, int size)
|
||||
{
|
||||
return gzwrite(cookie, (void*)data, size);
|
||||
}
|
||||
|
||||
FILE *
|
||||
zopen(const char *fname, const char *mode)
|
||||
{
|
||||
gzFile gz = gzopen(fname, mode);
|
||||
if(gz == NULL)
|
||||
return NULL;
|
||||
|
||||
if(*mode == 'r')
|
||||
return (funopen(gz, xgzread, NULL, NULL, gzclose));
|
||||
else
|
||||
return (funopen(gz, NULL, xgzwrite, NULL, gzclose));
|
||||
}
|
Loading…
Reference in New Issue