From: Kern Sibbald Date: Wed, 24 Aug 2005 16:29:01 +0000 (+0000) Subject: - Ensure that the drive is closed before calling the X-Git-Tag: Release-1.38.0~149 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d50591d2cdc827a2f52ced4055b7841339ee74bf;p=bacula%2Fbacula - Ensure that the drive is closed before calling the mtx-changer script so that the script can access the drive. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2355 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index bd469e473c..d3e99bbfe6 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -5,6 +5,8 @@ General: Changes to 1.37.37: 24Aug05 +- Ensure that the drive is closed before calling the + mtx-changer script so that the script can access the drive. - Add drive name to reserved Volume list printout in SD. 23Aug05 - Fix bug in acquire.c that incorrectly reported volume diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index 7eb129d851..a87840e1e0 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -87,6 +87,10 @@ int autoload_device(DCR *dcr, int writing, BSOCK *dir) goto bail_out; } + /* We are going to load a new tape, so close the device */ + offline_or_rewind_dev(dev); + force_close_device(dev); + /* * Load the desired cassette */ @@ -221,8 +225,8 @@ bool unload_autochanger(DCR *dcr, int loaded) return false; } - offline_or_rewind_dev(dev); /* We are going to load a new tape, so close the device */ + offline_or_rewind_dev(dev); force_close_device(dev); if (loaded < 0) { @@ -276,7 +280,7 @@ static bool unload_other_drive(DCR *dcr, int slot) if (changer->device->size() == 1) { return true; } - + foreach_alist(device, changer->device) { if (device->dev && device->dev->Slot == slot) { found = true; @@ -296,8 +300,8 @@ static bool unload_other_drive(DCR *dcr, int slot) return false; } + /* We are going to unload a tape, so close the device */ offline_or_rewind_dev(dev); - /* We are going to load a new tape, so close the device */ force_close_device(dev); POOLMEM *changer_cmd = get_pool_memory(PM_FNAME); diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index ed9b006b93..43b6456aa5 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -1088,14 +1088,8 @@ bool offline_dev(DEVICE *dev) { struct mtop mt_com; - if (dev->fd < 0) { - dev->dev_errno = EBADF; - Mmsg0(dev->errmsg, _("Bad call to offline_dev. Device not open\n")); - Emsg0(M_FATAL, 0, dev->errmsg); - return false; - } - if (!(dev->is_tape())) { - return true; + if (!dev || dev->fd < 0 || !dev->is_tape()) { + return true; /* device not open */ } dev->state &= ~(ST_APPEND|ST_READ|ST_EOT|ST_EOF|ST_WEOT); /* remove EOF/EOT flags */ diff --git a/bacula/src/stored/device.c b/bacula/src/stored/device.c index 5a59c94688..6a2f584ccc 100644 --- a/bacula/src/stored/device.c +++ b/bacula/src/stored/device.c @@ -324,9 +324,7 @@ void close_device(DEVICE *dev) */ void force_close_device(DEVICE *dev) { - if (!dev) { - Mmsg0(dev->errmsg, _("Bad call to force_close_dev. Device not open\n")); - Emsg0(M_FATAL, 0, dev->errmsg); + if (!dev || dev->fd < 0) { return; } Dmsg1(29, "Force close_dev %s\n", dev->print_name());