]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/dev.c
Add Bytes/Blocks read by SD during restore
[bacula/bacula] / bacula / src / stored / dev.c
index 5bccfb6f826872f0d344c889fa64341595e2781c..98eada35dc8e7caea1cac003c8a7489540073d23 100644 (file)
@@ -410,6 +410,7 @@ eod_dev(DEVICE *dev)
       }
       return 0;
    }
+#ifdef MTEOM
    if (dev_cap(dev, CAP_EOM)) {
       mt_com.mt_op = MTEOM;
       mt_com.mt_count = 1;
@@ -434,6 +435,9 @@ eod_dev(DEVICE *dev)
     * Rewind then use FSF until EOT reached
     */
    } else {
+#else
+   {
+#endif
       if (!rewind_dev(dev)) {
         return 0;
       }
@@ -980,10 +984,12 @@ clrerror_dev(DEVICE *dev, int func)
             msg = "WTWEOF";
            dev->capabilities &= ~CAP_EOF; /* turn off feature */
            break;
+#ifdef MTEOM
         case MTEOM:
             msg = "WTEOM";
            dev->capabilities &= ~CAP_EOM; /* turn off feature */
            break;
+#endif 
         case MTFSF:
             msg = "MTFSF";
            dev->capabilities &= ~CAP_FSF; /* turn off feature */
@@ -1010,16 +1016,26 @@ clrerror_dev(DEVICE *dev, int func)
         Emsg0(M_ERROR, 0, dev->errmsg);
       }
    }
+/* Found on Linux */
 #ifdef MTIOCLRERR
 {
    struct mtop mt_com;
-   int stat;
    mt_com.mt_op = MTIOCLRERR;
    mt_com.mt_count = 1;
-   stat = ioctl(dev->fd, MTIOCTOP, (char *)&mt_com);
+   /* Clear any error condition on the tape */
+   ioctl(dev->fd, MTIOCTOP, (char *)&mt_com);
    Dmsg0(200, "Did MTIOCLRERR\n");
 }
 #endif
+
+/* Typically on FreeBSD */
+#ifdef MTIOCERRSTAT
+{
+   /* Read and clear SCSI error status */
+   union mterrstat mt_errstat;
+   ioctl(dev->fd, MTIOCERRSTAT, (char *)&mt_errstat);
+}
+#endif
 }
 
 /*
@@ -1102,6 +1118,24 @@ dev_is_tape(DEVICE *dev)
    return (dev->state & ST_TAPE) ? 1 : 0;
 }
 
+
+/*
+ * return 1 if the device is read for write, and 0 otherwise
+ *   This is meant for checking at the end of a job to see
+ *   if we still have a tape (perhaps not if at end of tape
+ *   and the job is canceled).
+ */
+int
+dev_can_write(DEVICE *dev)
+{
+   if ((dev->state & ST_OPENED) &&  (dev->state & ST_APPEND) &&
+       (dev->state & ST_LABEL) && !(dev->state & ST_WEOT)) {
+      return 1;
+   } else {
+      return 0;
+   }
+}
+
 char *
 dev_name(DEVICE *dev)
 {