]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/dev.c
Use rentrant mysql lib, eliminate race in sql_list, Win32 streams, misc see kes-1.31
[bacula/bacula] / bacula / src / stored / dev.c
index 11a9cd3fd3b8c512b71c754598a57c065b294bb7..a6c3bee4fdb06e77e6368100c115add99f69ed27 100644 (file)
@@ -146,8 +146,6 @@ init_dev(DEVICE *dev, DEVRES *device)
    dev->capabilities = device->cap_bits;
    dev->min_block_size = device->min_block_size;
    dev->max_block_size = device->max_block_size;
-   dev->max_volume_jobs = device->max_volume_jobs;
-   dev->max_volume_files = device->max_volume_files;
    dev->max_volume_size = device->max_volume_size;
    dev->max_file_size = device->max_file_size;
    dev->volume_capacity = device->volume_capacity;
@@ -260,7 +258,7 @@ open_dev(DEVICE *dev, char *VolName, int mode)
         }
         if (errno == EBUSY && timeout-- > 0) {
             Dmsg2(100, "Device %s busy. ERR=%s\n", dev->dev_name, strerror(errno));
-           sleep(1);
+           bmicrosleep(1, 0);
            continue;
         }
         dev->dev_errno = errno;
@@ -288,7 +286,7 @@ open_dev(DEVICE *dev, char *VolName, int mode)
       Dmsg1(29, "open_dev: tape %d opened\n", dev->fd);
    } else {
       /*
-       * Handle opening of file
+       * Handle opening of File Archive (not a tape)
        */
       archive_name = get_pool_memory(PM_FNAME);
       pm_strcpy(&archive_name, dev->dev_name);
@@ -359,7 +357,7 @@ int rewind_dev(DEVICE *dev)
            clrerror_dev(dev, MTREW);
            if (dev->dev_errno == EIO && i > 0) {
                Dmsg0(200, "Sleeping 5 seconds.\n");
-              sleep(5);
+              bmicrosleep(5, 0);
               continue;
            }
             Mmsg2(&dev->errmsg, _("Rewind error on %s. ERR=%s.\n"),
@@ -412,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;
@@ -436,6 +435,9 @@ eod_dev(DEVICE *dev)
     * Rewind then use FSF until EOT reached
     */
    } else {
+#else
+   {
+#endif
       if (!rewind_dev(dev)) {
         return 0;
       }
@@ -487,7 +489,7 @@ int update_pos_dev(DEVICE *dev)
       dev->file_addr = 0;
       pos = lseek(dev->fd, (off_t)0, SEEK_CUR);
       if (pos < 0) {
-         Dmsg1(000, "Seek error: ERR=%s\n", strerror(dev->dev_errno));
+         Pmsg1(000, "Seek error: ERR=%s\n", strerror(dev->dev_errno));
         dev->dev_errno = errno;
          Mmsg2(&dev->errmsg, _("lseek error on %s. ERR=%s.\n"),
            dev->dev_name, strerror(dev->dev_errno));
@@ -518,15 +520,15 @@ status_dev(DEVICE *dev, uint32_t *status)
    uint32_t stat = 0;
 
    if (dev->state & (ST_EOT | ST_WEOT)) {
-      stat |= MT_EOD;
+      stat |= BMT_EOD;
       Dmsg0(-20, " EOD");
    }
    if (dev->state & ST_EOF) {
-      stat |= MT_EOF;
+      stat |= BMT_EOF;
       Dmsg0(-20, " EOF");
    }
    if (dev->state & ST_TAPE) {
-      stat |= MT_TAPE;
+      stat |= BMT_TAPE;
       Dmsg0(-20," Driver status:");
       Dmsg2(-20," file=%d block=%d\n", dev->file, dev->block_num);
       if (ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) < 0) {
@@ -539,45 +541,45 @@ status_dev(DEVICE *dev, uint32_t *status)
 
 #if defined(HAVE_LINUX_OS)
       if (GMT_EOF(mt_stat.mt_gstat)) {
-        stat |= MT_EOF;
+        stat |= BMT_EOF;
          Dmsg0(-20, " EOF");
       }
       if (GMT_BOT(mt_stat.mt_gstat)) {
-        stat |= MT_BOT;
+        stat |= BMT_BOT;
          Dmsg0(-20, " BOT");
       }
       if (GMT_EOT(mt_stat.mt_gstat)) {
-        stat |= MT_EOT;
+        stat |= BMT_EOT;
          Dmsg0(-20, " EOT");
       }
       if (GMT_SM(mt_stat.mt_gstat)) {
-        stat |= MT_SM;
+        stat |= BMT_SM;
          Dmsg0(-20, " SM");
       }
       if (GMT_EOD(mt_stat.mt_gstat)) {
-        stat |= MT_EOD;
+        stat |= BMT_EOD;
          Dmsg0(-20, " EOD");
       }
       if (GMT_WR_PROT(mt_stat.mt_gstat)) {
-        stat |= MT_WR_PROT;
+        stat |= BMT_WR_PROT;
          Dmsg0(-20, " WR_PROT");
       }
       if (GMT_ONLINE(mt_stat.mt_gstat)) {
-        stat |= MT_ONLINE;
+        stat |= BMT_ONLINE;
          Dmsg0(-20, " ONLINE");
       }
       if (GMT_DR_OPEN(mt_stat.mt_gstat)) {
-        stat |= MT_DR_OPEN;
+        stat |= BMT_DR_OPEN;
          Dmsg0(-20, " DR_OPEN");       
       }
       if (GMT_IM_REP_EN(mt_stat.mt_gstat)) {
-        stat |= MT_IM_REP_EN;
+        stat |= BMT_IM_REP_EN;
          Dmsg0(-20, " IM_REP_EN");
       }
 #endif /* !SunOS && !OSF */
       Dmsg2(-20, " file=%d block=%d\n", mt_stat.mt_fileno, mt_stat.mt_blkno);
    } else {
-      stat |= MT_ONLINE | MT_BOT;
+      stat |= BMT_ONLINE | BMT_BOT;
    }
    *status = stat; 
    return 1;
@@ -745,7 +747,7 @@ fsf_dev(DEVICE *dev, int num)
            dev->state &= ~(ST_EOF|ST_EOT);
         }
 
-         Dmsg0(200, "Doing MT_FSF\n");
+         Dmsg0(200, "Doing MTFSF\n");
         stat = ioctl(dev->fd, MTIOCTOP, (char *)&mt_com);
         if (stat < 0) {                 /* error => EOT */
            dev->state |= ST_EOT;
@@ -753,7 +755,7 @@ fsf_dev(DEVICE *dev, int num)
            clrerror_dev(dev, MTFSF);
             Mmsg2(&dev->errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"),
               dev->dev_name, strerror(dev->dev_errno));
-            Dmsg0(200, "Got < 0 for MT_FSF\n");
+            Dmsg0(200, "Got < 0 for MTFSF\n");
             Dmsg1(200, "%s", dev->errmsg);
         } else {
            dev->state |= ST_EOF;     /* just read EOF */
@@ -982,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 */