From dc6f71eb3668aba4bbd38375a5cb000e651d697f Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 5 Jun 2004 10:15:55 +0000 Subject: [PATCH] Misc update slots fixes git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1384 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/cats/sql_list.c | 3 ++- bacula/src/dird/protos.h | 2 +- bacula/src/dird/ua_cmds.c | 7 +++++-- bacula/src/dird/ua_label.c | 37 +++++++++++++++++++++---------------- bacula/src/dird/ua_select.c | 5 +++-- bacula/src/version.h | 4 ++-- 6 files changed, 34 insertions(+), 24 deletions(-) diff --git a/bacula/src/cats/sql_list.c b/bacula/src/cats/sql_list.c index 3f56ca248f..e5a6253925 100644 --- a/bacula/src/cats/sql_list.c +++ b/bacula/src/cats/sql_list.c @@ -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 " diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index 7f58f98cd1..8a1a85bdfd 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -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); diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 10e50d963d..bf654b3e67 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -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= volume= * changes pool info for volume + * update slots [scan=...] + * updates autochanger slots */ static int update_cmd(UAContext *ua, char *cmd) { diff --git a/bacula/src/dird/ua_label.c b/bacula/src/dird/ua_label.c index f663fc7ce6..f69b64bf20 100644 --- a/bacula/src/dird/ua_label.c +++ b/bacula/src/dird/ua_label.c @@ -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, diff --git a/bacula/src/dird/ua_select.c b/bacula/src/dird/ua_select.c index 8f4e255b18..17ea007638 100644 --- a/bacula/src/dird/ua_select.c +++ b/bacula/src/dird/ua_select.c @@ -766,9 +766,10 @@ STORE *get_storage_resource(UAContext *ua, int use_default) for (i=1; iargc; 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 */ diff --git a/bacula/src/version.h b/bacula/src/version.h index f07b7fd32d..aeb118554e 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -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 -- 2.39.5