/*
Bacula(R) - The Network Backup Solution
- Copyright (C) 2000-2015 Kern Sibbald
- Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2016 Kern Sibbald
The original author of Bacula is Kern Sibbald, with contributions
from many others, a complete list can be found in the file AUTHORS.
POOLMEM *newname, *oldname, *poolname, *mtype;
POOL_MEM dev_name;
BSOCK *dir = jcr->dir_bsock;
- DCR *dcr;
+ DCR *dcr = NULL;;
DEVICE *dev;
bool ok = false;
int32_t slot, drive;
unbash_spaces(mtype);
dcr = find_device(jcr, dev_name, mtype, drive);
if (dcr) {
+ uint32_t max_jobs;
dev = dcr->dev;
+ ok = true;
dev->Lock(); /* Use P to avoid indefinite block */
+ max_jobs = dev->max_concurrent_jobs;
+ dev->max_concurrent_jobs = 1;
+ bstrncpy(dcr->VolumeName, newname, sizeof(dcr->VolumeName));
+ if (dcr->can_i_write_volume()) {
+ if (reserve_volume(dcr, newname) == NULL) {
+ ok = false;
+ }
+ Dmsg1(000, "Reserved volume \"%s\"\n", newname);
+ } else {
+ ok = false;
+ }
+ if (!ok) {
+ Dmsg2(000, "Reserve error on volume \"%s\": ERR=%s\n", newname, jcr->errmsg);
+ dir->fsend(_("3908 Error reserving volume: %s\n"), jcr->errmsg);
+ dev->max_concurrent_jobs = max_jobs;
+ dev->Unlock();
+ goto bail_out;
+ }
if (!dev->is_open() && !dev->is_busy()) {
Dmsg1(400, "Can %slabel. Device is not open\n", relabel?"re":"");
label_volume_if_ok(dcr, oldname, newname, poolname, slot, relabel);
Dmsg0(400, "Can relabel. device not used\n");
label_volume_if_ok(dcr, oldname, newname, poolname, slot, relabel);
}
+ dev->max_concurrent_jobs = max_jobs;
+ volume_unused(dcr);
dev->Unlock();
- free_dcr(dcr);
} else {
dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), dev_name.c_str());
}
pm_strcpy(jcr->errmsg, dir->msg);
dir->fsend(_("3903 Error scanning label command: %s\n"), jcr->errmsg);
}
+bail_out:
+ if (dcr) {
+ free_dcr(dcr);
+ }
free_memory(oldname);
free_memory(newname);
free_memory(poolname);