]> git.wh0rd.org - dump.git/blobdiff - dump/main.c
minor print enhancement.
[dump.git] / dump / main.c
index 8f33f95e23847b16977f6776af732f82bb3711a7..5262d690fc1094bfbf874f12cce19f0d50603166 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: main.c,v 1.58 2001/08/16 13:12:30 stelian Exp $";
+       "$Id: main.c,v 1.62 2001/11/11 00:12:48 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -60,6 +60,7 @@ static const char rcsid[] =
 #include <sys/time.h>
 #include <time.h>
 #ifdef __linux__
+#include <linux/fs.h>
 #ifdef HAVE_EXT2FS_EXT2_FS_H
 #include <ext2fs/ext2_fs.h>
 #else
@@ -102,9 +103,11 @@ char       *tapeprefix;    /* prefix of the tape file */
 char   *dumpdates;     /* name of the file containing dump date information*/
 char   lastlevel;      /* dump level of previous dump */
 char   level;          /* dump level of this dump */
+int    bzipflag;       /* compression is done using bzlib */
 int    uflag;          /* update flag */
 int    Mflag;          /* multi-volume flag */
 int    qflag;          /* quit on errors flag */
+int     breademax = 32; /* maximum number of bread errors before we quit */
 char   *eot_script;    /* end of volume script fiag */
 int    diskfd;         /* disk file descriptor */
 int    tapefd;         /* tape file descriptor */
@@ -234,7 +237,11 @@ main(int argc, char *argv[])
 #endif /* USE_QFA */
 
        while ((ch = getopt(argc, argv,
-                           "0123456789aB:b:cd:e:E:f:F:h:L:"
+                           "0123456789aB:b:cd:e:E:f:F:h:I:"
+#ifdef HAVE_BZLIB
+                           "j::"
+#endif
+                           "L:"
 #ifdef KERBEROS
                            "k"
 #endif
@@ -318,6 +325,20 @@ main(int argc, char *argv[])
                        honorlevel = numarg("honor level", 0L, 10L);
                        break;
 
+#ifdef HAVE_BZLIB
+               case 'j':
+                       compressed = 2;
+                       bzipflag = 1;
+                       if (optarg)
+                               compressed = numarg("compress level", 1L, 9L);
+                       break;
+#endif /* HAVE_BZLIB */
+
+               case 'I':
+                       breademax =
+                         numarg ("number of errors to ignore", 1L, 0L);
+                       break;
+
 #ifdef KERBEROS
                case 'k':
                        dokerberos = 1;
@@ -614,6 +635,14 @@ main(int argc, char *argv[])
        } /* end of size estimate */
 
 #ifdef __linux__
+       if ((diskfd = OPEN(disk, O_RDONLY)) < 0) {
+               msg("Cannot open %s\n", disk);
+               msg("The ENTIRE dump is aborted.\n");
+               exit(X_STARTUP);
+       }
+#ifdef BLKFLSBUF
+       (void)ioctl(diskfd, BLKFLSBUF);
+#endif
        retval = dump_fs_open(disk, &fs);
        if (retval) {
                com_err(disk, retval, "while opening filesystem");
@@ -628,11 +657,6 @@ main(int argc, char *argv[])
                msg("The ENTIRE dump is aborted.\n");
                exit(X_STARTUP);
        }
-       if ((diskfd = OPEN(disk, O_RDONLY)) < 0) {
-               msg("Cannot open %s\n", disk);
-               msg("The ENTIRE dump is aborted.\n");
-               exit(X_STARTUP);
-       }
        /* if no user label specified, use ext2 filesystem label if available */
        if (spcl.c_label[0] == '\0') {
                const char *lbl;
@@ -693,8 +717,8 @@ main(int argc, char *argv[])
                msg("Label: %s\n", spcl.c_label);
 
                if (compressed)
-                       msg("Compressing output at compression level %d\n", 
-                           compressed);
+                       msg("Compressing output at compression level %d (%s)\n", 
+                           compressed, bzipflag ? "bzlib" : "zlib");
        }
 
 #if defined(SIGINFO)
@@ -960,11 +984,15 @@ usage(void)
 #endif
                "MnqSu"
                "] [-B records] [-b blocksize] [-d density]\n"
-               "\t%s [-e inode#,inode#,...] [-E file] [-f file] [-h level] "
+               "\t%s [-e inode#,inode#,...] [-E file] [-f file] [-h level]\n"
+               "\t%s [-I nr errors] "
+#ifdef HAVE_BZLIB
+               "[-j zlevel] "
+#endif
 #ifdef USE_QFA
                "[-Q file] "
 #endif
-               "\n\t%s [-s feet] [-T date] "
+               "[-s feet] [-T date] "
 #ifdef HAVE_ZLIB
                "[-z zlevel] "
 #endif