]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix ANSI tape reading
authorKern Sibbald <kern@sibbald.com>
Thu, 20 Sep 2007 16:36:18 +0000 (16:36 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 20 Sep 2007 16:36:18 +0000 (16:36 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@5615 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/stored/block.c
bacula/src/stored/label.c

index eb16996014265e29166c21436efe95f5dd0687f2..d23182a7eed9ed00022e6668fdce554fa55130e7 100644 (file)
@@ -273,6 +273,7 @@ static bool unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
       dev->dev_errno = EIO;
       Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"),
           dev->file, dev->block_num, BLKHDR2_ID, Id);
+      Dmsg1(50, "%s", dev->errmsg);
       if (block->read_errors == 0 || verbose >= 2) {
          Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
       }
@@ -1008,8 +1009,19 @@ reread:
       dev->set_ateof();
       return false;             /* return eof */
    }
+
    /* Continue here for successful read */
+
    block->read_len = stat;      /* save length read */
+   if (dev->at_eof() && block->read_len == 80 && 
+        (dcr->VolCatInfo.LabelType != B_BACULA_LABEL ||
+         dcr->device->label_type != B_BACULA_LABEL)) {
+      /* ***FIXME*** should check label */
+      Dmsg2(100, "Ignore 80 byte ANSI label at %u:%u\n", dev->file, dev->block_num);
+      dev->clear_eof();
+      goto reread;             /* skip ANSI/IBM label */
+   }
+                                          
    if (block->read_len < BLKHDR2_LENGTH) {
       dev->dev_errno = EIO;
       Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Very short block of %d bytes on device %s discarded.\n"),
index 089da8ebbe5713e4224f5794fd5bcdd521b67d88..8f926bb7cc86bee4f04f429d956c0922296e0c17 100644 (file)
@@ -119,7 +119,6 @@ int read_dev_volume_label(DCR *dcr)
    bstrncpy(dev->VolHdr.Id, "**error**", sizeof(dev->VolHdr.Id));
 
   /* Read ANSI/IBM label if so requested */
-  
   want_ansi_label = dcr->VolCatInfo.LabelType != B_BACULA_LABEL ||
                     dcr->device->label_type != B_BACULA_LABEL;
   if (want_ansi_label || dev->has_cap(CAP_CHECKLABELS)) {