/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2008 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.
This program is Free Software; you can redistribute it and/or
modify it under the terms of version two of the GNU General Public
- License as published by the Free Software Foundation plus additions
- that are listed in the file LICENSE.
+ License as published by the Free Software Foundation and included
+ in the file LICENSE.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
bstrncpy(dev->VolHdr.Id, "**error**", sizeof(dev->VolHdr.Id));
/* Read ANSI/IBM label if so requested */
-
want_ansi_label = dcr->VolCatInfo.LabelType != B_BACULA_LABEL ||
dcr->device->label_type != B_BACULA_LABEL;
if (want_ansi_label || dev->has_cap(CAP_CHECKLABELS)) {
return VOL_OK;
bail_out:
+ volume_unused(dcr); /* mark volume "released" */
empty_block(block);
dev->rewind(dcr);
Dmsg1(150, "return %d\n", stat);
Dmsg0(150, "write_volume_label()\n");
empty_block(dcr->block);
- /* If relabeling, truncate the device */
- if (relabel && !dev->truncate(dcr)) {
- goto bail_out;
- }
-
- if (relabel && !dev->is_tape()) {
- dev->close_part(dcr); /* make sure DVD/file closed for rename */
+ if (relabel) {
+ volume_unused(dcr); /* mark current volume unused */
+ /* Truncate device */
+ if (!dev->truncate(dcr)) {
+ goto bail_out;
+ }
+ if (!dev->is_tape()) {
+ dev->close_part(dcr); /* make sure DVD/file closed for rename */
+ }
}
/* Set the new filename for open, ... */
}
}
+ /* Temporarily mark in append state to enable writing */
+ dev->set_append();
+
/* Create PRE_LABEL or VOL_LABEL if DVD */
create_volume_label(dev, VolName, PoolName, dvdnow);
create_volume_label_record(dcr, dcr->rec);
dcr->rec->Stream = 0;
- /* Temporarily mark in append state to enable writing */
- dev->set_append();
if (!write_record_to_block(dcr->block, dcr->rec)) {
Dmsg2(130, "Bad Label write on %s: ERR=%s\n", dev->print_name(), dev->print_errmsg());
goto bail_out;
return true;
bail_out:
+ volume_unused(dcr);
dev->clear_volhdr();
dev->clear_append(); /* remove append since this is PRE_LABEL */
return false;
}
Dmsg0(150, "dir_update_vol_info. Set Append\n");
bstrncpy(dev->VolCatInfo.VolCatStatus, "Append", sizeof(dev->VolCatInfo.VolCatStatus));
- if (!dir_update_volume_info(dcr, true)) { /* indicate doing relabel */
+ if (!dir_update_volume_info(dcr, true, true)) { /* indicate doing relabel */
return false;
}
if (recycle) {
Dmsg1(130, "session_label record=%x\n", rec);
switch (label) {
case SOS_LABEL:
- if (dev->is_tape()) {
- dcr->StartBlock = dev->block_num;
- dcr->StartFile = dev->file;
- } else {
- dcr->StartBlock = (uint32_t)dev->file_addr;
- dcr->StartFile = (uint32_t)(dev->file_addr >> 32);
- }
+ set_start_vol_position(dcr);
break;
case EOS_LABEL:
if (dev->is_tape()) {
}
break;
default:
- Jmsg1(jcr, M_ABORT, 0, _("Bad session label = %d\n"), label);
+ Jmsg1(jcr, M_ABORT, 0, _("Bad Volume session label = %d\n"), label);
break;
}
create_session_label(dcr, rec, label);
Dmsg0(150, "Cannot write session label to block.\n");
if (!write_block_to_device(dcr)) {
Dmsg0(130, "Got session label write_block_to_dev error.\n");
- /* ****FIXME***** errno is not set here */
- Jmsg(jcr, M_FATAL, 0, _("Error writing Session label to %s: %s\n"),
- dev_vol_name(dev), strerror(errno));
free_record(rec);
return false;
}
}
if (!write_record_to_block(block, rec)) {
- Jmsg(jcr, M_FATAL, 0, _("Error writing Session label to %s: %s\n"),
- dev_vol_name(dev), strerror(errno));
free_record(rec);
return false;
}
free_record(rec);
Dmsg2(150, "Leave write_session_label Block=%ud File=%ud\n",
- dev->get_block(), dev->get_file());
+ dev->get_block_num(), dev->get_file());
return true;
}