]> git.wh0rd.org - dump.git/commitdiff
Some compression patches.
authorStelian Pop <stelian@popies.net>
Tue, 20 Mar 2001 20:15:43 +0000 (20:15 +0000)
committerStelian Pop <stelian@popies.net>
Tue, 20 Mar 2001 20:15:43 +0000 (20:15 +0000)
dump/dump.8.in
dump/main.c
dump/tape.c

index 4969b66307ce69ad3585b397692d46e38125b68b..2c8b701452702467064d0dbfc0ed7bec77980d9e 100644 (file)
@@ -30,7 +30,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\"    $Id: dump.8.in,v 1.21 2001/03/18 15:35:44 stelian Exp $
+.\"    $Id: dump.8.in,v 1.22 2001/03/20 20:15:43 stelian Exp $
 .\"
 .Dd __DATE__
 .Dt DUMP 8
@@ -40,7 +40,7 @@
 .Nd ext2 filesystem backup
 .Sh SYNOPSIS
 .Nm dump
-.Op Fl 0123456789ackMnSuz
+.Op Fl 0123456789ackMnSu
 .Op Fl B Ar records
 .Op Fl b Ar blocksize
 .Op Fl d Ar density
@@ -51,6 +51,7 @@
 .Op Fl L Ar label
 .Op Fl s Ar feet
 .Op Fl T Ar date
+.Op Fl z Ar compression level
 .Ar file-to-dump
 .Nm dump
 .Op Fl W Li \&| Fl w
@@ -315,13 +316,15 @@ Is like
 but prints only recognized filesystems in
 .Pa /etc/fstab
 which need to be dumped.
-.It Fl z
+.It Fl z Ar compression level
 Compress every block to be written on the tape using zlib library. This
 option will work only when dumping to a file or pipe or, when dumping
 to a tape drive, if the tape drive is capable of writing variable 
 length blocks. You will need at least the 0.4b22 version of restore in 
 order to extract compressed tapes. Tapes written using compression will
-not be compatible with the BSD tape format.
+not be compatible with the BSD tape format. The (optional) parameter 
+specifies the compression level zlib will use. The default compression
+level is 2.
 .El
 .Pp
 .Nm Dump
index 289f1e2308e39f9ff9585d6990ee4e9f61a15744..1acca2a880898ddbe419c465797417fc16b2401d 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: main.c,v 1.37 2001/03/20 10:02:48 stelian Exp $";
+       "$Id: main.c,v 1.38 2001/03/20 20:15:43 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -94,7 +94,7 @@ long  dev_bsize = 1;  /* recalculated below */
 long   blocksperfile;  /* output blocks per file */
 char   *host = NULL;   /* remote host (if any) */
 int    sizest = 0;     /* return size estimate only */
-int    compressed = 0; /* use zlib to compress the output */
+int    compressed = 0; /* use zlib to compress the output, compress level 1-9 */
 long long bytes_written = 0; /* total bytes written */
 long   uncomprblks = 0;/* uncompressed blocks written */
 
@@ -160,7 +160,7 @@ main(int argc, char *argv[])
 #endif
                            "Mns:ST:uWw"
 #ifdef HAVE_ZLIB
-                           "z"
+                           "z::"
 #endif
                            )) != -1)
 #undef optstring
@@ -292,7 +292,9 @@ main(int argc, char *argv[])
                        exit(X_FINOK);  /* do nothing else */
 #ifdef HAVE_ZLIB
                case 'z':
-                       compressed = 1;
+                       compressed = 2;
+                       if (optarg)
+                               compressed = numarg("compress level", 1L, 9L);
                        break;
 #endif /* HAVE_ZLIB */
 
@@ -569,6 +571,9 @@ main(int argc, char *argv[])
 
        msg("Label: %s\n", spcl.c_label);
 
+       if (compressed)
+               msg("Compressing output at compression level %d\n", compressed);
+
 #if defined(SIGINFO)
        (void)signal(SIGINFO, statussig);
 #endif
@@ -736,7 +741,7 @@ main(int argc, char *argv[])
                long tapekb = bytes_written / 1024;
                double rate = .0005 + (double) spcl.c_tapea / tapekb;
                msg("Wrote %ldKB uncompressed, %ldKB compressed,"
-                       " compression ratio %1.3f\n",
+                       " %1.3f:1\n",
                        spcl.c_tapea, tapekb, rate);
        }
 
@@ -772,9 +777,11 @@ usage(void)
 #ifdef HAVE_ZLIB
                "z"
 #endif
-               "] [-B records] [-b blocksize] [-d density]\n"
-               "\t%s [-e inode#] [-f file] [-h level] [-s feet] [-T date] filesystem\n"
-               "\t%s [-W | -w]\n", __progname, white, __progname);
+               "] [-B records] [-b blocksize]\n"
+               "\t%s [-d density] [-e inode#] [-f file] [-h level] [-s feet]\n"
+               "\t%s [-T date] [-z zlevel] filesystem\n"
+               "\t%s [-W | -w]\n", 
+               __progname, white, white, __progname);
        exit(X_STARTUP);
 }
 
index 7851719381ee78f3702acbbe2fc0bc70a2f5c2e7..b4bf6d4eb808b97a00cb72ae91c53b52cb539bf1 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.36 2001/03/20 10:02:48 stelian Exp $";
+       "$Id: tape.c,v 1.37 2001/03/20 20:15:59 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -303,7 +303,7 @@ do_stats(void)
                if (compressed) {
                        double rate = .0005 + (double) blocks / (double) volkb;
                        msg("Volume %d %ldKB uncompressed, %ldKB compressed,"
-                               " compression ratio %1.3f\n",
+                               " %1.3f:1\n",
                                tapeno, blocks, volkb, rate);
                }
        }
@@ -1038,7 +1038,7 @@ doslave(int cmd, int slave_number)
        char *buffer;
 #ifdef HAVE_ZLIB
        struct tapebuf *comp_buf = NULL;
-       int compresult, complevel = 6, do_compress = 0;
+       int compresult, do_compress = 0;
        unsigned long worklen;
 #endif /* HAVE_ZLIB */
        struct slave_results returns;
@@ -1113,7 +1113,6 @@ doslave(int cmd, int slave_number)
 
 #ifdef HAVE_ZLIB
                /* 
-                * The first NR_SLAVE blocks are not compressed.
                 * When writing a compressed dump, each block is
                 * written from struct tapebuf with an 4 byte prefix
                 * followed by the data. This can be less than
@@ -1121,6 +1120,7 @@ doslave(int cmd, int slave_number)
                 * length read to the compressed length in the header
                 * to verify that the read was good. Blocks which don't
                 * compress well are written uncompressed.
+                * The first block written by each slave is not compressed.
                 */
 
                if (compressed) {
@@ -1128,7 +1128,7 @@ doslave(int cmd, int slave_number)
                        worklen = TP_BSIZE + writesize;
                        if (do_compress)
                                compresult = compress2(comp_buf->buf, &worklen,
-                                       (char *)slp->tblock[0], writesize, complevel);
+                                       (char *)slp->tblock[0], writesize, compressed);
                        if (compresult == Z_OK && worklen <= writesize-32) {
                                /* write the compressed buffer */
                                comp_buf->length = worklen;