]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/label.c
Correct dvd code that breaks tape labeling
[bacula/bacula] / bacula / src / stored / label.c
index 4959d55268e1b87d168f5929d83069c29981332e..59a2380e8947b999238ea8c610ec4ab7f833db37 100644 (file)
@@ -388,27 +388,20 @@ bool rewrite_volume_label(DCR *dcr, bool recycle)
 {
    DEVICE *dev = dcr->dev;
    JCR *jcr = dcr->jcr;
-   bool can_write = true;
 
    if (dev->open(dcr, OPEN_READ_WRITE) < 0) {
-      /* If device is DVD, attempt to create it */
-      if (!dev->is_dvd()) {
-         return false;
-      }
-      if (dev->open(dcr, CREATE_READ_WRITE) < 0) {
-         /* We forge on for a DVD but don't do any writing */
-         can_write = false;
-      }
+      return false;
    }
    Dmsg2(190, "set append found freshly labeled volume. fd=%d dev=%x\n", dev->fd, dev);
    dev->VolHdr.LabelType = VOL_LABEL; /* set Volume label */
    dev->set_append();
-   if (can_write) {
-      if (!write_volume_label_to_block(dcr)) {
-         Dmsg0(200, "Error from write volume label.\n");
-         return false;
-      }
+   if (!write_volume_label_to_block(dcr)) {
+      Dmsg0(200, "Error from write volume label.\n");
+      return false;
    }
+
+   dev->VolCatInfo.VolCatBytes = 0;        /* reset byte count */
+
    /*
     * If we are not dealing with a streaming device,
     *  write the block now to ensure we have write permission.
@@ -416,15 +409,17 @@ bool rewrite_volume_label(DCR *dcr, bool recycle)
     * We do not write the block now if this is an ANSI label. This
     *  avoids re-writing the ANSI label, which we do not want to do.
     */
-   if (can_write && !dev_cap(dev, CAP_STREAM)) {
+   if (!dev_cap(dev, CAP_STREAM)) {
       if (!dev->rewind(dcr)) {
-         Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device %s: ERR=%s\n"),
+         Jmsg2(jcr, M_FATAL, 0, _("Rewind error on device %s: ERR=%s\n"),
                dev->print_name(), dev->bstrerror());
+         return false;
       }
       if (recycle) {
          if (!dev->truncate(dcr)) {
-            Jmsg2(jcr, M_WARNING, 0, _("Truncate error on device %s: ERR=%s\n"),
+            Jmsg2(jcr, M_FATAL, 0, _("Truncate error on device %s: ERR=%s\n"),
                   dev->print_name(), dev->bstrerror());
+            return false;
          }
       }
 
@@ -454,7 +449,6 @@ bool rewrite_volume_label(DCR *dcr, bool recycle)
    /* Set or reset Volume statistics */
    dev->VolCatInfo.VolCatJobs = 0;
    dev->VolCatInfo.VolCatFiles = 0;
-   dev->VolCatInfo.VolCatBytes = 1;
    dev->VolCatInfo.VolCatErrors = 0;
    dev->VolCatInfo.VolCatBlocks = 0;
    dev->VolCatInfo.VolCatRBytes = 0;
@@ -483,7 +477,7 @@ bool rewrite_volume_label(DCR *dcr, bool recycle)
     * End writing real Volume label (from pre-labeled tape), or recycling
     *  the volume.
     */
-   Dmsg0(200, "OK from rewite vol label.\n");
+   Dmsg0(200, "OK from rewrite vol label.\n");
    return true;
 }
 
@@ -712,14 +706,14 @@ bool write_session_label(DCR *dcr, int label)
       return false;
    }
 
-   Dmsg6(20, "Write sesson_label record JobId=%d FI=%s SessId=%d Strm=%s len=%d "
+   Dmsg6(50, "Write sesson_label record JobId=%d FI=%s SessId=%d Strm=%s len=%d "
              "remainder=%d\n", jcr->JobId,
       FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
       stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len,
       rec->remainder);
 
    free_record(rec);
-   Dmsg2(20, "Leave write_session_label Block=%d File=%d\n",
+   Dmsg2(50, "Leave write_session_label Block=%d File=%d\n",
       dev->block_num, dev->file);
    return true;
 }