]> git.sur5r.net Git - bacula/bacula/commitdiff
Prepare for adding high bits to Stream
authorKern Sibbald <kern@sibbald.com>
Wed, 24 Nov 2010 18:17:17 +0000 (19:17 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Thu, 25 Nov 2010 14:21:16 +0000 (15:21 +0100)
12 files changed:
bacula/src/findlib/bfile.c
bacula/src/stored/append.c
bacula/src/stored/askdir.c
bacula/src/stored/bextract.c
bacula/src/stored/bls.c
bacula/src/stored/bscan.c
bacula/src/stored/btape.c
bacula/src/stored/label.c
bacula/src/stored/match_bsr.c
bacula/src/stored/read_record.c
bacula/src/stored/record.c
bacula/src/stored/record.h

index c6fecfb1342f6e146d7065d18bd7be9c00129d7e..50fc23d7b73957ae96a53192d6db5663f7b28c44 100644 (file)
@@ -90,7 +90,7 @@ const char *stream_to_ascii(int stream)
 {
    static char buf[20];
 
-   switch (stream) {
+   switch (stream & STREAMMASK_TYPE) {
    case STREAM_UNIX_ATTRIBUTES:
       return _("Unix attributes");
    case STREAM_FILE_DATA:
index ffa92314db5b4f1efd2be6a846f4374bc092bc30..63e9f1968484b9c361600c5d4efafdfaf0a89a84 100644 (file)
@@ -184,6 +184,7 @@ bool do_append_data(JCR *jcr)
          rec.VolSessionTime = jcr->VolSessionTime;
          rec.FileIndex = file_index;
          rec.Stream = stream;
+         rec.maskedStream = stream & STREAMMASK_TYPE;   /* strip high bits */
          rec.data_len = fd->msglen;
          rec.data = fd->msg;            /* use message buffer */
 
@@ -325,12 +326,10 @@ bool do_append_data(JCR *jcr)
 /* Send attributes and digest to Director for Catalog */
 bool send_attrs_to_dir(JCR *jcr, DEV_RECORD *rec)
 {
-   int stream = rec->Stream;
-
-   if (stream == STREAM_UNIX_ATTRIBUTES    || 
-       stream == STREAM_UNIX_ATTRIBUTES_EX ||
-       stream == STREAM_RESTORE_OBJECT     ||
-       crypto_digest_stream_type(stream) != CRYPTO_DIGEST_NONE) {
+   if (rec->maskedStream == STREAM_UNIX_ATTRIBUTES    || 
+       rec->maskedStream == STREAM_UNIX_ATTRIBUTES_EX ||
+       rec->maskedStream == STREAM_RESTORE_OBJECT     ||
+       crypto_digest_stream_type(rec->maskedStream) != CRYPTO_DIGEST_NONE) {
       if (!jcr->no_attributes) {
          BSOCK *dir = jcr->dir_bsock;
          if (are_attributes_spooled(jcr)) {
index 898dfa093f40c97e5618c83d0a419080b34c6a07..36922bc6d4dc4f40271811ae61646dad75410b21 100644 (file)
@@ -479,8 +479,8 @@ bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec)
    ser_bytes(rec->data, rec->data_len);
    dir->msglen = ser_length(dir->msg);
    Dmsg1(1800, ">dird %s\n", dir->msg);    /* Attributes */
-   if (rec->Stream == STREAM_UNIX_ATTRIBUTES || 
-       rec->Stream == STREAM_UNIX_ATTRIBUTES_EX) {
+   if (rec->maskedStream == STREAM_UNIX_ATTRIBUTES || 
+       rec->maskedStream == STREAM_UNIX_ATTRIBUTES_EX) {
       dir->set_data_end();                 /* set offset of last valid data */
    }
    return dir->send();
index e794de1fd984462cc0f6d3300e0abacc3f3af87e..fde9a99b26211693aced54543d777a6617ed7701 100644 (file)
@@ -308,7 +308,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
 
    /* File Attributes stream */
 
-   switch (rec->Stream) {
+   switch (rec->maskedStream) {
    case STREAM_UNIX_ATTRIBUTES:
    case STREAM_UNIX_ATTRIBUTES_EX:
 
@@ -378,7 +378,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
    case STREAM_WIN32_DATA:
 
       if (extract) {
-         if (rec->Stream == STREAM_SPARSE_DATA) {
+         if (rec->maskedStream == STREAM_SPARSE_DATA) {
             ser_declare;
             uint64_t faddr;
             wbuf = rec->data + OFFSET_FADDR_SIZE;
@@ -413,7 +413,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
          uLong compress_len;
          int stat;
 
-         if (rec->Stream == STREAM_SPARSE_GZIP_DATA) {
+         if (rec->maskedStream == STREAM_SPARSE_GZIP_DATA) {
             ser_declare;
             uint64_t faddr;
             char ec1[50];
index 8a652909dd6c64a365da232eda5d2947b6dc3c98..1406a845ee75f9738e139c7519b2ca8b2c7d198b 100644 (file)
@@ -379,8 +379,8 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
       return true;
    }
    /* File Attributes stream */
-   if (rec->Stream == STREAM_UNIX_ATTRIBUTES ||
-       rec->Stream == STREAM_UNIX_ATTRIBUTES_EX) {
+   if (rec->maskedStream == STREAM_UNIX_ATTRIBUTES ||
+       rec->maskedStream == STREAM_UNIX_ATTRIBUTES_EX) {
       if (!unpack_attributes_record(jcr, rec->Stream, rec->data, rec->data_len, attr)) {
          if (!forge_on) {
             Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n"));
@@ -402,11 +402,11 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
          print_ls_output(jcr, attr);
          num_files++;
       }
-   } else if (rec->Stream == STREAM_PLUGIN_NAME) {
+   } else if (rec->maskedStream == STREAM_PLUGIN_NAME) {
       if (strncmp("0 0", rec->data, 3) != 0) {
          Pmsg1(000, "Plugin data: %s\n", rec->data);
       }
-   } else if (rec->Stream == STREAM_RESTORE_OBJECT) {
+   } else if (rec->maskedStream == STREAM_RESTORE_OBJECT) {
       Pmsg0(000, "Restore Object record\n");
    }
       
index 195448f73e296d3a4146ef86995a87bab7294b09..97581478c596df289810568c6001e3ccd8455335 100644 (file)
@@ -658,7 +658,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
    }
 
    /* File Attributes stream */
-   switch (rec->Stream) {
+   switch (rec->maskedStream) {
    case STREAM_UNIX_ATTRIBUTES:
    case STREAM_UNIX_ATTRIBUTES_EX:
 
@@ -704,7 +704,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
        * The data must be decrypted to know the correct length.
        */
       mjcr->JobBytes += rec->data_len;
-      if (rec->Stream == STREAM_SPARSE_DATA) {
+      if (rec->maskedStream == STREAM_SPARSE_DATA) {
          mjcr->JobBytes -= sizeof(uint64_t);
       }
 
index b4fbf4f23924c1dfe3fc090378f7ec9c2d7c567b..871697bf7d91204dbfcd47acee2f64977e6452fa 100644 (file)
@@ -2256,6 +2256,7 @@ static void fillcmd()
       rec.VolSessionTime = jcr->VolSessionTime;
       rec.FileIndex = ++file_index;
       rec.Stream = STREAM_FILE_DATA;
+      rec.maskedStream = STREAM_FILE_DATA;
 
       /* Mix up the data just a bit */
       mix_buffer(FILL_RANDOM, rec.data, rec.data_len);
index 0f480ab94474c0a768e4ad3dbf32c1866f0b4df9..af386241a10f7f0827335d9c33ad0c13e7624ccd 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2010 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.
@@ -31,8 +31,6 @@
  *
  *   Kern Sibbald, MM
  *
- *
- *   Version $Id$
  */
 
 #include "bacula.h"                   /* pull in global headers */
@@ -362,6 +360,7 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName,
 
    create_volume_label_record(dcr, dcr->rec);
    dcr->rec->Stream = 0;
+   dcr->rec->maskedStream = 0;
 
    if (!write_record_to_block(dcr->block, dcr->rec)) {
       Dmsg2(130, "Bad Label write on %s: ERR=%s\n", dev->print_name(), dev->print_errmsg());
@@ -591,6 +590,7 @@ static void create_volume_label_record(DCR *dcr, DEV_RECORD *rec)
    rec->VolSessionId = jcr->VolSessionId;
    rec->VolSessionTime = jcr->VolSessionTime;
    rec->Stream = jcr->NumWriteVolumes;
+   rec->maskedStream = jcr->NumWriteVolumes;
    Dmsg2(150, "Created Vol label rec: FI=%s len=%d\n", FI_to_ascii(buf, rec->FileIndex),
       rec->data_len);
 }
@@ -652,6 +652,7 @@ void create_session_label(DCR *dcr, DEV_RECORD *rec, int label)
    rec->VolSessionId   = jcr->VolSessionId;
    rec->VolSessionTime = jcr->VolSessionTime;
    rec->Stream         = jcr->JobId;
+   rec->maskedStream   = jcr->JobId;
 
    rec->data = check_pool_memory_size(rec->data, SER_LENGTH_Session_Label);
    ser_begin(rec->data, SER_LENGTH_Session_Label);
index 6bca56c4563917f72aadfee5d16cb2b05eb56c4a..698ed29f2c6e3d76187484a28a8bc06d1ca68aaf 100644 (file)
@@ -152,8 +152,8 @@ static int match_fileregex(BSR *bsr, DEV_RECORD *rec, JCR *jcr)
     * The code breaks if the first record associated with a file is
     * not of this type
     */
-   if (rec->Stream == STREAM_UNIX_ATTRIBUTES ||
-       rec->Stream == STREAM_UNIX_ATTRIBUTES_EX) {
+   if (rec->maskedStream == STREAM_UNIX_ATTRIBUTES ||
+       rec->maskedStream == STREAM_UNIX_ATTRIBUTES_EX) {
       bsr->skip_file = false;
       if (unpack_attributes_record(jcr, rec->Stream, rec->data, rec->data_len, bsr->attr)) {
          if (regexec(bsr->fileregex_re, bsr->attr->fname, 0, NULL, 0) == 0) {
index fef4cacc0d1286e2c0bdce819098f4eae0279361..47aacb18f322126018d8fa4058e366bd076d6715 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2002-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2002-2010 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.
@@ -38,7 +38,6 @@
  *
  *    Kern E. Sibbald, August MMII
  *
- *   Version $Id$
  */
 
 #include "bacula.h"
index 973518644702f692be66dcae1a3883600283e6e4..430e2690afbeb02fae8df75d7688ff1af96036b3 100644 (file)
@@ -91,116 +91,129 @@ const char *FI_to_ascii(char *buf, int fi)
  */
 const char *stream_to_ascii(char *buf, int stream, int fi)
 {
-    if (fi < 0) {
-       sprintf(buf, "%d", stream);
-       return buf;
-    }
-    switch (stream) {
-    case STREAM_UNIX_ATTRIBUTES:
-       return "UATTR";
-    case STREAM_FILE_DATA:
-       return "DATA";
-    case STREAM_WIN32_DATA:
-       return "WIN32-DATA";
-    case STREAM_WIN32_GZIP_DATA:
-       return "WIN32-GZIP";
-    case STREAM_MD5_DIGEST:
-       return "MD5";
-    case STREAM_SHA1_DIGEST:
-       return "SHA1";
-    case STREAM_GZIP_DATA:
-       return "GZIP";
-    case STREAM_UNIX_ATTRIBUTES_EX:
-       return "UNIX-ATTR-EX";
-    case STREAM_RESTORE_OBJECT:
-       return "RESTORE-OBJECT";
-    case STREAM_SPARSE_DATA:
-       return "SPARSE-DATA";
-    case STREAM_SPARSE_GZIP_DATA:
-       return "SPARSE-GZIP";
-    case STREAM_PROGRAM_NAMES:
-       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:
-       return "HFSPLUS-ATTR";
-    case STREAM_SHA256_DIGEST:
-       return "SHA256";
-    case STREAM_SHA512_DIGEST:
-       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:
-       return "contDATA";
-    case -STREAM_WIN32_DATA:
-       return "contWIN32-DATA";
-    case -STREAM_WIN32_GZIP_DATA:
-       return "contWIN32-GZIP";
-    case -STREAM_MD5_DIGEST:
-       return "contMD5";
-    case -STREAM_SHA1_DIGEST:
-       return "contSHA1";
-    case -STREAM_GZIP_DATA:
-       return "contGZIP";
-    case -STREAM_UNIX_ATTRIBUTES_EX:
-       return "contUNIX-ATTR-EX";
-    case -STREAM_RESTORE_OBJECT:
-       return "contRESTORE-OBJECT";
-    case -STREAM_SPARSE_DATA:
-       return "contSPARSE-DATA";
-    case -STREAM_SPARSE_GZIP_DATA:
-       return "contSPARSE-GZIP";
-    case -STREAM_PROGRAM_NAMES:
-       return "contPROG-NAMES";
-    case -STREAM_PROGRAM_DATA:
-       return "contPROG-DATA";
-    case -STREAM_MACOS_FORK_DATA:
-       return "contMACOS-RSRC";
-    case -STREAM_HFSPLUS_ATTRIBUTES:
-       return "contHFSPLUS-ATTR";
-    case -STREAM_SHA256_DIGEST:
-       return "contSHA256";
-    case -STREAM_SHA512_DIGEST:
-       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;
-    }
+
+   if (fi < 0) {
+      sprintf(buf, "%d", stream);
+      return buf;
+   }
+   if (stream < 0) {
+      stream = -stream;
+      stream &= STREAMMASK_TYPE;
+      /* Stream was negative => all are continuation items */
+      switch (stream) {
+      case STREAM_UNIX_ATTRIBUTES:
+         return "contUATTR";
+      case STREAM_FILE_DATA:
+         return "contDATA";
+      case STREAM_WIN32_DATA:
+         return "contWIN32-DATA";
+      case STREAM_WIN32_GZIP_DATA:
+         return "contWIN32-GZIP";
+      case STREAM_MD5_DIGEST:
+         return "contMD5";
+      case STREAM_SHA1_DIGEST:
+         return "contSHA1";
+      case STREAM_GZIP_DATA:
+         return "contGZIP";
+      case STREAM_UNIX_ATTRIBUTES_EX:
+         return "contUNIX-ATTR-EX";
+      case STREAM_RESTORE_OBJECT:
+         return "contRESTORE-OBJECT";
+      case STREAM_SPARSE_DATA:
+         return "contSPARSE-DATA";
+      case STREAM_SPARSE_GZIP_DATA:
+         return "contSPARSE-GZIP";
+      case STREAM_PROGRAM_NAMES:
+         return "contPROG-NAMES";
+      case STREAM_PROGRAM_DATA:
+         return "contPROG-DATA";
+      case STREAM_MACOS_FORK_DATA:
+         return "contMACOS-RSRC";
+      case STREAM_HFSPLUS_ATTRIBUTES:
+         return "contHFSPLUS-ATTR";
+      case STREAM_SHA256_DIGEST:
+         return "contSHA256";
+      case STREAM_SHA512_DIGEST:
+         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;
+      }
+   }
+
+   switch (stream & STREAMMASK_TYPE) {
+   case STREAM_UNIX_ATTRIBUTES:
+      return "UATTR";
+   case STREAM_FILE_DATA:
+      return "DATA";
+   case STREAM_WIN32_DATA:
+      return "WIN32-DATA";
+   case STREAM_WIN32_GZIP_DATA:
+      return "WIN32-GZIP";
+   case STREAM_MD5_DIGEST:
+      return "MD5";
+   case STREAM_SHA1_DIGEST:
+      return "SHA1";
+   case STREAM_GZIP_DATA:
+      return "GZIP";
+   case STREAM_UNIX_ATTRIBUTES_EX:
+      return "UNIX-ATTR-EX";
+   case STREAM_RESTORE_OBJECT:
+      return "RESTORE-OBJECT";
+   case STREAM_SPARSE_DATA:
+      return "SPARSE-DATA";
+   case STREAM_SPARSE_GZIP_DATA:
+      return "SPARSE-GZIP";
+   case STREAM_PROGRAM_NAMES:
+      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:
+      return "HFSPLUS-ATTR";
+   case STREAM_SHA256_DIGEST:
+      return "SHA256";
+   case STREAM_SHA512_DIGEST:
+      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";
+
+      default:
+         sprintf(buf, "%d", stream);
+         return buf;
+      }
 }
 
 /*
@@ -520,8 +533,10 @@ bool read_record_from_block(DCR *dcr, DEV_BLOCK *block, DEV_RECORD *rec)
             return false;             /* This is from some other Session */
          }
          rec->Stream = -Stream;       /* set correct Stream */
+         rec->maskedStream = rec->Stream & STREAMMASK_TYPE;
       } else {                        /* Regular record */
          rec->Stream = Stream;
+         rec->maskedStream = rec->Stream & STREAMMASK_TYPE;
          rec->data_len = 0;           /* transfer to beginning of data */
       }
       rec->VolSessionId = VolSessionId;
index a76bb4ce91dcad59208656473df6c3e3c9fc98b2..04a93cb609eaa0207b8b059b340bb221759f7427 100644 (file)
@@ -98,7 +98,8 @@ struct DEV_RECORD {
    uint32_t VolSessionId;             /* sequential id within this session */
    uint32_t VolSessionTime;           /* session start time */
    int32_t  FileIndex;                /* sequential file number */
-   int32_t  Stream;                   /* stream number */
+   int32_t  Stream;                   /* Full Stream number with high bits */
+   int32_t  maskedStream;             /* Masked Stream without high bits */
    uint32_t data_len;                 /* current record length */
    uint32_t remainder;                /* remaining bytes to read/write */
    uint32_t state;                    /* state bits */