]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/device.c
- Change Developers to Developer's Guide as requested by Michael.
[bacula/bacula] / bacula / src / stored / device.c
index b14f64c125e279ca68ba70d9e193cf1918c91c88..2807a97404bcb69ec4a9139dcba20f6a6dbc1df3 100644 (file)
@@ -29,7 +29,7 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000-2004 Kern Sibbald and John Walker
+   Copyright (C) 2000-2005 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -276,7 +276,7 @@ bool first_open_device(DEVICE *dev)
       return true;
    }
 
-   if (!(dev->state & ST_OPENED)) {
+   if (!dev->is_open()) {
        int mode;
        if (dev_cap(dev, CAP_STREAM)) {
          mode = OPEN_WRITE_ONLY;
@@ -285,7 +285,7 @@ bool first_open_device(DEVICE *dev)
        }
       Dmsg0(129, "Opening device.\n");
       if (open_dev(dev, NULL, mode) < 0) {
-        Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg);
+         Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg);
         unlock_device(dev);
         return false;
       }
@@ -303,21 +303,23 @@ bool open_device(DCR *dcr)
 {
    DEVICE *dev = dcr->dev;
    /* Open device */
-   if  (!(dev_state(dev, ST_OPENED))) {
-       int mode;
-       if (dev_cap(dev, CAP_STREAM)) {
-         mode = OPEN_WRITE_ONLY;
-       } else {
-         mode = OPEN_READ_WRITE;
-       }
-       if (open_dev(dev, dcr->VolCatInfo.VolCatName, mode) < 0) {
-         /* If polling, ignore the error */
-         if (!dev->poll) {
-            Jmsg2(dcr->jcr, M_FATAL, 0, _("Unable to open device %s. ERR=%s\n"),
-               dev_name(dev), strerror_dev(dev));
-         }
-         return false;
-       }
+   if  (!dev->is_open()) {
+      int mode;
+      if (dev_cap(dev, CAP_STREAM)) {
+        mode = OPEN_WRITE_ONLY;
+      } else {
+        mode = OPEN_READ_WRITE;
+      }
+      if (open_dev(dev, dcr->VolCatInfo.VolCatName, mode) < 0) {
+        /* If polling, ignore the error */
+        if (!dev->poll) {
+            Jmsg2(dcr->jcr, M_FATAL, 0, _("Unable to open archive %s. ERR=%s\n"),
+              dev_name(dev), strerror_dev(dev));
+            Pmsg2(000, "Unable to open archive %s. ERR=%s\n", 
+              dev_name(dev), strerror_dev(dev));
+        }
+        return false;
+      }
    }
    return true;
 }
@@ -353,7 +355,7 @@ void _lock_device(const char *file, int line, DEVICE *dev)
       while (dev->dev_blocked) {
         if ((stat = pthread_cond_wait(&dev->wait, &dev->mutex)) != 0) {
            V(dev->mutex);
-           Emsg1(M_ABORT, 0, _("pthread_cond_wait failure. ERR=%s\n"),
+            Emsg1(M_ABORT, 0, _("pthread_cond_wait failure. ERR=%s\n"),
               strerror(stat));
         }
       }