From a34d88f3992bcff8c34859f264c81b8df5652927 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 3 Aug 2005 11:35:29 +0000 Subject: [PATCH] - Require 5 arguments to mtx-changer except list and slots - Turn -EPIPE status returns from bpipe to ETIME - Include Slot in SD status output - Do not term_dev() during initialization in SD if the device could not be opened. In the case of a tape drive, there may be no tape in the drive. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2281 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 5 +++++ bacula/kes-1.37 | 7 +++++++ bacula/scripts/mtx-changer.in | 20 +++----------------- bacula/src/lib/bpipe.c | 4 ++-- bacula/src/lib/lex.c | 2 +- bacula/src/stored/autochanger.c | 15 +++++++++------ bacula/src/stored/protos.h | 1 + bacula/src/stored/reserve.c | 3 ++- bacula/src/stored/status.c | 15 ++++++++++++++- bacula/src/stored/stored.c | 7 +++++++ bacula/src/version.h | 6 +++--- 11 files changed, 54 insertions(+), 31 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index dce48aaf18..b8da8d6a10 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -11,6 +11,11 @@ Final items for 1.37 before release: 1. Fix bugs - Tape xxx in drive 0, requested in drive 1 - Multi-drive changer seems to only use drive 0 + Multiple drives don't seem to be opened. +- Why isn't the DEVICE structure defined when doing + a reservation? +- The mount command does not work with drives other than 0. + - --without-openssl breaks at least on Solaris. 9. Run the regression scripts on Solaris and FreeBSD - Figure out how to package gui, and rescue programs. diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index aae0dcd007..e8a4053796 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -4,6 +4,13 @@ General: Changes to 1.37.32: +03Aug03 +- Require 5 arguments to mtx-changer except list and slots +- Turn -EPIPE status returns from bpipe to ETIME +- Include Slot in SD status output +- Do not term_dev() during initialization in SD if the device + could not be opened. In the case of a tape drive, there may + be no tape in the drive. 02Aug05 - Correct PostgreSQL database scripts as suggested by a user. - Add additional info to FATAL message generated when a device diff --git a/bacula/scripts/mtx-changer.in b/bacula/scripts/mtx-changer.in index e390913b50..ae27f52291 100644 --- a/bacula/scripts/mtx-changer.in +++ b/bacula/scripts/mtx-changer.in @@ -72,30 +72,20 @@ ctl=$1 cmd="$2" slot=$3 device=$4 -# If drive not given, default to 0 -if test $# = 5 ; then - drive=$5 -else - drive=0 -fi +drive=$5 # # Check for special cases where only 2 arguments are needed, # all others are a minimum of 3 case $cmd in - loaded) - ;; - unload) - ;; list) ;; slots) ;; *) - if test $# -lt 3; then + if test $# -lt 5; then echo "usage: mtx-changer ctl-device command slot archive-device drive" echo " Insufficient number of arguments arguments given." - echo " Mimimum usage is first three arguments ..." exit 1 fi ;; @@ -108,11 +98,7 @@ case $cmd in # # enable the following line if you need to eject the cartridge # mt -f $device offline - if test x$slot = x; then - ${MTX} -f $ctl unload - else - ${MTX} -f $ctl unload $slot $drive - fi + ${MTX} -f $ctl unload $slot $drive ;; load) diff --git a/bacula/src/lib/bpipe.c b/bacula/src/lib/bpipe.c index f2e4dd77fe..03b7e35017 100644 --- a/bacula/src/lib/bpipe.c +++ b/bacula/src/lib/bpipe.c @@ -278,7 +278,7 @@ int run_program(char *prog, int wait, POOLMEM *results) * following lines run_program would not detect if the program was killed * by the watchdog. */ if (bpipe->timer_id->killed) { - stat1 = -EPIPE; + stat1 = ETIME; pm_strcat(results, "Program killed by Bacula watchdog (timeout)\n"); } } @@ -355,7 +355,7 @@ int run_program_full_output(char *prog, int wait, POOLMEM *results) Dmsg1(100, "Run program fgets killed=%d\n", bpipe->timer_id->killed); if (bpipe->timer_id->killed) { pm_strcat(tmp, "Program killed by Bacula watchdog (timeout)\n"); - stat1 = -EPIPE; + stat1 = ETIME; break; } } diff --git a/bacula/src/lib/lex.c b/bacula/src/lib/lex.c index fdeb700ec4..01ab91ad60 100644 --- a/bacula/src/lib/lex.c +++ b/bacula/src/lib/lex.c @@ -190,7 +190,7 @@ int lex_get_char(LEX *lf) } lf->line_no++; lf->col_no = 0; - Dmsg2(400, "fget line=%d %s", lf->line_no, lf->line); + Dmsg2(1000, "fget line=%d %s", lf->line_no, lf->line); } lf->ch = (uint8_t)lf->line[lf->col_no]; if (lf->ch == 0) { diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index fcb0828d55..f7b9619bcc 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -25,7 +25,6 @@ #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); @@ -147,13 +146,17 @@ bail_out: } -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); @@ -163,10 +166,10 @@ static int get_autochanger_loaded_slot(DCR *dcr) /* 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) { diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index d35e52a958..a7f4044091 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -52,6 +52,7 @@ int authenticate_filed(JCR *jcr); int autoload_device(DCR *dcr, int writing, BSOCK *dir); bool autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd); char *edit_device_codes(DCR *dcr, char *omsg, const char *imsg, const char *cmd); +int get_autochanger_loaded_slot(DCR *dcr); /* From block.c */ void dump_block(DEV_BLOCK *b, const char *msg); diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 4dc22f1c4c..fdaae01386 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -251,11 +251,12 @@ static bool use_storage_cmd(JCR *jcr) int Copy, Stripe; DIRSTORE *store; RCTX rctx; - rctx.jcr = jcr; #ifdef implemented char *error; #endif + memset(&rctx, 0, sizeof(RCTX)); + rctx.jcr = jcr; /* * If there are multiple devices, the director sends us * use_device for each device that it wants to use. diff --git a/bacula/src/stored/status.c b/bacula/src/stored/status.c index fb20e70cba..9579d926c5 100644 --- a/bacula/src/stored/status.c +++ b/bacula/src/stored/status.c @@ -143,7 +143,11 @@ bool status_cmd(JCR *jcr) edit_uint64_with_commas(dev->block_num, b2)); } else { - bnet_fsend(user, _("Archive \"%s\" is not open or does not exist.\n"), device->hdr.name); + if (dev) { + bnet_fsend(user, _("Device %s is not open or does not exist.\n"), dev->print_name()); + } else { + bnet_fsend(user, _("Device \"%s\" is not open or does not exist.\n"), device->hdr.name); + } send_blocked_status(jcr, dev); } } @@ -199,6 +203,15 @@ static void send_blocked_status(JCR *jcr, DEVICE *dev) default: break; } + /* Send autochanger slot status */ + if (dev->is_autochanger()) { + if (dev->Slot) { + bnet_fsend(user, _(" Slot %d is loaded in drive %d.\n"), + dev->Slot, dev->drive_index); + } else { + bnet_fsend(user, _(" Drive %d is not loaded.\n"), dev->drive_index); + } + } if (debug_level > 1) { bnet_fsend(user, _("Configured device capabilities:\n")); bnet_fsend(user, "%sEOF ", dev->capabilities & CAP_EOF ? "" : "!"); diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index 508b0abe45..4171439121 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -495,14 +495,21 @@ void *device_initialization(void *arg) } dcr = new_dcr(jcr, dev); + if (dev->is_autochanger()) { + /* If autochanger set slot in dev sturcture */ + get_autochanger_loaded_slot(dcr); + } if (device->cap_bits & CAP_ALWAYSOPEN) { Dmsg1(20, "calling first_open_device %s\n", dev->print_name()); if (!first_open_device(dcr)) { Jmsg1(NULL, M_ERROR, 0, _("Could not open device %s\n"), dev->print_name()); Dmsg1(20, "Could not open device %s\n", dev->print_name()); + +#ifdef xxx term_dev(dev); device->dev = NULL; +#endif free_dcr(dcr); continue; } diff --git a/bacula/src/version.h b/bacula/src/version.h index d3afab70de..f6a1bb755e 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION -#define VERSION "1.37.32" -#define BDATE "30 July 2005" -#define LSMDATE "30Jul05" +#define VERSION "1.37.33" +#define BDATE "03 August 2005" +#define LSMDATE "03Aug05" /* Debug flags */ #undef DEBUG -- 2.39.5