]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Update Plugin API code for FileSet management.
authorRadosław Korzeniewski <radoslaw@korzeniewski.net>
Thu, 7 Oct 2021 15:09:06 +0000 (17:09 +0200)
committerEric Bollengier <eric@baculasystems.com>
Wed, 6 Sep 2023 07:49:01 +0000 (09:49 +0200)
This patch removes the limit of dynamically created and managed
Include{} blocks using Bacula FD Plugin API. It fixes two main issues:
- New Include should always reset the state. It is basically done by
the Director executing "N" fileset command when giving information
about Fileset to backup. But for the dynamically created Includes
(by plugins) this state reset was never executed. Fixed.
- The AddInclude() has to deal with Bacula running the job (next file
to backup, other plugins, etc.), so the current `ff->incexe` variable
can change at any time. For this case it saves in its private context
the current include managed by the plugin. So the NewInclude(),
after the patch,  will switch include in private context to the newly
created, required by the plugin. Without it the newly created include
is lost for AddInclude(). Fixed.

bacula/src/filed/fd_plugins.c
bacula/src/filed/job.c
bacula/src/findlib/find.c

index 16fa7076b86a8419fa3091c49181399b7e503bce..2878e017d5c7ddce2322cca6cd6f6eb892f85e97 100644 (file)
@@ -2343,7 +2343,8 @@ static bRC baculaNewInclude(bpContext *ctx)
    if (!is_ctx_good(ctx, jcr, bctx)) {
       return bRC_Error;
    }
-   (void)new_include(jcr);
+   // without this any AddInclude() is unable to use more than one Include{} block
+   bctx->include = new_include(jcr);
    Dsm_check(999);
    return bRC_OK;
 }
index 5d05c734bd0b4807e60dc74ca498b54617051be2..ab2737658dca8ea0db4f0a8525fbfed9ef2a714f 100644 (file)
@@ -45,7 +45,7 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 const bool have_win32 = true;
 #else
 const bool have_win32 = false;
-#endif 
+#endif
 
 #ifdef HAVE_ACL
 const bool have_acl = true;
@@ -891,7 +891,7 @@ static int exit_cmd(JCR *jcr)
    return 0;
 }
 #endif
+
 /**
  * Hello from Director he must identify himself and provide his
  *  password.
@@ -1523,6 +1523,11 @@ findINCEXE *new_include(JCR *jcr)
    fileset->incexe->name_list.init(); /* for dlist;  was 1,true for alist */
    fileset->incexe->plugin_list.init();
    fileset->include_list.append(fileset->incexe);
+   // New Include should always reset the state.
+   // it is basically done by the Director executing "N" fileset command when giving information
+   // about Fileset to backup. But for the dynamically created Includes (by plugins) this state
+   // reset was never executed. This limits the usage to the single dynamic Include.
+   fileset->state = state_none;
    return fileset->incexe;
 }
 
@@ -2414,7 +2419,7 @@ static void sendit(JCR *jcr, const char *str)
 }
 
 /*
- * Query plugin parameter interface 
+ * Query plugin parameter interface
  *
  */
 static int query_cmd(JCR *jcr)
index c41dc28a1882be818a20ebfcf082b631ceeee6d8..7410fcdca805d209d9fd11277366a65947efb725 100644 (file)
@@ -93,7 +93,7 @@ set_find_changed_function(FF_PKT *ff, bool check_fct(JCR *jcr, FF_PKT *ff))
 }
 
 void
-set_find_snapshot_function(FF_PKT *ff, 
+set_find_snapshot_function(FF_PKT *ff,
                            bool convert_path(JCR *jcr, FF_PKT *ff, dlist *filelist, dlistString *node))
 {
    ff->snapshot_convert_fct = convert_path;