]> git.sur5r.net Git - bacula/bacula/commitdiff
Misc update slots fixes
authorKern Sibbald <kern@sibbald.com>
Sat, 5 Jun 2004 10:15:55 +0000 (10:15 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 5 Jun 2004 10:15:55 +0000 (10:15 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1384 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/cats/sql_list.c
bacula/src/dird/protos.h
bacula/src/dird/ua_cmds.c
bacula/src/dird/ua_label.c
bacula/src/dird/ua_select.c
bacula/src/version.h

index 3f56ca248faec0f7063d1b2531b3d369cd007caa..e5a62539257598c9eb7129355339b98ddba3e566 100644 (file)
@@ -81,7 +81,8 @@ db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_
    if (type == VERT_LIST) {
       Mmsg(&mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,"
          "AcceptAnyVolume,VolRetention,VolUseDuration,MaxVolJobs,MaxVolBytes,"
-         "AutoPrune,Recycle,PoolType,LabelFormat "
+         "AutoPrune,Recycle,PoolType,LabelFormat,Enabled,ScratchPoolId,"
+         "RecyclePoolId "
           "FROM Pool ORDER BY PoolId");
    } else {
       Mmsg(&mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,PoolType,LabelFormat "
index 7f58f98cd1f565e4bbc97cab76864ccac42edd07..8a1a85bdfd20fcc74d5b25d15c71a0958fc39fae 100644 (file)
@@ -132,7 +132,7 @@ int get_yesno(UAContext *ua, char *prompt);
 void parse_ua_args(UAContext *ua);
 
 /* ua_label.c */
-int is_volume_name_legal(UAContext *ua, char *name);
+bool is_volume_name_legal(UAContext *ua, char *name);
 
 /* ua_output.c */
 void prtit(void *ctx, char *msg);
index 10e50d963dae07c863c63b4b93ec78e9d3908f00..bf654b3e670c593d5c4a58952d1d63b3ed47e60a 100644 (file)
@@ -565,19 +565,20 @@ static int setip_cmd(UAContext *ua, char *cmd)
       bsendmsg(ua, _("Illegal command from this console.\n"));
       return 1;
    }
+   LockRes();
    client = (CLIENT *)GetResWithName(R_CLIENT, ua->cons->hdr.name);
 
    if (!client) {
       bsendmsg(ua, _("Client \"%s\" not found.\n"), ua->cons->hdr.name);
-      return 1;
+      goto get_out;
    }
-   LockRes();
    if (client->address) {
       free(client->address);
    }
    client->address = bstrdup(inet_ntoa(ua->UA_sock->client_addr.sin_addr));
    bsendmsg(ua, _("Client \"%s\" address set to %s\n"),
            client->hdr.name, client->address);
+get_out:
    UnlockRes();
    return 1;
 }
@@ -591,6 +592,8 @@ static int setip_cmd(UAContext *ua, char *cmd)
  *        updates pool from Pool resource
  *    update media pool=<pool-name> volume=<volume-name>
  *        changes pool info for volume
+ *    update slots [scan=...]
+ *        updates autochanger slots
  */
 static int update_cmd(UAContext *ua, char *cmd) 
 {
index f663fc7ce6d8848d2a5a67602940bd9365288f5a..f69b64bf20a2efcf167009a4e71c89d9857dd788 100644 (file)
@@ -45,7 +45,7 @@ static int send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr,
               POOL_DBR *pr, int relabel, bool media_record_exits);
 static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan);
 static void free_vol_list(vol_list_t *vol_list);
-static int is_cleaning_tape(UAContext *ua, MEDIA_DBR *mr, POOL_DBR *pr);
+static bool is_cleaning_tape(UAContext *ua, MEDIA_DBR *mr, POOL_DBR *pr);
 static BSOCK *open_sd_bsock(UAContext *ua);
 static void close_sd_bsock(UAContext *ua);
 static char *get_volume_name_from_SD(UAContext *ua, int Slot);
@@ -66,7 +66,7 @@ int relabel_cmd(UAContext *ua, char *cmd)
    return do_label(ua, cmd, 1);      /* relabel tape */
 }
 
-#define MAX_SLOTS 5000
+static int const max_slots = 5000;
 
 static bool get_user_slot_list(UAContext *ua, char *slot_list, int num_slots)
 {
@@ -174,8 +174,8 @@ int update_slots(UAContext *ua)
 
    scan = find_arg(ua, _("scan")) >= 0;
 
-   slot_list = (char *)malloc(MAX_SLOTS);
-   if (!get_user_slot_list(ua, slot_list, MAX_SLOTS)) {
+   slot_list = (char *)malloc(max_slots);
+   if (!get_user_slot_list(ua, slot_list, max_slots)) {
       free(slot_list);
       return 1;
    }
@@ -191,6 +191,7 @@ int update_slots(UAContext *ua)
    for (vl=vol_list; vl; vl=vl->next) {
       /* Check if user wants us to look at this slot */
       if (!slot_list[vl->Slot]) {
+         Dmsg1(100, "Skipping slot=%d\n", vl->Slot);
         continue;
       }
       /* If scanning, we read the label rather than the barcode */
@@ -200,8 +201,10 @@ int update_slots(UAContext *ua)
            vl->VolName = NULL;
         }
         vl->VolName = get_volume_name_from_SD(ua, vl->Slot);
+         Dmsg2(100, "Got Vol=%s from SD for Slot=%d\n", vl->VolName, vl->Slot);
       }
       if (!vl->VolName) {
+         Dmsg1(100, "No VolName for Slot=%d skipping.\n", vl->Slot);
         continue;
       }
       memset(&mr, 0, sizeof(mr));
@@ -414,8 +417,8 @@ static void label_from_barcodes(UAContext *ua)
    bool media_record_exists;
    char *slot_list;
 
-   slot_list = (char *)malloc(MAX_SLOTS);
-   if (!get_user_slot_list(ua, slot_list, MAX_SLOTS)) {
+   slot_list = (char *)malloc(max_slots);
+   if (!get_user_slot_list(ua, slot_list, max_slots)) {
       free(slot_list);
       return;
    }
@@ -512,7 +515,7 @@ bail_out:
  * Check if the Volume name has legal characters
  * If ua is non-NULL send the message
  */
-int is_volume_name_legal(UAContext *ua, char *name)
+bool is_volume_name_legal(UAContext *ua, char *name)
 {
    int len;
    char *p;
@@ -740,10 +743,14 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan)
       vl = (vol_list_t *)malloc(sizeof(vol_list_t));
       vl->Slot = Slot;
       if (p) {
+         if (*p == ':') {
+           p++;                      /* skip separator */
+        }
         vl->VolName = bstrdup(p);
       } else {
         vl->VolName = NULL;
       }
+      Dmsg2(100, "Add slot=%d Vol=%s to list.\n", vl->Slot, NPRT(vl->VolName));
       if (!vol_list) {
         vl->next = vol_list;
         vol_list = vl;
@@ -783,20 +790,18 @@ static void free_vol_list(vol_list_t *vol_list)
  *  with the Cleaning Prefix. If they match, this is a cleaning 
  *  tape.
  */
-static int is_cleaning_tape(UAContext *ua, MEDIA_DBR *mr, POOL_DBR *pr)
+static bool is_cleaning_tape(UAContext *ua, MEDIA_DBR *mr, POOL_DBR *pr)
 {
+   /* Find Pool resource */
+   ua->jcr->pool = (POOL *)GetResWithName(R_POOL, pr->Name);
    if (!ua->jcr->pool) {
-      /* Find Pool resource */
-      ua->jcr->pool = (POOL *)GetResWithName(R_POOL, pr->Name);
-      if (!ua->jcr->pool) {
-         bsendmsg(ua, _("Pool %s resource not found!\n"), pr->Name);
-        return 1;
-      }
+      bsendmsg(ua, _("Pool \"%s\" resource not found!\n"), pr->Name);
+      return true;
    }
    if (ua->jcr->pool->cleaning_prefix == NULL) {
-      return 0;
+      return false;
    }
-   Dmsg4(200, "CLNprefix=%s: Vol=%s: len=%d strncmp=%d\n",
+   Dmsg4(100, "CLNprefix=%s: Vol=%s: len=%d strncmp=%d\n",
       ua->jcr->pool->cleaning_prefix, mr->VolumeName,
       strlen(ua->jcr->pool->cleaning_prefix), 
       strncmp(mr->VolumeName, ua->jcr->pool->cleaning_prefix,
index 8f4e255b18f21354eeb4ef9b1fecd7521fd31b51..17ea007638e1564641022f59a031ddccfcc4e743 100644 (file)
@@ -766,9 +766,10 @@ STORE *get_storage_resource(UAContext *ua, int use_default)
 
    for (i=1; i<ua->argc; i++) {
       if (use_default && !ua->argv[i]) {
-        /* Ignore scan and barcode(s) keywords */
+        /* Ignore slots, scan and barcode(s) keywords */
          if (strncasecmp("scan", ua->argk[i], 4) == 0 ||
-             strncasecmp("barcode", ua->argk[i], 7) == 0) {
+             strncasecmp("barcode", ua->argk[i], 7) == 0 ||
+             strncasecmp("slots", ua->argk[i], 5) == 0) {
            continue;
         }
         /* Default argument is storage */
index f07b7fd32d45497a12b6b5e0ddb009474fac2c11..aeb118554efe8189ed683c08568d45f6a5fa19f0 100644 (file)
@@ -2,8 +2,8 @@
 #undef  VERSION
 #define VERSION "1.34.3"
 #define VSTRING "1"
-#define BDATE   "02 June 2004"
-#define LSMDATE "02Jun04"
+#define BDATE   "05 June 2004"
+#define LSMDATE "05Jun04"
 
 /* Debug flags */
 #undef  DEBUG