Jmsg(jcr, M_INFO, 0, _("3305 Autochanger \"load slot %d, drive %d\", status is OK.\n"),
slot, drive);
Dmsg2(100, "load slot %d, drive %d, status is OK.\n", slot, drive);
- dev->Slot = slot; /* set currently loaded slot */
+ dev->set_slot(slot); /* set currently loaded slot */
} else {
berrno be;
be.set_errno(status);
"ERR=%s.\nResults=%s\n"),
slot, drive, be.bstrerror(), results.c_str());
rtn_stat = -1; /* hard error */
- dev->Slot = -1; /* mark unknown */
+ dev->set_slot(-1); /* mark unknown */
}
Dmsg2(100, "load slot %d status=%d\n", slot, status);
unlock_changer(dcr);
} else {
status = 0; /* we got what we want */
- dev->Slot = slot; /* set currently loaded slot */
+ dev->set_slot(slot); /* set currently loaded slot */
}
Dmsg1(100, "After changer, status=%d\n", status);
if (status == 0) { /* did we succeed? */
// Jmsg(jcr, M_FATAL, 0, _("3992 Missing Changer command.\n"));
return -1;
}
- if (dev->Slot > 0) {
- return dev->Slot;
+ if (dev->get_slot() > 0) {
+ return dev->get_slot();
}
/* Virtual disk autochanger */
if (dcr->device->changer_command[0] == 0) {
if (loaded > 0) {
Jmsg(jcr, M_INFO, 0, _("3302 Autochanger \"loaded? drive %d\", result is Slot %d.\n"),
drive, loaded);
- dev->Slot = loaded;
+ dev->set_slot(loaded);
} else {
Jmsg(jcr, M_INFO, 0, _("3302 Autochanger \"loaded? drive %d\", result: nothing loaded.\n"),
drive);
- dev->Slot = -1; /* unknown */
+ dev->clear_slot(); /* unknown */
}
} else {
berrno be;
"ERR=%s\nResults=%s\n"),
loaded, dev->drive_index, be.bstrerror(), results.c_str());
ok = false;
- dev->Slot = -1; /* unknown */
+ dev->clear_slot(); /* unknown */
} else {
- dev->Slot = 0; /* nothing loaded */
+ dev->set_slot(0); /* nothing loaded */
}
unlock_changer(dcr);
}
foreach_alist(device, changer->device) {
- if (device->dev && device->dev->Slot == slot) {
+ if (device->dev && device->dev->get_slot() == slot) {
found = true;
dev = device->dev;
break;
Jmsg(dcr->jcr, M_WARNING, 0, _("Volume \"%s\" is in use by device %s\n"),
dcr->VolumeName, dev->print_name());
Dmsg4(100, "Vol %s for dev=%s is busy dev=%s slot=%d\n",
- dcr->VolumeName, dcr->dev->print_name(), dev->print_name(), dev->Slot);
+ dcr->VolumeName, dcr->dev->print_name(), dev->print_name(), dev->get_slot());
Dmsg2(100, "num_writ=%d reserv=%d\n", dev->num_writers, dev->num_reserved());
return false;
}
DEVICE *save_dev;
int save_slot;
- if (!changer || dev->Slot <= 0) {
+ if (!changer || dev->get_slot() <= 0) {
return false;
}
dev->dlock();
lock_changer(dcr);
Jmsg(jcr, M_INFO, 0,
_("3307 Issuing autochanger \"unload slot %d, drive %d\" command.\n"),
- dev->Slot, dev->drive_index);
+ dev->get_slot(), dev->drive_index);
Dmsg2(100, "Issuing autochanger \"unload slot %d, drive %d\" command.\n",
- dev->Slot, dev->drive_index);
+ dev->get_slot(), dev->drive_index);
save_dev = dcr->dev;
dcr->dev = dev;
save_slot = dcr->VolCatInfo.Slot;
- dcr->VolCatInfo.Slot = dev->Slot;
+ dcr->VolCatInfo.Slot = dev->get_slot();
changer_cmd = edit_device_codes(dcr, changer_cmd,
dcr->device->changer_command, "unload");
dev->close();
berrno be;
be.set_errno(stat);
Jmsg(jcr, M_INFO, 0, _("3995 Bad autochanger \"unload slot %d, drive %d\": ERR=%s.\n"),
- dev->Slot, dev->drive_index, be.bstrerror());
+ dev->get_slot(), dev->drive_index, be.bstrerror());
Dmsg3(100, "Bad autochanger \"unload slot %d, drive %d\": ERR=%s.\n",
- dev->Slot, dev->drive_index, be.bstrerror());
+ dev->get_slot(), dev->drive_index, be.bstrerror());
ok = false;
- dev->Slot = -1; /* unknown */
+ dev->clear_slot(); /* unknown */
} else {
- Dmsg2(100, "Slot %d unloaded %s\n", dev->Slot, dev->print_name());
- dev->Slot = 0; /* nothing loaded */
+ Dmsg2(100, "Slot %d unloaded %s\n", dev->get_slot(), dev->print_name());
+ dev->set_slot(0); /* nothing loaded */
}
dev->clear_unload();
unlock_changer(dcr);
dev = (DEVICE *)malloc(sizeof(DEVICE));
memset(dev, 0, sizeof(DEVICE));
- dev->Slot = -1; /* unknown */
+ dev->clear_slot(); /* unknown */
/* Copy user supplied device parameters from Resource */
dev->dev_name = get_memory(strlen(device->device_name)+1);
Dmsg4(100, "open dev: type=%d dev_name=%s vol=%s mode=%s\n", dev_type,
print_name(), VolCatInfo.VolCatName, mode_to_str(omode));
state &= ~(ST_LABEL|ST_APPEND|ST_READ|ST_EOT|ST_WEOT|ST_EOF);
- Slot = -1; /* unknown slot */
label_type = B_BACULA_LABEL;
if (is_tape() || is_fifo()) {
open_tape_device(dcr, omode);
tape_ioctl(m_fd, MTIOCTOP, (char *)&mt_com);
#endif
}
+
+void DEVICE::set_slot(int32_t slot)
+{
+ m_slot = slot;
+ if (vol) vol->clear_slot();
+}
+
+void DEVICE::clear_slot()
+{
+ m_slot = -1;
+ if (vol) vol->set_slot(-1);
+}
+
/*
file_addr = 0;
EndFile = EndBlock = 0;
openmode = 0;
- Slot = -1; /* unknown slot */
clear_volhdr();
memset(&VolCatInfo, 0, sizeof(VolCatInfo));
if (tid) {
class DEVRES; /* Device resource defined in stored_conf.h */
-
class DCR; /* forward reference */
class VOLRES; /* forward reference */
-
/*
* Device structure definition. There is one of these for
* each physical device. Everything here is "global" to
bool m_unload; /* set when Volume must be unloaded */
bool m_load; /* set when Volume must be loaded */
int m_num_reserved; /* counter of device reservations */
+ int32_t m_slot; /* slot loaded in drive or -1 if none */
+
public:
DEVICE * volatile swap_dev; /* Swap vol from this device */
dlist *attached_dcrs; /* attached DCR list */
bool initiated; /* set when init_dev() called */
int label_type; /* Bacula/ANSI/IBM label types */
uint32_t drive_index; /* Autochanger drive index (base 0) */
- int32_t Slot; /* Slot currently in drive (base 1) */
POOLMEM *dev_name; /* Physical device name */
POOLMEM *prt_name; /* Name used for display purposes */
char *errmsg; /* nicely edited error message */
void clear_load() { m_load = false; };
char *bstrerror(void) { return errmsg; };
char *print_errmsg() { return errmsg; };
+ int32_t get_slot() const { return m_slot; };
void clear_volhdr(); /* in dev.c */
void clrerror(int func); /* in dev.c */
boffset_t lseek(DCR *dcr, boffset_t offset, int whence); /* in dev.c */
bool update_pos(DCR *dcr); /* in dev.c */
+ void set_slot(int32_t slot); /* in dev.c */
+ void clear_slot(); /* in dev.c */
+
+
bool update_freespace(); /* in dvd.c */
uint32_t get_file() const { return file; };
void set_in_use() { m_in_use = true; };
void clear_in_use() { m_in_use = false; };
void set_slot(int32_t slot) { m_slot = slot; };
+ void clear_slot() { m_slot = -1; };
int32_t get_slot() const { return m_slot; };
};