Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/savecore Add "-Z level" to control the compression leve...



details:   https://anonhg.NetBSD.org/src/rev/e01e0eba0837
branches:  trunk
changeset: 514865:e01e0eba0837
user:      lukem <lukem%NetBSD.org@localhost>
date:      Wed Sep 12 02:58:29 2001 +0000

description:
Add "-Z level" to control the compression level that -z uses (which
defaults to -Z 6).  Depending on the relative speed of the CPU
versus disk, "-zZ1" might be faster than no compression at all.

diffstat:

 sbin/savecore/savecore.8 |  14 ++++++++++++--
 sbin/savecore/savecore.c |  27 ++++++++++++++++++++-------
 2 files changed, 32 insertions(+), 9 deletions(-)

diffs (130 lines):

diff -r 0f0f032f3bcc -r e01e0eba0837 sbin/savecore/savecore.8
--- a/sbin/savecore/savecore.8  Tue Sep 11 23:18:55 2001 +0000
+++ b/sbin/savecore/savecore.8  Wed Sep 12 02:58:29 2001 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: savecore.8,v 1.22 2001/08/20 14:23:59 wiz Exp $
+.\"    $NetBSD: savecore.8,v 1.23 2001/09/12 02:58:29 lukem Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -33,7 +33,7 @@
 .\"
 .\"     @(#)savecore.8 8.1 (Berkeley) 6/5/93
 .\"
-.Dd June 5, 1993
+.Dd September 12, 2001
 .Dt SAVECORE 8
 .Os
 .Sh NAME
@@ -45,6 +45,7 @@
 .Nm ""
 .Op Fl fvz
 .Op Fl N Ar system
+.Op Fl Z Ar level
 .Ar directory
 .Sh DESCRIPTION
 When the
@@ -117,6 +118,15 @@
 .It Fl z
 Compresses the core dump and kernel (see
 .Xr gzip 1 ) .
+.It Fl Z Ar level
+Set the compression level for
+.Fl z
+to
+.Ar level .
+Defaults to 6.
+Refer to
+.Xr gzip 1
+for more information regarding the compression level.
 .El
 .Pp
 .Nm
diff -r 0f0f032f3bcc -r e01e0eba0837 sbin/savecore/savecore.c
--- a/sbin/savecore/savecore.c  Tue Sep 11 23:18:55 2001 +0000
+++ b/sbin/savecore/savecore.c  Wed Sep 12 02:58:29 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: savecore.c,v 1.52 2001/06/13 23:16:27 wiz Exp $        */
+/*     $NetBSD: savecore.c,v 1.53 2001/09/12 02:58:29 lukem Exp $      */
 
 /*-
  * Copyright (c) 1986, 1992, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)savecore.c 8.5 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: savecore.c,v 1.52 2001/06/13 23:16:27 wiz Exp $");
+__RCSID("$NetBSD: savecore.c,v 1.53 2001/09/12 02:58:29 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -129,6 +129,7 @@
 char   panic_mesg[1024];
 long   panicstr;
 char   vers[1024];
+char   gzmode[3];
 
 static int     clear, compress, force, verbose;        /* flags */
 
@@ -152,14 +153,16 @@
 int
 main(int argc, char *argv[])
 {
-       int ch;
+       int ch, level;
+       char *ep;
 
        dirname = NULL;
        kernel = NULL;
+       gzmode[0] = 'w';
 
        openlog("savecore", LOG_PERROR, LOG_DAEMON);
 
-       while ((ch = getopt(argc, argv, "cdfN:vz")) != -1)
+       while ((ch = getopt(argc, argv, "cdfN:vzZ:")) != -1)
                switch(ch) {
                case 'c':
                        clear = 1;
@@ -177,6 +180,15 @@
                case 'z':
                        compress = 1;
                        break;
+               case 'Z':
+                       level = (int)strtol(optarg, &ep, 10);
+                       if (level < 0 || level > 9) {
+                               (void)syslog(LOG_ERR, "invalid compression %s",
+                                   optarg);
+                               usage();
+                       }
+                       gzmode[1] = level + '0';
+                       break;
                case '?':
                default:
                        usage();
@@ -499,7 +511,7 @@
        (void)snprintf(path, sizeof(path), "%s/netbsd.%d.core%s",
            dirname, bounds, compress ? ".gz" : "");
        if (compress) {
-               if ((fp = zopen(path, "w")) == NULL) {
+               if ((fp = zopen(path, gzmode)) == NULL) {
                        syslog(LOG_ERR, "%s: %m", path);
                        exit(1);
                }
@@ -561,7 +573,7 @@
        (void)snprintf(path, sizeof(path), "%s/netbsd.%d%s",
            dirname, bounds, compress ? ".gz" : "");
        if (compress) {
-               if ((fp = zopen(path, "w")) == NULL) {
+               if ((fp = zopen(path, gzmode)) == NULL) {
                        syslog(LOG_ERR, "%s: %m", path);
                        exit(1);
                }
@@ -774,6 +786,7 @@
 void
 usage(void)
 {
-       (void)syslog(LOG_ERR, "usage: savecore [-cfvz] [-N system] directory");
+       (void)syslog(LOG_ERR,
+           "usage: savecore [-cfvz] [-N system] [-Z level] directory");
        exit(1);
 }



Home | Main Index | Thread Index | Old Index