From: Kern Sibbald Date: Fri, 8 Feb 2008 14:11:58 +0000 (+0000) Subject: Plugin update X-Git-Tag: Release-7.0.0~5057 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7bdfdb633d338c36240e37d049649c53b8df7e89;p=bacula%2Fbacula Plugin update git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6378 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/bacula.h b/bacula/src/bacula.h index 07b1af6cea..00275e1799 100644 --- a/bacula/src/bacula.h +++ b/bacula/src/bacula.h @@ -1,12 +1,7 @@ -/* - * bacula.h -- main header file to include in all Bacula source - * - * Version $Id$ - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2006 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. @@ -30,6 +25,11 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * bacula.h -- main header file to include in all Bacula source + * + * Version $Id$ + */ #ifndef _BACULA_H #define _BACULA_H 1 diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 708a1635db..a863ddd505 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -443,7 +443,7 @@ int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level) if (!set_cmd_plugin(&ff_pkt->bfd, jcr)) { goto bail_out; } - send_plugin_name(jcr, sd); + send_plugin_name(jcr, sd, true); /* signal start of plugin data */ } /* Send attributes -- must be done after binit() */ @@ -642,6 +642,9 @@ int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level) sd->send(); sd->signal(BNET_EOD); /* end of checksum */ } + if (ff_pkt->cmd_plugin) { + send_plugin_name(jcr, sd, false); /* signal end of plugin data */ + } good_rtn: rtnstat = 1; /* good return */ diff --git a/bacula/src/filed/fd-plugins.c b/bacula/src/filed/fd-plugins.c index 53ba28879f..a2c4970c1e 100644 --- a/bacula/src/filed/fd-plugins.c +++ b/bacula/src/filed/fd-plugins.c @@ -93,6 +93,8 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) int len; char *p; char *cmd = (char *)value; + struct save_pkt sp; + FF_PKT *ff_pkt; if (!plugin_list) { return; @@ -124,8 +126,6 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) foreach_alist(plugin, plugin_list) { Dmsg3(000, "plugin=%s cmd=%s len=%d\n", plugin->file, cmd, len); if (strncmp(plugin->file, cmd, len) == 0) { - struct save_pkt sp; - FF_PKT *ff_pkt; Dmsg1(000, "Command plugin = %s\n", cmd); if (plug_func(plugin)->handlePluginEvent(&plugin_ctx_list[i], &event, value) != bRC_OK) { goto bail_out; @@ -135,6 +135,8 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) sp.portable = true; sp.cmd = cmd; Dmsg0(000, "Plugin startBackup\n"); + printf("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; } @@ -157,20 +159,26 @@ bail_out: } /* - * Send plugin name record to SD + * Send plugin name start/end record to SD */ -bool send_plugin_name(JCR *jcr, BSOCK *sd) +bool send_plugin_name(JCR *jcr, BSOCK *sd, bool start) { int stat; struct save_pkt *sp = (struct save_pkt *)jcr->plugin_sp; Plugin *plugin = (Plugin *)jcr->plugin; - if (!sd->fsend("%ld %d 0", jcr->JobFiles, STREAM_PLUGIN_NAME)) { + + if (!sd->fsend("%ld %d %d", jcr->JobFiles, STREAM_PLUGIN_NAME, start)) { Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), sd->bstrerror()); return false; } - stat = sd->fsend("%ld %d %s%c%s%c", jcr->JobFiles, sp->portable, 0, plugin->file, - sp->cmd, 0); + if (start) { + stat = sd->fsend("%ld 1 %d %s%c%s%c", jcr->JobFiles, sp->portable, plugin->file, 0, + sp->cmd, 0); + } else { + stat = sd->fsend("%ld 0 %d %s%c%s%c", jcr->JobFiles, sp->portable, plugin->file, 0, + sp->cmd, 0); + } if (!stat) { Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), sd->bstrerror()); diff --git a/bacula/src/filed/fd-plugins.h b/bacula/src/filed/fd-plugins.h index 18e392fceb..e6a9cdf37a 100644 --- a/bacula/src/filed/fd-plugins.h +++ b/bacula/src/filed/fd-plugins.h @@ -35,6 +35,19 @@ #ifndef __FD_PLUGINS_H #define __FD_PLUGINS_H +#ifndef _BACULA_H +#ifdef __cplusplus +/* Workaround for SGI IRIX 6.5 */ +#define _LANGUAGE_C_PLUS_PLUS 1 +#endif +#define _REENTRANT 1 +#define _THREAD_SAFE 1 +#define _POSIX_PTHREAD_SEMANTICS 1 +#define _FILE_OFFSET_BITS 64 +#define _LARGEFILE_SOURCE 1 +#define _LARGE_FILES 1 +#endif + #include #ifndef __CONFIG_H #define __CONFIG_H @@ -119,7 +132,7 @@ void load_fd_plugins(const char *plugin_dir); void new_plugins(JCR *jcr); void free_plugins(JCR *jcr); void generate_plugin_event(JCR *jcr, bEventType event, void *value=NULL); -bool send_plugin_name(JCR *jcr, BSOCK *sd); +bool send_plugin_name(JCR *jcr, BSOCK *sd, bool start); #ifdef __cplusplus extern "C" { diff --git a/bacula/src/plugins/fd/bpipe-fd.c b/bacula/src/plugins/fd/bpipe-fd.c index a14c8292e3..f4b257fa16 100644 --- a/bacula/src/plugins/fd/bpipe-fd.c +++ b/bacula/src/plugins/fd/bpipe-fd.c @@ -31,7 +31,6 @@ * Kern Sibbald, October 2007 * */ -#include #include "fd-plugins.h" #undef malloc @@ -193,6 +192,9 @@ static bRC startPluginBackup(bpContext *ctx, struct save_pkt *sp) sp->statp.st_size = 100; sp->statp.st_blksize = 4096; sp->statp.st_blocks = 1; + printf("bpipe: st_size=%p st_blocks=%p sp=%p\n", &sp->statp.st_size, &sp->statp.st_blocks, + sp); + printf("bpipe-fd: startPluginBackup\n"); return bRC_OK; } diff --git a/bacula/src/stored/bls.c b/bacula/src/stored/bls.c index a3a344eeed..82cc3f1b7b 100644 --- a/bacula/src/stored/bls.c +++ b/bacula/src/stored/bls.c @@ -403,7 +403,10 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) print_ls_output(jcr, attr); num_files++; } + } else if (rec->Stream == STREAM_PLUGIN_NAME) { + Pmsg1(000, "Plugin name: %s\n", rec->data); } + return true; }