]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/label.c
kes Close bat console windows first to eliminate error message
[bacula/bacula] / bacula / src / stored / label.c
index e56e32c39be11f77e852d77a5c677d6ac8fbd988..5ec6a72b68141e9a2821a0b83e2352e152727c5d 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -257,6 +257,7 @@ int read_dev_volume_label(DCR *dcr)
    return VOL_OK;
 
 bail_out:
+   volume_unused(dcr);                /* mark volume "released" */
    empty_block(block);
    dev->rewind(dcr);
    Dmsg1(150, "return %d\n", stat);
@@ -315,13 +316,15 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName,
    Dmsg0(150, "write_volume_label()\n");
    empty_block(dcr->block);
 
-   /* If relabeling, truncate the device */
-   if (relabel && !dev->truncate(dcr)) {
-      goto bail_out;
-   }
-
-   if (relabel && !dev->is_tape()) {
-      dev->close_part(dcr);              /* make sure DVD/file closed for rename */
+   if (relabel) {
+      volume_unused(dcr);             /* mark current volume unused */
+      /* Truncate device */
+      if (!dev->truncate(dcr)) {
+         goto bail_out;
+      }
+      if (!dev->is_tape()) {
+         dev->close_part(dcr);        /* make sure DVD/file closed for rename */
+      }
    }
 
    /* Set the new filename for open, ... */
@@ -408,6 +411,7 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName,
    return true;
 
 bail_out:
+   volume_unused(dcr);
    dev->clear_volhdr();
    dev->clear_append();               /* remove append since this is PRE_LABEL */
    return false;
@@ -505,7 +509,7 @@ bool rewrite_volume_label(DCR *dcr, bool recycle)
    }
    Dmsg0(150, "dir_update_vol_info. Set Append\n");
    bstrncpy(dev->VolCatInfo.VolCatStatus, "Append", sizeof(dev->VolCatInfo.VolCatStatus));
-   if (!dir_update_volume_info(dcr, true)) {  /* indicate doing relabel */
+   if (!dir_update_volume_info(dcr, true, true)) {  /* indicate doing relabel */
       return false;
    }
    if (recycle) {
@@ -698,13 +702,7 @@ bool write_session_label(DCR *dcr, int label)
    Dmsg1(130, "session_label record=%x\n", rec);
    switch (label) {
    case SOS_LABEL:
-      if (dev->is_tape()) {
-         dcr->StartBlock = dev->block_num;
-         dcr->StartFile  = dev->file;
-      } else {
-         dcr->StartBlock = (uint32_t)dev->file_addr;
-         dcr->StartFile = (uint32_t)(dev->file_addr >> 32);
-      }
+      set_start_vol_position(dcr);
       break;
    case EOS_LABEL:
       if (dev->is_tape()) {
@@ -716,7 +714,7 @@ bool write_session_label(DCR *dcr, int label)
       }
       break;
    default:
-      Jmsg1(jcr, M_ABORT, 0, _("Bad session label = %d\n"), label);
+      Jmsg1(jcr, M_ABORT, 0, _("Bad Volume session label = %d\n"), label);
       break;
    }
    create_session_label(dcr, rec, label);