if (dev->get_slot() > 0) {
return dev->get_slot();
}
+
/* Virtual disk autochanger */
if (dcr->device->changer_command[0] == 0) {
return 1;
return unload_dev(dcr, dev);
}
+/*
+ * Unconditionally unload a specified drive
+ */
bool unload_dev(DCR *dcr, DEVICE *dev)
{
JCR *jcr = dcr->jcr;
DEVICE *save_dev;
int save_slot;
- if (!changer || dev->get_slot() <= 0) {
+ if (!changer) {
return false;
}
+
+ save_dev = dcr->dev; /* save dcr device */
+ dcr->dev = dev; /* temporarily point dcr at other device */
+ save_slot = dcr->VolCatInfo.Slot;
+
+ if (dev->get_slot() <= 0 && get_autochanger_loaded_slot(dcr) <= 0) {
+ dcr->VolCatInfo.Slot = save_slot;
+ dcr->dev = save_dev;
+ return false;
+ }
+ dcr->VolCatInfo.Slot = dev->get_slot();
+
dev->dlock();
POOLMEM *changer_cmd = get_pool_memory(PM_FNAME);
Dmsg2(100, "Issuing autochanger \"unload slot %d, drive %d\" command.\n",
dev->get_slot(), dev->drive_index);
- save_dev = dcr->dev;
- dcr->dev = dev;
- save_slot = dcr->VolCatInfo.Slot;
- dcr->VolCatInfo.Slot = dev->get_slot();
changer_cmd = edit_device_codes(dcr, changer_cmd,
dcr->device->changer_command, "unload");
dev->close();