#include "stored.h" /* pull in Storage Deamon headers */
/* Forward referenced functions */
-static char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd);
+char *edit_device_codes(JCR *jcr, char *omsg, const char *imsg, const char *cmd);
static int get_autochanger_loaded_slot(JCR *jcr);
}
if (dir_find_next_appendable_volume(jcr)) {
slot = jcr->VolCatInfo.Slot;
+ } else {
+ slot = 0;
}
}
Dmsg1(400, "Want changer slot=%d\n", slot);
if (slot > 0 && jcr->device->changer_name && jcr->device->changer_command) {
uint32_t timeout = jcr->device->max_changer_wait;
- POOLMEM *changer, *results;
+ POOLMEM *changer;
int loaded, status;
- results = get_pool_memory(PM_MESSAGE);
changer = get_pool_memory(PM_FNAME);
loaded = get_autochanger_loaded_slot(jcr);
- Dmsg1(400, "loaded=%s\n", results);
-
/* If tape we want is not loaded, load it. */
if (loaded != slot) {
offline_or_rewind_dev(dev);
/* We are going to load a new tape, so close the device */
force_close_dev(dev);
- if (loaded != 0) { /* must unload drive */
+ if (loaded != 0 && loaded != -1) { /* must unload drive */
Dmsg0(400, "Doing changer unload.\n");
Jmsg(jcr, M_INFO, 0,
_("3303 Issuing autochanger \"unload slot %d, drive %d\" command.\n"),
status = 0; /* we got what we want */
}
free_pool_memory(changer);
- free_pool_memory(results);
Dmsg1(400, "After changer, status=%d\n", status);
if (status == 0) { /* did we succeed? */
rtn_stat = 1; /* tape loaded by changer */
* cmd = command string (load, unload, ...)
*
*/
-static char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd)
+char *edit_device_codes(JCR *jcr, char *omsg, const char *imsg, const char *cmd)
{
- char *p;
+ const char *p;
const char *str;
char add[20];