(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
-/*
+/**
* Main program to test loading and running Bacula plugins.
* Destined to become Bacula pluginloader, ...
*
static void *baculaMalloc(bpContext *ctx, const char *file, int line,
size_t size);
static void baculaFree(bpContext *ctx, const char *file, int line, void *mem);
+static bRC baculaAddExclude(bpContext *ctx, const char *file);
static bool is_plugin_compatible(Plugin *plugin);
/*
baculaJobMsg,
baculaDebugMsg,
baculaMalloc,
- baculaFree
+ baculaFree,
+ baculaAddExclude
};
/*
JCR *jcr; /* jcr for plugin */
bRC rc; /* last return code */
bool disabled; /* set if plugin disabled */
+ findFILESET *fileset; /* pointer to exclude files */
};
static bool is_plugin_disabled(JCR *jcr)
}
-/*
+/**
* Create a plugin event
*/
void generate_plugin_event(JCR *jcr, bEventType eventType, void *value)
return;
}
-/*
+/**
* Check if file was seen for accurate
*/
bool plugin_check_file(JCR *jcr, char *fname)
}
-/*
+/**
* Sequence of calls for a backup:
* 1. plugin_save() here is called with ff_pkt
* 2. we find the plugin requested on the command string
return 1;
}
-/*
+/**
* Send plugin name start/end record to SD
*/
bool send_plugin_name(JCR *jcr, BSOCK *sd, bool start)
return true;
}
-/*
+/**
* Plugin name stream found during restore. The record passed in
* argument name was generated in send_plugin_name() above.
*
return start;
}
-/*
+/**
* Tell the plugin to create the file. Return values are
* This is called only during Restore
*
return CF_EXTRACT;
}
-/*
+/**
* Reset the file attributes after all file I/O is done -- this allows
* the previous access time/dates to be set properly, and it also allows
* us to properly set directory permissions.
fprintf(fp, "\tdescription=%s\n", NPRTB(info->plugin_description));
}
-/*
+/**
* This entry point is called internally by Bacula to ensure
* that the plugin IO calls come into this code.
*/
dbg_plugin_add_hook(dump_fd_plugin);
}
-/*
+/**
* Check if a plugin is compatible. Called by the load_plugin function
* to allow us to verify the plugin.
*/
}
-/*
+/**
* Create a new instance of each plugin for this Job
* Note, plugin_list can exist but jcr->plugin_ctx_list can
* be NULL if no plugins were loaded.
}
}
-/*
+/**
* Free the plugin instances for this Job
*/
void free_plugins(JCR *jcr)
struct io_pkt io;
Dmsg1(dbglvl, "plugin_bopen flags=%x\n", flags);
+ if (!plugin || !jcr->plugin_ctx) {
+ return 0;
+ }
io.pkt_size = sizeof(io);
io.pkt_end = sizeof(io);
io.func = IO_OPEN;
JCR *jcr = bfd->jcr;
Plugin *plugin = (Plugin *)jcr->plugin;
struct io_pkt io;
+
Dmsg0(dbglvl, "===== plugin_bclose\n");
+ if (!plugin || !jcr->plugin_ctx) {
+ return 0;
+ }
io.pkt_size = sizeof(io);
io.pkt_end = sizeof(io);
io.func = IO_CLOSE;
JCR *jcr = bfd->jcr;
Plugin *plugin = (Plugin *)jcr->plugin;
struct io_pkt io;
+
Dmsg0(dbglvl, "plugin_bread\n");
+ if (!plugin || !jcr->plugin_ctx) {
+ return 0;
+ }
io.pkt_size = sizeof(io);
io.pkt_end = sizeof(io);
io.func = IO_READ;
JCR *jcr = bfd->jcr;
Plugin *plugin = (Plugin *)jcr->plugin;
struct io_pkt io;
+
Dmsg0(dbglvl, "plugin_bwrite\n");
+ if (!plugin || !jcr->plugin_ctx) {
+ return 0;
+ }
io.pkt_size = sizeof(io);
io.pkt_end = sizeof(io);
io.func = IO_WRITE;
JCR *jcr = bfd->jcr;
Plugin *plugin = (Plugin *)jcr->plugin;
struct io_pkt io;
+
Dmsg0(dbglvl, "plugin_bseek\n");
+ if (!plugin || !jcr->plugin_ctx) {
+ return 0;
+ }
io.pkt_size = sizeof(io);
io.pkt_end = sizeof(io);
io.func = IO_SEEK;
if (!value || !ctx) {
return bRC_Error;
}
- jcr = ((bacula_ctx *)ctx->bContext)->jcr;
// Dmsg1(dbglvl, "bacula: baculaGetValue var=%d\n", var);
jcr = ((bacula_ctx *)ctx->bContext)->jcr;
if (!jcr) {
break;
case bVarFileSeen:
break; /* a write only variable, ignore read request */
+ case bVarVssObject:
+#ifdef HAVE_WIN32
+ if (g_pVSSClient) {
+ *(void **)value = g_pVSSClient->GetVssObject();
+ break;
+ }
+#endif
+ return bRC_Error;
+ case bVarVssDllHandle:
+#ifdef HAVE_WIN32
+ if (g_pVSSClient) {
+ *(void **)value = g_pVSSClient->GetVssDllHandle();
+ break;
+ }
+#endif
+ return bRC_Error;
}
return bRC_OK;
}
if (!value || !ctx) {
return bRC_Error;
}
- jcr = ((bacula_ctx *)ctx->bContext)->jcr;
// Dmsg1(dbglvl, "bacula: baculaGetValue var=%d\n", var);
jcr = ((bacula_ctx *)ctx->bContext)->jcr;
if (!jcr) {
#endif
}
+/**
+ * Let the plugin define files/directories to be excluded
+ * from the main backup.
+ */
+static bRC baculaAddExclude(bpContext *ctx, const char *file)
+{
+ JCR *jcr;
+ bacula_ctx *bctx;
+ if (ctx) {
+ return bRC_Error;
+ }
+ if (!file) {
+ return bRC_Error;
+ }
+ bctx = (bacula_ctx *)ctx->bContext;
+ if (!bctx) {
+ return bRC_Error;
+ }
+ jcr = bctx->jcr;
+ if (!jcr) {
+ return bRC_Error;
+ }
+ if (!bctx->fileset) {
+ bctx->fileset = new_exclude(jcr);
+ }
+ add_file_to_fileset(jcr, file, bctx->fileset, true);
+ return bRC_OK;
+}
#ifdef TEST_PROGRAM