]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/autochanger.c
Simplify two messages in acquire.c
[bacula/bacula] / bacula / src / stored / autochanger.c
index 1f5f271f3813115f16add28c52c5e3a0d12e1a46..7f3bea26f35fe645ee3fffe8e853451b2690c420 100644 (file)
@@ -74,6 +74,7 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir)
       changer = get_pool_memory(PM_FNAME);
 
       /* Find out what is loaded, zero means device is unloaded */
+      Jmsg(jcr, M_INFO, 0, _("3301 Issuing autochanger \"loaded\" command.\n"));
       changer = edit_device_codes(jcr, changer, jcr->device->changer_command, 
                    "loaded");
       status = run_program(changer, timeout, results);
@@ -81,6 +82,7 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir)
       if (status == 0) {
         loaded = atoi(results);
       } else {
+         Jmsg(jcr, M_INFO, 0, _("3991 Bad autochanger \"load slot\" status=%d.\n"), status);
         loaded = -1;              /* force unload */
       }
       Dmsg1(100, "loaded=%s\n", results);
@@ -94,11 +96,7 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir)
         force_close_dev(dev);
         if (loaded != 0) {        /* must unload drive */
             Dmsg0(100, "Doing changer unload.\n");
-           if (dir) {
-               bnet_fsend(dir, _("3902 Issuing autochanger \"unload\" command.\n"));
-           } else {
-               Jmsg(jcr, M_INFO, 0, _("Issuing autochanger \"unload\" command.\n"));
-           }
+            Jmsg(jcr, M_INFO, 0, _("3302 Issuing autochanger \"unload\" command.\n"));
            changer = edit_device_codes(jcr, changer, 
                         jcr->device->changer_command, "unload");
            status = run_program(changer, timeout, NULL);
@@ -108,21 +106,17 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir)
          * Load the desired cassette    
          */
          Dmsg1(100, "Doing changer load slot %d\n", slot);
-        if (dir) {
-            bnet_fsend(dir, _("3903 Issuing autochanger \"load slot %d\" command.\n"),
-              slot);
-        } else {
-            Jmsg(jcr, M_INFO, 0, _("Issuing autochanger \"load slot %d\" command.\n"),
-              slot);
-        }
+         Jmsg(jcr, M_INFO, 0, _("3303 Issuing autochanger \"load slot %d\" command.\n"), 
+             slot);
         changer = edit_device_codes(jcr, changer, 
                       jcr->device->changer_command, "load");
         status = run_program(changer, timeout, NULL);
         if (status == 0) {
-            Jmsg(jcr, M_INFO, 0, _("Autochanger \"load slot\" status is OK.\n"));
+            Jmsg(jcr, M_INFO, 0, _("3304 Autochanger \"load slot %d\" status is OK.\n"),
+                   slot);
         } else {
-            Jmsg(jcr, M_INFO, 0, _("Bad autochanger \"load slot\" status = %d.\n"),
-              status);
+            Jmsg(jcr, M_INFO, 0, _("3992 Bad autochanger \"load slot\" status=%d.\n"),
+                   status);
         }
          Dmsg2(100, "load slot %d status=%d\n", slot, status);
       }
@@ -136,9 +130,20 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir)
    return rtn_stat;
 }
 
+void invalidate_slot_in_catalog(JCR *jcr)
+{
+   Jmsg(jcr, M_ERROR, 0, _("Autochanger Volume \"%s\" not found in slot %d.\n"
+"    Setting slot to zero in catalog.\n"),
+       jcr->VolCatInfo.VolCatName, jcr->VolCatInfo.Slot);
+   jcr->VolCatInfo.Slot = 0; /* invalidate slot */
+   Dmsg0(200, "update vol info in mount\n");
+   dir_update_volume_info(jcr, &jcr->VolCatInfo, 1);  /* set slot */
+}
+
 /*
  * List the Volumes that are in the autoloader possibly
  *   with their barcodes.
+ *   We assume that it is always the Console that is calling us.
  */
 int autochanger_list(JCR *jcr, DEVICE *dev, BSOCK *dir)
 {
@@ -149,7 +154,7 @@ int autochanger_list(JCR *jcr, DEVICE *dev, BSOCK *dir)
 
    if (!dev_cap(dev, CAP_AUTOCHANGER) || !jcr->device->changer_name ||
        !jcr->device->changer_command) {
-      bnet_fsend(dir, _("Not a changer device.\n"));
+      bnet_fsend(dir, _("3993 Not a autochanger device.\n"));
       return 0;
    }
 
@@ -161,16 +166,16 @@ int autochanger_list(JCR *jcr, DEVICE *dev, BSOCK *dir)
    force_close_dev(dev);
 
    /* First unload any tape */
-   bnet_fsend(dir, _("3902 Issuing autochanger \"unload\" command.\n"));
+   bnet_fsend(dir, _("3305 Issuing autochanger \"unload\" command.\n"));
    changer = edit_device_codes(jcr, changer, jcr->device->changer_command, "unload");
    run_program(changer, timeout, NULL);
 
    /* Now list slots occupied */
    changer = edit_device_codes(jcr, changer, jcr->device->changer_command, "list");
-   bnet_fsend(dir, _("3903 Issuing autochanger \"list\" command.\n"));
+   bnet_fsend(dir, _("3306 Issuing autochanger \"list\" command.\n"));
    bpipe = open_bpipe(changer, timeout, "r");
    if (!bpipe) {
-      bnet_fsend(dir, _("Open bpipe failed.\n"));
+      bnet_fsend(dir, _("3993 Open bpipe failed.\n"));
       goto bail_out;
    }
    /* Get output from changer */