/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
/* Media record -- same as the database */
-struct MEDIA_DBR {
+class MEDIA_DBR {
+public:
+ MEDIA_DBR() { memset(this, 0, sizeof(MEDIA_DBR)); };
+ ~MEDIA_DBR() { };
+ void clear() { memset(this, 0, sizeof(MEDIA_DBR)); };
+ void copy(MEDIA_DBR *omr) { memcpy(this, omr, sizeof(MEDIA_DBR)); };
+
DBId_t MediaId; /* Unique volume id */
char VolumeName[MAX_NAME_LENGTH]; /* Volume name */
char MediaType[MAX_NAME_LENGTH]; /* Media type */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
edit_int64(mr->PoolId, ed1), esc_type,
esc_status, changer.c_str(), order, item);
}
- Dmsg1(050, "fnextvol=%s\n", mdb->cmd);
+ Dmsg1(100, "fnextvol=%s\n", mdb->cmd);
if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
db_unlock(mdb);
return 0;
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2003-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2003-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
* Basic tasks done here:
* Display the job report.
*
- * Version $Id$
*/
#include "bacula.h"
MEDIA_DBR mr;
Dmsg0(100, "Enter backup_cleanup()\n");
- memset(&mr, 0, sizeof(mr));
update_job_end(jcr, TermCode);
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2002-2008 Free Software Foundation Europe e.V.
+ Copyright (C) 2002-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
*
* Kern Sibbald, May MMII
*
- * Version $Id$
*/
#include "bacula.h"
* volume and no appendable volumes are available.
*
*/
-void prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
+void prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr,
+ STORE *store)
{
int count;
int i;
ed2[0] = 0;
}
- if(mr->ScratchPoolId) {
+ if (mr->ScratchPoolId) {
edit_int64(mr->ScratchPoolId, ed3);
bstrncat(ed2, ed3, sizeof(ed2));
bstrncat(ed2, ",", sizeof(ed2));
/* Visit each Volume and Prune it until we find one that is purged */
for (i=0; i<ids.num_ids; i++) {
MEDIA_DBR lmr;
- memset(&lmr, 0, sizeof(lmr));
lmr.MediaId = ids.DBId[i];
Dmsg1(100, "Get record MediaId=%d\n", (int)lmr.MediaId);
if (!db_get_media_record(jcr, jcr->db, &lmr)) {
*/
if (lmr.PoolId == mr->PoolId) {
Dmsg2(100, "Got Vol=%s MediaId=%d purged.\n", lmr.VolumeName, (int)lmr.MediaId);
- memcpy(mr, &lmr, sizeof(lmr));
+ mr->copy(&lmr);
+ set_storageid_in_mr(store, mr);
break; /* got a volume */
}
}
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
}
Dmsg2(100, "Enter backup_cleanup %d %c\n", TermCode, TermCode);
- memset(&mr, 0, sizeof(mr));
memset(&cr, 0, sizeof(cr));
#ifdef xxxx
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2001-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2001-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
utime_t VolFirstWritten;
utime_t VolLastWritten;
- memset(&mr, 0, sizeof(mr));
memset(&sdmr, 0, sizeof(sdmr));
memset(&jm, 0, sizeof(jm));
Dsm_check(100);
ok = db_get_pool_record(jcr, jcr->db, &pr);
if (ok) {
mr.PoolId = pr.PoolId;
- mr.StorageId = jcr->wstore->StorageId;
+ set_storageid_in_mr(jcr->wstore, &mr);
mr.ScratchPoolId = pr.ScratchPoolId;
ok = find_next_volume_for_append(jcr, &mr, index, fnv_create_vol, fnv_prune);
Dmsg3(050, "find_media ok=%d idx=%d vol=%s\n", ok, index, mr.VolumeName);
mr.LastWritten = VolLastWritten;
}
- /*
- * Update to point to the last device used to write the Volume.
- * However, do so only if we are writing the tape, i.e.
- * the number of VolWrites has increased.
- */
- if (jcr->wstore && jcr->wstore->StorageId && sdmr.VolWrites > mr.VolWrites) {
- Dmsg2(050, "Update StorageId old=%d new=%d\n",
- mr.StorageId, jcr->wstore->StorageId);
- if (jcr->wstore->StorageId == 0) {
- Jmsg(jcr, M_ERROR, 0, _("Attempt to set StorageId to zero.\n"));
- } else {
- mr.StorageId = jcr->wstore->StorageId;
- }
- }
/* Copy updated values to original media record */
mr.VolJobs = sdmr.VolJobs;
mr.VolWriteTime = sdmr.VolWriteTime;
}
+ /*
+ * Update to point to the last device used to write the Volume.
+ * However, do so only if we are writing the tape, i.e.
+ * the number of VolWrites has increased.
+ */
+ if (jcr->wstore && jcr->wstore->StorageId && sdmr.VolWrites > mr.VolWrites) {
+ Dmsg2(050, "Update StorageId old=%d new=%d\n",
+ mr.StorageId, jcr->wstore->StorageId);
+ if (jcr->wstore->StorageId == 0) {
+ Jmsg(jcr, M_ERROR, 0, _("Attempt to set StorageId to zero.\n"));
+ db_unlock(jcr->db);
+ return;
+ } else {
+ set_storageid_in_mr(jcr->wstore, &mr);
+ }
+ } else {
+ /* ***FIXME*** is this correct? */
+ set_storageid_in_mr(NULL, &mr);
+ }
+
Dmsg2(400, "db_update_media_record. Stat=%s Vol=%s\n", mr.VolStatus, mr.VolumeName);
/*
* Update the database, then before sending the response to the
Jmsg1(jcr, M_FATAL, 0, _("Invalid Catalog request: %s"), omsg);
free_memory(omsg);
}
+
Dmsg1(400, ">CatReq response: %s", bs->msg);
Dmsg1(400, "Leave catreq jcr 0x%x\n", jcr);
return;
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
STORE *store;
foreach_res(store, R_STORAGE) {
STORAGE_DBR sr;
- MEDIATYPE_DBR mr;
+ MEDIATYPE_DBR mtr;
memset(&sr, 0, sizeof(sr));
- memset(&mr, 0, sizeof(mr));
+ memset(&mtr, 0, sizeof(mtr));
if (store->media_type) {
- bstrncpy(mr.MediaType, store->media_type, sizeof(mr.MediaType));
- mr.ReadOnly = 0;
- db_create_mediatype_record(NULL, db, &mr);
+ bstrncpy(mtr.MediaType, store->media_type, sizeof(mtr.MediaType));
+ mtr.ReadOnly = 0;
+ db_create_mediatype_record(NULL, db, &mtr);
} else {
- mr.MediaTypeId = 0;
+ mtr.MediaTypeId = 0;
}
bstrncpy(sr.Name, store->name(), sizeof(sr.Name));
sr.AutoChanger = store->autochanger;
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2004-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2004-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
Dmsg2(100, "Enter migrate_cleanup %d %c\n", TermCode, TermCode);
update_job_end(jcr, TermCode);
- memset(&mr, 0, sizeof(mr));
/*
* Check if we actually did something.
-/*
- *
- * Bacula Director -- mountreq.c -- handles the message channel
- * Mount request from the Storage daemon.
- *
- * Kern Sibbald, March MMI
- *
- * This routine runs as a thread and must be thread reentrant.
- *
- * Basic tasks done here:
- * Handle Mount services.
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2001-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2001-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * Bacula Director -- mountreq.c -- handles the message channel
+ * Mount request from the Storage daemon.
+ *
+ * Kern Sibbald, March MMI
+ *
+ * This routine runs as a thread and must be thread reentrant.
+ *
+ * Basic tasks done here:
+ * Handle Mount services.
+ *
+ */
#include "bacula.h"
#include "dird.h"
void mount_request(JCR *jcr, BSOCK *bs, char *buf)
{
- MNT_REQ *mr;
+ MNT_REQ *mreq;
- mr = (MNT_REQ *) malloc(sizeof(MNT_REQ));
- memset(mr, 0, sizeof(MNT_REQ));
- mr->jcr = jcr;
- mr->bs = bs;
+ mreq = (MNT_REQ *) malloc(sizeof(MNT_REQ));
+ memset(mreq, 0, sizeof(MNT_REQ));
+ mreq->jcr = jcr;
+ mreq->bs = bs;
P(mutex);
num_reqs++;
- qinsert(&mountq, &mr->bq);
+ qinsert(&mountq, &mreq->bq);
V(mutex);
return;
}
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
* Basic tasks done here:
* If possible create a new Media entry
*
- * Version $Id$
*/
#include "bacula.h"
* The media record must have the PoolId filled in when
* calling this routine.
*/
-bool newVolume(JCR *jcr, MEDIA_DBR *mr)
+bool newVolume(JCR *jcr, MEDIA_DBR *mr, STORE *store)
{
POOL_DBR pr;
goto bail_out;
}
if (pr.MaxVols == 0 || pr.NumVols < pr.MaxVols) {
- memset(mr, 0, sizeof(MEDIA_DBR));
+ mr->clear();
set_pool_dbr_defaults_in_media_dbr(mr, &pr);
jcr->VolumeName[0] = 0;
bstrncpy(mr->MediaType, jcr->wstore->media_type, sizeof(mr->MediaType));
}
pr.NumVols++;
mr->Enabled = 1;
+ set_storageid_in_mr(store, mr);
if (db_create_media_record(jcr, jcr->db, mr) &&
db_update_pool_record(jcr, jcr->db, &pr)) {
db_unlock(jcr->db);
}
for (int i=(int)ctx.value+1; i<(int)ctx.value+100; i++) {
MEDIA_DBR tmr;
- memset(&tmr, 0, sizeof(tmr));
sprintf(num, "%04d", i);
bstrncpy(tmr.VolumeName, name, sizeof(tmr.VolumeName));
bstrncat(tmr.VolumeName, num, sizeof(tmr.VolumeName));
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2001-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2001-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
static int const dbglvl = 50; /* debug level */
+/* Set storage id if possible */
+void set_storageid_in_mr(STORE *store, MEDIA_DBR *mr)
+{
+ if (store != NULL) {
+ mr->StorageId = store->StorageId;
+ }
+}
+
/*
* Items needed:
* mr.PoolId must be set
- * mr.StorageId should also be set
* mr.ScratchPoolId could be set (used if create==true)
* jcr->wstore
* jcr->db
/*
* 1. Look for volume with "Append" status.
*/
+ set_storageid_in_mr(store, mr); /* put StorageId in new record */
ok = db_find_next_volume(jcr, jcr->db, index, InChanger, mr);
if (!ok) {
+ /*
+ * No volume found, apply algorithm
+ */
Dmsg4(dbglvl, "after find_next_vol ok=%d index=%d InChanger=%d Vstat=%s\n",
ok, index, InChanger, mr->VolStatus);
/*
* 2. Try finding a recycled volume
*/
- ok = find_recycled_volume(jcr, InChanger, mr);
+ ok = find_recycled_volume(jcr, InChanger, mr, store);
+ set_storageid_in_mr(store, mr); /* put StorageId in new record */
Dmsg2(dbglvl, "find_recycled_volume ok=%d FW=%d\n", ok, mr->FirstWritten);
if (!ok) {
/*
* 3. Try recycling any purged volume
*/
- ok = recycle_oldest_purged_volume(jcr, InChanger, mr);
+ ok = recycle_oldest_purged_volume(jcr, InChanger, mr, store);
+ set_storageid_in_mr(store, mr); /* put StorageId in new record */
if (!ok) {
/*
* 4. Try pruning Volumes
*/
if (prune) {
Dmsg0(dbglvl, "Call prune_volumes\n");
- prune_volumes(jcr, InChanger, mr);
+ prune_volumes(jcr, InChanger, mr, store);
}
- ok = recycle_oldest_purged_volume(jcr, InChanger, mr);
+ ok = recycle_oldest_purged_volume(jcr, InChanger, mr, store);
+ set_storageid_in_mr(store, mr); /* put StorageId in new record */
if (!ok && create) {
Dmsg4(dbglvl, "after prune volumes_vol ok=%d index=%d InChanger=%d Vstat=%s\n",
ok, index, InChanger, mr->VolStatus);
/*
* 5. Try pulling a volume from the Scratch pool
*/
- ok = get_scratch_volume(jcr, InChanger, mr);
+ ok = get_scratch_volume(jcr, InChanger, mr, store);
+ set_storageid_in_mr(store, mr); /* put StorageId in new record */
Dmsg4(dbglvl, "after get scratch volume ok=%d index=%d InChanger=%d Vstat=%s\n",
ok, index, InChanger, mr->VolStatus);
}
/*
* 6. Try "creating" a new Volume
*/
- ok = newVolume(jcr, mr);
+ ok = newVolume(jcr, mr, store);
}
/*
* Look at more drastic ways to find an Appendable Volume
Dmsg2(dbglvl, "No next volume found. PurgeOldest=%d\n RecyleOldest=%d",
jcr->pool->purge_oldest_volume, jcr->pool->recycle_oldest_volume);
/* Find oldest volume to recycle */
+ set_storageid_in_mr(store, mr); /* update storage id */
ok = db_find_next_volume(jcr, jcr->db, -1, InChanger, mr);
+ set_storageid_in_mr(store, mr); /* update storageid */
Dmsg1(dbglvl, "Find oldest=%d Volume\n", ok);
if (ok && prune) {
UAContext *ua;
if (expired) {
/* Need to update media */
Dmsg1(dbglvl, "Vol=%s has expired update media record\n", mr->VolumeName);
+ set_storageid_in_mr(NULL, mr);
if (!db_update_media_record(jcr, jcr->db, mr)) {
Jmsg(jcr, M_ERROR, 0, _("Catalog error updating volume \"%s\". ERR=%s"),
mr->VolumeName, db_strerror(jcr->db));
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
+bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr,
+ STORE *store)
{
MEDIA_DBR smr; /* for searching scratch pool */
POOL_DBR spr, pr;
bstrncpy(spr.Name, "Scratch", sizeof(spr.Name));
spr.PoolId = mr->ScratchPoolId;
if (db_get_pool_record(jcr, jcr->db, &spr)) {
- memset(&smr, 0, sizeof(smr));
smr.PoolId = spr.PoolId;
if (InChanger) {
smr.StorageId = mr->StorageId; /* want only Scratch Volumes in changer */
* recycling any existing purged volumes, then
* try to take the oldest volume.
*/
+ set_storageid_in_mr(store, &smr); /* put StorageId in new record */
if (db_find_next_volume(jcr, jcr->db, 1, InChanger, &smr)) {
found = true;
- } else if (find_recycled_volume(jcr, InChanger, &smr)) {
+ } else if (find_recycled_volume(jcr, InChanger, &smr, store)) {
found = true;
- } else if (recycle_oldest_purged_volume(jcr, InChanger, &smr)) {
+ } else if (recycle_oldest_purged_volume(jcr, InChanger, &smr, store)) {
found = true;
}
goto bail_out;
}
- memcpy(mr, &smr, sizeof(MEDIA_DBR));
+ mr->copy(&smr);
+ set_storageid_in_mr(store, mr);
/* Set default parameters from current pool */
set_pool_dbr_defaults_in_media_dbr(mr, &pr);
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
/* autoprune.c */
extern void do_autoprune(JCR *jcr);
-extern void prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr);
+extern void prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr,
+ STORE *store);
/* autorecycle.c */
-extern bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr);
+extern bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger,
+ MEDIA_DBR *mr, STORE *store);
+
extern int recycle_volume(JCR *jcr, MEDIA_DBR *mr);
-extern bool find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr);
+extern bool find_recycled_volume(JCR *jcr, bool InChanger,
+ MEDIA_DBR *mr, STORE *store);
/* backup.c */
extern int wait_for_job_termination(JCR *jcr, int timeout=0);
extern bool send_bootstrap_file(JCR *jcr, BSOCK *sd);
/* next_vol.c */
+void set_storageid_in_mr(STORE *store, MEDIA_DBR *mr);
int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index,
bool create, bool purge);
bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr);
void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **reason);
-bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr);
+bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr,
+ STORE *store);
/* newvol.c */
-bool newVolume(JCR *jcr, MEDIA_DBR *mr);
+bool newVolume(JCR *jcr, MEDIA_DBR *mr, STORE *store);
/* python.c */
int generate_job_event(JCR *jcr, const char *event);
MEDIA_DBR mr;
int ok;
JCR *jcr = get_jcr_from_PyObject(self);
- memset(&mr, 0, sizeof(mr));
bstrncpy(mr.VolumeName, VolName, sizeof(mr.VolumeName));
ok = db_get_media_record(jcr, jcr->db, &mr);
return Py_BuildValue("i", ok);
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2002-2008 Free Software Foundation Europe e.V.
+ Copyright (C) 2002-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
*
* Kern Sibbald, May MMII
*
- * Version $Id$
*/
/* Forward referenced functions */
-bool find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
+bool find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr,
+ STORE *store)
{
bstrncpy(mr->VolStatus, "Recycle", sizeof(mr->VolStatus));
+ set_storageid_in_mr(store, mr);
if (db_find_next_volume(jcr, jcr->db, 1, InChanger, mr)) {
jcr->MediaId = mr->MediaId;
Dmsg1(20, "Find_next_vol MediaId=%u\n", jcr->MediaId);
pm_strcpy(jcr->VolumeName, mr->VolumeName);
+ set_storageid_in_mr(store, mr);
return true;
}
return false;
/*
* Look for oldest Purged volume
*/
-bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
+bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger,
+ MEDIA_DBR *mr, STORE *store)
{
bstrncpy(mr->VolStatus, "Purged", sizeof(mr->VolStatus));
if (db_find_next_volume(jcr, jcr->db, 1, InChanger, mr)) {
+ set_storageid_in_mr(store, mr);
if (recycle_volume(jcr, mr)) {
Jmsg(jcr, M_INFO, 0, _("Recycled volume \"%s\"\n"), mr->VolumeName);
Dmsg1(100, "return 1 recycle_oldest_purged_volume Vol=%s\n", mr->VolumeName);
mr->FirstWritten = mr->LastWritten = 0;
mr->RecycleCount++;
mr->set_first_written = true;
+ set_storageid_in_mr(NULL, mr);
return db_update_media_record(jcr, jcr->db, mr);
}
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
}
memset(&pr, 0, sizeof(pr));
- memset(&mr, 0, sizeof(mr));
if (!get_pool_dbr(ua, &pr)) {
return 1;
bsnprintf(mr.VolumeName, sizeof(mr.VolumeName), name, i);
mr.Slot = Slot++;
mr.InChanger = InChanger;
- mr.StorageId = store->StorageId;
mr.Enabled = 1;
+ set_storageid_in_mr(store, &mr);
Dmsg1(200, "Create Volume %s\n", mr.VolumeName);
if (!db_create_media_record(ua->jcr, ua->db, &mr)) {
ua->error_msg("%s", db_strerror(ua->db));
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2003-2011 Free Software Foundation Europe e.V.
+ Copyright (C) 2003-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
Dmsg2(100, "Got Vol=%s from SD for Slot=%d\n", vl->VolName, vl->Slot);
}
slot_list[vl->Slot] = 0; /* clear Slot */
- memset(&mr, 0, sizeof(mr));
mr.Slot = vl->Slot;
mr.InChanger = 1;
- mr.StorageId = store.store->StorageId;
+ set_storageid_in_mr(store.store, &mr);
/* Set InChanger to zero for this Slot */
+ /**** ***FIXME**** */
db_lock(ua->db);
db_make_inchanger_unique(ua->jcr, ua->db, &mr);
db_unlock(ua->db);
ua->info_msg(_("No VolName for Slot=%d InChanger set to zero.\n"), vl->Slot);
continue;
}
- memset(&mr, 0, sizeof(mr));
- bstrncpy(mr.VolumeName, vl->VolName, sizeof(mr.VolumeName));
db_lock(ua->db);
+ bstrncpy(mr.VolumeName, vl->VolName, sizeof(mr.VolumeName));
if (db_get_media_record(ua->jcr, ua->db, &mr)) {
if (mr.Slot != vl->Slot || !mr.InChanger || mr.StorageId != store.store->StorageId) {
mr.Slot = vl->Slot;
mr.InChanger = 1;
- mr.StorageId = store.store->StorageId;
if (have_enabled) {
mr.Enabled = Enabled;
}
+ set_storageid_in_mr(store.store, &mr);
if (!db_update_media_record(ua->jcr, ua->db, &mr)) {
ua->error_msg("%s", db_strerror(ua->db));
} else {
}
db_unlock(ua->db);
}
- memset(&mr, 0, sizeof(mr));
+ mr.clear();
mr.InChanger = 1;
- mr.StorageId = store.store->StorageId;
+ set_storageid_in_mr(store.store, &mr);
db_lock(ua->db);
for (int i=1; i <= max_slots; i++) {
if (slot_list[i]) {
/* Check for oldvolume=name */
i = find_arg_with_value(ua, "oldvolume");
if (i >= 0) {
- memset(&omr, 0, sizeof(omr));
bstrncpy(omr.VolumeName, ua->argv[i], sizeof(omr.VolumeName));
if (db_get_media_record(ua->jcr, ua->db, &omr)) {
goto checkVol;
continue;
}
- memset(&mr, 0, sizeof(mr));
bstrncpy(mr.VolumeName, ua->cmd, sizeof(mr.VolumeName));
/* If VolBytes are zero the Volume is not labeled */
if (db_get_media_record(ua->jcr, ua->db, &mr)) {
}
mr.InChanger = mr.Slot > 0; /* if slot give assume in changer */
}
- mr.StorageId = store.store->StorageId;
+ set_storageid_in_mr(store.store, &mr);
bstrncpy(mr.MediaType, store.store->media_type, sizeof(mr.MediaType));
if (!select_pool_dbr(ua, &pr)) {
goto bail_out;
}
- memset(&omr, 0, sizeof(omr));
/* Fire off the label requests */
for (vl=vol_list; vl; vl=vl->next) {
if (!vl->VolName || !slot_list[vl->Slot]) {
continue;
}
- memset(&mr, 0, sizeof(mr));
+ mr.clear();
bstrncpy(mr.VolumeName, vl->VolName, sizeof(mr.VolumeName));
media_record_exists = false;
if (db_get_media_record(ua->jcr, ua->db, &mr)) {
vl->Slot, mr.VolumeName);
mr.Slot = vl->Slot;
mr.InChanger = mr.Slot > 0; /* if slot give assume in changer */
- mr.StorageId = store->StorageId;
+ set_storageid_in_mr(store, &mr);
if (!db_update_media_record(ua->jcr, ua->db, &mr)) {
ua->error_msg(_("Error setting InChanger: ERR=%s"), db_strerror(ua->db));
}
media_record_exists = true;
}
mr.InChanger = mr.Slot > 0; /* if slot give assume in changer */
- mr.StorageId = store->StorageId;
+ set_storageid_in_mr(store, &mr);
/*
* Deal with creating cleaning tape here. Normal tapes created in
* send_label_request() below
mr.VolBytes = 1; /* any bytes to indicate it exists */
bstrncpy(mr.VolStatus, "Cleaning", sizeof(mr.VolStatus));
mr.MediaType[0] = 0;
- mr.StorageId = store->StorageId;
+ set_storageid_in_mr(store, &mr);
if (!db_update_media_record(ua->jcr, ua->db, &mr)) {
ua->error_msg("%s", db_strerror(ua->db));
}
set_pool_dbr_defaults_in_media_dbr(&mr, &pr);
bstrncpy(mr.VolStatus, "Cleaning", sizeof(mr.VolStatus));
mr.MediaType[0] = 0;
+ set_storageid_in_mr(store, &mr);
if (db_create_media_record(ua->jcr, ua->db, &mr)) {
ua->send_msg(_("Catalog record for cleaning tape \"%s\" successfully created.\n"),
mr.VolumeName);
if (media_record_exists) { /* we update it */
mr->VolBytes = VolBytes;
mr->InChanger = mr->Slot > 0; /* if slot give assume in changer */
- mr->StorageId = ua->jcr->wstore->StorageId;
+ set_storageid_in_mr(ua->jcr->wstore, mr);
if (!db_update_media_record(ua->jcr, ua->db, mr)) {
ua->error_msg("%s", db_strerror(ua->db));
ok = false;
set_pool_dbr_defaults_in_media_dbr(mr, pr);
mr->VolBytes = VolBytes;
mr->InChanger = mr->Slot > 0; /* if slot give assume in changer */
- mr->StorageId = ua->jcr->wstore->StorageId;
mr->Enabled = 1;
+ set_storageid_in_mr(ua->jcr->wstore, mr);
if (db_create_media_record(ua->jcr, ua->db, mr)) {
ua->info_msg(_("Catalog record for Volume \"%s\", Slot %d successfully created.\n"),
mr->VolumeName, mr->Slot);
const char *slot_api_empty_format="%c|%i||||||||\n";
if (is_volume_name_legal(NULL, vol_name)) {
- memset(&mr, 0, sizeof(mr));
bstrncpy(mr.VolumeName, vol_name, sizeof(mr.VolumeName));
if (db_get_media_record(ua->jcr, ua->db, &mr)) {
memset(&pr, 0, sizeof(POOL_DBR));
}
}
- memset(&mr, 0, sizeof(mr));
bstrncpy(mr.VolumeName, vl->VolName, sizeof(mr.VolumeName));
db_lock(ua->db);
if (mr.VolumeName[0] && db_get_media_record(ua->jcr, ua->db, &mr)) {
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
memset(&jr, 0, sizeof(jr));
memset(&pr, 0, sizeof(pr));
- memset(&mr, 0, sizeof(mr));
Dmsg1(20, "list: %s\n", cmd);
MEDIA_DBR mr;
POOL_DBR pr;
- memset(&mr, 0, sizeof(mr));
int i = find_arg_with_value(ua, "job");
if (i <= 0) {
if ((job = select_job_resource(ua)) == NULL) {
}
mr.PoolId = jcr->jr.PoolId;
get_job_storage(&store, job, run);
- mr.StorageId = store.store->StorageId;
+ set_storageid_in_mr(store.store, &mr);
/* no need to set ScratchPoolId, since we use fnv_no_create_vol */
if (!find_next_volume_for_append(jcr, &mr, 1, fnv_no_create_vol, fnv_prune)) {
ua->error_msg(_("Could not find next Volume for Job %s (Pool=%s, Level=%s).\n"),
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2002-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2002-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
if (ok) {
mr->VolBytes = VolBytes;
mr->VolFiles = 0;
+ set_storageid_in_mr(NULL, mr);
if (!db_update_media_record(ua->jcr, ua->db, mr)) {
ua->error_msg(_("Can't update volume size in the catalog\n"));
}
BSOCK *sd = NULL;
memset(&pr, 0, sizeof(pr));
- memset(&mr, 0, sizeof(mr));
/* Look at arguments */
for (int i=1; i<ua->argc; i++) {
if (!store) {
goto bail_out;
}
- mr.StorageId = store->StorageId;
if (!open_db(ua)) {
Dmsg0(100, "Can't open db\n");
mr.Recycle = 1;
mr.Enabled = 1;
mr.VolBytes = 10000;
+ set_storageid_in_mr(store, &mr);
bstrncpy(mr.VolStatus, "Purged", sizeof(mr.VolStatus));
if (!db_get_media_ids(ua->jcr, ua->db, &mr, &nb, &results)) {
Dmsg0(100, "No results from db_get_media_ids\n");
* Loop over the candidate Volumes and actually truncate them
*/
for (int i=0; i < nb; i++) {
- memset(&mr, 0, sizeof(mr));
+ mr.clear();
mr.MediaId = results[i];
if (db_get_media_record(ua->jcr, ua->db, &mr)) {
/* TODO: ask for drive and change Pool */
strcmp(mr->VolStatus, "Used") == 0 ||
strcmp(mr->VolStatus, "Error") == 0) {
bstrncpy(mr->VolStatus, "Purged", sizeof(mr->VolStatus));
+ set_storageid_in_mr(NULL, mr);
if (!db_update_media_record(jcr, ua->db, mr)) {
return false;
}
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2001-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2001-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
POOLMEM *err = get_pool_memory(PM_FNAME);
*err=0;
- memset(mr, 0, sizeof(MEDIA_DBR));
-
+ mr->clear();
i = find_arg_with_value(ua, "volume");
if (i >= 0) {
if (is_name_valid(ua->argv[i], &err)) {
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2001-2011 Free Software Foundation Europe e.V.
+ Copyright (C) 2001-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
int orig_jobtype;
orig_jobtype = jcr->getJobType();
- memset(&mr, 0, sizeof(mr));
if (sp->job->JobType == JT_BACKUP) {
jcr->db = NULL;
ok = complete_jcr_for_job(jcr, sp->job, sp->pool);
}
if (ok) {
mr.PoolId = jcr->jr.PoolId;
- mr.StorageId = sp->store->StorageId;
jcr->wstore = sp->store;
+ set_storageid_in_mr(jcr->wstore, &mr);
Dmsg0(250, "call find_next_volume_for_append\n");
/* no need to set ScratchPoolId, since we use fnv_no_create_vol */
ok = find_next_volume_for_append(jcr, &mr, 1, fnv_no_create_vol, fnv_no_prune);
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
* Make sure to use db_update... rather than doing this directly,
* so that any Slot is handled correctly.
*/
+ set_storageid_in_mr(NULL, mr);
if (!db_update_media_record(ua->jcr, ua->db, mr)) {
ua->error_msg(_("Error updating media record Slot: ERR=%s"), db_strerror(ua->db));
} else {
MEDIA_DBR mr;
memset(&pr, 0, sizeof(pr));
- memset(&mr, 0, sizeof(mr));
bstrncpy(pr.Name, pool_name, sizeof(pr.Name));
if (!get_pool_dbr(ua, &pr)) {
MEDIA_DBR mr;
memset(&pr, 0, sizeof(pr));
- memset(&mr, 0, sizeof(mr));
if (!db_get_pool_ids(ua->jcr, ua->db, &num_pools, &ids)) {
ua->error_msg(_("Error obtaining pool ids. ERR=%s\n"), db_strerror(ua->db));
if (mr->Enabled < 0) {
return;
}
+ set_storageid_in_mr(NULL, mr);
if (!db_update_media_record(ua->jcr, ua->db, mr)) {
ua->error_msg(_("Error updating media record Enabled: ERR=%s"),
db_strerror(ua->db));
mr->ActionOnPurge = 0;
}
+ set_storageid_in_mr(NULL, mr);
if (!db_update_media_record(ua->jcr, ua->db, mr)) {
ua->error_msg(_("Error updating media record ActionOnPurge: ERR=%s"),
db_strerror(ua->db));
* Make sure to use db_update... rather than doing this directly,
* so that any Slot is handled correctly.
*/
+ set_storageid_in_mr(NULL, &mr);
if (!db_update_media_record(ua->jcr, ua->db, &mr)) {
ua->error_msg(_("Error updating media record Slot: ERR=%s"), db_strerror(ua->db));
} else {
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2008-2011 Free Software Foundation Europe e.V.
+ Copyright (C) 2008-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
POOL_MEM query(PM_MESSAGE);
Dmsg2(100, "Enter backup_cleanup %d %c\n", TermCode, TermCode);
- memset(&mr, 0, sizeof(mr));
memset(&cr, 0, sizeof(cr));
jcr->setJobLevel(L_FULL); /* we want this to appear as a Full backup */