From: Kern Sibbald Date: Sun, 18 Apr 2010 16:28:40 +0000 (+0200) Subject: Change plugin FileSet function names add NewOptions and NewIncludes X-Git-Tag: Release-7.0.0~1914 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=32da5e4fec94cd2bb0b554b350a4b13ae195d8bc;p=bacula%2Fbacula Change plugin FileSet function names add NewOptions and NewIncludes --- diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index 13b9fb0d05..a55427796c 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -66,9 +66,11 @@ static void *baculaMalloc(bpContext *ctx, const char *file, int line, static void baculaFree(bpContext *ctx, const char *file, int line, void *mem); static bRC baculaAddExclude(bpContext *ctx, const char *file); static bRC baculaAddInclude(bpContext *ctx, const char *file); -static bRC baculaAddIncludeOptions(bpContext *ctx, const char *opts); -static bRC baculaAddRegexToInclude(bpContext *ctx, const char *item, int type); -static bRC baculaAddWildToInclude(bpContext *ctx, const char *item, int type); +static bRC baculaAddOptions(bpContext *ctx, const char *opts); +static bRC baculaAddRegex(bpContext *ctx, const char *item, int type); +static bRC baculaAddWild(bpContext *ctx, const char *item, int type); +static bRC baculaNewOptions(bpContext *ctx); +static bRC baculaNewInclude(bpContext *ctx); static bool is_plugin_compatible(Plugin *plugin); /* @@ -101,9 +103,11 @@ static bFuncs bfuncs = { baculaFree, baculaAddExclude, baculaAddInclude, - baculaAddIncludeOptions, - baculaAddRegexToInclude, - baculaAddWildToInclude + baculaAddOptions, + baculaAddRegex, + baculaAddWild, + baculaNewOptions, + baculaNewInclude }; /* @@ -1129,7 +1133,7 @@ static bRC baculaAddInclude(bpContext *ctx, const char *file) return bRC_OK; } -static bRC baculaAddIncludeOptions(bpContext *ctx, const char *opts) +static bRC baculaAddOptions(bpContext *ctx, const char *opts) { JCR *jcr; bacula_ctx *bctx; @@ -1144,7 +1148,7 @@ static bRC baculaAddIncludeOptions(bpContext *ctx, const char *opts) return bRC_OK; } -static bRC baculaAddRegexToInclude(bpContext *ctx, const char *item, int type) +static bRC baculaAddRegex(bpContext *ctx, const char *item, int type) { JCR *jcr; bacula_ctx *bctx; @@ -1159,7 +1163,7 @@ static bRC baculaAddRegexToInclude(bpContext *ctx, const char *item, int type) return bRC_OK; } -static bRC baculaAddWildToInclude(bpContext *ctx, const char *item, int type) +static bRC baculaAddWild(bpContext *ctx, const char *item, int type) { JCR *jcr; bacula_ctx *bctx; @@ -1174,8 +1178,27 @@ static bRC baculaAddWildToInclude(bpContext *ctx, const char *item, int type) return bRC_OK; } +static bRC baculaNewOptions(bpContext *ctx) +{ + JCR *jcr; + bacula_ctx *bctx; + if (!is_ctx_good(ctx, jcr, bctx)) { + return bRC_Error; + } + (void)new_options(jcr, NULL); + return bRC_OK; +} - +static bRC baculaNewInclude(bpContext *ctx) +{ + JCR *jcr; + bacula_ctx *bctx; + if (!is_ctx_good(ctx, jcr, bctx)) { + return bRC_Error; + } + (void)new_include(jcr); + return bRC_OK; +} #ifdef TEST_PROGRAM diff --git a/bacula/src/filed/fd_plugins.h b/bacula/src/filed/fd_plugins.h index a8ca050c35..875936c963 100644 --- a/bacula/src/filed/fd_plugins.h +++ b/bacula/src/filed/fd_plugins.h @@ -246,9 +246,11 @@ typedef struct s_baculaFuncs { void (*baculaFree)(bpContext *ctx, const char *file, int line, void *mem); bRC (*AddExclude)(bpContext *ctx, const char *file); bRC (*AddInclude)(bpContext *ctx, const char *file); - bRC (*AddIncludeOptions)(bpContext *ctx, const char *opts); - bRC (*AddRegexToInclude)(bpContext *ctx, const char *item, int type); - bRC (*AddWildToInclude)(bpContext *ctx, const char *item, int type); + bRC (*AddOptions)(bpContext *ctx, const char *opts); + bRC (*AddRegex)(bpContext *ctx, const char *item, int type); + bRC (*AddWild)(bpContext *ctx, const char *item, int type); + bRC (*NewOptions)(bpContext *ctx); + bRC (*NewInclude)(bpContext *ctx); } bFuncs; diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index b373c916a7..2a9dca806f 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -889,6 +889,9 @@ static findFOPTS *start_options(FF_PKT *ff) */ void new_options(JCR *jcr, findINCEXE *incexe) { + if (!incexe) { + incexe = jcr->ff->fileset->incexe; + } findFOPTS *fo = (findFOPTS *)malloc(sizeof(findFOPTS)); memset(fo, 0, sizeof(findFOPTS)); fo->regex.init(1, true); @@ -902,7 +905,7 @@ void new_options(JCR *jcr, findINCEXE *incexe) fo->fstype.init(1, true); fo->drivetype.init(1, true); incexe->current_opts = fo; - incexe->opts_list.append(fo); + incexe->opts_list.prepend(fo); jcr->ff->fileset->state = state_options; } @@ -1230,6 +1233,7 @@ static int set_options(findFOPTS *fo, const char *opts) break; case 'R': /* Resource forks and Finder Info */ fo->flags |= FO_HFSPLUS; + break; case 'r': /* read fifo */ fo->flags |= FO_READFIFO; break; diff --git a/bacula/src/filed/protos.h b/bacula/src/filed/protos.h index 9def837dd9..dc7fd48c8b 100644 --- a/bacula/src/filed/protos.h +++ b/bacula/src/filed/protos.h @@ -75,3 +75,4 @@ void add_file_to_fileset(JCR *jcr, const char *fname, bool is_file); int add_options_to_fileset(JCR *jcr, const char *item); int add_wild_to_fileset(JCR *jcr, const char *item, int type); int add_regex_to_fileset(JCR *jcr, const char *item, int type); +findINCEXE *new_include(JCR *jcr); diff --git a/bacula/src/plugins/fd/test-plugin-fd.c b/bacula/src/plugins/fd/test-plugin-fd.c index c0d1feede1..681ca2192b 100644 --- a/bacula/src/plugins/fd/test-plugin-fd.c +++ b/bacula/src/plugins/fd/test-plugin-fd.c @@ -230,12 +230,13 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) break; /* End of Dir FileSet commands, now we can add excludes */ case bEventEndFileSet: - bfuncs->AddWildToInclude(ctx, "*.c", ' '); - bfuncs->AddWildToInclude(ctx, "*.cpp", ' '); - bfuncs->AddIncludeOptions(ctx, "ei"); /* exclude, ignore case */ + bfuncs->NewOptions(ctx); + bfuncs->AddWild(ctx, "*.c", ' '); + bfuncs->AddWild(ctx, "*.cpp", ' '); + bfuncs->AddOptions(ctx, "ei"); /* exclude, ignore case */ + bfuncs->AddExclude(ctx, "/home/kern/bacula/regress/README"); break; case bEventStartBackupJob: - bfuncs->AddExclude(ctx, "/home/kern/bacula/regress/README"); break; case bEventRestoreObject: printf("Plugin RestoreObject\n");