From bb755fd81f9dd111fc0c14e27cfc79e799719c98 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 20 Sep 2007 16:36:18 +0000 Subject: [PATCH] Fix ANSI tape reading 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 | 12 ++++++++++++ bacula/src/stored/label.c | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index eb16996014..d23182a7ee 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -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"), diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index 089da8ebbe..8f926bb7cc 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -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)) { -- 2.39.5