This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
- version 2 as ammended with additional clauses defined in the
+ version 2 as amended with additional clauses defined in the
file LICENSE in the main source directory.
This program is distributed in the hope that it will be useful,
#include "stored.h" /* pull in Storage Deamon headers */
/* Forward referenced functions */
-static int get_autochanger_loaded_slot(DCR *dcr);
static void lock_changer(DCR *dcr);
static void unlock_changer(DCR *dcr);
* Handle autoloaders here. If we cannot autoload it, we
* will return 0 so that the sysop will be asked to load it.
*/
- if (writing && dev_cap(dev, CAP_AUTOCHANGER) && slot <= 0) {
+ if (writing && dev->is_autochanger() && slot <= 0) {
if (dir) {
return 0; /* For user, bail out right now */
}
if (loaded != slot) {
offline_or_rewind_dev(dev);
/* We are going to load a new tape, so close the device */
- force_close_dev(dev);
+ force_close_device(dev);
lock_changer(dcr);
if (loaded != 0 && loaded != -1) { /* must unload drive */
Dmsg0(400, "Doing changer unload.\n");
}
-static int get_autochanger_loaded_slot(DCR *dcr)
+/*
+ * Returns: -1 if error from changer command
+ * slot otherwise
+ */
+int get_autochanger_loaded_slot(DCR *dcr)
{
JCR *jcr = dcr->jcr;
POOLMEM *changer, *results;
int status, loaded;
uint32_t timeout = dcr->device->max_changer_wait;
- int drive = dcr->device->drive_index;
+ int drive = dcr->dev->drive_index;
results = get_pool_memory(PM_MESSAGE);
changer = get_pool_memory(PM_FNAME);
/* Find out what is loaded, zero means device is unloaded */
Jmsg(jcr, M_INFO, 0, _("3301 Issuing autochanger \"loaded drive %d\" command.\n"),
drive);
- changer = edit_device_codes(dcr, changer,
- dcr->device->changer_command, "loaded");
+ changer = edit_device_codes(dcr, changer, dcr->device->changer_command, "loaded");
+ *results = 0;
status = run_program(changer, timeout, results);
- Dmsg3(50, "run_prog: %s stat=%d result=%s", changer, status, results);
+ Dmsg3(50, "run_prog: %s stat=%d result=%s\n", changer, status, results);
if (status == 0) {
loaded = atoi(results);
if (loaded > 0) {
bool ok = false;
int stat;
- if (!dev_cap(dev, CAP_AUTOCHANGER) || !dcr->device->changer_name ||
+ if (!dev->is_autochanger() || !dcr->device->changer_name ||
!dcr->device->changer_command) {
bnet_fsend(dir, _("3993 Device %s not an autochanger device.\n"),
dev->print_name());
/* Yes, to get a good listing, we unload any volumes */
offline_or_rewind_dev(dev);
/* We are going to load a new tape, so close the device */
- force_close_dev(dev);
+ force_close_device(dev);
/* First unload any tape */
loaded = get_autochanger_loaded_slot(dcr);