]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/askdir.c
kes Make sure valid argument passed to str_to_utime() where Arno
[bacula/bacula] / bacula / src / stored / askdir.c
index b5b4c106b3caed6da2dcbf791c4a33136941e483..54e125d92c58f142c98ffc58ad227ac3d76b86fa 100644 (file)
@@ -7,7 +7,7 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -41,12 +41,12 @@ static char Job_status[]     = "Status Job=%s JobStatus=%d\n";
 
 
 /* Responses received from the Director */
-static char OK_media[] = "1000 OK VolName=%127s VolJobs=%u VolFiles=%u"
-   " VolBlocks=%u VolBytes=%" lld " VolMounts=%u VolErrors=%u VolWrites=%u"
-   " MaxVolBytes=%" lld " VolCapacityBytes=%" lld " VolStatus=%20s"
-   " Slot=%d MaxVolJobs=%u MaxVolFiles=%u InChanger=%d"
-   " VolReadTime=%" lld " VolWriteTime=%" lld " EndFile=%u EndBlock=%u"
-   " VolParts=%u LabelType=%d";
+static char OK_media[] = "1000 OK VolName=%127s VolJobs=%u VolFiles=%lu"
+   " VolBlocks=%lu VolBytes=%lld VolMounts=%lu VolErrors=%lu VolWrites=%lu"
+   " MaxVolBytes=%lld VolCapacityBytes=%lld VolStatus=%20s"
+   " Slot=%ld MaxVolJobs=%lu MaxVolFiles=%lu InChanger=%ld"
+   " VolReadTime=%lld VolWriteTime=%lld EndFile=%lu EndBlock=%lu"
+   " VolParts=%lu LabelType=%ld";
 
 
 static char OK_create[] = "1000 OK CreateJobMedia\n";
@@ -153,7 +153,7 @@ static bool do_get_volume_info(DCR *dcr)
     BSOCK *dir = jcr->dir_bsock;
     VOLUME_CAT_INFO vol;
     int n;
-    int InChanger;
+    int32_t InChanger;
 
     dcr->VolumeName[0] = 0;           /* No volume */
     if (bnet_recv(dir) <= 0) {
@@ -162,7 +162,7 @@ static bool do_get_volume_info(DCR *dcr)
        return false;
     }
     memset(&vol, 0, sizeof(vol));
-    Dmsg1(100, "<dird %s", dir->msg);
+    Dmsg1(110, "<dird %s", dir->msg);
     n = sscanf(dir->msg, OK_media, vol.VolCatName,
                &vol.VolCatJobs, &vol.VolCatFiles,
                &vol.VolCatBlocks, &vol.VolCatBytes,
@@ -174,7 +174,7 @@ static bool do_get_volume_info(DCR *dcr)
                &vol.EndFile, &vol.EndBlock, &vol.VolCatParts,
                &vol.LabelType);
     if (n != 21) {
-       Dmsg2(100, "Bad response from Dir fields=%d: %s", n, dir->msg);
+       Dmsg2(110, "Bad response from Dir fields=%d: %s", n, dir->msg);
        Mmsg(jcr->errmsg, _("Error getting Volume info: %s"), dir->msg);
        return false;
     }
@@ -213,6 +213,8 @@ bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw writing)
     return ok;
 }
 
+
+
 /*
  * Get info on the next appendable volume in the Director's database
  * Returns: true  on success
@@ -233,6 +235,7 @@ bool dir_find_next_appendable_volume(DCR *dcr)
      *   the most available could already be mounted on another
      *   drive, so we continue looking for a not in use Volume.
      */
+    lock_reservations();
     for (int vol_index=1;  vol_index < 20; vol_index++) {
        bash_spaces(dcr->media_type);
        bash_spaces(dcr->pool_name);
@@ -250,16 +253,20 @@ bool dir_find_next_appendable_volume(DCR *dcr)
              continue;
           }
        } else {
-          Dmsg0(200, "No volume info, return false\n");
-          return false;
+          Dmsg2(100, "No vol. index %d return false. dev=%s\n", vol_index,
+             dcr->dev->print_name());
+          found = false;
+          break;
        }
     }
     if (found) {
        Dmsg0(400, "dir_find_next_appendable_volume return true\n");
        new_volume(dcr, dcr->VolumeName);   /* reserve volume */
+       unlock_reservations();
        return true;
     }
     dcr->VolumeName[0] = 0;
+    unlock_reservations();
     return false;
 }
 
@@ -295,7 +302,6 @@ bool dir_update_volume_info(DCR *dcr, bool label)
    /* Just labeled or relabeled the tape */
    if (label) {
       bstrncpy(vol->VolCatStatus, "Append", sizeof(vol->VolCatStatus));
-      vol->VolCatBytes = 1;           /* indicates tape labeled */
    }
    pm_strcpy(VolumeName, vol->VolCatName);
    bash_spaces(VolumeName);
@@ -315,7 +321,7 @@ bool dir_update_volume_info(DCR *dcr, bool label)
    /* Do not lock device here because it may be locked from label */
    if (!do_get_volume_info(dcr)) {
       Jmsg(jcr, M_FATAL, 0, "%s", jcr->errmsg);
-      Pmsg2(000, _("Didn't get vol info vol=%s: ERR=%s"), 
+      Dmsg2(100, _("Didn't get vol info vol=%s: ERR=%s"), 
          vol->VolCatName, jcr->errmsg);
       return false;
    }
@@ -444,7 +450,7 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr)
          }
       }
 
-      jcr->JobStatus = JS_WaitMedia;
+      set_jcr_job_status(jcr, JS_WaitMedia);
       dir_send_job_status(jcr);
 
       stat = wait_for_sysop(dcr);
@@ -510,7 +516,7 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr)
       }
 
       if (dev->is_dvd()) {   
-         unmount_dev(dev, 0);
+         unmount_dvd(dev, 0);
       }
       
       /*
@@ -525,7 +531,7 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr)
                dcr->VolumeName, dev->print_name(), jcr->Job);
       }
 
-      jcr->JobStatus = JS_WaitMount;
+      set_jcr_job_status(jcr, JS_WaitMount);
       dir_send_job_status(jcr);
 
       stat = wait_for_sysop(dcr);          /* wait on device */