]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
More Enterprise backports
authorKern Sibbald <kern@sibbald.com>
Sun, 11 Nov 2018 16:30:25 +0000 (17:30 +0100)
committerKern Sibbald <kern@sibbald.com>
Sun, 11 Nov 2018 16:30:25 +0000 (17:30 +0100)
20 files changed:
bacula/src/lib/bsockcore.c
bacula/src/lib/bsockcore.h
bacula/src/lib/crypto.c
bacula/src/lib/devlock.c
bacula/src/lib/lockmgr.c
bacula/src/lib/mem_pool.c
bacula/src/lib/message.c
bacula/src/lib/message.h
bacula/src/lib/openssl.c
bacula/src/lib/output.c
bacula/src/lib/parse_conf.c
bacula/src/lib/protos.h
bacula/src/lib/runscript.c
bacula/src/lib/tls.c
bacula/src/lib/tree.c
bacula/src/stored/askdir.c
bacula/src/stored/autochanger.c
bacula/src/stored/block.h
bacula/src/stored/bscan.c
bacula/src/stored/dev.c

index 3b9c7c692d01700f4593e4a269c326b7125c9914..2cda1f798647cf7b66ef1bee97fcfbcdd1bc61fb 100644 (file)
@@ -714,7 +714,8 @@ bool BSOCKCORE::set_buffer_size(uint32_t size, int rw)
       dbuf_size = DEFAULT_NETWORK_BUFFER_SIZE;
    }
    start_size = dbuf_size;
-   if ((msg = realloc_pool_memory(msg, dbuf_size + 100)) == NULL) {
+   /* The extra 512 can hold data such as Sparse/Offset pointer */
+   if ((msg = realloc_pool_memory(msg, dbuf_size + 512)) == NULL) {
       Qmsg0(get_jcr(), M_FATAL, 0, _("Could not malloc BSOCKCORE data buffer\n"));
       return false;
    }
index 695ad38d4c2e6ca29b228330209e954b699ab270..70e9e829935f511dcd2f13165301fb1942458139 100644 (file)
@@ -124,7 +124,7 @@ protected:
    void master_lock() const { if (m_use_locking) pP((&m_mmutex)); };
    void master_unlock() const { if (m_use_locking) pV((&m_mmutex)); };
    virtual void init();
-   void _destroy();                   /* called by destroy() */
+   virtual void _destroy();                   /* called by destroy() */
    virtual int32_t write_nbytes(char *ptr, int32_t nbytes);
    virtual int32_t read_nbytes(char *ptr, int32_t nbytes);
 
@@ -140,7 +140,7 @@ public:
    virtual int32_t recv(int /*len*/);
    virtual bool send();
    bool fsend(const char*, ...);
-   void close();              /* close connection and destroy packet */
+   virtual void close();              /* close connection and destroy packet */
    void destroy();                    /* destroy socket packet */
    const char *bstrerror();           /* last error on socket */
    int get_peer(char *buf, socklen_t buflen);
index 0cb4f9feef60ab448adb04412b99751b037e6ed3..c8e9b2a3a03238787ae4acd15835147b8577ec92 100644 (file)
@@ -195,7 +195,7 @@ IMPLEMENT_ASN1_FUNCTIONS(RecipientInfo)
 IMPLEMENT_ASN1_FUNCTIONS(SignatureData)
 IMPLEMENT_ASN1_FUNCTIONS(CryptoData)
 
-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
+#if defined(DEFINE_STACK_OF)
 DEFINE_STACK_OF(SignerInfo);
 DEFINE_STACK_OF(RecipientInfo);
 #else
@@ -391,7 +391,7 @@ X509_KEYPAIR *crypto_keypair_dup(X509_KEYPAIR *keypair)
    if (keypair->pubkey) {
       ret = EVP_PKEY_up_ref(keypair->pubkey);
       if (ret == 0)
-             goto out_free_new;
+              goto out_free_new;
       newpair->pubkey = keypair->pubkey;
    }
 
@@ -399,7 +399,7 @@ X509_KEYPAIR *crypto_keypair_dup(X509_KEYPAIR *keypair)
    if (keypair->privkey) {
       ret = EVP_PKEY_up_ref(keypair->privkey);
       if (ret == 0)
-             goto out_free_new;
+              goto out_free_new;
       newpair->privkey = keypair->privkey;
    }
 
@@ -407,7 +407,7 @@ X509_KEYPAIR *crypto_keypair_dup(X509_KEYPAIR *keypair)
    if (keypair->keyid) {
       newpair->keyid = ASN1_OCTET_STRING_dup(keypair->keyid);
       if (!newpair->keyid)
-             goto out_free_new;
+              goto out_free_new;
    }
 
    return newpair;
@@ -600,7 +600,7 @@ DIGEST *crypto_digest_new(JCR *jcr, crypto_digest_t type)
    /* Initialize the OpenSSL message digest context */
    digest->ctx = EVP_MD_CTX_new();
    if (!digest->ctx)
-          goto err;
+           goto err;
    EVP_MD_CTX_reset(digest->ctx);
 
    /* Determine the correct OpenSSL message digest type */
@@ -1261,11 +1261,11 @@ CIPHER_CONTEXT *crypto_cipher_new(CRYPTO_SESSION *cs, bool encrypt, uint32_t *bl
 
    cipher_ctx = (CIPHER_CONTEXT *)malloc(sizeof(CIPHER_CONTEXT));
    if (!cipher_ctx)
-          return NULL;
+           return NULL;
 
    cipher_ctx->ctx = EVP_CIPHER_CTX_new();
    if (!cipher_ctx->ctx)
-          goto err;
+           goto err;
 
    /*
     * Acquire a cipher instance for the given ASN.1 cipher NID
index 606449ffc758b0f6824ad8c5af2ee122dcfe491c..5975f6a172bd21099c9c97723c2d6220757daf60 100644 (file)
@@ -44,7 +44,7 @@ devlock *new_devlock()
 {
    devlock *lock;
    lock = (devlock *)malloc(sizeof (devlock));
-   memset(lock, 0, sizeof(devlock));
+   bmemset(lock, 0, sizeof(devlock));
    return lock;
 }
 
index 53f466af825f98455d77c7e15350aafc5a2a815d..3ec1c2e5a5744eb88a025ba53278326361640342 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula(R) - The Network Backup Solution
 
-   Copyright (C) 2000-2017 Kern Sibbald
+   Copyright (C) 2000-2018 Kern Sibbald
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -582,7 +582,11 @@ static pthread_key_t lmgr_key;  /* used to get lgmr_thread_t object */
 static dlist *global_mgr = NULL;  /* used to store all lgmr_thread_t objects */
 static pthread_mutex_t lmgr_global_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_t undertaker;
-static bool use_undertaker=true;
+static pthread_cond_t undertaker_cond;
+static pthread_mutex_t undertaker_mutex = PTHREAD_MUTEX_INITIALIZER;
+static bool use_undertaker = true;
+static bool do_quit = false;
+
 
 #define lmgr_is_active() (global_mgr != NULL)
 
@@ -745,12 +749,26 @@ void cln_hdl(void *a)
 
 void *check_deadlock(void *)
 {
-   int old;
    lmgr_init_thread();
    pthread_cleanup_push(cln_hdl, NULL);
 
-   while (!bmicrosleep(30, 0)) {
-      pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old);
+   while (!do_quit) {
+      struct timeval tv;
+      struct timezone tz;
+      struct timespec timeout;
+
+      gettimeofday(&tv, &tz);
+      timeout.tv_nsec = 0;
+      timeout.tv_sec = tv.tv_sec + 30;
+
+      pthread_mutex_lock(&undertaker_mutex);
+      pthread_cond_timedwait(&undertaker_cond, &undertaker_mutex, &timeout);
+      pthread_mutex_unlock(&undertaker_mutex);
+
+      if(do_quit) {
+         goto bail_out;
+      }
+   
       if (lmgr_detect_deadlock()) {
          /* If we have information about P()/V(), display them */
          if (debug_flags & DEBUG_MUTEX_EVENT && chk_dbglvl(DBGLEVEL_EVENT)) {
@@ -759,9 +777,9 @@ void *check_deadlock(void *)
          lmgr_dump();
          ASSERT2(0, "Lock deadlock");   /* Abort if we found a deadlock */
       }
-      pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old);
-      pthread_testcancel();
    }
+   
+bail_out:
    Dmsg0(100, "Exit check_deadlock.\n");
    pthread_cleanup_pop(1);
    return NULL;
@@ -817,6 +835,14 @@ void create_lmgr_key()
    global_mgr = New(dlist(n, &n->link));
 
    if (use_undertaker) {
+      /* Create condwait */
+      status = pthread_cond_init(&undertaker_cond, NULL);
+      if (status != 0) {
+         berrno be;
+         Pmsg1(000, _("pthread_cond_init failed: ERR=%s\n"),
+               be.bstrerror(status));
+         ASSERT2(0, "pthread_cond_init failed");
+      }
       status = pthread_create(&undertaker, NULL, check_deadlock, NULL);
       if (status != 0) {
          berrno be;
@@ -871,11 +897,14 @@ void lmgr_cleanup_main()
       return;
    }
    if (use_undertaker) {
-      pthread_cancel(undertaker);
-#ifdef DEVELOPER
+      /* Signal to the check_deadlock thread to stop itself */
+      pthread_mutex_lock(&undertaker_mutex);
+      do_quit = true;
+      pthread_cond_signal(&undertaker_cond);
+      pthread_mutex_unlock(&undertaker_mutex);
       /* Should avoid memory leak reporting */
       pthread_join(undertaker, NULL);
-#endif
+      pthread_cond_destroy(&undertaker_cond);
    }
    lmgr_cleanup_thread();
    lmgr_p(&lmgr_global_mutex);
index a29e68ef38bf2fb302e0176f373097141dcb67b8..feedc2d6d045b045490e0a3849e1073d85bdf864 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula(R) - The Network Backup Solution
 
-   Copyright (C) 2000-2017 Kern Sibbald
+   Copyright (C) 2000-2018 Kern Sibbald
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -145,9 +145,11 @@ POOLMEM *sm_get_memory(const char *fname, int lineno, int32_t size)
    buf->ablen = size;
    buf->pool = pool;
    buf->next = NULL;
+   P(mutex);
    pool_ctl[pool].in_use++;
    if (pool_ctl[pool].in_use > pool_ctl[pool].max_used)
       pool_ctl[pool].max_used = pool_ctl[pool].in_use;
+   V(mutex);
    return (POOLMEM *)(((char *)buf)+HEAD_SIZE);
 }
 
index 786853b7de282ded0407ea8e6f8b214f841743bb..b8e78ed5c23e704ff38a0afc9cc6b49749d368f1 100644 (file)
@@ -1191,6 +1191,21 @@ void set_trace(int trace_flag)
    }
 }
 
+/*
+ * Can be called by Bacula's tools that use Bacula's libraries, to control where
+ * to redirect Dmsg() emitted by the code inside the Bacula's library.
+ * This should not be called by the main daemon, this is a Hack !
+ * See in bsnapshot.c how it is used
+ * In your tools be careful to no call any function that here in messages.c
+ * that modify "trace" or close() or re-open() trace_fd
+ */
+void set_trace_for_tools(FILE *new_trace_fd)
+{
+   // don't call fclose(trace_fd) here
+   trace = true;
+   trace_fd = new_trace_fd;
+}
+
 void set_hangup(int hangup_value)
 {
    if (hangup_value != -1) {
index f4a63818f2ade6c7bbcad0c0ea3a2ecf2b6f1d3e..ed23ce39fed57d777915b636f27c03d6b93671e9 100644 (file)
@@ -179,6 +179,7 @@ bool get_trace(void);
 void set_debug_flags(char *options);
 const char *get_basename(const char *pathname);
 bool is_message_type_set(JCR *jcr, int type);
+void set_trace_for_tools(FILE *new_trace_fd); // called by Bacula's tools only
 
 class BDB;                                              /* define forward reference */
 typedef bool (*sql_query_call)(JCR *jcr, const char *cmd);
index 558868b5205a0c23bafa2be501ab8e5ca3af990d..7499a301dd2d03777d4142dcb7a66462f1d987ee 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula(R) - The Network Backup Solution
 
-   Copyright (C) 2000-2016 Kern Sibbald
+   Copyright (C) 2000-2018 Kern Sibbald
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -11,7 +11,7 @@
    Public License, v3.0 ("AGPLv3") and some additional permissions and
    terms pursuant to its AGPLv3 Section 7.
 
-   This notice must be preserved when any source code is 
+   This notice must be preserved when any source code is
    conveyed and/or propagated.
 
    Bacula(R) is a registered trademark of Kern Sibbald.
@@ -69,7 +69,7 @@ void openssl_post_errors(JCR *jcr, int code, const char *errstring)
    }
 }
 
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
 /* Array of mutexes for use with OpenSSL static locking */
 static pthread_mutex_t *mutexes;
 
@@ -267,7 +267,7 @@ int init_crypto (void)
 {
    int stat = 0;
 
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
    if ((stat = openssl_init_threads()) != 0) {
       berrno be;
       Jmsg1(NULL, M_ABORT, 0,
@@ -314,7 +314,7 @@ int cleanup_crypto (void)
       Jmsg0(NULL, M_ERROR, 0, _("Failed to save OpenSSL PRNG\n"));
    }
 
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
    openssl_cleanup_threads();
 
    /* Free libssl and libcrypto error strings */
index e07ad7dc4afc56b41aa3e8512dd096507f9b8eb1..ae12c1627863b92ae67aeafae4d63653762654e9 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula(R) - The Network Backup Solution
 
-   Copyright (C) 2000-2017 Kern Sibbald
+   Copyright (C) 2000-2018 Kern Sibbald
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -205,7 +205,7 @@ char *OutputWriter::get_output(va_list ap, POOLMEM **out, OutputType first)
    POOLMEM   *tmp2 = get_pool_memory(PM_FNAME);
    POOLMEM   *tmp = get_pool_memory(PM_FNAME);
    OutputType val = first;
-
+         
    while (val != OT_END) {
 
       *tmp = 0;
@@ -306,6 +306,12 @@ char *OutputWriter::get_output(va_list ap, POOLMEM **out, OutputType first)
          Mmsg(tmp, "%s_epoch=%lld%c%s=%s%c", k, bt, separator, k, ed1, separator);
          break;
 
+      case OT_DURATION:
+         bt = va_arg(ap, utime_t);     
+         bstrutime(ed1, sizeof(ed1), bt); 
+         Mmsg(tmp, "%s=%lld%c%s_str=%s%c", k, bt, separator, k, edit_utime(bt, ed1, sizeof(ed1)), separator);
+         break;
+
       case OT_SIZE:
       case OT_INT64:
          i64 = va_arg(ap, int64_t);
@@ -326,7 +332,11 @@ char *OutputWriter::get_output(va_list ap, POOLMEM **out, OutputType first)
       case OT_JOBTYPE:
       case OT_JOBSTATUS:
          i32 = va_arg(ap, int32_t);
-         Mmsg(tmp, "%s=%c%c", k, (char) i32, separator);
+         if (i32 == 0) {
+            Mmsg(tmp, "%s=%c", k, separator);
+         } else {
+            Mmsg(tmp, "%s=%c%c", k, (char)i32, separator);
+         }
          break;
 
       case OT_CLEAR:
index cb3573fbdd2dfce1242312fdd71e29f04eef6cd8..d907a7cd700aa7b93f4b87d33608f679bf515409 100644 (file)
@@ -94,7 +94,7 @@ static const char *get_default_configdir();
  *  name         handler      value       code   flags  default_value
  */
 RES_ITEM msgs_items[] = {
-   {"Name",        store_name,    ITEM(res_msgs.hdr.name),  0, 0, 0},
+   {"Name",        store_name,    ITEM(res_msgs.hdr.name),  0, ITEM_REQUIRED, 0},
    {"Description", store_str,     ITEM(res_msgs.hdr.desc),  0, 0, 0},
    {"MailCommand", store_str,     ITEM(res_msgs.mail_cmd),  0, ITEM_ALLOW_DUPS, 0},
    {"OperatorCommand", store_str, ITEM(res_msgs.operator_cmd), 0, ITEM_ALLOW_DUPS, 0},
index 939546be2d0b2461c2722ea3d0ebc65ffe811ff3..53c5a470c9212551dcc47ff5b59817967477a473 100644 (file)
@@ -145,6 +145,7 @@ int      bget_msg(BSOCK *sock);
 /* bpipe.c */
 BPIPE *          open_bpipe(char *prog, int wait, const char *mode, char *envp[]=NULL);
 int              close_wpipe(BPIPE *bpipe);
+int              close_epipe(BPIPE *bpipe);
 int              close_bpipe(BPIPE *bpipe);
 
 /* cram-md5.c */
index bbe7ce06379d4a1a28d7b78566c0aa596d9fe7c1..3aa7af5016c120bb03acdaac86bf0155cbd6eb1d 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula(R) - The Network Backup Solution
 
-   Copyright (C) 2000-2016 Kern Sibbald
+   Copyright (C) 2000-2018 Kern Sibbald
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -11,7 +11,7 @@
    Public License, v3.0 ("AGPLv3") and some additional permissions and
    terms pursuant to its AGPLv3 Section 7.
 
-   This notice must be preserved when any source code is 
+   This notice must be preserved when any source code is
    conveyed and/or propagated.
 
    Bacula(R) is a registered trademark of Kern Sibbald.
@@ -276,9 +276,11 @@ void free_runscripts(alist *runscripts)
 {
    Dmsg0(500, "runscript: freeing all RUNSCRIPTS object\n");
 
-   RUNSCRIPT *elt;
-   foreach_alist(elt, runscripts) {
-      free_runscript(elt);
+   if (runscripts){
+      RUNSCRIPT *elt;
+      foreach_alist(elt, runscripts) {
+         free_runscript(elt);
+      }
    }
 }
 
index 7d25ea35448659e7ceaf38bd6cf8793f21e2b7cc..604ccaee7c219427ed66c5e038d22ba0d3c09a70 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula(R) - The Network Backup Solution
 
-   Copyright (C) 2000-2017 Kern Sibbald
+   Copyright (C) 2000-2018 Kern Sibbald
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -79,6 +79,15 @@ static int openssl_verify_peer(int ok, X509_STORE_CTX *store)
       char issuer[256];
       char subject[256];
 
+      if (err == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT ||
+          err == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN)
+      {
+         /* It seems that the error can be also
+          * 24 X509_V_ERR_INVALID_CA: invalid CA certificate
+          * But it's not very specific...
+          */
+         Jmsg0(NULL, M_ERROR, 0, _("CA certificate is self signed. With OpenSSL 1.1, enforce basicConstraints = CA:true in the certificate creation to avoid this issue\n"));
+      }
       X509_NAME_oneline(X509_get_issuer_name(cert), issuer, 256);
       X509_NAME_oneline(X509_get_subject_name(cert), subject, 256);
 
@@ -219,7 +228,6 @@ TLS_CONTEXT *new_tls_context(const char *ca_certfile, const char *ca_certdir,
                          SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
                          openssl_verify_peer);
    }
-
    return ctx;
 
 err:
@@ -731,7 +739,6 @@ bool tls_bsock_probe(BSOCKCORE *bsock)
    return SSL_peek(bsock->tls->openssl, &pktsiz, sizeof(pktsiz))==sizeof(pktsiz);
 }
 
-
 #else /* HAVE_OPENSSL */
 # error No TLS implementation available.
 #endif /* !HAVE_OPENSSL */
index 76a5542c48e724db90327e55e3de24e0dcf466a5..572d9cd8c7055316e113e0dfec45d136c508ee55 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula(R) - The Network Backup Solution
 
-   Copyright (C) 2000-2017 Kern Sibbald
+   Copyright (C) 2000-2018 Kern Sibbald
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -81,7 +81,7 @@ TREE_ROOT *new_tree(int count)
       count = 1000;
    }
    root = (TREE_ROOT *)malloc(sizeof(TREE_ROOT));
-   memset(root, 0, sizeof(TREE_ROOT));
+   bmemset(root, 0, sizeof(TREE_ROOT));
    /* Assume filename + node  = 40 characters average length */
    size = count * (BALIGN(sizeof(TREE_NODE)) + 40);
    if (count > 1000000 || size > (MAX_BUF_SIZE / 2)) {
@@ -107,7 +107,7 @@ static TREE_NODE *new_tree_node(TREE_ROOT *root)
    TREE_NODE *node;
    int size = sizeof(TREE_NODE);
    node = (TREE_NODE *)tree_alloc(root, size);
-   memset(node, 0, size);
+   bmemset(node, 0, size);
    node->delta_seq = -1;
    node->can_access = 1;
    return node;
index 4da226a0e0a2af809a7f4e017c9b2cb384753400..fa65232f9fd841510d141e0c44acd92aca0f6e9c 100644 (file)
@@ -319,7 +319,13 @@ bool dir_find_next_appendable_volume(DCR *dcr)
     BSOCK *dir = jcr->dir_bsock;
     bool rtn;
     char lastVolume[MAX_NAME_LENGTH];
+    int nb_retry;
 
+    /*
+     * Calculate the number of possible drives + 30 for the size of the
+     *  Volume list to consider.
+     */
+    nb_retry = ((rblist *)res_head[R_DEVICE-r_first]->res_list)->size() + 30;
     Dmsg2(dbglvl, "dir_find_next_appendable_volume: reserved=%d Vol=%s\n",
        dcr->is_reserved(), dcr->VolumeName);
     Mmsg(jcr->errmsg, "Unknown error\n");
@@ -333,7 +339,7 @@ bool dir_find_next_appendable_volume(DCR *dcr)
     P(vol_info_mutex);
     dcr->clear_found_in_use();
     lastVolume[0] = 0;
-    for (int vol_index=1;  vol_index < 30; vol_index++) {
+    for (int vol_index=1;  vol_index < nb_retry; vol_index++) {
        bash_spaces(dcr->media_type);
        bash_spaces(dcr->pool_name);
        dir->fsend(Find_media, jcr->JobId, vol_index, dcr->pool_name, dcr->media_type,
@@ -358,7 +364,7 @@ bool dir_find_next_appendable_volume(DCR *dcr)
            */
           /* ***FIXME*** find better way to handle voltype */
           if (dcr->VolCatInfo.VolCatType != 0 &&
-              (dcr->dev->dev_type == B_FILE_DEV || dcr->dev->dev_type == B_ALIGNED_DEV || 
+              (dcr->dev->dev_type == B_FILE_DEV || dcr->dev->dev_type == B_ALIGNED_DEV ||
                dcr->dev->dev_type == B_CLOUD_DEV) &&
                dcr->dev->dev_type != (int)dcr->VolCatInfo.VolCatType) {
              Dmsg2(000, "Skip vol. Wanted VolType=%d Got=%d\n", dcr->dev->dev_type, dcr->VolCatInfo.VolCatType);
@@ -433,7 +439,7 @@ bool dir_update_volume_info(DCR *dcr, bool label, bool update_LastWritten,
    POOL_MEM VolumeName;
 
    /* If system job, do not update catalog, except if we explicitly force it. */
-   if (jcr->getJobType() == JT_SYSTEM && 
+   if (jcr->getJobType() == JT_SYSTEM &&
        !dcr->force_update_volume_info) {
       return true;
    }
@@ -537,6 +543,7 @@ bool dir_update_volume_info(DCR *dcr, bool label, bool update_LastWritten,
          dev->VolCatInfo.VolCatRecycles = dcr->VolCatInfo.VolCatRecycles;
          dev->VolCatInfo.VolCatWrites = dcr->VolCatInfo.VolCatWrites;
          dev->VolCatInfo.VolCatReads = dcr->VolCatInfo.VolCatReads;
+         dev->VolCatInfo.VolEnable = dcr->VolCatInfo.VolEnable;
          dev->VolCatInfo.VolRecycle = dcr->VolCatInfo.VolRecycle;
       }
       ok = true;
index c0e386881d55225d577d559fb5478386eead194f..24ffacab5f8e779d938e5ce92115bcd42ec737b5 100644 (file)
@@ -771,7 +771,9 @@ char *edit_device_codes(DCR *dcr, char *omsg, const char *imsg, const char *cmd)
             str = dcr->jcr->Job;
             break;
          case 'v':
-            if (dcr->VolCatInfo.VolCatName[0]) {
+            if (dcr->dev->LoadedVolName[0]) {
+               str = dcr->dev->LoadedVolName;
+            } else if (dcr->VolCatInfo.VolCatName[0]) {
                str = dcr->VolCatInfo.VolCatName;
             } else if (dcr->VolumeName[0]) {
                str = dcr->VolumeName;
index 6b23d3ebe38d06b2c0fa4eb0cbd00b130880275e..2a2e2f1f8775c161840648f1cb81b260ea08b22f 100644 (file)
@@ -52,6 +52,7 @@
  *  int32_t FileIndex
  *  int32_t Stream
  *  uint32_t data_length
+ *  uint64_t FileOffset (if offset_stream)
  */
 #define RECHDR2_LENGTH  (3*sizeof(int32_t))
 #define WRITE_RECHDR_LENGTH RECHDR2_LENGTH
index eb53b63be0884397cef4fe02c37dc538788ac7f6..9815d879300cbb92c484cc30f1a15806f0b7c86a 100644 (file)
@@ -391,12 +391,12 @@ static void do_scan()
 {
    attr = new_attr(bjcr);
 
-   memset(&ar, 0, sizeof(ar));
-   memset(&pr, 0, sizeof(pr));
-   memset(&jr, 0, sizeof(jr));
-   memset(&cr, 0, sizeof(cr));
-   memset(&fsr, 0, sizeof(fsr));
-   memset(&fr, 0, sizeof(fr));
+   bmemset(&ar, 0, sizeof(ar));
+   bmemset(&pr, 0, sizeof(pr));
+   bmemset(&jr, 0, sizeof(jr));
+   bmemset(&cr, 0, sizeof(cr));
+   bmemset(&fsr, 0, sizeof(fsr));
+   bmemset(&fr, 0, sizeof(fr));
 
    /* Detach bscan's jcr as we are not a real Job on the tape */
 
@@ -483,7 +483,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
          }
 
          /* Check Media Info */
-         memset(&mr, 0, sizeof(mr));
+         bmemset(&mr, 0, sizeof(mr));
          bstrncpy(mr.VolumeName, dev->VolHdr.VolumeName, sizeof(mr.VolumeName));
          mr.PoolId = pr.PoolId;
          num_media++;
@@ -528,7 +528,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
             ignored_msgs = 0;
          }
          unser_session_label(&label, rec);
-         memset(&jr, 0, sizeof(jr));
+         bmemset(&jr, 0, sizeof(jr));
          bstrncpy(jr.Job, label.Job, sizeof(jr.Job));
          if (db_get_job_record(bjcr, db, &jr)) {
             /* Job record already exists in DB */
@@ -669,6 +669,9 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
          Pmsg3(0, _("End of all Volumes. VolFiles=%u VolBlocks=%u VolBytes=%s\n"), mr.VolFiles,
                     mr.VolBlocks, edit_uint64_with_commas(mr.VolBytes, ec1));
          break;
+      case STREAM_PLUGIN_NAME:
+         break;
+
       default:
          break;
       } /* end switch */
@@ -887,7 +890,7 @@ static void bscan_free_jcr(JCR *jcr)
    free_bsock(jcr->file_bsock);
    free_bsock(jcr->store_bsock);
    if (jcr->RestoreBootstrap) {
-      free(jcr->RestoreBootstrap);
+      bfree_and_null(jcr->RestoreBootstrap);
    }
    if (jcr->dcr) {
       free_dcr(jcr->dcr);
@@ -1279,7 +1282,7 @@ static int create_jobmedia_record(BDB *db, JCR *mjcr)
    dcr->EndAddr = dev->EndAddr;
    dcr->VolMediaId = dev->VolCatInfo.VolMediaId;
 
-   memset(&jmr, 0, sizeof(jmr));
+   bmemset(&jmr, 0, sizeof(jmr));
    jmr.JobId = mjcr->JobId;
    jmr.MediaId = mr.MediaId;
    jmr.FirstIndex = dcr->VolFirstIndex;
index dc098280c8486d23f63d9beedadc08f20d1781da..257875bca31e7105e344f3150ad2b37a40d33831 100644 (file)
@@ -430,7 +430,7 @@ btime_t DEVICE::get_timer_count()
 /* read from fd */
 ssize_t DEVICE::read(void *buf, size_t len)
 {
-   ssize_t read_len ;
+   ssize_t read_len;
 
    get_timer_count();