]> git.wh0rd.org - dump.git/blobdiff - dump/main.c
Made -Q option work on regular files.
[dump.git] / dump / main.c
index 722ca71e1764bb5fd381818210011d26155fa5ca..a64ad67c0fcc67e0f6a7a8036073458b1010744f 100644 (file)
@@ -2,8 +2,8 @@
  *     Ported to Linux's Second Extended File System as part of the
  *     dump and restore backup suit
  *     Remy Card <card@Linux.EU.Org>, 1994-1997
- *     Stelian Pop <pop@noos.fr>, 1999-2000
- *     Stelian Pop <pop@noos.fr> - Alcôve <www.alcove.fr>, 2000
+ *     Stelian Pop <stelian@popies.net>, 1999-2000
+ *     Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
  */
 
 /*-
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: main.c,v 1.60 2001/09/06 09:00:32 stelian Exp $";
+       "$Id: main.c,v 1.66 2002/01/22 11:12:28 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -107,6 +107,7 @@ 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 */
@@ -236,7 +237,7 @@ main(int argc, char *argv[])
 #endif /* USE_QFA */
 
        while ((ch = getopt(argc, argv,
-                           "0123456789aB:b:cd:e:E:f:F:h:"
+                           "0123456789aB:b:cd:e:E:f:F:h:I:"
 #ifdef HAVE_BZLIB
                            "j::"
 #endif
@@ -333,6 +334,11 @@ main(int argc, char *argv[])
                        break;
 #endif /* HAVE_BZLIB */
 
+               case 'I':
+                       breademax =
+                         numarg ("number of errors to ignore", 1L, 0L);
+                       break;
+
 #ifdef KERBEROS
                case 'k':
                        dokerberos = 1;
@@ -464,6 +470,13 @@ main(int argc, char *argv[])
                tapeprefix = strchr(host, ':');
                *tapeprefix++ = '\0';
 #ifdef RDUMP
+#ifdef USE_QFA
+               if (tapepos) {
+                       msg("Cannot use -Q option on remote media\n");
+                       msg("The ENTIRE dump is aborted.\n");
+                       exit(X_STARTUP);
+               }
+#endif
                if (index(tapeprefix, '\n')) {
                        msg("invalid characters in tape\n");
                        msg("The ENTIRE dump is aborted.\n");
@@ -493,6 +506,13 @@ main(int argc, char *argv[])
                signal(SIGTERM, sig);
        if (signal(SIGINT, interrupt) == SIG_IGN)
                signal(SIGINT, SIG_IGN);
+#ifdef SIGXCPU
+       signal(SIGXCPU, SIG_IGN);
+#endif /* SIGXCPU */
+#ifdef SIGXFSZ
+       signal(SIGXFSZ, SIG_IGN);
+#endif /* SIGXFSZ */
+
        set_operators();        /* /etc/group snarfed */
        getfstab();             /* /etc/fstab snarfed */
 
@@ -669,7 +689,7 @@ main(int argc, char *argv[])
        tp_bshift = ffs(TP_BSIZE) - 1;
        if (TP_BSIZE != (1 << tp_bshift))
                quit("TP_BSIZE (%d) is not a power of 2", TP_BSIZE);
-       maxino = fs->super->s_inodes_count;
+       maxino = fs->super->s_inodes_count + 1;
 #if    0
        spcl.c_flags |= DR_NEWINODEFMT;
 #endif
@@ -833,10 +853,11 @@ main(int argc, char *argv[])
 #ifdef USE_QFA
        if (tapepos) {
                msg("writing QFA positions to %s\n", gTapeposfile);
-               if ((gTapeposfd = open(gTapeposfile, O_RDWR|O_CREAT, S_IRUSR | S_IWUSR)) < 0)
+               if ((gTapeposfd = open(gTapeposfile, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR | S_IWUSR)) < 0)
                        quit("can't open tapeposfile\n");
                /* print QFA-file header */
-               sprintf(gTps, "%s\n%s\n%ld\n\n", QFA_MAGIC, QFA_VERSION, (unsigned long)spcl.c_date);
+               snprintf(gTps, sizeof(gTps), "%s\n%s\n%ld\n\n", QFA_MAGIC, QFA_VERSION, (unsigned long)spcl.c_date);
+               gTps[sizeof(gTps) - 1] = '\0';
                if (write(gTapeposfd, gTps, strlen(gTps)) != strlen(gTps))
                        quit("can't write tapeposfile\n");
                sprintf(gTps, "ino\ttapeno\ttapepos\n");
@@ -978,11 +999,11 @@ 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
-               "\n\t%s "
 #ifdef USE_QFA
                "[-Q file] "
 #endif