]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/askdir.c
This commit was manufactured by cvs2svn to create tag
[bacula/bacula] / bacula / src / stored / askdir.c
index a48dc5de7cdc43b5cfb49b068fa354f472357a44..11949fc63944144a6befae2a8d2053bb85dabdc2 100644 (file)
@@ -79,6 +79,7 @@ static int do_request_volume_info(JCR *jcr)
        Mmsg(&jcr->errmsg, _("Network error on bnet_recv in req_vol_info.\n"));
        return 0;
     }
+    memset(&vol, 0, sizeof(vol));
     if (sscanf(dir->msg, OK_media, vol.VolCatName, 
               &vol.VolCatJobs, &vol.VolCatFiles,
               &vol.VolCatBlocks, &vol.VolCatBytes,
@@ -147,23 +148,37 @@ int dir_find_next_appendable_volume(JCR *jcr)
  * After writing a Volume, send the updated statistics
  * back to the director.
  */
-int dir_update_volume_info(JCR *jcr, VOLUME_CAT_INFO *vol, int relabel)
+int dir_update_volume_info(JCR *jcr, DEVICE *dev, int label)
 {
    BSOCK *dir = jcr->dir_bsock;
    time_t EndTime = time(NULL);
    char ed1[50], ed2[50];
+   VOLUME_CAT_INFO *vol = &dev->VolCatInfo;
 
    if (vol->VolCatName[0] == 0) {
       Jmsg0(jcr, M_ERROR, 0, _("NULL Volume name. This shouldn't happen!!!\n"));
       return 0;
    }
+   if (dev_state(dev, ST_READ)) {
+      Jmsg0(jcr, M_ERROR, 0, _("Attempt to update_volume_info in read mode!!!\n"));
+      return 0;
+   }
+   if (!dev_state(dev, ST_LABEL)) {
+      Jmsg0(jcr, M_ERROR, 0, _("Attempt to update_volume_info on non-labeled Volume!!!\n"));
+      return 0;
+   }
+   /* Just labeled or relabeled the tape */
+   if (label) {
+      bstrncpy(vol->VolCatStatus, "Append", sizeof(vol->VolCatStatus));
+      vol->VolCatBytes = 1;          /* indicates tape labeled */
+   }
    bash_spaces(vol->VolCatName);
    bnet_fsend(dir, Update_media, jcr->Job, 
       vol->VolCatName, vol->VolCatJobs, vol->VolCatFiles,
       vol->VolCatBlocks, edit_uint64(vol->VolCatBytes, ed1),
       vol->VolCatMounts, vol->VolCatErrors,
       vol->VolCatWrites, edit_uint64(vol->VolCatMaxBytes, ed2), 
-      EndTime, vol->VolCatStatus, vol->Slot, relabel);
+      EndTime, vol->VolCatStatus, vol->Slot, label);
    Dmsg1(120, "update_volume_data(): %s", dir->msg);
    unbash_spaces(vol->VolCatName);
    if (bnet_recv(dir) <= 0) {
@@ -280,10 +295,12 @@ int dir_ask_sysop_to_mount_next_volume(JCR *jcr, DEVICE *dev)
         jstat = JS_WaitMount;
         /*
          * If we have a valid volume name and we are not
-         * removable media, return now, otherwise wait
+         * removable media, return now, or if we have a
+         * Slot for an autochanger, otherwise wait
          * for the operator to mount the media.
          */
-        if (jcr->VolumeName[0] && !dev_cap(dev, CAP_REM) && dev_cap(dev, CAP_LABEL)) {
+        if ((jcr->VolumeName[0] && !dev_cap(dev, CAP_REM) && dev_cap(dev, CAP_LABEL)) ||
+            (jcr->VolumeName[0] && jcr->VolCatInfo.Slot)) {
             Dmsg0(190, "Return 1 from mount without wait.\n");
            return 1;
         }