]> 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/gnome2-console/authenticate.c
bacula/src/gnome2-console/console.c
bacula/src/stored/btape.c
bacula/src/stored/dev.c
bacula/technotes-1.39

index 8c9ccfa1785895afdbc118704d6e43b00831b6b0..ceee2951168b48d9112a5ba31af49230f31b1d6c 100644 (file)
  *
  */
 /*
-   Copyright (C) 2000, 2001 Kern Sibbald and John Walker
+   Copyright (C) 2001-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 2
-   of the License, or (at your option) any later version.
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
 #include "bacula.h"
index ac380765e427e2db8f0bbff32dae24dcefabe26a..3e10d24b5d6edb0de0841ee603d286519d81a656 100644 (file)
@@ -7,7 +7,7 @@
  *     Version $Id$
  */
 /*
-   Copyright (C) 2002-2005 Kern Sibbald
+   Copyright (C) 2002-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -124,7 +124,7 @@ static int tls_pem_callback(char *buf, int size, const void *userdata)
  */
 static int check_resources()
 {
-   int xOK = true;
+   bool ok = true;
    DIRRES *director;
 
    LockRes();
@@ -138,7 +138,7 @@ static int check_resources()
             director->tls_enable = true;
          } else {
             Jmsg(NULL, M_FATAL, 0, _("TLS required but not configured in Bacula.\n"));
-            xOK = false;
+            ok = false;
             continue;
          }
       }
@@ -148,14 +148,14 @@ static int check_resources()
                              " or \"TLS CA Certificate Dir\" are defined for Director \"%s\" in %s."
                              " At least one CA certificate store is required.\n"),
                              director->hdr.name, configfile);
-         xOK = false;
+         ok = false;
       }
    }
    
    if (numdir == 0) {
       Emsg1(M_FATAL, 0, _("No Director resource defined in %s\n"
                           "Without that I don't how to speak to the Director :-(\n"), configfile);
-      xOK = false;
+      ok = false;
    }
 
    CONRES *cons;
@@ -167,7 +167,7 @@ static int check_resources()
             cons->tls_enable = true;
          } else {
             Jmsg(NULL, M_FATAL, 0, _("TLS required but not configured in Bacula.\n"));
-            xOK = false;
+            ok = false;
             continue;
          }
       }
@@ -176,13 +176,13 @@ static int check_resources()
          Emsg2(M_FATAL, 0, _("Neither \"TLS CA Certificate\""
                              " or \"TLS CA Certificate Dir\" are defined for Console \"%s\" in %s.\n"),
                              cons->hdr.name, configfile);
-         xOK = false;
+         ok = false;
       }
    }
 
    UnlockRes();
 
-   return xOK;
+   return ok;
 }
 
 
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.