From 970221ee04633bbb51574e91df664f5d8e0aa450 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 12 Feb 2008 21:01:20 +0000 Subject: [PATCH] Plugin updates git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6407 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/filed/backup.c | 6 - bacula/src/filed/fd-plugins.c | 189 ++++++++++++---------- bacula/src/filed/fd-plugins.h | 30 ++-- bacula/src/filed/job.c | 12 +- bacula/src/filed/restore.c | 1 + bacula/src/plugins/fd/Makefile | 2 +- bacula/src/plugins/fd/bpipe-fd.c | 55 +++++-- bacula/src/plugins/fd/example-plugin-fd.c | 32 ++-- bacula/src/stored/append.c | 2 +- bacula/src/stored/record.c | 5 + 10 files changed, 191 insertions(+), 143 deletions(-) diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 4cb4b6e2b5..646f17928f 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -40,7 +40,6 @@ /* Forward referenced functions */ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level); -static int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level); static void strip_path(FF_PKT *ff_pkt); static void unstrip_path(FF_PKT *ff_pkt); static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, DIGEST *signature_digest); @@ -239,11 +238,6 @@ static bool crypto_session_send(JCR *jcr, BSOCK *sd) return true; } -int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) -{ - generate_plugin_event(jcr, bEventPluginCommand, (void *)ff_pkt->top_fname); - return 1; -} /* * Called here by find() for each file included. diff --git a/bacula/src/filed/fd-plugins.c b/bacula/src/filed/fd-plugins.c index f8a9bfb37d..2e1d151a40 100644 --- a/bacula/src/filed/fd-plugins.c +++ b/bacula/src/filed/fd-plugins.c @@ -81,12 +81,43 @@ static bFuncs bfuncs = { baculaDebugMsg }; + +/* + * Create a plugin event + */ +void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) +{ + bEvent event; + Plugin *plugin; + int i = 0; + + if (!plugin_list) { + return; /* Return if no plugins loaded */ + } + + bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list; + event.eventType = eventType; + + Dmsg2(dbglvl, "plugin_ctx=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); + + /* Pass event to every plugin */ + foreach_alist(plugin, plugin_list) { + bRC rc; + rc = plug_func(plugin)->handlePluginEvent(&plugin_ctx_list[i++], &event, value); + if (rc != bRC_OK) { + break; + } + } + + return; +} + /* * Sequence of calls for a backup: - * 1. generate_plugin_event called with bEventPluginCommand - * the command string is passed as an argument. + * 1. plugin_save() here is called with ff_pkt * 2. we find the plugin requested on the command string - * 3. we generate a bEventPluginCommand event to the specified plugin + * 3. we generate a bEventBackupCommand event to the specified plugin + * and pass it the command string. * 4. we make a startPluginBackup call to the plugin, which gives * us the data we need in save_pkt * 5. we call Bacula's save_file() subroutine to save the specified @@ -96,94 +127,75 @@ static bFuncs bfuncs = { * Sequence of calls for restore: * See subroutine plugin_name_stream() below. */ - -/* - * Create a plugin event - */ -void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) +int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) { - bEvent event; Plugin *plugin; int i = 0; int len; char *p; - char *cmd = (char *)value; + char *cmd = ff_pkt->top_fname; struct save_pkt sp; - FF_PKT *ff_pkt; + bEvent event; + + bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list; + event.eventType = bEventBackupCommand; if (!plugin_list) { - return; + return 1; /* Return if no plugins loaded */ } - bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list; - event.eventType = eventType; + /* Handle plugin command here backup */ + Dmsg1(100, "plugin cmd=%s\n", cmd); + if (!(p = strchr(cmd, ':'))) { + Jmsg1(jcr, M_ERROR, 0, "Malformed plugin command: %s\n", cmd); + goto bail_out; + } + len = p - cmd; + if (len <= 0) { + goto bail_out; + } - Dmsg2(dbglvl, "plugin_ctx=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); - switch (eventType) { - case bEventPluginCommand: - /* Handle plugin command here backup */ - Dmsg1(100, "plugin cmd=%s\n", cmd); - if (!(p = strchr(cmd, ':'))) { - Jmsg1(jcr, M_ERROR, 0, "Malformed plugin command: %s\n", cmd); - goto bail_out; + foreach_alist(plugin, plugin_list) { + Dmsg3(100, "plugin=%s cmd=%s len=%d\n", plugin->file, cmd, len); + if (strncmp(plugin->file, cmd, len) != 0) { + i++; + continue; } - len = p - cmd; - if (len <= 0) { + Dmsg1(100, "Command plugin = %s\n", cmd); + /* Send the backup command */ + if (plug_func(plugin)->handlePluginEvent(&plugin_ctx_list[i], &event, cmd) != bRC_OK) { goto bail_out; } - - foreach_alist(plugin, plugin_list) { - Dmsg3(100, "plugin=%s cmd=%s len=%d\n", plugin->file, cmd, len); - if (strncmp(plugin->file, cmd, len) != 0) { - i++; - continue; - } - while (!job_canceled(jcr)) { - Dmsg1(100, "Command plugin = %s\n", cmd); - if (plug_func(plugin)->handlePluginEvent(&plugin_ctx_list[i], &event, value) != bRC_OK) { - goto bail_out; - } - memset(&sp, 0, sizeof(sp)); - sp.type = FT_REG; - sp.portable = true; - sp.cmd = cmd; - Dmsg3(000, "startBackup st_size=%p st_blocks=%p sp=%p\n", &sp.statp.st_size, &sp.statp.st_blocks, - &sp); - if (plug_func(plugin)->startPluginBackup(&plugin_ctx_list[i], &sp) != bRC_OK) { - goto bail_out; - } - jcr->plugin_ctx = &plugin_ctx_list[i]; - jcr->plugin = plugin; - jcr->plugin_sp = &sp; - ff_pkt = jcr->ff; - ff_pkt->fname = sp.fname; - ff_pkt->type = sp.type; - memcpy(&ff_pkt->statp, &sp.statp, sizeof(ff_pkt->statp)); - Dmsg1(000, "Save_file: file=%s\n", ff_pkt->fname); - save_file(jcr, ff_pkt, true); - /* ***FIXME***/ - /* add call to endPluginBackup() and loop on bRC_MORE */ + /* Loop getting filenames to backup then saving them */ + while (!job_canceled(jcr)) { + memset(&sp, 0, sizeof(sp)); + sp.type = FT_REG; + sp.portable = true; + sp.cmd = cmd; + Dmsg3(000, "startBackup st_size=%p st_blocks=%p sp=%p\n", &sp.statp.st_size, &sp.statp.st_blocks, + &sp); + /* Get the file save parameters */ + if (plug_func(plugin)->startBackupFile(&plugin_ctx_list[i], &sp) != bRC_OK) { goto bail_out; } - } - Jmsg1(jcr, M_ERROR, 0, "Command plugin \"%s\" not found.\n", cmd); - break; - - default: - /* Pass event to every plugin */ - foreach_alist(plugin, plugin_list) { - bRC rc; - rc = plug_func(plugin)->handlePluginEvent(&plugin_ctx_list[i++], &event, value); - if (rc != bRC_OK) { - break; + jcr->plugin_ctx = &plugin_ctx_list[i]; + jcr->plugin = plugin; + jcr->plugin_sp = &sp; + ff_pkt = jcr->ff; + ff_pkt->fname = sp.fname; + ff_pkt->type = sp.type; + memcpy(&ff_pkt->statp, &sp.statp, sizeof(ff_pkt->statp)); + Dmsg1(000, "Save_file: file=%s\n", ff_pkt->fname); + save_file(jcr, ff_pkt, true); + if (plug_func(plugin)->endBackupFile(&plugin_ctx_list[i]) != bRC_More) { + goto bail_out; } } - break; } + Jmsg1(jcr, M_ERROR, 0, "Command plugin \"%s\" not found.\n", cmd); - bail_out: - return; + return 1; } /* @@ -194,37 +206,44 @@ bool send_plugin_name(JCR *jcr, BSOCK *sd, bool start) int stat; struct save_pkt *sp = (struct save_pkt *)jcr->plugin_sp; - if (!sd->fsend("%ld %d %d", jcr->JobFiles, STREAM_PLUGIN_NAME, start)) { + Dmsg1(000, "send_plugin_name=%s\n", sp->cmd); + if (!sd->fsend("%ld %d 0", jcr->JobFiles, STREAM_PLUGIN_NAME)) { Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), sd->bstrerror()); return false; } - stat = sd->fsend("%ld %d %d %s%c", jcr->JobFiles, start, sp->portable, sp->cmd, 0); + Dmsg1(000, "send: %s\n", sd->msg); + + if (start) { + stat = sd->fsend("%ld 1 %d %s%c", jcr->JobFiles, sp->portable, sp->cmd, 0); + } else { + stat = sd->fsend("%ld 0"); + } if (!stat) { Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), sd->bstrerror()); return false; } + Dmsg1(000, "send: %s\n", sd->msg); sd->signal(BNET_EOD); /* indicate end of plugin name data */ return true; } /* - * Plugin name stream found during restore. This is the record - * that was generated in send_plugin_name() above. + * Plugin name stream found during restore. The record passed in + * argument name was generated in send_plugin_name() above. */ void plugin_name_stream(JCR *jcr, char *name) { char *p = name; char *cmd; bool start, portable; - bEvent event; Plugin *plugin; int len; int i = 0; - bpContext *plugin_ctx_list; + bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list; - Dmsg1(000, "plugin stream string=%s\n", name); + Dmsg1(000, "Read plugin stream string=%s\n", name); skip_nonspaces(&p); /* skip over jcr->JobFiles */ skip_spaces(&p); start = *p == '1'; @@ -234,7 +253,6 @@ void plugin_name_stream(JCR *jcr, char *name) skip_nonspaces(&p); /* skip portable flag */ skip_spaces(&p); cmd = p; - event.eventType = start ? bEventRestoreStart : bEventRestoreEnd; /* Check for restore end */ if (!start) { @@ -242,7 +260,7 @@ void plugin_name_stream(JCR *jcr, char *name) * If end of restore, notify plugin, then clear flags */ plugin = (Plugin *)jcr->plugin; - plug_func(plugin)->handlePluginEvent((bpContext *)jcr->plugin_ctx, &event, cmd); + plug_func(plugin)->endRestoreFile(&plugin_ctx_list[i]); jcr->plugin_ctx = NULL; jcr->plugin = NULL; goto bail_out; @@ -262,17 +280,20 @@ void plugin_name_stream(JCR *jcr, char *name) goto bail_out; } - - plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list; + /* + * Search for correct plugin as specified on the command + */ foreach_alist(plugin, plugin_list) { - Dmsg3(100, "plugin=%s cmd=%s len=%d\n", plugin->file, cmd, len); + bEvent event; + Dmsg3(000, "plugin=%s cmd=%s len=%d\n", plugin->file, cmd, len); if (strncmp(plugin->file, cmd, len) != 0) { i++; continue; } - Dmsg1(100, "Command plugin = %s\n", cmd); + Dmsg1(000, "Restore Command plugin = %s\n", cmd); + event.eventType = bEventRestoreCommand; if (plug_func(plugin)->handlePluginEvent(&plugin_ctx_list[i], - &event, (void *)name) != bRC_OK) { + &event, cmd) != bRC_OK) { goto bail_out; } jcr->plugin_ctx = &plugin_ctx_list[i]; diff --git a/bacula/src/filed/fd-plugins.h b/bacula/src/filed/fd-plugins.h index 78de898382..08365fc549 100644 --- a/bacula/src/filed/fd-plugins.h +++ b/bacula/src/filed/fd-plugins.h @@ -113,18 +113,18 @@ typedef enum { } bVariable; typedef enum { - bEventJobStart = 1, - bEventJobEnd = 2, - bEventBackupStart = 3, - bEventBackupEnd = 4, - bEventRestoreStart = 5, - bEventRestoreEnd = 6, - bEventVerifyStart = 7, - bEventVerifyEnd = 8, - bEventPluginCommand = 9, - bEventPluginFile = 10, - bEventLevel = 11, - bEventSince = 12, + bEventJobStart = 1, + bEventJobEnd = 2, + bEventStartBackupJob = 3, + bEventEndBackupJob = 4, + bEventStartRestoreJob = 5, + bEventEndRestoreJob = 6, + bEventStartVerifyJob = 7, + bEventEndVerifyJob = 8, + bEventBackupCommand = 9, + bEventRestoreCommand = 10, + bEventLevel = 11, + bEventSince = 12, } bEventType; typedef struct s_bEvent { @@ -138,6 +138,7 @@ typedef struct s_baculaInfo { /* Bacula Core Routines -- not used by plugins */ struct BFILE; /* forward referenced */ +struct FF_PKT; void load_fd_plugins(const char *plugin_dir); void new_plugins(JCR *jcr); void free_plugins(JCR *jcr); @@ -146,6 +147,7 @@ bool send_plugin_name(JCR *jcr, BSOCK *sd, bool start); void plugin_name_stream(JCR *jcr, char *name); int plugin_create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace); bool plugin_set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd); +int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level); #ifdef __cplusplus extern "C" { @@ -208,8 +210,8 @@ typedef struct s_pluginFuncs { bRC (*getPluginValue)(bpContext *ctx, pVariable var, void *value); bRC (*setPluginValue)(bpContext *ctx, pVariable var, void *value); bRC (*handlePluginEvent)(bpContext *ctx, bEvent *event, void *value); - bRC (*startPluginBackup)(bpContext *ctx, struct save_pkt *sp); - bRC (*endPluginBackup)(bpContext *ctx); + bRC (*startBackupFile)(bpContext *ctx, struct save_pkt *sp); + bRC (*endBackupFile)(bpContext *ctx); bRC (*startRestoreFile)(bpContext *ctx, const char *cmd); bRC (*endRestoreFile)(bpContext *ctx); bRC (*pluginIO)(bpContext *ctx, struct io_pkt *io); diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index b7d821e696..23921df0c8 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1429,7 +1429,7 @@ static int backup_cmd(JCR *jcr) } generate_daemon_event(jcr, "JobStart"); - generate_plugin_event(jcr, bEventBackupStart); + generate_plugin_event(jcr, bEventStartBackupJob); #if defined(WIN32_VSS) /* START VSS ON WIN32 */ @@ -1542,7 +1542,7 @@ cleanup: } #endif - generate_plugin_event(jcr, bEventBackupEnd); + generate_plugin_event(jcr, bEventEndBackupJob); return 0; /* return and stop command loop */ } @@ -1581,7 +1581,7 @@ static int verify_cmd(JCR *jcr) generate_daemon_event(jcr, "JobStart"); generate_plugin_event(jcr, bEventLevel, (void *)jcr->JobLevel); - generate_plugin_event(jcr, bEventVerifyStart); + generate_plugin_event(jcr, bEventStartVerifyJob); Dmsg1(110, "bfiled>dird: %s", dir->msg); @@ -1619,7 +1619,7 @@ static int verify_cmd(JCR *jcr) } dir->signal(BNET_EOD); - generate_plugin_event(jcr, bEventVerifyEnd); + generate_plugin_event(jcr, bEventEndVerifyJob); return 0; /* return and terminate command loop */ } @@ -1697,7 +1697,7 @@ static int restore_cmd(JCR *jcr) */ start_dir_heartbeat(jcr); generate_daemon_event(jcr, "JobStart"); - generate_plugin_event(jcr, bEventRestoreStart); + generate_plugin_event(jcr, bEventStartRestoreJob); do_restore(jcr); stop_dir_heartbeat(jcr); @@ -1724,7 +1724,7 @@ bail_out: } Dmsg0(130, "Done in job.c\n"); - generate_plugin_event(jcr, bEventRestoreEnd); + generate_plugin_event(jcr, bEventEndRestoreJob); return 0; /* return and terminate command loop */ } diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index 2032af27b0..5624b2d33d 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -645,6 +645,7 @@ void do_restore(JCR *jcr) break; case STREAM_PLUGIN_NAME: + Dmsg1(000, "stream_plugin_name=%s\n", sd->msg); plugin_name_stream(jcr, sd->msg); break; diff --git a/bacula/src/plugins/fd/Makefile b/bacula/src/plugins/fd/Makefile index df708819c9..2fa3e63ec2 100644 --- a/bacula/src/plugins/fd/Makefile +++ b/bacula/src/plugins/fd/Makefile @@ -13,7 +13,7 @@ LIBDIR=../../lib .c.o: $(CC) -I${SRCDIR} -I${FDDOR} -DTEST_PROGRAM -c $< -all: main example-plugin-fd.so bpipe-fd.so +all: main bpipe-fd.so fd-plugins.o: ${FDDIR}/fd-plugins.h ${FDDIR}/fd-plugins.c $(CC) -I${SRCDIR} -I${FDDIR} -DTEST_PROGRAM -c ${FDDIR}/fd-plugins.c diff --git a/bacula/src/plugins/fd/bpipe-fd.c b/bacula/src/plugins/fd/bpipe-fd.c index 9b16235e33..e470050385 100644 --- a/bacula/src/plugins/fd/bpipe-fd.c +++ b/bacula/src/plugins/fd/bpipe-fd.c @@ -53,8 +53,8 @@ static bRC freePlugin(bpContext *ctx); static bRC getPluginValue(bpContext *ctx, pVariable var, void *value); static bRC setPluginValue(bpContext *ctx, pVariable var, void *value); static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value); -static bRC startPluginBackup(bpContext *ctx, struct save_pkt *sp); -static bRC endPluginBackup(bpContext *ctx); +static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp); +static bRC endBackupFile(bpContext *ctx); static bRC pluginIO(bpContext *ctx, struct io_pkt *io); static bRC startRestoreFile(bpContext *ctx, const char *cmd); static bRC endRestoreFile(bpContext *ctx); @@ -87,8 +87,8 @@ static pFuncs pluginFuncs = { getPluginValue, setPluginValue, handlePluginEvent, - startPluginBackup, - endPluginBackup, + startBackupFile, + endBackupFile, startRestoreFile, endRestoreFile, pluginIO, @@ -164,10 +164,10 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) case bEventJobEnd: // printf("bpipe-fd: JobEnd\n"); break; - case bEventBackupStart: + case bEventStartBackupJob: // printf("bpipe-fd: BackupStart\n"); break; - case bEventBackupEnd: + case bEventEndBackupJob: // printf("bpipe-fd: BackupEnd\n"); break; case bEventLevel: @@ -177,17 +177,20 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) // printf("bpipe-fd: since=%d\n", (int)value); break; - case bEventRestoreStart: -// printf("bpipe-fd: RestoreStart\n"); + case bEventStartRestoreJob: + printf("bpipe-fd: StartRestoreJob\n"); break; - case bEventRestoreEnd: -// printf("bpipe-fd: RestoreEnd\n"); + + case bEventEndRestoreJob: + printf("bpipe-fd: EndRestoreJob\n"); break; - /* Plugin command e.g. plugin = ::command */ - case bEventPluginCommand: + /* Plugin command e.g. plugin = ::read command:write command */ + case bEventRestoreCommand: + printf("bpipe-fd: EventRestoreCommand cmd=%s\n", (char *)value); + case bEventBackupCommand: char *p; -// printf("bpipe-fd: pluginEvent cmd=%s\n", (char *)value); + printf("bpipe-fd: pluginEvent cmd=%s\n", (char *)value); p_ctx->cmd = strdup((char *)value); p = strchr(p_ctx->cmd, ':'); if (!p) { @@ -224,7 +227,7 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) return bRC_OK; } -static bRC startPluginBackup(bpContext *ctx, struct save_pkt *sp) +static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp) { struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext; time_t now = time(NULL); @@ -237,12 +240,17 @@ static bRC startPluginBackup(bpContext *ctx, struct save_pkt *sp) sp->statp.st_blksize = 4096; sp->statp.st_blocks = 1; p_ctx->backup = true; -// printf("bpipe-fd: startPluginBackup\n"); +// printf("bpipe-fd: startBackupFile\n"); return bRC_OK; } -static bRC endPluginBackup(bpContext *ctx) +static bRC endBackupFile(bpContext *ctx) { + /* + * We would return bRC_More if we wanted startBackupFile to be + * called again to backup another file + */ +// printf("bpipe-fd: endBackupFile\n"); return bRC_OK; } @@ -262,7 +270,7 @@ static bRC pluginIO(bpContext *ctx, struct io_pkt *io) if (!p_ctx->fd) { io->io_errno = errno; snprintf(msg, sizeof(msg), "bpipe-fd: reader=%s failed: ERR=%d\n", p_ctx->reader, errno); - bfuncs->JobMessage(ctx, __FILE__, __LINE__, 1, 0, msg); + bfuncs->JobMessage(ctx, __FILE__, __LINE__, M_FATAL, 0, msg); printf("%s", msg); return bRC_Error; } @@ -271,9 +279,14 @@ static bRC pluginIO(bpContext *ctx, struct io_pkt *io) break; case IO_READ: + if (!p_ctx->fd) { + bfuncs->JobMessage(ctx, __FILE__, __LINE__, M_FATAL, 0, "NULL FD\n"); + return bRC_Error; + } io->status = fread(io->buf, 1, io->count, p_ctx->fd); printf("bpipe-fd: IO_READ buf=%p len=%d\n", io->buf, io->status); if (io->status == 0 && ferror(p_ctx->fd)) { + bfuncs->JobMessage(ctx, __FILE__, __LINE__, M_FATAL, 0, "Pipe I/O error\n"); printf("Error reading pipe\n"); return bRC_Error; } @@ -285,6 +298,10 @@ static bRC pluginIO(bpContext *ctx, struct io_pkt *io) break; case IO_CLOSE: + if (!p_ctx->fd) { + bfuncs->JobMessage(ctx, __FILE__, __LINE__, M_FATAL, 0, "NULL FD\n"); + return bRC_Error; + } io->status = pclose(p_ctx->fd); printf("bpipe-fd: IO_CLOSE\n"); break; @@ -298,21 +315,25 @@ static bRC pluginIO(bpContext *ctx, struct io_pkt *io) static bRC startRestoreFile(bpContext *ctx, const char *cmd) { + printf("bpipe-fd: startRestoreFile cmd=%s\n", cmd); return bRC_OK; } static bRC endRestoreFile(bpContext *ctx) { + printf("bpipe-fd: endRestoreFile\n"); return bRC_OK; } static bRC createFile(bpContext *ctx, struct restore_pkt *rp) { + printf("bpipe-fd: createFile\n"); return bRC_OK; } static bRC setFileAttributes(bpContext *ctx, struct restore_pkt *rp) { + printf("bpipe-fd: setFileAttributes\n"); return bRC_OK; } diff --git a/bacula/src/plugins/fd/example-plugin-fd.c b/bacula/src/plugins/fd/example-plugin-fd.c index 935ef6ef9f..afd4b1778a 100644 --- a/bacula/src/plugins/fd/example-plugin-fd.c +++ b/bacula/src/plugins/fd/example-plugin-fd.c @@ -50,8 +50,8 @@ static bRC freePlugin(bpContext *ctx); static bRC getPluginValue(bpContext *ctx, pVariable var, void *value); static bRC setPluginValue(bpContext *ctx, pVariable var, void *value); static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value); -static bRC startPluginBackup(bpContext *ctx, struct save_pkt *sp); -static bRC endPluginBackup(bpContext *ctx); +static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp); +static bRC endBackupFile(bpContext *ctx); static bRC pluginIO(bpContext *ctx, struct io_pkt *io); static bRC startRestoreFile(bpContext *ctx, const char *cmd); static bRC endRestoreFile(bpContext *ctx); @@ -84,8 +84,8 @@ static pFuncs pluginFuncs = { getPluginValue, setPluginValue, handlePluginEvent, - startPluginBackup, - endPluginBackup, + startBackupFile, + endBackupFile, startRestoreFile, endRestoreFile, pluginIO, @@ -151,10 +151,10 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) case bEventJobEnd: printf("plugin: JobEnd\n"); break; - case bEventBackupStart: + case bEventStartBackupJob: printf("plugin: BackupStart\n"); break; - case bEventBackupEnd: + case bEventEndBackupJob: printf("plugin: BackupEnd\n"); break; case bEventLevel: @@ -163,16 +163,20 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) case bEventSince: printf("plugin: since=%d\n", (int)value); break; - case bEventRestoreStart: - printf("bpipe-fd: RestoreStart\n"); + case bEventStartRestoreJob: + printf("plugin: StartRestoreJob\n"); break; - case bEventRestoreEnd: - printf("bpipe-fd: RestoreEnd\n"); + case bEventEndRestoreJob: + printf("plugin: EndRestoreJob\"); break; /* Plugin command e.g. plugin = ::command */ - case bEventPluginCommand: - printf("plugin: command=%s\n", (char *)value); + case bEventRestoreCommand: + printf("plugin: backup command=%s\n", (char *)value); + break; + + case bEventBackupCommand: + printf("plugin: backup command=%s\n", (char *)value); break; default: @@ -185,12 +189,12 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) return bRC_OK; } -static bRC startPluginBackup(bpContext *ctx, struct save_pkt *sp) +static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp) { return bRC_OK; } -static bRC endPluginBackup(bpContext *ctx) +static bRC endBackupFile(bpContext *ctx) { return bRC_OK; } diff --git a/bacula/src/stored/append.c b/bacula/src/stored/append.c index 972b14bb4c..60278ee3dc 100644 --- a/bacula/src/stored/append.c +++ b/bacula/src/stored/append.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + Copyright (C) 2000-2008 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. diff --git a/bacula/src/stored/record.c b/bacula/src/stored/record.c index d47d74ccd8..e20b4ccd54 100644 --- a/bacula/src/stored/record.c +++ b/bacula/src/stored/record.c @@ -116,6 +116,8 @@ const char *stream_to_ascii(char *buf, int stream, int fi) return "PROG-NAMES"; case STREAM_PROGRAM_DATA: return "PROG-DATA"; + case STREAM_PLUGIN_NAME: + return "PLUGIN-NAME"; case STREAM_MACOS_FORK_DATA: return "MACOS-RSRC"; case STREAM_HFSPLUS_ATTRIBUTES: @@ -184,6 +186,9 @@ const char *stream_to_ascii(char *buf, int stream, int fi) return "contENCRYPTED-WIN32-GZIP"; case -STREAM_ENCRYPTED_MACOS_FORK_DATA: return "contENCRYPTED-MACOS-RSRC"; + case -STREAM_PLUGIN_NAME: + return "contPLUGIN-NAME"; + default: sprintf(buf, "%d", stream); return buf; -- 2.39.5