]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/read_record.c
Fix for reused thread ids by FreeBSD + qfill command
[bacula/bacula] / bacula / src / stored / read_record.c
index 965b2c067b82924db23c28d8b4551fbe8b160735..273be3d2d9f4ea7de2e9a2d6fe35d4bed80aebb9 100644 (file)
@@ -6,10 +6,12 @@
  *    as well as a callback for mounting the next tape.  It takes
  *    care of reading blocks, applying the bsr, ...
  *
+ *    Kern E. Sibbald, August MMII
+ *
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+   Copyright (C) 2000-2003 Kern Sibbald and John Walker
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -43,19 +45,18 @@ int read_records(JCR *jcr,  DEVICE *dev,
    DEV_BLOCK *block;
    DEV_RECORD *rec;
    uint32_t record, num_files = 0;
-   int verbose = FALSE;
    int ok = TRUE;
    int done = FALSE;
    SESSION_LABEL sessrec;
 
    block = new_block(dev);
    rec = new_record();
-   for ( ;ok && !done; ) {
-      if (job_cancelled(jcr)) {
+   for ( ; ok && !done; ) {
+      if (job_canceled(jcr)) {
         ok = FALSE;
         break;
       }
-      if (!read_block_from_device(dev, block)) {
+      if (!read_block_from_device(jcr, dev, block, CHECK_BLOCK_NUMBERS)) {
          Dmsg0(20, "!read_record()\n");
         if (dev->state & ST_EOT) {
            DEV_RECORD *trec = new_record();
@@ -85,26 +86,27 @@ int read_records(JCR *jcr,  DEVICE *dev,
             *  and pass it off to the callback routine, then continue
             *  most likely reading the previous record.
             */
-           read_block_from_device(dev, block);
+           read_block_from_device(jcr, dev, block, NO_BLOCK_NUMBER_CHECK);
            read_record_from_block(block, trec);
            get_session_record(dev, trec, &sessrec);
            record_cb(jcr, dev, block, trec);
            free_record(trec);
-           goto next_record;
-        }
-        if (dev->state & ST_EOF) {
-            Emsg2(M_INFO, 0, "Got EOF on device %s, Volume \"%s\"\n", 
-                 dev_name(dev), jcr->VolumeName);
+           goto next_record;         /* go read new tape */
+
+        } else if (dev->state & ST_EOF) {
+            Jmsg(jcr, M_INFO, 0, "Got EOF at file %u  on device %s, Volume \"%s\"\n", 
+                 dev->file, dev_name(dev), jcr->VolumeName);
             Dmsg0(20, "read_record got eof. try again\n");
            continue;
-        }
-        if (dev->state & ST_SHORT) {
-           Emsg0(M_INFO, 0, dev->errmsg);
+        } else if (dev->state & ST_SHORT) {
+            Jmsg(jcr, M_INFO, 0, "%s", dev->errmsg);
            continue;
+        } else {
+           /* I/O error or strange end of tape */
+           display_tape_error_status(jcr, dev);
+           ok = FALSE;
+           break;
         }
-//      display_error_status();
-        ok = FALSE;
-        break;
       }
       if (verbose) {
          Dmsg2(10, "Block: %d blen=%d\n", block->BlockNumber, block->block_len);