]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Apply the recycle patch from Richard Mortimer.
authorKern Sibbald <kern@sibbald.com>
Mon, 25 Sep 2006 07:37:18 +0000 (07:37 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 25 Sep 2006 07:37:18 +0000 (07:37 +0000)
kes  Convert a few if statements in dev.c to switch statements.
kes  Start using print_errmsg instead of bstrerror().
kes  Print a job message in SD when a job is marked to be canceled.

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

bacula/src/lib/bpipe.h
bacula/src/stored/append.c
bacula/src/stored/dev.c
bacula/src/stored/dircmd.c
bacula/src/stored/label.c
bacula/src/version.h
bacula/technotes-1.39

index 353dd553f0ae767f45ae8ad51edf574277e69731..38c2c21f10afcdc3e259e6dc2d7e12a25368d980 100644 (file)
@@ -5,30 +5,26 @@
  */
 
 /*
-   Copyright (C) 2002-2004 Kern Sibbald and John Walker
+   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 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.
 
  */
 
-typedef struct s_bpipe {
+class BPIPE {
+public:
    pid_t worker_pid;
    time_t worker_stime;
    int wait;
    btimer_t *timer_id;
    FILE *rfd;
    FILE *wfd;
-} BPIPE;
+};      
index 9910ce1c0e54584170d2a431a9b441c830839dee..bbecc716e52aece587f6e835a0772845ac0b83de 100644 (file)
@@ -205,8 +205,6 @@ bool do_append_data(JCR *jcr)
             if (!write_block_to_device(dcr)) {
                Dmsg2(90, "Got write_block_to_dev error on device %s. %s\n",
                   dev->print_name(), dev->bstrerror());
-               Jmsg2(jcr, M_FATAL, 0, _("Fatal append error on device %s: ERR=%s\n"),
-                     dev->print_name(), dev->bstrerror());
                ok = false;
                break;
             }
index 80160e630d133ed44a08a988845e7803467fd31f..0d0110510d5e311696f81d52bc95e3216ae3f787 100644 (file)
@@ -1811,12 +1811,12 @@ void DEVICE::close_part(DCR *dcr)
 
 off_t DEVICE::lseek(DCR *dcr, off_t offset, int whence)
 {
-   if (is_dvd()) {
+   switch (dev_type) {
+   case B_DVD_DEV:
       return lseek_dvd(dcr, offset, whence);
-   }
-   if (is_file()) {
+   case B_FILE_DEV:
       return ::lseek(fd, offset, whence);
-   }
+   }  
    return -1;
 }
 
@@ -1824,25 +1824,25 @@ off_t DEVICE::lseek(DCR *dcr, off_t offset, int whence)
 bool DEVICE::truncate(DCR *dcr) /* We need the DCR for DVD-writing */
 {
    Dmsg1(100, "truncate %s\n", print_name());
-   if (is_tape()) {
-      return true;                    /* we don't really truncate tapes */
+   switch (dev_type) {
+   case B_TAPE_DEV:
       /* maybe we should rewind and write and eof ???? */
-   }
-   
-   if (is_dvd()) {
+      return true;                    /* we don't really truncate tapes */
+   case B_DVD_DEV:
       return truncate_dvd(dcr);
+   case B_FILE_DEV:
+      /* ***FIXME*** we really need to unlink() the file so that
+       *  its name can be changed for a relabel.
+       */
+      if (ftruncate(fd, 0) != 0) {
+         berrno be;
+         Mmsg2(errmsg, _("Unable to truncate device %s. ERR=%s\n"), 
+               print_name(), be.strerror());
+         return false;
+      }
+      return true;
    }
-   
-   /* ***FIXME*** we really need to unlink() the file so that
-    *  its name can be changed for a relabel.
-    */
-   if (ftruncate(fd, 0) != 0) {
-      berrno be;
-      Mmsg2(errmsg, _("Unable to truncate device %s. ERR=%s\n"), 
-            print_name(), be.strerror());
-      return false;
-   }
-   return true;
+   return false;
 }
 
 /* Mount the device.
index f3ce023113d1add4217428b5c879d1fbb9c13fe0..f83263105b618a22451ed0ca75751f3ab17213d0 100644 (file)
@@ -279,6 +279,7 @@ static bool cancel_cmd(JCR *cjcr)
             pthread_cond_broadcast(&jcr->read_dcr->dev->wait_next_vol);
             pthread_cond_broadcast(&wait_device_release);
          }
+         Jmsg(jcr, M_INFO, 0, _("Job marked to be canceled.\n"));
          bnet_fsend(dir, _("3000 Job %s marked to be canceled.\n"), jcr->Job);
          free_jcr(jcr);
       }
index 12b25388d58485b25c841ab62ad5382613e63de3..b00045572378578bd366b4e2f954c1a6f564ea28 100644 (file)
@@ -99,7 +99,7 @@ int read_dev_volume_label(DCR *dcr)
 
    if (!dev->rewind(dcr)) {
       Mmsg(jcr->errmsg, _("Couldn't rewind device %s: ERR=%s\n"), 
-         dev->print_name(), dev->bstrerror());
+         dev->print_name(), dev->print_errmsg());
       Dmsg1(30, "return VOL_NO_MEDIA: %s", jcr->errmsg);
       return VOL_NO_MEDIA;
    }
@@ -138,14 +138,14 @@ int read_dev_volume_label(DCR *dcr)
    if (!read_block_from_dev(dcr, NO_BLOCK_NUMBER_CHECK)) {
       Mmsg(jcr->errmsg, _("Requested Volume \"%s\" on %s is not a Bacula "
            "labeled Volume, because: ERR=%s"), NPRT(VolName), 
-           dev->print_name(), dev->bstrerror());
+           dev->print_name(), dev->print_errmsg());
       Dmsg1(30, "%s", jcr->errmsg);
    } else if (!read_record_from_block(block, record)) {
       Mmsg(jcr->errmsg, _("Could not read Volume label from block.\n"));
       Dmsg1(30, "%s", jcr->errmsg);
    } else if (!unser_volume_label(dev, record)) {
       Mmsg(jcr->errmsg, _("Could not unserialize Volume label: ERR=%s\n"),
-         dev->bstrerror());
+         dev->print_errmsg());
       Dmsg1(30, "%s", jcr->errmsg);
    } else if (strcmp(dev->VolHdr.Id, BaculaId) != 0 &&
               strcmp(dev->VolHdr.Id, OldBaculaId) != 0) {
@@ -321,7 +321,7 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName,
    if (!dev->rewind(dcr)) {
       free_volume(dev);
       memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
-      Dmsg2(30, "Bad status on %s from rewind: ERR=%s\n", dev->print_name(), dev->bstrerror());
+      Dmsg2(30, "Bad status on %s from rewind: ERR=%s\n", dev->print_name(), dev->print_errmsg());
       if (!forge_on) {
          goto bail_out;
       }
@@ -350,7 +350,7 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName,
    /* Temporarily mark in append state to enable writing */
    dev->set_append();
    if (!write_record_to_block(dcr->block, dcr->rec)) {
-      Dmsg2(30, "Bad Label write on %s: ERR=%s\n", dev->print_name(), dev->bstrerror());
+      Dmsg2(30, "Bad Label write on %s: ERR=%s\n", dev->print_name(), dev->print_errmsg());
       goto bail_out;
    } else {
       Dmsg2(30, "Wrote label of %d bytes to %s\n", dcr->rec->data_len, dev->print_name());
@@ -358,7 +358,7 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName,
 
    Dmsg0(99, "Call write_block_to_dev()\n");
    if (!write_block_to_dev(dcr)) {
-      Dmsg2(30, "Bad Label write on %s: ERR=%s\n", dev->print_name(), dev->bstrerror());
+      Dmsg2(30, "Bad Label write on %s: ERR=%s\n", dev->print_name(), dev->print_errmsg());
       goto bail_out;
    }
 
@@ -366,7 +366,7 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName,
    if (dev->is_dvd() && dvdnow) {
       Dmsg1(150, "New VolName=%s\n", dev->VolCatInfo.VolCatName);
       if (!dvd_write_part(dcr)) {
-         Dmsg2(30, "Bad DVD write on %s: ERR=%s\n", dev->print_name(), dev->bstrerror());
+         Dmsg2(30, "Bad DVD write on %s: ERR=%s\n", dev->print_name(), dev->print_errmsg());
          goto bail_out;
       }
    }
@@ -426,13 +426,19 @@ bool rewrite_volume_label(DCR *dcr, bool recycle)
    if (!dev_cap(dev, CAP_STREAM)) {
       if (!dev->rewind(dcr)) {
          Jmsg2(jcr, M_FATAL, 0, _("Rewind error on device %s: ERR=%s\n"),
-               dev->print_name(), dev->bstrerror());
+               dev->print_name(), dev->print_errmsg());
          return false;
       }
       if (recycle) {
          if (!dev->truncate(dcr)) {
             Jmsg2(jcr, M_FATAL, 0, _("Truncate error on device %s: ERR=%s\n"),
-                  dev->print_name(), dev->bstrerror());
+                  dev->print_name(), dev->print_errmsg());
+            return false;
+         }
+         if (dev->open(dcr, OPEN_READ_WRITE) < 0) {
+            Jmsg2(jcr, M_FATAL, 0,
+               _("Failed to re-open DVD after truncate on device %s: ERR=%s\n"),
+               dev->print_name(), dev->print_errmsg());
             return false;
          }
       }
@@ -455,11 +461,12 @@ bool rewrite_volume_label(DCR *dcr, bool recycle)
       Dmsg1(200, "Attempt to write to device fd=%d.\n", dev->fd);
       if (!write_block_to_dev(dcr)) {
          Jmsg2(jcr, M_ERROR, 0, _("Unable to write device %s: ERR=%s\n"),
-            dev->print_name(), dev->bstrerror());
+            dev->print_name(), dev->print_errmsg());
          Dmsg0(200, "===ERROR write block to dev\n");
          return false;
       }
    }
+   dev->set_labeled();
    /* Set or reset Volume statistics */
    dev->VolCatInfo.VolCatJobs = 0;
    dev->VolCatInfo.VolCatFiles = 0;
index a5393b4bbe2c786075b8eea1238de6757e36e9fc..530bbd840c08146065e265df9b69264dfa90c24d 100644 (file)
@@ -4,8 +4,8 @@
 
 #undef  VERSION
 #define VERSION "1.39.23"
-#define BDATE   "23 September 2006"
-#define LSMDATE "23Sep06"
+#define BDATE   "24 September 2006"
+#define LSMDATE "24Sep06"
 #define BYEAR "2006"       /* year for copyright messages in progs */
 
 /* Debug flags */
index 5592d3775fd887ce2cb7735d509041137a6c6900..59440762b2e04cf10405312ee5df8814b5007eb8 100644 (file)
@@ -1,6 +1,11 @@
               Technical notes on version 1.39  
 
 General:
+24Sep06
+kes  Apply the recycle patch from Richard Mortimer.
+kes  Convert a few if statements in dev.c to switch statements.
+kes  Start using print_errmsg instead of bstrerror().
+kes  Print a job message in SD when a job is marked to be canceled.
 23Sep06
 kes  All code added back. Fixed block.c read/write to loop only 3
      times. This apparently keeps the OS from crashing (at least