]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/block.c
Simplify two messages in acquire.c
[bacula/bacula] / bacula / src / stored / block.c
index 3faa66eb0c41a855dccb6ce2828b0ecbee7266ee..e21533d2cb2e7fefa353b4159ebcc9593d4738bb 100644 (file)
@@ -256,8 +256,8 @@ static int unser_block_header(DEVICE *dev, DEV_BLOCK *block)
       if (BlockCheckSum != CheckSum) {
          Dmsg2(00, "Block checksum mismatch: calc=%x blk=%x\n", BlockCheckSum,
            CheckSum);
-         Mmsg2(&dev->errmsg, _("Block checksum mismatch: calc=%x blk=%x\n"), BlockCheckSum,
-           CheckSum);
+         Mmsg3(&dev->errmsg, _("Block checksum mismatch in block %u: calc=%x blk=%x\n"), 
+           (unsigned)BlockNumber, BlockCheckSum, CheckSum);
         return 0;
       }
    }
@@ -304,6 +304,7 @@ int write_block_to_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
    /* dump_block(block, "before write"); */
    if (dev->state & ST_WEOT) {
       Dmsg0(100, "return write_block_to_dev with ST_WEOT\n");
+      Jmsg(&dev->errmsg, M_FATAL, 0,  _("Cannot write block. Device at EOF.\n"));
       return 0;
    }
    wlen = block->binbuf;
@@ -348,10 +349,10 @@ int write_block_to_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
       dev->state |= ST_WEOT;
       Dmsg0(10, "==== Output bytes Triggered medium max capacity.\n");
       if (hit_max1) {
-         Mmsg2(&dev->errmsg, _("Max. Volume capacity %s exceeded on device %s.\n"),
+         Jmsg(&dev->errmsg, M_INFO, 0, _("Max. Volume capacity %s exceeded on device %s.\n"),
            edit_uint64(dev->max_volume_size, ed1),  dev->dev_name);
       } else {
-         Mmsg2(&dev->errmsg, _("Max. Volume capacity %s exceeded on device %s.\n"),
+         Jmsg(&dev->errmsg, M_INFO, 0,  _("Max. Volume capacity %s exceeded on device %s.\n"),
            edit_uint64(dev->VolCatInfo.VolCatMaxBytes, ed1),  dev->dev_name);
       }
       block->failed_write = TRUE;
@@ -393,8 +394,13 @@ int write_block_to_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
       Dmsg4(10, "=== Write error. size=%u rtn=%d  errno=%d: ERR=%s\n", 
         wlen, stat, dev->dev_errno, strerror(dev->dev_errno));
 
-      Mmsg4(&dev->errmsg, _("Write error on device %s. Write of %u bytes got %d. ERR=%s.\n"), 
-        dev->dev_name, wlen, stat, strerror(dev->dev_errno));
+      if (stat == -1) {
+         Jmsg2(&dev->errmsg, M_ERROR, 0, _("Write error on device %s. ERR=%s.\n"), 
+           dev->dev_name, strerror(dev->dev_errno));
+      } else {
+         Jmsg3(&dev->errmsg, M_INFO, 0, _("End of media on device %s. Write of %u bytes got %d.\n"), 
+           dev->dev_name, wlen, stat);
+      }  
       block->failed_write = TRUE;
       dev->EndBlock = dev->block_num;
       dev->EndFile  = dev->file;
@@ -421,6 +427,16 @@ int write_block_to_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
         if (ok && bsr_dev(dev, 1) != 0) {
            ok = FALSE;
             Jmsg(jcr, M_ERROR, 0, _("Back space record at EOT failed. ERR=%s\n"), strerror(dev->dev_errno));
+           /* ****FIXME*****
+            *  On FreeBSD systems, if the user got here, it is likely that his/her
+             *    tape drive is "frozen".  The correct thing to do is a 
+            *    rewind(), but if we do that, higher levels in cleaning up, will
+            *    most likely write the EOS record over the beginning of the
+            *    tape.  The rewind *is* done later in mount.c when another
+            *    tape is requested. However, it should be done here. In that
+            *    case, we need to send back some fatal error status to avoid
+            *    future writes.
+            */
         }
         if (ok) {
            DEV_BLOCK *lblock = new_block(dev);
@@ -538,7 +554,7 @@ reread:
       Mmsg2(&dev->errmsg,  _("Block length %u is greater than buffer %u. Attempting recovery.\n"),
         block->block_len, block->buf_len);
       Emsg0(M_WARNING, 0, dev->errmsg);
-      Dmsg1(000, "%s", dev->errmsg);
+      Pmsg1(000, "%s", dev->errmsg);
       /* Attempt to reposition to re-read the block */
       if (dev->state & ST_TAPE) {
          Dmsg0(100, "Backspace record for reread.\n");
@@ -555,7 +571,7 @@ reread:
       }
       Mmsg1(&dev->errmsg, _("Resetting buffer size to %u bytes.\n"), block->block_len);
       Emsg0(M_WARNING, 0, dev->errmsg);
-      Dmsg1(000, "%s", dev->errmsg);
+      Pmsg1(000, "%s", dev->errmsg);
       /* Set new block length */
       dev->max_block_size = block->block_len;
       block->buf_len = block->block_len;