From: Radosław Korzeniewski Date: Thu, 7 Oct 2021 15:09:06 +0000 (+0200) Subject: Update Plugin API code for FileSet management. X-Git-Tag: Beta-15.0.0~860 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93177e625ad9e827c93482e2678d559d6536c8d6;p=thirdparty%2Fbacula.git Update Plugin API code for FileSet management. 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. --- diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index 16fa7076b..2878e017d 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -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; } diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 5d05c734b..ab2737658 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -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) diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c index c41dc28a1..7410fcdca 100644 --- a/bacula/src/findlib/find.c +++ b/bacula/src/findlib/find.c @@ -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;