*/
/*
- Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+ Copyright (C) 2000-2003 Kern Sibbald and John Walker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
* into the Media DB record just before creating a media (Volume)
* record.
*/
-static void set_pool_dbr_defaults_in_media_dbr(MEDIA_DBR *mr, POOL_DBR *pr)
+void set_pool_dbr_defaults_in_media_dbr(MEDIA_DBR *mr, POOL_DBR *pr)
{
mr->PoolId = pr->PoolId;
strcpy(mr->VolStatus, "Append");
sprintf(mr.VolumeName, name, i);
mr.Slot = slot++;
Dmsg1(200, "Create Volume %s\n", mr.VolumeName);
- if (!db_create_media_record(ua->db, &mr)) {
+ if (!db_create_media_record(ua->jcr, ua->db, &mr)) {
bsendmsg(ua, db_strerror(ua->db));
return 1;
}
}
pr.NumVols += num;
Dmsg0(200, "Update pool record.\n");
- if (db_update_pool_record(ua->db, &pr) != 1) {
+ if (db_update_pool_record(ua->jcr, ua->db, &pr) != 1) {
bsendmsg(ua, db_strerror(ua->db));
return 1;
}
switch (jcr->JobStatus) {
case JS_Created:
- jcr->JobStatus = JS_Cancelled;
+ set_jcr_job_status(jcr, JS_Cancelled);
bsendmsg(ua, _("JobId %d, Job %s marked to be cancelled.\n"),
jcr->JobId, jcr->Job);
free_jcr(jcr);
default:
- jcr->JobStatus = JS_Cancelled;
+ set_jcr_job_status(jcr, JS_Cancelled);
/* Cancel File daemon */
ua->jcr->client = jcr->client;
if (!connect_to_file_daemon(ua->jcr, 10, FDConnectTimeout, 1)) {
* 1 record created
*/
-int create_pool(B_DB *db, POOL *pool)
+int create_pool(JCR *jcr, B_DB *db, POOL *pool)
{
POOL_DBR pr;
strcpy(pr.Name, pool->hdr.name);
- if (db_get_pool_record(db, &pr)) {
+ if (db_get_pool_record(jcr, db, &pr)) {
return 0; /* exists */
}
set_pooldbr_from_poolres(&pr, pool, 1);
- if (!db_create_pool_record(db, &pr)) {
+ if (!db_create_pool_record(jcr, db, &pr)) {
return -1; /* error */
}
return 1;
return 1;
}
- switch (create_pool(ua->db, pool)) {
+ switch (create_pool(ua->jcr, ua->db, pool)) {
case 0:
bsendmsg(ua, _("Error: Pool %s already exists.\n\
Use update to change it.\n"), pool->hdr.name);
}
for (int done=0; !done; ) {
- if (!db_get_media_record(ua->db, &mr)) {
+ if (!db_get_media_record(ua->jcr, ua->db, &mr)) {
if (mr.MediaId != 0) {
bsendmsg(ua, _("Volume record for MediaId %d not found.\n"), mr.MediaId);
} else {
add_prompt(ua, _("Maximum Volume Bytes"));
add_prompt(ua, _("Recycle Flag"));
add_prompt(ua, _("Slot"));
+ add_prompt(ua, _("Volume Files"));
add_prompt(ua, _("Done"));
switch (do_prompt(ua, _("Select parameter to modify"), NULL, 0)) {
case 0: /* Volume Status */
free_pool_memory(query);
break;
+ case 8: /* Volume Files */
+ int32_t VolFiles;
+ bsendmsg(ua, _("Warning changing Volume Files can result\n"
+ "in loss of data on your Volume\n\n"));
+ bsendmsg(ua, _("Current Volume Files is: %u\n"), mr.VolFiles);
+ if (!get_cmd(ua, _("Enter new number of Files for Volume: "))) {
+ return 0;
+ }
+ VolFiles = atoi(ua->cmd);
+ if (VolFiles < 0) {
+ bsendmsg(ua, _("Invalid number, it must be 0 or greater\n"));
+ break;
+ }
+ if (VolFiles != (int)(mr.VolFiles + 1)) {
+ bsendmsg(ua, _("Normally, you should only increase Volume Files by one!\n"));
+ if (!get_cmd(ua, _("Continue? (yes/no): ")) ||
+ strcasecmp(ua->cmd, "yes") != 0) {
+ break;
+ }
+ }
+ query = get_pool_memory(PM_MESSAGE);
+ Mmsg(&query, "UPDATE Media SET VolFiles=%u WHERE MediaId=%u",
+ VolFiles, mr.MediaId);
+ if (!db_sql_query(ua->db, query, NULL, NULL)) {
+ bsendmsg(ua, "%s", db_strerror(ua->db));
+ } else {
+ bsendmsg(ua, _("New Volume Files is: %u\n"), VolFiles);
+ }
+ free_pool_memory(query);
+ break;
+
default: /* Done or error */
bsendmsg(ua, "Selection done.\n");
return 1;
set_pooldbr_from_poolres(&pr, pool, 0); /* update */
- id = db_update_pool_record(ua->db, &pr);
+ id = db_update_pool_record(ua->jcr, ua->db, &pr);
if (id <= 0) {
bsendmsg(ua, _("db_update_pool_record returned %d. ERR=%s\n"),
id, db_strerror(ua->db));
return 1;
}
if (strcasecmp(ua->cmd, _("yes")) == 0) {
- db_delete_media_record(ua->db, &mr);
+ db_delete_media_record(ua->jcr, ua->db, &mr);
}
return 1;
}
return 1;
}
if (strcasecmp(ua->cmd, _("yes")) == 0) {
- db_delete_pool_record(ua->db, &pr);
+ db_delete_pool_record(ua->jcr, ua->db, &pr);
}
return 1;
}
memset(&mr, 0, sizeof(mr));
strcpy(mr.VolumeName, ua->cmd);
- if (db_get_media_record(ua->db, &mr)) {
+ if (db_get_media_record(ua->jcr, ua->db, &mr)) {
bsendmsg(ua, _("Media record for Volume %s already exists.\n"),
mr.VolumeName);
return 1;
unbash_spaces(mr.VolumeName);
unbash_spaces(mr.MediaType);
unbash_spaces(pr.Name);
+ mr.LabelDate = time(NULL);
if (ok) {
set_pool_dbr_defaults_in_media_dbr(&mr, &pr);
- if (db_create_media_record(ua->db, &mr)) {
+ if (db_create_media_record(ua->jcr, ua->db, &mr)) {
bsendmsg(ua, _("Media record for Volume=%s successfully created.\n"),
mr.VolumeName);
if (ua->automount) {
static int versioncmd(UAContext *ua, char *cmd)
{
- bsendmsg(ua, "%s Version: " VERSION " (" DATE ")\n", my_name);
+ bsendmsg(ua, "%s Version: " VERSION " (" BDATE ")\n", my_name);
return 1;
}
ua->catalog = (CAT *)GetNextRes(R_CATALOG, NULL);
UnlockRes();
if (!ua->catalog) {
- bnet_fsend(ua->UA_sock, _("Could not find a Catalog resource\n"));
+ bsendmsg(ua, _("Could not find a Catalog resource\n"));
return 0;
} else {
- bnet_fsend(ua->UA_sock, _("Using default Catalog name=%s DB=%s\n"),
+ bsendmsg(ua, _("Using default Catalog name=%s DB=%s\n"),
ua->catalog->hdr.name, ua->catalog->db_name);
}
}
Dmsg0(150, "Open database\n");
- ua->db = db_init_database(NULL, ua->catalog->db_name, ua->catalog->db_user,
+ ua->db = db_init_database(ua->jcr, ua->catalog->db_name, ua->catalog->db_user,
ua->catalog->db_password);
- if (!db_open_database(ua->db)) {
- bnet_fsend(ua->UA_sock, _("Could not open DB %s: ERR=%s"),
+ if (!db_open_database(ua->jcr, ua->db)) {
+ bsendmsg(ua, _("Could not open DB %s: ERR=%s"),
ua->catalog->db_name, db_strerror(ua->db));
close_db(ua);
return 0;
void close_db(UAContext *ua)
{
if (ua->db) {
- db_close_database(ua->db);
+ db_close_database(ua->jcr, ua->db);
}
ua->db = NULL;
ua->jcr->db = NULL;