]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/mount.c
Add V: to bextract and bscan
[bacula/bacula] / bacula / src / stored / mount.c
index f47f53c347c3671db4657cb2c5b14e1c9e085f3b..816c830e45110cb03c06be31caa53866563b1545 100644 (file)
@@ -63,26 +63,7 @@ mount_next_vol:
    recycle = ask = autochanger = 0;
    if (release) {
       Dmsg0(100, "mount_next_volume release=1\n");
-      /* 
-       * First erase all memory of the current volume  
-       */
-      dev->block_num = dev->file = 0;
-      dev->EndBlock = dev->EndFile = 0;
-      memset(&dev->VolCatInfo, 0, sizeof(dev->VolCatInfo));
-      memset(&jcr->VolCatInfo, 0, sizeof(jcr->VolCatInfo));
-      memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
-      dev->state &= ~ST_LABEL;       /* label not yet read */
-      jcr->VolumeName[0] = 0;
-
-      if (!dev_is_tape(dev) || !dev_cap(dev, CAP_ALWAYSOPEN)) {
-        offline_or_rewind_dev(dev);
-        close_dev(dev);
-      }
-
-      /* If we have not closed the device, then at least rewind the tape */
-      if (dev->state & ST_OPENED) {
-        offline_or_rewind_dev(dev);
-      }
+      release_volume(jcr, dev);
       ask = 1;                       /* ask operator to mount tape */
    }
 
@@ -114,7 +95,6 @@ mount_next_vol:
 
    dev->state &= ~(ST_APPEND|ST_READ|ST_EOT|ST_WEOT|ST_EOF);
 
-   jcr->VolFirstIndex = jcr->JobFiles; /* first update of Vol FileIndex */
    for ( ;; ) {
       int vol_label_status;
       autochanger = autoload_device(jcr, dev, 1, NULL);
@@ -193,7 +173,7 @@ read_volume:
         memcpy(&VolCatInfo, &jcr->VolCatInfo, sizeof(jcr->VolCatInfo));
         /* Check if this is a valid Volume in the pool */
         pm_strcpy(&jcr->VolumeName, dev->VolHdr.VolName);                         
-        if (!dir_get_volume_info(jcr, 1)) {
+        if (!dir_get_volume_info(jcr, GET_VOL_INFO_FOR_WRITE)) {
             Mmsg(&jcr->errmsg, _("Director wanted Volume \"%s\".\n"
                  "    Current Volume \"%s\" not acceptable because:\n"
                  "    %s"),
@@ -378,3 +358,35 @@ int mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
    Dmsg0(90, "End of Device reached.\n");
    return 0;
 }
+
+/*
+ * Either because we are going to hang a new volume, or because
+ *  of explicit user request, we release the current volume.
+ */
+void release_volume(JCR *jcr, DEVICE *dev)
+{
+
+   if (jcr->WroteVol) {
+      Jmsg0(jcr, M_ERROR, 0, "Hey!!!!! WroteVol non-zero !!!!!\n");
+   }
+   /* 
+    * First erase all memory of the current volume   
+    */
+   dev->block_num = dev->file = 0;
+   dev->EndBlock = dev->EndFile = 0;
+   memset(&dev->VolCatInfo, 0, sizeof(dev->VolCatInfo));
+   memset(&jcr->VolCatInfo, 0, sizeof(jcr->VolCatInfo));
+   memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
+   dev->state &= ~ST_LABEL;       /* label not yet read */
+   jcr->VolumeName[0] = 0;
+
+   if (!dev_is_tape(dev) || !dev_cap(dev, CAP_ALWAYSOPEN)) {
+      offline_or_rewind_dev(dev);
+      close_dev(dev);
+   }
+
+   /* If we have not closed the device, then at least rewind the tape */
+   if (dev->state & ST_OPENED) {
+      offline_or_rewind_dev(dev);
+   }
+}