]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/mount.c
Other modifications outside DVD functions. (@kern please double-check this)
[bacula/bacula] / bacula / src / stored / mount.c
index 9ecbf991f8890d1c27ee79fc53a0d9d326ad7b01..bf71087cf5bc51ed5af1ac12d4c7c5220b8d1172 100644 (file)
@@ -12,7 +12,7 @@
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
-   version 2 as ammended with additional clauses defined in the
+   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,
@@ -48,7 +48,7 @@ bool mount_next_write_volume(DCR *dcr, bool release)
    JCR *jcr = dcr->jcr;
    DEV_BLOCK *block = dcr->block;
 
-   Dmsg0(100, "Enter mount_next_volume()\n");
+   Dmsg1(100, "Enter mount_next_volume(release=%d)\n", release);
 
    init_device_wait_timers(dcr);
 
@@ -97,8 +97,6 @@ mount_next_vol:
    Dmsg3(100, "After find_next_append. Vol=%s Slot=%d Parts=%d\n",
          dcr->VolCatInfo.VolCatName, dcr->VolCatInfo.Slot, dcr->VolCatInfo.VolCatParts);
    
-   dev->num_parts = dcr->VolCatInfo.VolCatParts;
-
    /*
     * Get next volume and ready it for append
     * This code ensures that the device is ready for
@@ -125,10 +123,12 @@ mount_next_vol:
     *   we will err, recurse and ask the operator the next time.
     */
    if (!release && dev->is_tape() && dev_cap(dev, CAP_AUTOMOUNT)) {
+      Dmsg0(100, "(1)Ask=0");
       ask = false;                 /* don't ask SYSOP this time */
    }
    /* Don't ask if not removable */
    if (!dev_cap(dev, CAP_REM)) {
+      Dmsg0(100, "(2)Ask=0");
       ask = false;
    }
    Dmsg2(100, "Ask=%d autochanger=%d\n", ask, autochanger);
@@ -148,25 +148,12 @@ mount_next_vol:
    }
 
    /* Ensure the device is open */
-   /* If we have a dvd that requires mount, we first want to guess
-    * which Volume is loaded, so we continue (if the wrong device is
-    * loaded, open_device just below would fail. 
-    */
-   if (!dev->is_dvd()) {
-      if (!open_device(dcr)) {
-         if (dev->poll) {
-            goto mount_next_vol;
-         } else {
-            return false;
-         }
+   if (!open_device(dcr)) {
+      if ((dev->poll) || (dev->is_dvd())) {
+         goto mount_next_vol;
+      } else {
+         return false;
       }
-   } else {
-      /*
-       * Just copy the VolCatName in the device resource 
-       *   (usually done by open_dev).
-       * It is necessary so we can open the real files later.   
-       */
-      bstrncpy(dev->VolCatInfo.VolCatName, dcr->VolCatInfo.VolCatName, sizeof(dev->VolCatInfo.VolCatName));
    }
 
    /*
@@ -181,8 +168,6 @@ read_volume:
       vol_label_status = VOL_OK;
       create_volume_label(dev, dcr->VolumeName, "Default");
       dev->VolHdr.LabelType = PRE_LABEL;
-   } else if (dev->is_dvd()) {
-      vol_label_status = read_dvd_volume_label(dcr, /*write*/true);
    } else {
       vol_label_status = read_dev_volume_label(dcr);
    }
@@ -235,7 +220,7 @@ read_volume:
          /* Restore desired volume name, note device info out of sync */
          /* This gets the info regardless of the Pool */
          bstrncpy(dcr->VolumeName, dev->VolHdr.VolumeName, sizeof(dcr->VolumeName));
-         if (autochanger && dir_get_volume_info(dcr, GET_VOL_INFO_FOR_READ)) {
+         if (autochanger && !dir_get_volume_info(dcr, GET_VOL_INFO_FOR_READ)) {
             mark_volume_not_inchanger(dcr);
          }
          memcpy(&dev->VolCatInfo, &devVolCatInfo, sizeof(dev->VolCatInfo));
@@ -298,6 +283,10 @@ read_volume:
             dcr->VolumeName, dev->print_name());
          goto read_volume;      /* read label we just wrote */
       }
+      if (!dev_cap(dev, CAP_LABEL) && dcr->VolCatInfo.VolCatBytes == 0) {
+         Jmsg(jcr, M_INFO, 0, _("Warning device %s not configured to autolabel Volumes.\n"), 
+            dev->print_name());
+      }
       /* If not removable, Volume is broken */
       if (!dev_cap(dev, CAP_REM)) {
          Jmsg(jcr, M_WARNING, 0, _("Volume \"%s\" not on device %s.\n"),
@@ -455,7 +444,7 @@ void release_volume(DCR *dcr)
    if (dev->is_open()) {
       offline_or_rewind_dev(dev);
    }
-   Dmsg0(190, "===== release_volume ---");
+   Dmsg0(190, "release_volume\n");
 }
 
 /*