]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix btape test for TWO EOF + use driver idea of file in fsf_dev
authorKern Sibbald <kern@sibbald.com>
Mon, 29 Dec 2003 19:58:48 +0000 (19:58 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 29 Dec 2003 19:58:48 +0000 (19:58 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@969 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/stored/btape.c
bacula/src/stored/dev.c

index aca13e57e9ca569d0eed893eb25f647ee478ba09..d596e0afd284e7d403c3d290959381c1fe55b0a4 100644 (file)
@@ -724,6 +724,9 @@ static int append_test()
    wrcmd();
    wrcmd();
    weofcmd();    /* end file 2 */
+   if (dev_cap(dev, CAP_TWOEOF)) {
+      weofcmd();
+   }
    rewindcmd();
    Pmsg0(0, _("Now moving to end of medium.\n"));
    eodcmd();
@@ -737,6 +740,9 @@ static int append_test()
    Pmsg0(-1, _("\nNow the important part, I am going to attempt to append to the tape.\n\n"));
    wrcmd(); 
    weofcmd();
+   if (dev_cap(dev, CAP_TWOEOF)) {
+      weofcmd();
+   }
    rewindcmd();
    Pmsg0(-1, _("Done appending, there should be no I/O errors\n\n"));
    Pmsg0(-1, "Doing Bacula scan of blocks:\n");
@@ -909,6 +915,9 @@ static int fsf_test()
    weofcmd();    /* end file 3 */
    wrcmd();
    weofcmd();    /* end file 4 */
+   if (dev_cap(dev, CAP_TWOEOF)) {
+      weofcmd();
+   }
 
 test_again:
    rewindcmd();
index 23ae6502089dbc5f449c588940a6a0ebd4aa0dfa..2dc51f42b6e9c7ad8ba081de02b7d700ec57f2fe 100644 (file)
@@ -469,8 +469,15 @@ eod_dev(DEVICE *dev)
          *   to set EOD or to turn off CAP_FASTFSF if on.
          */
         if (file_num == (int)dev->file) {
+           struct mtget mt_stat;
             Dmsg1(000, "fsf_dev did not advance from file %d\n", file_num);
-           return 0;                 /* we are not progressing, bail out */
+           if (ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) == 0 && 
+                     mt_stat.mt_fileno >= 0) {
+               Dmsg2(000, "Adjust file from %d to %d\n", dev->file , mt_stat.mt_fileno);
+              dev->file = mt_stat.mt_fileno;
+           }
+           stat = 0;
+           break;                    /* we are not progressing, bail out */
         }
       }
    }
@@ -484,9 +491,11 @@ eod_dev(DEVICE *dev)
       /* Backup over EOF */
       stat = bsf_dev(dev, 1);
       /* If BSF worked and fileno is known (not -1), set file */
-      if (stat == 0 && ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) == 0 &&
-         mt_stat.mt_fileno >= 0) {
+      if (ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) == 0 && mt_stat.mt_fileno >= 0) {
+         Dmsg2(000, "Adjust file from %d to %d\n", dev->file , mt_stat.mt_fileno);
         dev->file = mt_stat.mt_fileno;
+      } else {
+        dev->file++;                 /* wing it -- not correct on all OSes */
       }
    } else {
       update_pos_dev(dev);                  /* update position */
@@ -560,7 +569,7 @@ status_dev(DEVICE *dev, uint32_t *status)
    }
    if (dev->state & ST_TAPE) {
       stat |= BMT_TAPE;
-      Dmsg0(-20," Driver status:");
+      Dmsg0(-20," Bacula status:");
       Dmsg2(-20," file=%d block=%d\n", dev->file, dev->block_num);
       if (ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) < 0) {
         dev->dev_errno = errno;