]> git.sur5r.net Git - bacula/bacula/commitdiff
Insure that all the SD tools init the Autochanger
authorKern Sibbald <kern@sibbald.com>
Sat, 22 Oct 2005 15:22:54 +0000 (15:22 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 22 Oct 2005 15:22:54 +0000 (15:22 +0000)
  resources.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2476 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kes-1.37
bacula/src/stored/autochanger.c
bacula/src/stored/butil.c
bacula/src/stored/protos.h
bacula/src/stored/stored.c
bacula/src/version.h

index 010f5dc93958963fb54df9a28db08c9852386a92..2e653e80106a0f8ba22d9ec659e7eed6c69cf809 100644 (file)
@@ -3,6 +3,11 @@
 
 General:
 
+Changes to 1.37.42:
+22Oct05
+- Insure that all the SD tools init the Autochanger
+  resources.
+
 Changes to 1.37.41:
 22Oct05
 - Print error message if no Changer Command found.
index a1e49d18051fc73a8a6c208f00aa183038eec6c6..dafae5f749c206b7c7f97ef6988136a344792d73 100644 (file)
@@ -29,6 +29,57 @@ static void lock_changer(DCR *dcr);
 static void unlock_changer(DCR *dcr);
 static bool unload_other_drive(DCR *dcr, int slot);
 
+/* Init all the autochanger resources found */
+bool init_autochangers()
+{
+   bool OK = true;
+   AUTOCHANGER *changer;
+   /* Ensure that the media_type for each device is the same */
+   foreach_res(changer, R_AUTOCHANGER) {
+      DEVRES *device;
+      char *media_type = NULL;
+      foreach_alist(device, changer->device) {
+         /*
+          * If the device does not have a changer name or changer command
+          *   defined, used the one from the Autochanger resource 
+          */
+         if (!device->changer_name && changer->changer_name) {
+            device->changer_name = bstrdup(changer->changer_name);
+         }
+         if (!device->changer_command && changer->changer_command) {
+            device->changer_command = bstrdup(changer->changer_command);
+         }
+         if (!device->changer_name) {
+            Jmsg(NULL, M_ERROR, 0, 
+               _("No Changer Name given for device %s. Cannot continue.\n"),
+               device->hdr.name);
+            OK = false;
+         }   
+         if (!device->changer_command) {
+            Jmsg(NULL, M_ERROR, 0, 
+               _("No Changer Command given for device %s. Cannot continue.\n"),
+               device->hdr.name);
+            OK = false;
+         }   
+
+         if (media_type == NULL) {
+            media_type = device->media_type;     /* get Media Type of first device */
+            continue;
+         }     
+         /* Ensure that other devices Media Types are the same */
+         if (strcmp(media_type, device->media_type) != 0) {
+            Jmsg(NULL, M_ERROR, 0, 
+               _("Media Type not the same for all devices in changer %s. Cannot continue.\n"),
+               changer->hdr.name);
+            OK = false;
+            continue;
+         }
+      }
+   }
+   return OK;
+}
+
+
 /*
  * Called here to do an autoload using the autochanger, if
  *  configured, and if a Slot has been defined for this Volume.
index 37de8852839e6b85a60946c0ffbd48b2b1ff5874..92923e03e647be89fc41b00e5ed90f8767928265 100644 (file)
@@ -92,6 +92,8 @@ JCR *setup_jcr(const char *name, char *dev_name, BSR *bsr,
    jcr->fileset_md5 = get_pool_memory(PM_FNAME);
    pm_strcpy(jcr->fileset_md5, "Dummy.fileset.md5");
 
+   init_autochangers();
+
    dcr = setup_to_access_device(jcr, dev_name, VolumeName, mode);
    if (!dcr) {
       return NULL;
index 99b5fe4f9563178885b596a2f59daa58ba1afdfd..2dc535451e2a7044be36f8b237d17af8d2a1d9de 100644 (file)
@@ -49,6 +49,7 @@ int     authenticate_director(JCR *jcr);
 int     authenticate_filed(JCR *jcr);
 
 /* From autochanger.c */
+bool     init_autochangers();
 int      autoload_device(DCR *dcr, int writing, BSOCK *dir);
 bool     autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd);
 bool     unload_autochanger(DCR *dcr, int loaded);
index cc600569bd8459084368ba43d8bd64ab543f5ce9..11f31b2209c232262b802214b104aae087e2be03 100644 (file)
@@ -258,7 +258,6 @@ uint32_t newVolSessionId()
 static int check_resources()
 {
    bool OK = true;
-   AUTOCHANGER *changer;
 
 
    me = (STORES *)GetNextRes(R_STORAGE, NULL);
@@ -397,48 +396,8 @@ static int check_resources()
       }
    }
 
-   /* Ensure that the media_type for each device is the same */
-   foreach_res(changer, R_AUTOCHANGER) {
-      DEVRES *device;
-      char *media_type = NULL;
-      foreach_alist(device, changer->device) {
-         /*
-          * If the device does not have a changer name or changer command
-          *   defined, used the one from the Autochanger resource 
-          */
-         if (!device->changer_name && changer->changer_name) {
-            device->changer_name = bstrdup(changer->changer_name);
-         }
-         if (!device->changer_command && changer->changer_command) {
-            device->changer_command = bstrdup(changer->changer_command);
-         }
-         if (!device->changer_name) {
-            Jmsg(NULL, M_ERROR, 0, 
-               _("No Changer Name given for device %s. Cannot continue.\n"),
-               device->hdr.name);
-            OK = false;
-         }   
-         if (!device->changer_command) {
-            Jmsg(NULL, M_ERROR, 0, 
-               _("No Changer Command given for device %s. Cannot continue.\n"),
-               device->hdr.name);
-            OK = false;
-         }   
+   OK = init_autochangers();
 
-         if (media_type == NULL) {
-            media_type = device->media_type;     /* get Media Type of first device */
-            continue;
-         }     
-         /* Ensure that other devices Media Types are the same */
-         if (strcmp(media_type, device->media_type) != 0) {
-            Jmsg(NULL, M_ERROR, 0, 
-               _("Media Type not the same for all devices in changer %s. Cannot continue.\n"),
-               changer->hdr.name);
-            OK = false;
-            continue;
-         }
-      }
-   }
    
    if (OK) {
       close_msg(NULL);                   /* close temp message handler */
index 2fc06ed30fda3f71b578f36e23405912f14a55dc..083dde788dff027b910b776f1d88187df12724f8 100644 (file)
@@ -3,7 +3,7 @@
  */
 
 #undef  VERSION
-#define VERSION "1.37.41"
+#define VERSION "1.37.42"
 #define BDATE   "22 October 2005"
 #define LSMDATE "22Oct05"