]> git.wh0rd.org - dump.git/blobdiff - restore/tape.c
Added -F script option to restore.
[dump.git] / restore / tape.c
index d7e8ed635be54041c6872d5512e64eca52d861ea..a8616a1069eaf3b7a90635bc523c6b4a716fffd6 100644 (file)
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.39 2001/05/26 11:04:46 stelian Exp $";
+       "$Id: tape.c,v 1.42 2001/07/18 12:54:06 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
 #include <compatlfs.h>
 #include <errno.h>
 #include <compaterr.h>
+#include <system.h>
 #include <setjmp.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -67,7 +68,11 @@ static const char rcsid[] =
 #ifdef __linux__
 #include <sys/time.h>
 #include <time.h>
+#ifdef HAVE_EXT2FS_EXT2_FS_H
+#include <ext2fs/ext2_fs.h>
+#else
 #include <linux/ext2_fs.h>
+#endif
 #include <ext2fs/ext2fs.h>
 #include <bsdcompat.h>
 #else  /* __linux__ */
@@ -253,10 +258,18 @@ newcomprbuf(int size)
 void
 setup(void)
 {
-       int i, j, *ip;
+       int i, j, *ip, bot_code;
        struct STAT stbuf;
 
        Vprintf(stdout, "Verify tape and initialize maps\n");
+       if (bot_script) {
+               msg("Launching %s\n", bot_script);
+               bot_code = system_command(bot_script, magtape, 1);
+               if (bot_code != 0 && bot_code != 1) {
+                       msg("Restore aborted by the beginning of tape script\n");
+                       exit(1);
+               }
+       }
 #ifdef RRESTORE
        if (host)
                mt = rmtopen(magtape, 0);
@@ -370,7 +383,7 @@ getvol(long nextvol)
        union u_spcl tmpspcl;
 #      define tmpbuf tmpspcl.s_spcl
        char buf[TP_BSIZE];
-       int haderror = 0;
+       int haderror = 0, bot_code;
 
        if (nextvol == 1) {
                tapesread = 0;
@@ -434,7 +447,15 @@ again:
                snprintf(magtape, MAXPATHLEN, "%s%03ld", magtapeprefix, newvol);
                magtape[MAXPATHLEN - 1] = '\0';
        }
-       if (!Mflag || haderror) {
+       if (bot_script && !haderror) {
+               msg("Launching %s\n", bot_script);
+               bot_code = system_command(bot_script, magtape, newvol);
+               if (bot_code != 0 && bot_code != 1) {
+                       msg("Restore aborted by the beginning of tape script\n");
+                       exit(1);
+               }
+       }
+       if (haderror || (bot_code && !Mflag)) {
                haderror = 0;
                fprintf(stderr, "Mount tape volume %ld\n", (long)newvol);
                fprintf(stderr, "Enter ``none'' if there are no more tapes\n");
@@ -448,8 +469,11 @@ again:
                        return;
                }
                if (buf[0] != '\n') {
+                       char *pos;
                        (void) strncpy(magtape, buf, sizeof(magtape));
                        magtape[sizeof(magtape) - 1] = '\0';
+                       if ((pos = strchr(magtape, '\n'))) 
+                               magtape[pos - magtape] = '\0';
                }
        }
 #ifdef RRESTORE