]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/catreq.c
- Convert more atoi to str_to_int64() for DB.
[bacula/bacula] / bacula / src / dird / catreq.c
index 6df8db94fe382a38eb0b6583392f8414154ac155..17ff0a194657b8cf3e69e9dfdf64b1abb266e75f 100644 (file)
@@ -41,7 +41,7 @@
  */
 
 /* Requests from the Storage daemon */
-static char Find_media[] = "CatReq Job=%127s FindMedia=%d PoolId=%lld\n";
+static char Find_media[] = "CatReq Job=%127s FindMedia=%d pool_name=%127s media_type=%127s\n";
 static char Get_Vol_Info[] = "CatReq Job=%127s GetVolInfo VolName=%127s write=%d\n";
 
 static char Update_media[] = "CatReq Job=%127s UpdateMedia VolName=%s"
@@ -86,7 +86,7 @@ static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr
       mr->VolParts,
       mr->LabelType);
    unbash_spaces(mr->VolumeName);
-   Dmsg2(400, "Vol Info for %s: %s", jcr->Job, sd->msg);
+   Dmsg2(100, "Vol Info for %s: %s", jcr->Job, sd->msg);
    return stat;
 }
 
@@ -95,8 +95,10 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
    MEDIA_DBR mr, sdmr;
    JOBMEDIA_DBR jm;
    char Job[MAX_NAME_LENGTH];
+   char pool_name[MAX_NAME_LENGTH];
    int index, ok, label, writing;
    POOLMEM *omsg;
+   POOL_DBR pr;
 
    memset(&mr, 0, sizeof(mr));
    memset(&sdmr, 0, sizeof(sdmr));
@@ -105,7 +107,7 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
    /*
     * Request to find next appendable Volume for this Job
     */
-   Dmsg1(400, "catreq %s", bs->msg);
+   Dmsg1(100, "catreq %s", bs->msg);
    if (!jcr->db) {
       omsg = get_memory(bs->msglen+1);
       pm_strcpy(omsg, bs->msg);
@@ -117,8 +119,14 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
    /*
     * Find next appendable medium for SD
     */
-   if (sscanf(bs->msg, Find_media, &Job, &index, &mr.PoolId) == 3) {
-      ok = find_next_volume_for_append(jcr, &mr, true /*permit create new vol*/);
+   if (sscanf(bs->msg, Find_media, &Job, &index, &pool_name, &mr.MediaType) == 4) {
+      memset(&pr, 0, sizeof(pr));
+      bstrncpy(pr.Name, pool_name, sizeof(pr.Name));
+      ok = db_get_pool_record(jcr, jcr->db, &pr);
+      if (ok) {
+        mr.PoolId = pr.PoolId;
+        ok = find_next_volume_for_append(jcr, &mr, true /*permit create new vol*/);
+      }
       /*
        * Send Find Media response to Storage daemon
        */
@@ -126,13 +134,14 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
         send_volume_info_to_storage_daemon(jcr, bs, &mr);
       } else {
          bnet_fsend(bs, "1901 No Media.\n");
+         Dmsg0(500, "1901 No Media.\n");
       }
 
    /*
     * Request to find specific Volume information
     */
    } else if (sscanf(bs->msg, Get_Vol_Info, &Job, &mr.VolumeName, &writing) == 3) {
-      Dmsg1(400, "CatReq GetVolInfo Vol=%s\n", mr.VolumeName);
+      Dmsg1(500, "CatReq GetVolInfo Vol=%s\n", mr.VolumeName);
       /*
        * Find the Volume
        */
@@ -186,6 +195,7 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
 
       } else {
          bnet_fsend(bs, "1997 Volume \"%s\" not in catalog.\n", mr.VolumeName);
+         Dmsg1(400, "1997 Volume \"%s\" not in catalog.\n", mr.VolumeName);
       }
 
    /*
@@ -227,8 +237,12 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
          * Insanity check for VolFiles get set to a smaller value
          */
         if (sdmr.VolFiles < mr.VolFiles) {
-            Jmsg(jcr, M_ERROR, 0, _("ERROR!! Volume Files at %u being set to %u. This is probably wrong.\n"),
-              mr.VolFiles, sdmr.VolFiles);
+            Jmsg(jcr, M_FATAL, 0, _("Volume Files at %u being set to %u"
+                 " for Volume \"%s\". This is incorrect.\n"),
+              mr.VolFiles, sdmr.VolFiles, mr.VolumeName);
+            bnet_fsend(bs, "1992 Update Media error\n");
+           db_unlock(jcr->db);
+           return;
         }
       }
       Dmsg2(400, "Update media: BefVolJobs=%u After=%u\n", mr.VolJobs, sdmr.VolJobs);