]> git.sur5r.net Git - bacula/bacula/commitdiff
29Jul05
authorKern Sibbald <kern@sibbald.com>
Fri, 29 Jul 2005 09:16:26 +0000 (09:16 +0000)
committerKern Sibbald <kern@sibbald.com>
Fri, 29 Jul 2005 09:16:26 +0000 (09:16 +0000)
- Apply user's patch to make mutiple modifiers for times
  work correctly.
- Make read_dev_volume_label() handle ANSI/IBM labels
  correctly -- ie space over any label at the beginning
  of the tape.
28Jul05
- Make ANSI/IBM writing of HDR1/2 labels ignore any
  errors if at end of tape.
- Apply Martin's patch to improve Python detection in
  configure.in

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

bacula/autoconf/configure.in
bacula/configure
bacula/kes-1.37
bacula/src/lib/parse_conf.c
bacula/src/stored/acquire.c
bacula/src/stored/ansi_label.c
bacula/src/stored/label.c
bacula/src/stored/read_record.c
bacula/src/version.h

index 3ddacdbac5305fbf039f645dbfc6f90e78ba3c90..b57ad991841fdfa8c03fe7027a8876535d0903ae 100644 (file)
@@ -557,29 +557,37 @@ AC_ARG_WITH(python,
   PYTHON_LIBS=
   if test "$withval" != "no"; then
      if test "$withval" = "yes"; then
-       if test -f /usr/include/python2.2/Python.h; then
-          PYTHON_INCDIR=-I/usr/include/python2.2
-          PYTHON_LIBS="-L/usr/lib/python2.2/config -lpython2.2 -lutil -ldl"
-       elif test -f /usr/include/python2.3/Python.h; then
-          PYTHON_INCDIR=-I/usr/include/python2.3
-          PYTHON_LIBS="-L/usr/lib/python2.3/config -lpython2.3 -lutil -ldl"
-       elif test -f /usr/include/python2.4/Python.h; then
-          PYTHON_INCDIR=-I/usr/include/python2.4
-          PYTHON_LIBS="-L/usr/lib/python2.4/config -lpython2.4 -lutil -ldl"
-       elif test -f $prefix/include/Python.h; then
-          PYTHON_INCDIR=-I$prefix/include
-          PYTHON_LIBS="-L$prefix/lib/config -lpython -lutil -ldl"
-       else
+       for python_root in /usr /usr/local; do
+         if test -f $python_root/include/python2.2/Python.h; then
+            PYTHON_INCDIR=-I$python_root/include/python2.2
+            PYTHON_LIBS="-L$python_root/lib/python2.2/config -lpython2.2 -lutil"
+            break
+         elif test -f $python_root/include/python2.3/Python.h; then
+            PYTHON_INCDIR=-I$python_root/include/python2.3
+            PYTHON_LIBS="-L$python_root/lib/python2.3/config -lpython2.3 -lutil"
+            break
+         elif test -f $python_root/include/python2.4/Python.h; then
+            PYTHON_INCDIR=-I$python_root/include/python2.4
+            PYTHON_LIBS="-L$python_root/lib/python2.4/config -lpython2.4 -lutil"
+            break
+         fi
+       done
+       if test x$PYTHON_INCDIR = x; then
+         if test -f $prefix/include/Python.h; then
+            PYTHON_INCDIR=-I$prefix/include
+            PYTHON_LIBS="-L$prefix/lib/config -lpython -lutil"
+         else
           AC_MSG_RESULT(no)
           AC_MSG_ERROR(Unable to find Python.h in standard locations)
+         fi
        fi
      else
        if test -f $withval/Python.h; then
           PYTHON_INCDIR=-I$withval
-          PYTHON_LIBS="-L$withval/config -lpython -lutil -ldl"
+          PYTHON_LIBS="-L$withval/config -lpython -lutil"
        elif test -f $withval/include/Python.h; then
           PYTHON_INCDIR=-I$withval/include
-          PYTHON_LIBS="-L$withval/lib/config -lpython -lutil -ldl"
+          PYTHON_LIBS="-L$withval/lib/config -lpython -lutil"
        else
           AC_MSG_RESULT(no)
           AC_MSG_ERROR(Invalid Python directory $withval - unable to find Python.h under $withval)
@@ -1550,6 +1558,7 @@ PFILES="platforms/Makefile"
 PSCMD="ps -e"
 WIN32=
 MACOSX=
+PYTHON_LIBS_EXTRAS="-ldl"
 hostname=`uname -n | cut -d '.' -f 1`
 case "$DISTNAME" in
 aix)
@@ -1623,6 +1632,7 @@ freebsd)
            platforms/freebsd/bacula-sd \
            platforms/freebsd/bacula-dir"
        largefile_support="yes"
+       PYTHON_LIBS_EXTRAS=
   ;;
 hpux)
        PSCMD="UNIX95=1 ps -e -o pid,comm"
@@ -1775,6 +1785,9 @@ esac
 AC_SUBST(hostname)
 
 LIBS="$PTHREAD_LIB $LIBS"
+if test "x$PYTHON_LIBS" != x -a "x$PYTHON_LIBS_EXTRAS" != x; then
+  PYTHON_LIBS="$PYTHON_LIBS $PYTHON_LIBS_EXTRAS"
+fi
 
 AC_DEFINE_UNQUOTED(lld, "$lld")
 AC_DEFINE_UNQUOTED(llu, "$llu")
index 1a3f602504dc3c14d5810fec8f115944bef8f1b3..6cc5f15ccd3e37b154f61f396080a9f0244c0768 100755 (executable)
@@ -7245,32 +7245,40 @@ if test "${with_python+set}" = set; then
   PYTHON_LIBS=
   if test "$withval" != "no"; then
      if test "$withval" = "yes"; then
-       if test -f /usr/include/python2.2/Python.h; then
-          PYTHON_INCDIR=-I/usr/include/python2.2
-          PYTHON_LIBS="-L/usr/lib/python2.2/config -lpython2.2 -lutil -ldl"
-       elif test -f /usr/include/python2.3/Python.h; then
-          PYTHON_INCDIR=-I/usr/include/python2.3
-          PYTHON_LIBS="-L/usr/lib/python2.3/config -lpython2.3 -lutil -ldl"
-       elif test -f /usr/include/python2.4/Python.h; then
-          PYTHON_INCDIR=-I/usr/include/python2.4
-          PYTHON_LIBS="-L/usr/lib/python2.4/config -lpython2.4 -lutil -ldl"
-       elif test -f $prefix/include/Python.h; then
-          PYTHON_INCDIR=-I$prefix/include
-          PYTHON_LIBS="-L$prefix/lib/config -lpython -lutil -ldl"
-       else
+       for python_root in /usr /usr/local; do
+         if test -f $python_root/include/python2.2/Python.h; then
+            PYTHON_INCDIR=-I$python_root/include/python2.2
+            PYTHON_LIBS="-L$python_root/lib/python2.2/config -lpython2.2 -lutil"
+            break
+         elif test -f $python_root/include/python2.3/Python.h; then
+            PYTHON_INCDIR=-I$python_root/include/python2.3
+            PYTHON_LIBS="-L$python_root/lib/python2.3/config -lpython2.3 -lutil"
+            break
+         elif test -f $python_root/include/python2.4/Python.h; then
+            PYTHON_INCDIR=-I$python_root/include/python2.4
+            PYTHON_LIBS="-L$python_root/lib/python2.4/config -lpython2.4 -lutil"
+            break
+         fi
+       done
+       if test x$PYTHON_INCDIR = x; then
+         if test -f $prefix/include/Python.h; then
+            PYTHON_INCDIR=-I$prefix/include
+            PYTHON_LIBS="-L$prefix/lib/config -lpython -lutil"
+         else
           echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
           { { echo "$as_me:$LINENO: error: Unable to find Python.h in standard locations" >&5
 echo "$as_me: error: Unable to find Python.h in standard locations" >&2;}
    { (exit 1); exit 1; }; }
+         fi
        fi
      else
        if test -f $withval/Python.h; then
           PYTHON_INCDIR=-I$withval
-          PYTHON_LIBS="-L$withval/config -lpython -lutil -ldl"
+          PYTHON_LIBS="-L$withval/config -lpython -lutil"
        elif test -f $withval/include/Python.h; then
           PYTHON_INCDIR=-I$withval/include
-          PYTHON_LIBS="-L$withval/lib/config -lpython -lutil -ldl"
+          PYTHON_LIBS="-L$withval/lib/config -lpython -lutil"
        else
           echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
@@ -20934,6 +20942,7 @@ PFILES="platforms/Makefile"
 PSCMD="ps -e"
 WIN32=
 MACOSX=
+PYTHON_LIBS_EXTRAS="-ldl"
 hostname=`uname -n | cut -d '.' -f 1`
 case "$DISTNAME" in
 aix)
@@ -21007,6 +21016,7 @@ freebsd)
            platforms/freebsd/bacula-sd \
            platforms/freebsd/bacula-dir"
        largefile_support="yes"
+       PYTHON_LIBS_EXTRAS=
   ;;
 hpux)
        PSCMD="UNIX95=1 ps -e -o pid,comm"
@@ -21165,6 +21175,9 @@ esac
 
 
 LIBS="$PTHREAD_LIB $LIBS"
+if test "x$PYTHON_LIBS" != x -a "x$PYTHON_LIBS_EXTRAS" != x; then
+  PYTHON_LIBS="$PYTHON_LIBS $PYTHON_LIBS_EXTRAS"
+fi
 
 cat >>confdefs.h <<_ACEOF
 #define lld "$lld"
index 1a5812d5f5641c940754d0ce546808f86776a066..e2020f5b61d26bf5f96191932ab979420ee9d10f 100644 (file)
@@ -4,7 +4,17 @@
 General:
 
 Changes to 1.37.32:
+29Jul05
+- Apply user's patch to make mutiple modifiers for times
+  work correctly.
+- Make read_dev_volume_label() handle ANSI/IBM labels
+  correctly -- ie space over any label at the beginning
+  of the tape.
 28Jul05
+- Make ANSI/IBM writing of HDR1/2 labels ignore any
+  errors if at end of tape.
+- Apply Martin's patch to improve Python detection in
+  configure.in
 - Temporarily turn off disk seeking until I find the
   cause of the problem.
 27Jul05
index 6139f86c9cef40995962e024062af343b9bf37ce..2765489552dc780c717def6fbf414aae06e785ad 100755 (executable)
@@ -619,9 +619,10 @@ void store_size(LEX *lc, RES_ITEM *item, int index, int pass)
    case T_UNQUOTED_STRING:
       bstrncpy(bsize, lc->str, sizeof(bsize));  /* save first part */
       /* if terminated by space, scan and get modifier */
-      if (lc->ch == ' ') {
+      while (lc->ch == ' ') {
          token = lex_get_token(lc, T_ALL);
          switch (token) {
+         case T_NUMBER:
          case T_IDENTIFIER:
          case T_UNQUOTED_STRING:
             bstrncat(bsize, lc->str, sizeof(bsize));
@@ -660,9 +661,10 @@ void store_time(LEX *lc, RES_ITEM *item, int index, int pass)
    case T_UNQUOTED_STRING:
       bstrncpy(period, lc->str, sizeof(period));  /* get first part */
       /* if terminated by space, scan and get modifier */
-      if (lc->ch == ' ') {
+      while (lc->ch == ' ') {
          token = lex_get_token(lc, T_ALL);
          switch (token) {
+         case T_NUMBER:
          case T_IDENTIFIER:
          case T_UNQUOTED_STRING:
             bstrncat(period, lc->str, sizeof(period));
index 148a365165e0b5a169ffd2f021c7a15d66a35f91..6776086724041192dafdcff5e8204414a16ccec1 100644 (file)
@@ -196,12 +196,15 @@ DCR *acquire_device_for_read(DCR *dcr)
                goto default_path;
             }
             
+#ifdef xxx_needed
             /* If we have a dvd that requires mount, 
              * we need to try to open the label, so the info can be reported
-             * if a wrong volume has been mounted. */
-/*            if (dev->is_dvd() && (dcr->VolCatInfo.VolCatParts > 0)) {
+             * if a wrong volume has been mounted.   
+             */
+            if (dev->is_dvd() && (dcr->VolCatInfo.VolCatParts > 0)) {
                break;
-            }*/
+            }  
+#endif
             
             Jmsg3(jcr, M_FATAL, 0, _("Open device %s Volume \"%s\" failed: ERR=%s\n"),
                 dev->print_name(), dcr->VolumeName, strerror_dev(dev));
@@ -210,9 +213,10 @@ DCR *acquire_device_for_read(DCR *dcr)
          Dmsg1(100, "opened dev %s OK\n", dev->print_name());
       }
       
-      vol_label_status = read_dev_volume_label(dcr);
+      /* Read Volume Label */
       
       Dmsg0(200, "calling read-vol-label\n");
+      vol_label_status = read_dev_volume_label(dcr);
       switch (vol_label_status) {
       case VOL_OK:
          vol_ok = true;
index aefecce7ef82ea0a697f5682df8a55ef18a940af..fa643b9c5f7c4e3fe54935bf61dd342f82e1f8a0 100644 (file)
@@ -319,15 +319,30 @@ bool write_ansi_ibm_labels(DCR *dcr, int type, const char *VolName)
       if (label_type == B_IBM_LABEL) {
          ascii_to_ebcdic(label, label, sizeof(label));
       }
+
+      /*
+       * This could come at the end of a tape, ignore
+       *  EOT errors.
+       */
       stat = write(dev->fd, label, sizeof(label));
       if (stat != sizeof(label)) {
          berrno be;
-         Jmsg1(jcr, M_FATAL, 0, _("Could not write ANSI HDR1 label. ERR=%s\n"),
-            be.strerror());
-         return false;
+         if (stat == -1) {
+            clrerror_dev(dev, -1);
+            if (dev->dev_errno == 0) {
+               dev->dev_errno = ENOSPC; /* out of space */
+            }
+            if (dev->dev_errno != ENOSPC) {
+               Jmsg1(jcr, M_FATAL, 0, _("Could not write ANSI HDR1 label. ERR=%s\n"),
+               be.strerror());
+               return false;
+            }
+         } else {
+            Jmsg(jcr, M_FATAL, 0, _("Could not write ANSI HDR1 label.\n"));
+            return false;
+         }
       }
 
-
       /* Now construct HDR2 label */
       memset(label, ' ', sizeof(label));
       ser_begin(label, sizeof(label));
@@ -341,9 +356,22 @@ bool write_ansi_ibm_labels(DCR *dcr, int type, const char *VolName)
       stat = write(dev->fd, label, sizeof(label));
       if (stat != sizeof(label)) {
          berrno be;
-         Jmsg1(jcr, M_FATAL, 0, _("Could not write ANSI HDR1 label. ERR=%s\n"),
-            be.strerror());
-         return false;
+         if (stat == -1) {
+            clrerror_dev(dev, -1);
+            if (dev->dev_errno == 0) {
+               dev->dev_errno = ENOSPC; /* out of space */
+            }
+            if (dev->dev_errno != ENOSPC) {
+               Jmsg1(jcr, M_FATAL, 0, _("Could not write ANSI HDR1 label. ERR=%s\n"),
+               be.strerror());
+               return false;
+            }
+            weof_dev(dev, 1);
+            return true;
+         } else {
+            Jmsg(jcr, M_FATAL, 0, _("Could not write ANSI HDR1 label.\n"));
+            return false;
+         }
       }
       if (weof_dev(dev, 1) < 0) {
          Jmsg(jcr, M_FATAL, 0, _("Error writing EOF to tape. ERR=%s"), dev->errmsg);
index e83532e4b1274b4320c97a6e65eab4e37428be77..5b39ff7fdab85ca78d82803254a2029191e24cea 100644 (file)
@@ -64,6 +64,7 @@ int read_dev_volume_label(DCR *dcr)
    DEV_BLOCK *block = dcr->block;
    int stat;
    bool want_ansi_label;
+   bool have_ansi_label = false;
 
    Dmsg3(100, "Enter read_volume_label device=%s vol=%s dev_Vol=%s\n",
       dev->print_name(), VolName, dev->VolHdr.VolumeName[0]?dev->VolHdr.VolumeName:
@@ -85,7 +86,8 @@ int read_dev_volume_label(DCR *dcr)
             Jmsg(jcr, M_FATAL, 0, "Too many tries: %s", jcr->errmsg);
          }
          Dmsg0(100, "return VOL_NAME_ERROR\n");
-         return VOL_NAME_ERROR;
+         stat = VOL_NAME_ERROR;
+         goto bail_out;
       }
       Dmsg0(30, "Leave read_volume_label() VOL_OK\n");
       return VOL_OK;       /* label already read */
@@ -112,9 +114,7 @@ int read_dev_volume_label(DCR *dcr)
       stat = read_ansi_ibm_label(dcr);            
       /* If we want a label and didn't find it, return error */
       if (want_ansi_label && stat != VOL_OK) {
-         empty_block(block);
-         rewind_dev(dev);
-         return stat;
+         goto bail_out;
       }
       if (stat == VOL_NAME_ERROR || stat == VOL_LABEL_ERROR) {
          Mmsg(jcr->errmsg, _("Wrong Volume mounted on device %s: Wanted %s have %s\n"),
@@ -122,13 +122,12 @@ int read_dev_volume_label(DCR *dcr)
          if (!dev->poll && jcr->label_errors++ > 100) {
             Jmsg(jcr, M_FATAL, 0, "Too many tries: %s", jcr->errmsg);
          }
-         empty_block(block);
-         rewind_dev(dev);
-         Dmsg1(100, "return %d\n", stat);
-         return stat;
+         goto bail_out;
       }
       if (stat != VOL_OK) {           /* Not an ANSI/IBM label, so re-read */
          rewind_dev(dev);
+      } else {
+         have_ansi_label = true;
       }
    }
   
@@ -157,17 +156,16 @@ int read_dev_volume_label(DCR *dcr)
       ok = true;
    }
    free_record(record);               /* finished reading Volume record */
-   empty_block(block);                /* done with block */
 
    if (!ok) {
       if (forge_on || jcr->ignore_label_errors) {
          dev->set_labeled();         /* set has Bacula label */
          Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg);
+         empty_block(block);
          return VOL_OK;
       }
-      rewind_dev(dev);
-      Dmsg0(100, "return VOL_NO_LABEL\n");
-      return VOL_NO_LABEL;
+      stat = VOL_NO_LABEL;
+      goto bail_out;
    }
 
    /* At this point, we have read the first Bacula block, and
@@ -175,10 +173,6 @@ int read_dev_volume_label(DCR *dcr)
     * make sure we have the right Volume.
     */
 
-   /* If we are a streaming device, we only get one chance to read */
-   if (!dev_cap(dev, CAP_STREAM)) {
-      rewind_dev(dev);
-   }
 
    if (dev->VolHdr.VerNum != BaculaTapeVersion &&
        dev->VolHdr.VerNum != OldCompatibleBaculaTapeVersion1 &&
@@ -186,7 +180,8 @@ int read_dev_volume_label(DCR *dcr)
       Mmsg(jcr->errmsg, _("Volume on %s has wrong Bacula version. Wanted %d got %d\n"),
          dev->print_name(), BaculaTapeVersion, dev->VolHdr.VerNum);
       Dmsg1(30, "VOL_VERSION_ERROR: %s", jcr->errmsg);
-      return VOL_VERSION_ERROR;
+      stat = VOL_VERSION_ERROR;
+      goto bail_out;
    }
 
    /* We are looking for either an unused Bacula tape (PRE_LABEL) or
@@ -200,7 +195,8 @@ int read_dev_volume_label(DCR *dcr)
          Jmsg(jcr, M_FATAL, 0, "Too many tries: %s", jcr->errmsg);
       }
       Dmsg0(100, "return VOL_LABEL_ERROR\n");
-      return VOL_LABEL_ERROR;
+      stat = VOL_LABEL_ERROR;
+      goto bail_out;
    }
 
    dev->set_labeled();               /* set has Bacula label */
@@ -220,7 +216,8 @@ int read_dev_volume_label(DCR *dcr)
          Jmsg(jcr, M_FATAL, 0, "Too many tries: %s", jcr->errmsg);
       }
       Dmsg0(100, "return VOL_NAME_ERROR\n");
-      return VOL_NAME_ERROR;
+      stat = VOL_NAME_ERROR;
+      goto bail_out;
    }
    Dmsg1(30, "Copy vol_name=%s\n", dev->VolHdr.VolumeName);
 
@@ -228,7 +225,25 @@ int read_dev_volume_label(DCR *dcr)
       dump_volume_label(dev);
    }
    Dmsg0(30, "Leave read_volume_label() VOL_OK\n");
+   /* If we are a streaming device, we only get one chance to read */
+   if (!dev_cap(dev, CAP_STREAM)) {
+      rewind_dev(dev);
+      if (have_ansi_label) {
+         stat = read_ansi_ibm_label(dcr);            
+         /* If we want a label and didn't find it, return error */
+         if (stat != VOL_OK) {
+            goto bail_out;
+         }
+      }
+   }
+   empty_block(block);
    return VOL_OK;
+
+bail_out:
+   empty_block(block);
+   rewind_dev(dev);
+   Dmsg1(100, "return %d\n", stat);
+   return stat;
 }
 
 /*
index 98242e83fa36f5e1eaedcb839b72e6405181b895..42056dde1832a083cec8236339c62d354f0e400e 100644 (file)
    Copyright (C) 2000-2005 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.
+   modify it under the terms of the GNU General Public License
+   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.
-
-   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.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
index 8e1525ad317aa2130cbc9a465d1b18eb828d3fc0..5e9e25a316b1c9d531cbcde873096de57608c9cf 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #undef  VERSION
 #define VERSION "1.37.32"
-#define BDATE   "28 July 2005"
-#define LSMDATE "28Jul05"
+#define BDATE   "29 July 2005"
+#define LSMDATE "29Jul05"
 
 /* Debug flags */
 #undef  DEBUG