]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/read_record.c
- Implement first cut of Migration.
[bacula/bacula] / bacula / src / stored / read_record.c
index dbf5a6c49c078e268400775de74676731e46ee6e..c6e77c0f1aff0883a1721881e81a33bbbfa43a58 100644 (file)
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public
-   License along with this program; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
@@ -70,10 +65,10 @@ bool read_records(DCR *dcr,
       if (!read_block_from_device(dcr, CHECK_BLOCK_NUMBERS)) {
          if (dev->at_eot()) {
             DEV_RECORD *trec = new_record();
-            Jmsg(jcr, M_INFO, 0, "End of Volume at file %u on device %s, Volume \"%s\"\n",
+            Jmsg(jcr, M_INFO, 0, _("End of Volume at file %u on device %s, Volume \"%s\"\n"),
                  dev->file, dev->print_name(), dcr->VolumeName);
             if (!mount_cb(dcr)) {
-               Jmsg(jcr, M_INFO, 0, "End of all volumes.\n");
+               Jmsg(jcr, M_INFO, 0, _("End of all volumes.\n"));
                ok = false;            /* Stop everything */
                /*
                 * Create EOT Label so that Media record may
@@ -107,13 +102,13 @@ bool read_records(DCR *dcr,
 
          } else if (dev->at_eof()) {
             if (verbose) {
-               Jmsg(jcr, M_INFO, 0, "Got EOF at file %u  on device %s, Volume \"%s\"\n",
+               Jmsg(jcr, M_INFO, 0, _("Got EOF at file %u  on device %s, Volume \"%s\"\n"),
                   dev->file, dev->print_name(), dcr->VolumeName);
             }
             Dmsg3(200, "Got EOF at file %u  on device %s, Volume \"%s\"\n",
                   dev->file, dev->print_name(), dcr->VolumeName);
             continue;
-         } else if (dev_state(dev, ST_SHORT)) {
+         } else if (dev->is_short_block()) {
             Jmsg1(jcr, M_ERROR, 0, "%s", dev->errmsg);
             continue;
          } else {
@@ -121,7 +116,7 @@ bool read_records(DCR *dcr,
             display_tape_error_status(jcr, dev);
             if (forge_on || jcr->ignore_label_errors) {
                dev->fsr(1);       /* try skipping bad record */
-               Pmsg0(000, "Did fsr\n");
+               Pmsg0(000, _("Did fsr\n"));
                continue;              /* try to continue */
             }
             ok = false;               /* stop everything */
@@ -162,7 +157,7 @@ bool read_records(DCR *dcr,
       record = 0;
       rec->state = 0;
       Dmsg1(300, "Block empty %d\n", is_block_empty(rec));
-      for (rec->state=0; !is_block_empty(rec); ) {
+      for (rec->state=0; ok && !is_block_empty(rec); ) {
          if (!read_record_from_block(block, rec)) {
             Dmsg3(400, "!read-break. state=%s blk=%d rem=%d\n", rec_state_to_str(rec),
                   block->BlockNumber, rec->remainder);
@@ -210,7 +205,7 @@ bool read_records(DCR *dcr,
                Dmsg2(300, "All done=(file:block) %u:%u\n", dev->file, dev->block_num);
                break;
             } else if (stat == 0) {  /* no match */
-               Dmsg4(300, "Clear rem=%d FI=%d before set_eof pos %u:%u\n",
+               Dmsg4(300, "BSR no match: clear rem=%d FI=%d before set_eof pos %u:%u\n",
                   rec->remainder, rec->FileIndex, dev->file, dev->block_num);
                rec->remainder = 0;
                rec->state &= ~REC_PARTIAL_RECORD;
@@ -220,6 +215,7 @@ bool read_records(DCR *dcr,
                continue;              /* we don't want record, read next one */
             }
          }
+         dcr->VolLastIndex = rec->FileIndex;  /* let caller know where we are */
          if (is_partial_record(rec)) {
             Dmsg6(300, "Partial, break. recno=%d state=%s blk=%d SI=%d ST=%d FI=%d\n", record,
                rec_state_to_str(rec), block->BlockNumber,
@@ -227,7 +223,7 @@ bool read_records(DCR *dcr,
             break;                    /* read second part of record */
          }
          ok = record_cb(dcr, rec);
-         if (rec->Stream == STREAM_MD5_SIGNATURE || rec->Stream == STREAM_SHA1_SIGNATURE) {
+         if (crypto_digest_stream_type(rec->Stream) != CRYPTO_DIGEST_NONE) {
             Dmsg3(300, "Done FI=%u before set_eof pos %u:%u\n", rec->FileIndex,
                   dev->file, dev->block_num);
             if (match_set_eof(jcr->bsr, rec) && try_repositioning(jcr, rec, dev)) {
@@ -270,14 +266,14 @@ static bool try_repositioning(JCR *jcr, DEV_RECORD *rec, DEVICE *dev)
       if (!dev->at_eot()) {
          /* Set EOT flag to force mount of next Volume */
          jcr->mount_next_volume = true;
-         dev->state |= ST_EOT;
+         dev->set_eot();
       }
       rec->Block = 0;
       return true;
    }
    if (bsr) {
       if (verbose) {
-         Jmsg(jcr, M_INFO, 0, "Reposition from (file:block) %u:%u to %u:%u\n",
+         Jmsg(jcr, M_INFO, 0, _("Reposition from (file:block) %u:%u to %u:%u\n"),
             dev->file, dev->block_num, bsr->volfile->sfile,
             bsr->volblock->sblock);
       }
@@ -323,28 +319,28 @@ static void handle_session_record(DEVICE *dev, DEV_RECORD *rec, SESSION_LABEL *s
    memset(sessrec, 0, sizeof(sessrec));
    switch (rec->FileIndex) {
    case PRE_LABEL:
-      rtype = "Fresh Volume Label";
+      rtype = _("Fresh Volume Label");
       break;
    case VOL_LABEL:
-      rtype = "Volume Label";
+      rtype = _("Volume Label");
       unser_volume_label(dev, rec);
       break;
    case SOS_LABEL:
-      rtype = "Begin Session";
+      rtype = _("Begin Session");
       unser_session_label(sessrec, rec);
       break;
    case EOS_LABEL:
-      rtype = "End Session";
+      rtype = _("End Session");
       break;
    case EOM_LABEL:
-      rtype = "End of Media";
+      rtype = _("End of Media");
       break;
    default:
-      bsnprintf(buf, sizeof(buf), "Unknown code %d\n", rec->FileIndex);
+      bsnprintf(buf, sizeof(buf), _("Unknown code %d\n"), rec->FileIndex);
       rtype = buf;
       break;
    }
-   Dmsg5(300, "%s Record: VolSessionId=%d VolSessionTime=%d JobId=%d DataLen=%d\n",
+   Dmsg5(300, _("%s Record: VolSessionId=%d VolSessionTime=%d JobId=%d DataLen=%d\n"),
          rtype, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len);
 }