From: Kern Sibbald Date: Thu, 20 Sep 2007 16:11:28 +0000 (+0000) Subject: kes Fix ANSI tape labeling. Fix restoring ANSI labeled Volumes. X-Git-Tag: Release-3.0.0~2490 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=81c716ec4dc2d82a540a388ae4ad7b34dd1c456d;p=bacula%2Fbacula kes Fix ANSI tape labeling. Fix restoring ANSI labeled Volumes. This fixes bug #954. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5612 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/findlib/save_cwd.h b/bacula/src/findlib/save_cwd.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/bacula/src/stored/ansi_label.c b/bacula/src/stored/ansi_label.c index 1414868491..e8978ec7bc 100644 --- a/bacula/src/stored/ansi_label.c +++ b/bacula/src/stored/ansi_label.c @@ -1,18 +1,7 @@ -/* - * - * ansi_label.c routines to handle ANSI (and perhaps one day IBM) - * tape labels. - * - * Kern Sibbald, MMV - * - * - * - * Version $Id$ - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2005-2006 Free Software Foundation Europe e.V. + Copyright (C) 2005-2007 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -36,6 +25,17 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * + * ansi_label.c routines to handle ANSI (and perhaps one day IBM) + * tape labels. + * + * Kern Sibbald, MMV + * + * + * + * Version $Id$ + */ #include "bacula.h" /* pull in global headers */ #include "stored.h" /* pull in Storage Deamon headers */ @@ -115,6 +115,7 @@ int read_ansi_ibm_label(DCR *dcr) if (strncmp("VOL1", label, 4) == 0) { ok = true; dev->label_type = B_ANSI_LABEL; + Dmsg0(100, "Got ANSI VOL1 label\n"); } else { /* Try EBCDIC */ ebcdic_to_ascii(label, label, sizeof(label)); @@ -122,6 +123,7 @@ int read_ansi_ibm_label(DCR *dcr) ok = true;; dev->label_type = B_IBM_LABEL; Dmsg0(100, "Found IBM label.\n"); + Dmsg0(100, "Got IBM VOL1 label\n"); } } } @@ -168,6 +170,7 @@ int read_ansi_ibm_label(DCR *dcr) dev->VolHdr.VolumeName); return VOL_NAME_ERROR; /* Not a Bacula label */ } + Dmsg0(100, "Got HDR1 label\n"); break; case 2: if (dev->label_type == B_IBM_LABEL) { @@ -178,6 +181,7 @@ int read_ansi_ibm_label(DCR *dcr) Mmsg0(jcr->errmsg, _("No HDR2 label while reading ANSI/IBM label.\n")); return VOL_LABEL_ERROR; } + Dmsg0(100, "Got ANSI HDR2 label\n"); break; default: if (stat == 0) { @@ -192,6 +196,7 @@ int read_ansi_ibm_label(DCR *dcr) Mmsg0(jcr->errmsg, _("Unknown or bad ANSI/IBM label record.\n")); return VOL_LABEL_ERROR; } + Dmsg0(100, "Got HDR label\n"); break; } } 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)) { diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 30b0d05ea1..607ad8b595 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -2,7 +2,8 @@ General: 20Sep07 -kes Fix ANSI tape labeling. This fixes bug #954. +kes Fix ANSI tape labeling. Fix restoring ANSI labeled Volumes. + This fixes bug #954. kes Increase the max block size to 4MB fixes bug #957. kes ERABT if user sets min block size > max block size. Fixes bug #956. kes Apply 2.2.4-poll-mount fix, that resolves bug #908 where a tape