]> git.sur5r.net Git - bacula/bacula/commitdiff
- Ensure that the drive is closed before calling the
authorKern Sibbald <kern@sibbald.com>
Wed, 24 Aug 2005 16:29:01 +0000 (16:29 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 24 Aug 2005 16:29:01 +0000 (16:29 +0000)
  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

bacula/kes-1.37
bacula/src/stored/autochanger.c
bacula/src/stored/dev.c
bacula/src/stored/device.c

index bd469e473cd8cadc92a140690c7a04c71f458120..d3e99bbfe6541e6d561d97d0bac4ddb2c8e096f3 100644 (file)
@@ -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
index 7eb129d851f67503497085d2c92bd7bd609ef521..a87840e1e0224e4811c51e9112824e0daaf113f1 100644 (file)
@@ -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);
index ed9b006b9315fa714d05f78c4643b663ebdfb710..43b6456aa51175dc20714a4529ececf7c0e25e3d 100644 (file)
@@ -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 */
index 5a59c9468831d0067b2fb56213162a0a117b481b..6a2f584ccc8ed262f67c42306ed6125c570ce481 100644 (file)
@@ -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());