]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/record.c
ebl Add faketape driver to trunk. Must use --enable-faketape
[bacula/bacula] / bacula / src / stored / record.c
index 522c50a49bb1da48c3fe543a7a747a09be1c3935..e20b4ccd54877d7a07769bc11d70ebb875442069 100644 (file)
@@ -1,3 +1,30 @@
+/*
+   Bacula® - The Network Backup Solution
+
+   Copyright (C) 2001-2008 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.
+   This program is Free Software; you can redistribute it and/or
+   modify it under the terms of version two of the GNU General Public
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
+
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
 /*
  *
  *   record.c -- tape record handling functions
  *   Version $Id$
  *
  */
-/*
-   Copyright (C) 2001-2005 Kern Sibbald
-
-   This program is free software; you can redistribute it and/or
-   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 
-   the file LICENSE for additional details.
-
- */
 
 
 #include "bacula.h"
 #include "stored.h"
 
-extern int debug_level;
-
 /*
  * Convert a FileIndex into a printable
  *   ASCII string.  Not reentrant.
@@ -105,6 +116,8 @@ const char *stream_to_ascii(char *buf, int stream, int fi)
        return "PROG-NAMES";
     case STREAM_PROGRAM_DATA:
        return "PROG-DATA";
+    case STREAM_PLUGIN_NAME:
+       return "PLUGIN-NAME";
     case STREAM_MACOS_FORK_DATA:
        return "MACOS-RSRC";
     case STREAM_HFSPLUS_ATTRIBUTES:
@@ -115,6 +128,18 @@ const char *stream_to_ascii(char *buf, int stream, int fi)
        return "SHA512";
     case STREAM_SIGNED_DIGEST:
        return "SIGNED-DIGEST";
+    case STREAM_ENCRYPTED_SESSION_DATA:
+       return "ENCRYPTED-SESSION-DATA";
+    case STREAM_ENCRYPTED_FILE_DATA:
+       return "ENCRYPTED-FILE";
+    case STREAM_ENCRYPTED_FILE_GZIP_DATA:
+       return "ENCRYPTED-GZIP";
+    case STREAM_ENCRYPTED_WIN32_DATA:
+       return "ENCRYPTED-WIN32-DATA";
+    case STREAM_ENCRYPTED_WIN32_GZIP_DATA:
+       return "ENCRYPTED-WIN32-GZIP";
+    case STREAM_ENCRYPTED_MACOS_FORK_DATA:
+       return "ENCRYPTED-MACOS-RSRC";
     case -STREAM_UNIX_ATTRIBUTES:
        return "contUATTR";
     case -STREAM_FILE_DATA:
@@ -149,6 +174,21 @@ const char *stream_to_ascii(char *buf, int stream, int fi)
        return "contSHA512";
     case -STREAM_SIGNED_DIGEST:
        return "contSIGNED-DIGEST";
+    case -STREAM_ENCRYPTED_SESSION_DATA:
+       return "contENCRYPTED-SESSION-DATA";
+    case -STREAM_ENCRYPTED_FILE_DATA:
+       return "contENCRYPTED-FILE";
+    case -STREAM_ENCRYPTED_FILE_GZIP_DATA:
+       return "contENCRYPTED-GZIP";
+    case -STREAM_ENCRYPTED_WIN32_DATA:
+       return "contENCRYPTED-WIN32-DATA";
+    case -STREAM_ENCRYPTED_WIN32_GZIP_DATA:
+       return "contENCRYPTED-WIN32-GZIP";
+    case -STREAM_ENCRYPTED_MACOS_FORK_DATA:
+       return "contENCRYPTED-MACOS-RSRC";
+    case -STREAM_PLUGIN_NAME:
+       return "contPLUGIN-NAME";
+
     default:
        sprintf(buf, "%d", stream);
        return buf;
@@ -219,7 +259,7 @@ bool write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec)
    ASSERT(block->buf_len >= block->binbuf);
 
    Dmsg6(890, "write_record_to_block() FI=%s SessId=%d Strm=%s len=%d\n"
-"rem=%d remainder=%d\n",
+      "rem=%d remainder=%d\n",
       FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
       stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len,
       remlen, rec->remainder);
@@ -330,7 +370,7 @@ bool write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec)
          if (!sm_check_rtn(__FILE__, __LINE__, False)) {
             /* We damaged a buffer */
             Dmsg6(0, "Damaged block FI=%s SessId=%d Strm=%s len=%d\n"
-"rem=%d remainder=%d\n",
+               "rem=%d remainder=%d\n",
                FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
                stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len,
                remlen, rec->remainder);
@@ -391,7 +431,7 @@ bool can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec)
  *                 routine may have to be called again with a new
  *                 block if the entire record was not read.
  */
-bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec)
+bool read_record_from_block(DCR *dcr, DEV_BLOCK *block, DEV_RECORD *rec)
 {
    ser_declare;
    uint32_t remlen;
@@ -503,7 +543,18 @@ bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec)
       return false;
    }
 
-   ASSERT(data_bytes < MAX_BLOCK_LENGTH);       /* temp sanity check */
+   /* Sanity check */
+   if (data_bytes >= MAX_BLOCK_LENGTH) {
+      /*
+       * Something is wrong, force read of next block, abort 
+       *   continuing with this block.
+       */
+      rec->state |= (REC_NO_HEADER | REC_BLOCK_EMPTY);
+      empty_block(block);
+      Jmsg2(dcr->jcr, M_WARNING, 0, _("Sanity check failed. maxlen=%d datalen=%d. Block discarded.\n"),
+         MAX_BLOCK_LENGTH, data_bytes);
+      return false;
+   }
 
    rec->data = check_pool_memory_size(rec->data, rec->data_len+data_bytes);
 
@@ -530,7 +581,7 @@ bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec)
       rec->remainder = 1;             /* partial record transferred */
       Dmsg1(450, "read_record_block: partial xfered=%d\n", rec->data_len);
       rec->state |= (REC_PARTIAL_RECORD | REC_BLOCK_EMPTY);
-      return 1;
+      return true;
    }
    rec->remainder = 0;
    Dmsg4(450, "Rtn full rd_rec_blk FI=%s SessId=%d Strm=%s len=%d\n",