Dmsg3(100, "Enter read_volume_label device=%s vol=%s dev_Vol=%s\n",
dev_name(dev), VolName, dev->VolHdr.VolName);
- if (dev->state & ST_LABEL) { /* did we already read label? */
+ if (dev_state(dev, ST_LABEL)) { /* did we already read label? */
/* Compare Volume Names allow special wild card */
if (VolName && *VolName && *VolName != '*' && strcmp(dev->VolHdr.VolName, VolName) != 0) {
Mmsg(&jcr->errmsg, _("Wrong Volume mounted on device %s: Wanted %s have %s\n"),
strerror_dev(dev));
return jcr->label_status = VOL_NO_MEDIA;
}
- strcpy(dev->VolHdr.Id, "**error**");
+ bstrncpy(dev->VolHdr.Id, "**error**", sizeof(dev->VolHdr.Id));
/* Read the Volume label block */
record = new_record();
}
if (!ok) {
free_record(record);
+ if (jcr->ignore_label_errors) {
+ dev->state |= ST_LABEL; /* set has Bacula label */
+ Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg);
+ return jcr->label_status = VOL_OK;
+ }
empty_block(block);
rewind_dev(dev);
return jcr->label_status = VOL_NO_LABEL;
return jcr->label_status = VOL_VERSION_ERROR;
}
+ /* We are looking for either an unused Bacula tape (PRE_LABEL) or
+ * a Bacula volume label (VOL_LABEL)
+ */
+ if (dev->VolHdr.LabelType != PRE_LABEL && dev->VolHdr.LabelType != VOL_LABEL) {
+ Mmsg(&jcr->errmsg, _("Volume on %s has bad Bacula label type: %x\n"),
+ dev_name(dev), dev->VolHdr.LabelType);
+ return jcr->label_status = VOL_LABEL_ERROR;
+ }
+
+ dev->state |= ST_LABEL; /* set has Bacula label */
+
/* Compare Volume Names */
Dmsg2(30, "Compare Vol names: VolName=%s hdr=%s\n", VolName?VolName:"*", dev->VolHdr.VolName);
if (VolName && *VolName && *VolName != '*' && strcmp(dev->VolHdr.VolName, VolName) != 0) {
}
Dmsg1(30, "Copy vol_name=%s\n", dev->VolHdr.VolName);
- /* We are looking for either an unused Bacula tape (PRE_LABEL) or
- * a Bacula volume label (VOL_LABEL)
- */
- if (dev->VolHdr.LabelType != PRE_LABEL && dev->VolHdr.LabelType != VOL_LABEL) {
- Mmsg(&jcr->errmsg, _("Volume on %s has bad Bacula label type: %x\n"),
- dev_name(dev), dev->VolHdr.LabelType);
- return jcr->label_status = VOL_LABEL_ERROR;
- }
-
- dev->state |= ST_LABEL; /* set has Bacula label */
if (debug_level >= 10) {
dump_volume_label(dev);
}
/* ***FIXME*** we really need to get the volume name,
* pool name, and pool type from the database.
*/
- strcpy(dev->VolHdr.Id, BaculaId);
+ bstrncpy(dev->VolHdr.Id, BaculaId, sizeof(dev->VolHdr.Id));
dev->VolHdr.VerNum = BaculaTapeVersion;
dev->VolHdr.LabelType = PRE_LABEL; /* Mark tape as unused */
bstrncpy(dev->VolHdr.VolName, VolName, sizeof(dev->VolHdr.VolName));
bstrncpy(dev->VolHdr.PoolName, PoolName, sizeof(dev->VolHdr.PoolName));
bstrncpy(dev->VolHdr.MediaType, device->media_type, sizeof(dev->VolHdr.MediaType));
- strcpy(dev->VolHdr.PoolType, "Backup");
+ bstrncpy(dev->VolHdr.PoolType, "Backup", sizeof(dev->VolHdr.PoolType));
/* Put label time/date in header */
if (BaculaTapeVersion >= 11) {
*/
void create_session_label(JCR *jcr, DEV_RECORD *rec, int label)
{
+ DCR *dcr = jcr->dcr;
ser_declare;
rec->VolSessionId = jcr->VolSessionId;
if (label == EOS_LABEL) {
ser_uint32(jcr->JobFiles);
ser_uint64(jcr->JobBytes);
- ser_uint32(jcr->StartBlock);
- ser_uint32(jcr->EndBlock);
- ser_uint32(jcr->StartFile);
- ser_uint32(jcr->EndFile);
+ ser_uint32(dcr->StartBlock);
+ ser_uint32(dcr->EndBlock);
+ ser_uint32(dcr->StartFile);
+ ser_uint32(dcr->EndFile);
ser_uint32(jcr->JobErrors);
/* Added in VerNum 11 */
int write_session_label(JCR *jcr, DEV_BLOCK *block, int label)
{
DEVICE *dev = jcr->device->dev;
+ DCR *dcr = jcr->dcr;
DEV_RECORD *rec;
rec = new_record();
switch (label) {
case SOS_LABEL:
if (dev->state & ST_TAPE) {
- jcr->StartBlock = dev->block_num;
- jcr->StartFile = dev->file;
+ dcr->StartBlock = dev->block_num;
+ dcr->StartFile = dev->file;
} else {
- jcr->StartBlock = (uint32_t)dev->file_addr;
- jcr->StartFile = (uint32_t)(dev->file_addr >> 32);
+ dcr->StartBlock = (uint32_t)dev->file_addr;
+ dcr->StartFile = (uint32_t)(dev->file_addr >> 32);
}
break;
case EOS_LABEL:
if (dev->state & ST_TAPE) {
- jcr->EndBlock = dev->EndBlock;
- jcr->EndFile = dev->EndFile;
+ dcr->EndBlock = dev->EndBlock;
+ dcr->EndFile = dev->EndFile;
} else {
- jcr->EndBlock = (uint32_t)dev->file_addr;
- jcr->EndFile = (uint32_t)(dev->file_addr >> 32);
+ dcr->EndBlock = (uint32_t)dev->file_addr;
+ dcr->EndFile = (uint32_t)(dev->file_addr >> 32);
}
break;
default: