From: Kern Sibbald Date: Wed, 24 Nov 2010 18:17:17 +0000 (+0100) Subject: Prepare for adding high bits to Stream X-Git-Tag: Release-7.0.0~1341 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dbbeae205ca8108aa1943901e58ecb4a35ff99a0;p=bacula%2Fbacula Prepare for adding high bits to Stream --- diff --git a/bacula/src/findlib/bfile.c b/bacula/src/findlib/bfile.c index c6fecfb134..50fc23d7b7 100644 --- a/bacula/src/findlib/bfile.c +++ b/bacula/src/findlib/bfile.c @@ -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: diff --git a/bacula/src/stored/append.c b/bacula/src/stored/append.c index ffa92314db..63e9f19684 100644 --- a/bacula/src/stored/append.c +++ b/bacula/src/stored/append.c @@ -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)) { diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index 898dfa093f..36922bc6d4 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -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(); diff --git a/bacula/src/stored/bextract.c b/bacula/src/stored/bextract.c index e794de1fd9..fde9a99b26 100644 --- a/bacula/src/stored/bextract.c +++ b/bacula/src/stored/bextract.c @@ -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]; diff --git a/bacula/src/stored/bls.c b/bacula/src/stored/bls.c index 8a652909dd..1406a845ee 100644 --- a/bacula/src/stored/bls.c +++ b/bacula/src/stored/bls.c @@ -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"); } diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index 195448f73e..97581478c5 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -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); } diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index b4fbf4f239..871697bf7d 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -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); diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index 0f480ab944..af386241a1 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -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); diff --git a/bacula/src/stored/match_bsr.c b/bacula/src/stored/match_bsr.c index 6bca56c456..698ed29f2c 100644 --- a/bacula/src/stored/match_bsr.c +++ b/bacula/src/stored/match_bsr.c @@ -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) { diff --git a/bacula/src/stored/read_record.c b/bacula/src/stored/read_record.c index fef4cacc0d..47aacb18f3 100644 --- a/bacula/src/stored/read_record.c +++ b/bacula/src/stored/read_record.c @@ -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" diff --git a/bacula/src/stored/record.c b/bacula/src/stored/record.c index 9735186447..430e2690af 100644 --- a/bacula/src/stored/record.c +++ b/bacula/src/stored/record.c @@ -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; diff --git a/bacula/src/stored/record.h b/bacula/src/stored/record.h index a76bb4ce91..04a93cb609 100644 --- a/bacula/src/stored/record.h +++ b/bacula/src/stored/record.h @@ -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 */