]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/device.c
- Fix ANSI labels to put EOF1 and EOF2 after each file mark.
[bacula/bacula] / bacula / src / stored / device.c
index b14f64c125e279ca68ba70d9e193cf1918c91c88..d6bdf470cfc35b373104da8fbe5446eb43ce020e 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
@@ -134,7 +134,7 @@ bool fixup_device_block_write_error(DCR *dcr)
    P(dev->mutex);                 /* lock again */
 
    Jmsg(jcr, M_INFO, 0, _("New volume \"%s\" mounted on device %s at %s.\n"),
-      dcr->VolumeName, dev_name(dev), bstrftime(dt, sizeof(dt), time(NULL)));
+      dcr->VolumeName, dev->print_name(), bstrftime(dt, sizeof(dt), time(NULL)));
 
    /*
     * If this is a new tape, the label_blk will contain the
@@ -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,12 +285,12 @@ 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;
       }
    }
-   Dmsg1(129, "open_dev %s OK\n", dev_name(dev));
+   Dmsg1(129, "open_dev %s OK\n", dev->print_name());
 
    unlock_device(dev);
    return true;
@@ -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->print_name(), strerror_dev(dev));
+            Pmsg2(000, "Unable to open archive %s: ERR=%s\n", 
+              dev->print_name(), 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));
         }
       }