]> git.wh0rd.org - dump.git/commitdiff
Make dump ask upon a tape write error if it should rewrite the current volume or...
authorStelian Pop <stelian@popies.net>
Thu, 21 Dec 2000 15:01:53 +0000 (15:01 +0000)
committerStelian Pop <stelian@popies.net>
Thu, 21 Dec 2000 15:01:53 +0000 (15:01 +0000)
CHANGES
dump/tape.c
restore/tape.c

diff --git a/CHANGES b/CHANGES
index 775a3f899be79d6c341bf5b10dddd4f103f4da9b..5fddb93d0f554078ec26b6c5abfef486b1476bf1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.98 2000/12/21 11:14:52 stelian Exp $
+$Id: CHANGES,v 1.99 2000/12/21 15:01:53 stelian Exp $
 
 Changes between versions 0.4b20 and 0.4b21 (released ?????????????????)
 =======================================================================
@@ -34,7 +34,7 @@ Changes between versions 0.4b20 and 0.4b21 (released ?????????????????)
        fully testing it... (of course, if this patch will break
        anything, he is to blame for :-)).
 
-7.     Make dump and restore LFS aware. Dump can dump a filesystem
+7.     Made dump and restore LFS aware. Dump can dump a filesystem
        containing large files, generate a large file on output and
        restore can restore them. This feature is not enabled by
        default, use --enable-largefile option of configure to enable
@@ -43,6 +43,12 @@ Changes between versions 0.4b20 and 0.4b21 (released ?????????????????)
        and to Theodore T'so <tytso@valinux.com> for his always
        useful thoughts.
 
+8.     Made dump ask upon a tape write error if it should rewrite
+       the current volume (assume this is a bad tape) or if it should
+       assume an end-of-tape condition (useful for tape drives which
+       behaves badly at the end of the tape). Thanks to Andreas
+       Dilger <adilger@turbolinux.com> for the suggestion.
+
 Changes between versions 0.4b19 and 0.4b20 (released November 10, 2000)
 =======================================================================
 
index 16328bd0a313ca691400985edf414bd888776104..b0eed5b1beb672cfac4ddbfffe32a18bfc860d11 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.27 2000/12/21 11:14:54 stelian Exp $";
+       "$Id: tape.c,v 1.28 2000/12/21 15:01:54 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -236,24 +236,27 @@ dumpblock(daddr_t blkno, int size)
 int    nogripe = 0;
 
 static void
-tperror(int signo)
+tperror(int errnum)
 {
 
        if (pipeout) {
-               msg("write error on %s\n", tape);
+               msg("write error on %s: %s\n", tape, strerror(errnum));
                quit("Cannot recover\n");
                /* NOTREACHED */
        }
-       msg("write error %d blocks into volume %d\n", blocksthisvol, tapeno);
+       msg("write error %d blocks into volume %d: %s\n", blocksthisvol, tapeno, strerror(errnum));
        broadcast("DUMP WRITE ERROR!\n");
-       if (!query("Do you want to restart?"))
-               dumpabort(0);
-       msg("Closing this volume.  Prepare to restart with new media;\n");
-       msg("this dump volume will be rewritten.\n");
-       killall();
-       nogripe = 1;
-       close_rewind();
-       Exit(X_REWRITE);
+       if (query("Do you want to rewrite this volume?")) {
+               msg("Closing this volume.  Prepare to restart with new media;\n");
+               msg("this dump volume will be rewritten.\n");
+               killall();
+               nogripe = 1;
+               close_rewind();
+               Exit(X_REWRITE);
+       }
+       if (query("Do you want to start the next tape?"))
+               return;
+       dumpabort(0);
 }
 
 static void
@@ -371,6 +374,10 @@ flushtape(void)
                }
                slp->sent = 0;
 
+               /* Check for errors */
+               if (got < 0)
+                       tperror(-got);
+               
                /* Check for end of tape */
                if (got < writesize) {
                        msg("End of tape detected\n");
@@ -484,6 +491,10 @@ trewind(void)
                                dumpabort(0);
                        }
                        slaves[f].sent = 0;
+
+                       if (got < 0)
+                               tperror(-got);
+
                        if (got != writesize) {
                                msg("EOT detected in last 2 tape records!\n");
                                msg("Use a longer tape, decrease the size estimate\n");
@@ -657,6 +668,9 @@ rollforward(void)
                }
                slp->sent = 0;
 
+               if (got < 0)
+                       tperror(-got);
+
                if (got != writesize) {
                        quit("EOT detected at start of the tape!\n");
                }
@@ -916,8 +930,6 @@ enslave(void)
        sigaction(SIGTERM, &sa, NULL); /* Slave sends SIGTERM on dumpabort() */
        sa.sa_handler = sigpipe;
        sigaction(SIGPIPE, &sa, NULL);
-       sa.sa_handler = tperror;
-       sigaction(SIGUSR1, &sa, NULL); /* Slave sends SIGUSR1 on tape errors */
        sa.sa_handler = proceed;
        sa.sa_flags = SA_RESTART;
        sigaction(SIGUSR2, &sa, NULL); /* Slave sends SIGUSR2 to next slave */
@@ -1002,7 +1014,6 @@ doslave(int cmd, int slave_number)
        register int nread;
        int nextslave, size, eot_count;
        volatile int wrote = 0;
-       sigset_t sigset;
 #ifdef __linux__
        errcode_t retval;
 #endif
@@ -1095,19 +1106,17 @@ doslave(int cmd, int slave_number)
                if (eot_count > 0)
                        size = 0;
 
-               if (wrote < 0) {
-                       (void) kill(master, SIGUSR1);
-                       sigemptyset(&sigset);
-                       sigaddset(&sigset, SIGINT);
-                       for (;;)
-                               sigsuspend(&sigset);
-               } else {
-                       /*
-                        * pass size of write back to master
-                        * (for EOT handling)
-                        */
-                       (void) atomic_write( cmd, (char *)&size, sizeof size);
-               }
+               /*
+                * pass errno back to master for special handling
+                */
+               if (wrote < 0)
+                       size = -errno;
+
+               /*
+                * pass size of write back to master
+                * (for EOT handling)
+                */
+               (void) atomic_write( cmd, (char *)&size, sizeof size);
 
                /*
                 * If partial write, don't want next slave to go.
index 4e1713042931a764e8b3259fa9f8984b201ac05a..015dc876dffc3f61508d53170877221c24ca070d 100644 (file)
@@ -46,7 +46,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.22 2000/12/21 11:14:54 stelian Exp $";
+       "$Id: tape.c,v 1.23 2000/12/21 15:01:54 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -1300,8 +1300,12 @@ getmore:
 #endif
                        seek_failed = (lseek(mt, i, SEEK_CUR) == (off_t)-1);
 
-               if (seek_failed)
-                       err(1, "continuation failed");
+               if (seek_failed) {
+                       warn("continuation failed");
+                       if (!yflag && !reply("assume end-of-tape and continue"))
+                               exit(1);
+                       i = 0;
+               }
        }
        /*
         * Handle end of tape.