#endif
extern int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level);
+extern bool check_changes(JCR *jcr, FF_PKT *ff_pkt);
/* Function pointers to be set here */
extern DLL_IMP_EXP int (*plugin_bopen)(BFILE *bfd, const char *fname, int flags, mode_t mode);
static bRC baculaNewInclude(bpContext *ctx);
static bool is_plugin_compatible(Plugin *plugin);
static bool get_plugin_name(JCR *jcr, char *cmd, int *ret);
+static bRC baculaCheckChanges(bpContext *ctx, struct save_pkt *sp);
/*
* These will be plugged into the global pointer structure for
baculaAddRegex,
baculaAddWild,
baculaNewOptions,
- baculaNewInclude
+ baculaNewInclude,
+ baculaCheckChanges
};
/*
case bVarWorkingDir:
*(void **)value = me->working_directory;
break;
+ case bVarWhere:
+ *(char **)value = jcr->where;
+ break;
+ case bVarRegexWhere:
+ *(char **)value = jcr->RegexWhere;
+ break;
}
return bRC_OK;
}
}
+/*
+ * Check if a file have to be backuped using Accurate code
+ */
+static bRC baculaCheckChanges(bpContext *ctx, struct save_pkt *sp)
+{
+ JCR *jcr;
+ bacula_ctx *bctx;
+ FF_PKT *ff_pkt;
+ bRC ret = bRC_Error;
+
+ if (!is_ctx_good(ctx, jcr, bctx)) {
+ goto bail_out;
+ }
+ if (!sp) {
+ goto bail_out;
+ }
+
+ ff_pkt = jcr->ff;
+ /*
+ * Copy fname and link because save_file() zaps them. This
+ * avoids zaping the plugin's strings.
+ */
+ ff_pkt->type = sp->type;
+ if (!sp->fname) {
+ Jmsg0(jcr, M_FATAL, 0, _("Command plugin: no fname in baculaCheckChanges packet.\n"));
+ goto bail_out;
+ }
+
+ ff_pkt->fname = sp->fname;
+ ff_pkt->link = sp->link;
+ memcpy(&ff_pkt->statp, &sp->statp, sizeof(ff_pkt->statp));
+
+ if (check_changes(jcr, ff_pkt)) {
+ ret = bRC_OK;
+ } else {
+ ret = bRC_Seen;
+ }
+
+bail_out:
+ Dmsg1(100, "checkChanges=%i\n", ret);
+ return ret;
+}
+
+
#ifdef TEST_PROGRAM
int (*plugin_bopen)(JCR *jcr, const char *fname, int flags, mode_t mode) = NULL;
bVarFileSeen = 10,
bVarVssObject = 11,
bVarVssDllHandle = 12,
- bVarWorkingDir = 13
+ bVarWorkingDir = 13,
+ bVarWhere = 14,
+ bVarRegexWhere = 15
} bVariable;
/* Events that are passed to plugin */
bRC (*AddWild)(bpContext *ctx, const char *item, int type);
bRC (*NewOptions)(bpContext *ctx);
bRC (*NewInclude)(bpContext *ctx);
+ bRC (*checkChanges)(bpContext *ctx, struct save_pkt *sp);
} bFuncs;
#define FD_PLUGIN_MAGIC "*FDPluginData*"
-#define FD_PLUGIN_INTERFACE_VERSION 4
+#define FD_PLUGIN_INTERFACE_VERSION 5
typedef struct s_pluginInfo {
uint32_t size;
* For incremental/diffential or accurate backups, we
* determine if the current file has changed.
*/
-static bool check_changes(JCR *jcr, FF_PKT *ff_pkt)
+bool check_changes(JCR *jcr, FF_PKT *ff_pkt)
{
/* in special mode (like accurate backup), the programmer can
* choose his comparison function.
char *p, dev_t parent_device, bool top_level);
int term_find_one(FF_PKT *ff);
bool has_file_changed(JCR *jcr, FF_PKT *ff_pkt);
+bool check_changes(JCR *jcr, FF_PKT *ff_pkt);
/* From get_priv.c */
int enable_backup_privileges(JCR *jcr, int ignore_errors);