X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fstored%2Flabel.c;h=e7fb9ee89f2b1cf90e90988728dcd3d9b14d067b;hb=37190d54ceff7f2b45a58a1c6241688cc5cba1c2;hp=063375c54838c6d47981b59994ecf2d8003ac7b2;hpb=abef8271979074d70e8c67a3591d0ce69e8425f2;p=bacula%2Fbacula diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index 063375c548..e7fb9ee89f 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -1,16 +1,7 @@ -/* - * - * 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. @@ -34,6 +25,15 @@ (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 */ @@ -213,7 +213,12 @@ int read_dev_volume_label(DCR *dcr) } 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); @@ -316,8 +321,8 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, 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, ... */ @@ -393,7 +398,12 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, 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;