X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fdird%2Fua_cmds.c;h=481b51b0e3294762be72aa334c42abfb61a77294;hb=44566f589dd96e4414e38ec4bf7d76b22fbcd9aa;hp=7e71408bb4f3ccf0d4cdb6f91c601033d8d60b7a;hpb=8e1a4eeb2bdc80c9ab45a822a8da1cfa0ece1a6d;p=bacula%2Fbacula diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 7e71408bb4..481b51b0e3 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -30,7 +30,6 @@ extern int r_first; extern int r_last; extern struct s_res resources[]; -extern char my_name[]; extern jobq_t job_queue; /* job queue */ @@ -147,8 +146,8 @@ int do_a_command(UAContext *ua, const char *cmd) return 1; } - while (ua->jcr->storage->size()) { - ua->jcr->storage->remove(0); + while (ua->jcr->wstorage->size()) { + ua->jcr->wstorage->remove(0); } len = strlen(ua->argk[0]); @@ -673,10 +672,10 @@ static void do_storage_setdebug(UAContext *ua, STORE *store, int level, int trac BSOCK *sd; JCR *jcr = ua->jcr; - set_storage(jcr, store); + set_wstorage(jcr, store); /* Try connecting for up to 15 seconds */ bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"), - store->hdr.name, store->address, store->SDport); + store->name(), store->address, store->SDport); if (!connect_to_storage_daemon(jcr, 1, 15, 0)) { bsendmsg(ua, _("Failed to connect to Storage daemon.\n")); return; @@ -1238,23 +1237,15 @@ static void delete_job_id_range(UAContext *ua, char *tok) /* * do_job_delete now performs the actual delete operation atomically - * we always return 1 because C++ is pissy about void functions */ static void do_job_delete(UAContext *ua, JobId_t JobId) { - POOLMEM *query = get_pool_memory(PM_MESSAGE); + POOL_MEM query(PM_MESSAGE); char ed1[50]; - Mmsg(query, "DELETE FROM Job WHERE JobId=%s", edit_int64(JobId, ed1)); - db_sql_query(ua->db, query, NULL, (void *)NULL); - Mmsg(query, "DELETE FROM MAC WHERE JobId=%s", ed1); - db_sql_query(ua->db, query, NULL, (void *)NULL); - Mmsg(query, "DELETE FROM File WHERE JobId=%s", ed1); - db_sql_query(ua->db, query, NULL, (void *)NULL); - Mmsg(query, "DELETE FROM JobMedia WHERE JobId=%s", ed1); - db_sql_query(ua->db, query, NULL, (void *)NULL); - free_pool_memory(query); + purge_files_from_job(ua, JobId); + purge_job_from_catalog(ua, JobId); bsendmsg(ua, _("Job %s and associated records deleted from the catalog.\n"), edit_int64(JobId, ed1)); } @@ -1310,6 +1301,7 @@ static void do_mount_cmd(UAContext *ua, const char *command) JCR *jcr = ua->jcr; char dev_name[MAX_NAME_LENGTH]; int drive; + int slot = -1; if (!open_db(ua)) { return; @@ -1320,8 +1312,11 @@ static void do_mount_cmd(UAContext *ua, const char *command) if (!store) { return; } - set_storage(jcr, store); + set_wstorage(jcr, store); drive = get_storage_drive(ua, store); + if (strcmp(command, "mount") == 0) { + slot = get_storage_slot(ua, store); + } Dmsg3(120, "Found storage, MediaType=%s DevName=%s drive=%d\n", store->media_type, store->dev_name(), drive); @@ -1333,7 +1328,11 @@ static void do_mount_cmd(UAContext *ua, const char *command) sd = jcr->store_bsock; bstrncpy(dev_name, store->dev_name(), sizeof(dev_name)); bash_spaces(dev_name); - bnet_fsend(sd, "%s %s drive=%d", command, dev_name, drive); + if (slot > 0) { + bnet_fsend(sd, "%s %s drive=%d slot=%d", command, dev_name, drive, slot); + } else { + bnet_fsend(sd, "%s %s drive=%d", command, dev_name, drive); + } while (bnet_recv(sd) >= 0) { bsendmsg(ua, "%s", sd->msg); } @@ -1343,7 +1342,7 @@ static void do_mount_cmd(UAContext *ua, const char *command) } /* - * mount [storage=] [drive=nn] + * mount [storage=] [drive=nn] [slot=mm] */ static int mount_cmd(UAContext *ua, const char *cmd) { @@ -1587,9 +1586,8 @@ static int version_cmd(UAContext *ua, const char *cmd) } -/* A bit brain damaged in that if the user has not done - * a "use catalog xxx" command, we simply find the first - * catalog resource and open it. +/* + * Open the catalog database. */ bool open_db(UAContext *ua) { @@ -1597,19 +1595,10 @@ bool open_db(UAContext *ua) return true; } if (!ua->catalog) { - LockRes(); - ua->catalog = (CAT *)GetNextRes(R_CATALOG, NULL); - UnlockRes(); + ua->catalog = get_catalog_resource(ua); if (!ua->catalog) { bsendmsg(ua, _("Could not find a Catalog resource\n")); return false; - } else if (!acl_access_ok(ua, Catalog_ACL, ua->catalog->hdr.name)) { - bsendmsg(ua, _("You must specify a \"use \" command before continuing.\n")); - ua->catalog = NULL; - return false; - } else { - bsendmsg(ua, _("Using default Catalog name=%s DB=%s\n"), - ua->catalog->hdr.name, ua->catalog->db_name); } }