]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Apply the three patches from Richard Mortimer.
authorKern Sibbald <kern@sibbald.com>
Fri, 13 Oct 2006 09:01:26 +0000 (09:01 +0000)
committerKern Sibbald <kern@sibbald.com>
Fri, 13 Oct 2006 09:01:26 +0000 (09:01 +0000)
     bacula-reposition.patch, bacula-tape-reopen.patch, and
     bacula-eod.patch. This corrects tape positioning on older devices,
     and also a problem with btape.
kes  Apply fix from bug report #696 where writing to a FIFO does not
     work due to a dumb typo.
kes  Unlock the tape door before the file descriptor is released. This
     should fix lots of somewhat subtle failures when using an autochanger.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3551 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/stored/btape.c
bacula/src/stored/dev.c
bacula/technotes-1.39

index 6ebe43b62095e0bbd44d10a4f398287f34b9a7ff..3cd41fa656101394c707fca827f8c7ec500ce830 100644 (file)
@@ -1533,7 +1533,9 @@ static void wrcmd()
    DEV_RECORD *rec = dcr->rec;
    int i;
 
-   open_the_device();
+   if (!dev->is_open()) {
+      open_the_device();
+   }
    sm_check(__FILE__, __LINE__, false);
    empty_block(block);
    if (verbose > 1) {
index 70c083417de3a9dc51721ecca4f18adf652694f9..c0cc13822d825c2edac9fc42c5276df24b6649a5 100644 (file)
@@ -118,7 +118,7 @@ init_dev(JCR *jcr, DEVRES *device)
       } else if (S_ISCHR(statp.st_mode)) {
          device->dev_type = B_TAPE_DEV;
       } else if (S_ISFIFO(statp.st_mode)) {
-         device->dev_type = B_FILE_DEV;
+         device->dev_type = B_FIFO_DEV;
       } else if (!(device->cap_bits & CAP_REQMOUNT)) {
          Jmsg2(jcr, M_ERROR, 0, _("%s is an unknown device type. Must be tape or directory\n"
                " or have RequiresMount=yes for DVD. st_mode=%x\n"),
@@ -942,12 +942,12 @@ bool DEVICE::eod(DCR *dcr)
          /*
           * Avoid infinite loop by ensuring we advance.
           */
-         if (file_num == (int)file) {
+         if (!at_eot() && file_num == (int)file) {
             struct mtget mt_stat;
             Dmsg1(100, "fsf did not advance from file %d\n", file_num);
             set_ateof();
             if (dev_get_os_pos(this, &mt_stat)) {
-               Dmsg2(100, "Adjust file from %d to %d\n", file , mt_stat.mt_fileno);
+               Dmsg2(100, "Adjust file from %d to %d\n", file_num, mt_stat.mt_fileno);
                file = mt_stat.mt_fileno;
             }       
             break;
@@ -1584,8 +1584,7 @@ bool DEVICE::reposition(DCR *dcr, uint32_t rfile, uint32_t rblock)
    }
 
    /* After this point, we are tape only */
-   Dmsg4(100, "reposition from %u:%u to %u:%u\n",
-      file, block_num, rfile, rblock);
+   Dmsg4(100, "reposition from %u:%u to %u:%u\n", file, block_num, rfile, rblock);
    if (rfile < file) {
       Dmsg0(100, "Rewind\n");
       if (!rewind(NULL)) {
@@ -1612,6 +1611,17 @@ bool DEVICE::reposition(DCR *dcr, uint32_t rfile, uint32_t rblock)
       /* Ignore errors as Bacula can read to the correct block */
       Dmsg1(100, "fsr %d\n", rblock-block_num);
       return fsr(rblock-block_num);
+   } else {
+      while (rblock > block_num) {
+         if (!read_block_from_dev(dcr, NO_BLOCK_NUMBER_CHECK)) {
+            berrno be;
+            dev_errno = errno;
+            Dmsg2(30, "Failed to find requested block on %s: ERR=%s",
+               print_name(), be.strerror());
+            return false;
+         }
+         Dmsg2(300, "moving forward wanted_blk=%d at_blk=%d\n", rblock, block_num);
+      }
    }
    return true;
 }
@@ -1834,8 +1844,8 @@ void DEVICE::close()
 
    switch (dev_type) {
    case B_TAPE_DEV:
-      tape_close(fd);
       unlock_door(); 
+      tape_close(fd);
       break;
    default:
       ::close(fd);
index f17f9edbf3b31e24db6a635a21e71dc146669cf4..54fcfe8b9faf7abfdd4bedabd72c5e4ae00554d6 100644 (file)
@@ -1,6 +1,15 @@
               Technical notes on version 1.39  
 
 General:
+12Oct06
+kes  Apply the three patches from Richard Mortimer. 
+     bacula-reposition.patch, bacula-tape-reopen.patch, and
+     bacula-eod.patch. This corrects tape positioning on older devices,
+     and also a problem with btape.
+kes  Apply fix from bug report #696 where writing to a FIFO does not
+     work due to a dumb typo.
+kes  Unlock the tape door before the file descriptor is released. This
+     should fix lots of somewhat subtle failures when using an autochanger.
 11Oct06
 kes  Correct mtx-changer bug that I introduced in a recent commit, and
      pointed out by Robert Nelson -- thanks.