-/*
- *
- * label.c Bacula routines to handle labels
- *
- * Kern Sibbald, MM
- *
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2007 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.
*/
+/*
+ *
+ * label.c Bacula routines to handle labels
+ *
+ * Kern Sibbald, MM
+ *
+ *
+ * Version $Id$
+ */
#include "bacula.h" /* pull in global headers */
#include "stored.h" /* pull in Storage Deamon headers */
}
dev->set_labeled(); /* set has Bacula label */
- new_volume(dcr, dev->VolHdr.VolumeName);
+ if (reserve_volume(dcr, dev->VolHdr.VolumeName) == NULL) {
+ Mmsg2(jcr->errmsg, _("Could not reserve volume %s on %s\n"),
+ dev->VolHdr.VolumeName, dev->print_name());
+ stat = VOL_NAME_ERROR;
+ goto bail_out;
+ }
/* Compare Volume Names */
Dmsg2(30, "Compare Vol names: VolName=%s hdr=%s\n", VolName?VolName:"*", dev->VolHdr.VolumeName);
goto bail_out;
}
- if (relabel) {
- dev->close_part(dcr); /* make sure closed for rename */
+ if (relabel && !dev->is_tape()) {
+ dev->close_part(dcr); /* make sure DVD/file closed for rename */
}
/* Set the new filename for open, ... */
}
Dmsg1(150, "Label type=%d\n", dev->label_type);
if (!dev->rewind(dcr)) {
- free_volume(dev);
- memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
+ dev->clear_volhdr();
Dmsg2(30, "Bad status on %s from rewind: ERR=%s\n", dev->print_name(), dev->print_errmsg());
if (!forge_on) {
goto bail_out;
if (debug_level >= 20) {
dump_volume_label(dev);
}
- new_volume(dcr, VolName);
+ if (reserve_volume(dcr, VolName) == NULL) {
+ Mmsg2(dcr->jcr->errmsg, _("Could not reserve volume %s on %s\n"),
+ dev->VolHdr.VolumeName, dev->print_name());
+ goto bail_out;
+ }
+
dev->clear_append(); /* remove append since this is PRE_LABEL */
return true;
bail_out:
- free_volume(dev);
- memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
+ dev->clear_volhdr();
dev->clear_append(); /* remove append since this is PRE_LABEL */
return false;
}
ASSERT(dev != NULL);
- free_volume(dev); /* release any old volume */
- memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
+ dev->clear_volhdr(); /* release any old volume */
bstrncpy(dev->VolHdr.Id, BaculaId, sizeof(dev->VolHdr.Id));
dev->VolHdr.VerNum = BaculaTapeVersion;