Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Sep 2001 01:16:31 -0700
From:      Kris Kennaway <kris@obsecurity.org>
To:        hackers@FreeBSD.org
Subject:   gzipped crashdumps
Message-ID:  <20010901011631.A59345@xor.obsecurity.org>

next in thread | raw e-mail | index | archive | help

--azLHFNyN32YCQGCU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Anyone else think this patch from NetBSD is worthwhile?

Should I also extend it to support bzip2'ed dumps now that that's in
the base system, or would that be overkill?

Kris

Index: Makefile
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mnt/ncvs/src/sbin/savecore/Makefile,v
retrieving revision 1.5
diff -u -r1.5 Makefile
--- Makefile	2001/03/26 14:33:23	1.5
+++ Makefile	2001/09/01 08:15:14
@@ -5,8 +5,7 @@
 SRCS=3D	savecore.c zopen.c
 MAN=3D	savecore.8
=20
-ZOPENPATH=3D ${.CURDIR}/../../usr.bin/compress
-.PATH:	${ZOPENPATH}
-CFLAGS+=3D -I${ZOPENPATH}
+DPADD+=3D	${LIBZ}
+LDADD+=3D	-lz
=20
 .include <bsd.prog.mk>
Index: savecore.8
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mnt/ncvs/src/sbin/savecore/savecore.8,v
retrieving revision 1.12
diff -u -r1.12 savecore.8
--- savecore.8	2001/07/10 11:02:27	1.12
+++ savecore.8	2001/09/01 08:11:50
@@ -72,7 +72,7 @@
 Print out some additional debugging information.
 .It Fl z
 Compress the core dump and kernel (see
-.Xr compress 1 ) .
+.Xr gzip 1 ) .
 .El
 .Pp
 .Nm Savecore
@@ -113,8 +113,8 @@
 .Sh BUGS
 The minfree code does not consider the effect of compression.
 .Sh SEE ALSO
-.Xr compress 1 ,
 .Xr getbootfile 3 ,
+.Xr gzip 1 ,
 .Xr syslogd 8
 .Sh HISTORY
 The
Index: savecore.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mnt/ncvs/src/sbin/savecore/savecore.c,v
retrieving revision 1.41
diff -u -r1.41 savecore.c
--- savecore.c	2001/06/09 01:41:03	1.41
+++ savecore.c	2001/09/01 08:06:48
@@ -63,8 +63,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include "zopen.h"
=20
+extern FILE *zopen(const char *fname, const char *mode);
+
 #ifdef __alpha__
 #define ok(number) ALPHA_K0SEG_TO_PHYS(number)
 #endif
@@ -131,7 +132,7 @@
 int	 get_crashtime __P((void));
 void	 get_dumpsize __P((void));
 void	 kmem_setup __P((void));
-void	 log __P((int, char *, ...));
+void	 log __P((int, char *, ...)) __printf0like(2, 3);
 void	 Lseek __P((int, off_t, int));
 int	 Open __P((const char *, int rw));
 int	 Read __P((int, void *, int));
@@ -384,9 +385,9 @@
 	/* Create the core file. */
 	oumask =3D umask(S_IRWXG|S_IRWXO); /* Restrict access to the core file.*/
 	(void)snprintf(path, sizeof(path), "%s/vmcore.%d%s",
-	    savedir, bounds, compress ? ".Z" : "");
+	    savedir, bounds, compress ? ".gz" : "");
 	if (compress)
-		fp =3D zopen(path, "w", 0);
+		fp =3D zopen(path, "w");
 	else
 		fp =3D fopen(path, "w");
 	if (fp =3D=3D NULL) {
@@ -463,9 +464,9 @@
 	/* Copy the kernel. */
 	ifd =3D Open(kernel ? kernel : getbootfile(), O_RDONLY);
 	(void)snprintf(path, sizeof(path), "%s/kernel.%d%s",
-	    savedir, bounds, compress ? ".Z" : "");
+	    savedir, bounds, compress ? ".gz" : "");
 	if (compress)
-		fp =3D zopen(path, "w", 0);
+		fp =3D zopen(path, "w");
 	else
 		fp =3D fopen(path, "w");
 	if (fp =3D=3D NULL) {
--- /dev/null	Sat Sep  1 01:13:34 2001
+++ zopen.c	Sat Sep  1 01:10:14 2001
@@ -0,0 +1,39 @@
+/*
+ * Public domain stdio wrapper for libz, written by Johan Danielsson.
+ */
+
+#ifndef lint
+static const char rcsid[] =3D=20
+  "$FreeBSD$";
+#endif /* not lint */
+
+#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 =3D gzopen(fname, mode);
+    if(gz =3D=3D NULL)
+	return NULL;
+
+    if(*mode =3D=3D 'r')
+	return (funopen(gz, xgzread, NULL, NULL, gzclose));
+    else
+	return (funopen(gz, NULL, xgzwrite, NULL, gzclose));
+}

--azLHFNyN32YCQGCU
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE7kJlfWry0BWjoQKURAoLAAKC98j8n0yvwRJ6wuv/VJaK4OtFDEgCgrEjD
Y3FKJwfrqNhEJxWrZp/cyyM=
=LCFL
-----END PGP SIGNATURE-----

--azLHFNyN32YCQGCU--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010901011631.A59345>