#include "filed.h"
/* Forward referenced functions */
-int save_file(FF_PKT *ff_pkt, void *pkt, bool top_level);
+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);
jcr->acl_text = get_pool_memory(PM_MESSAGE);
/* Subroutine save_file() is called for each file */
- if (!find_files(jcr, (FF_PKT *)jcr->ff, save_file)) {
+ if (!find_files(jcr, (FF_PKT *)jcr->ff, save_file, plugin_save)) {
ok = false; /* error */
set_jcr_job_status(jcr, JS_ErrorTerminated);
}
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.
* This is a callback. The original is find_files() above.
* 0 if error
* -1 to ignore file/directory (not used here)
*/
-int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level)
+int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
{
bool do_read = false;
int stat, data_stream;
#else
crypto_digest_t signing_algorithm = CRYPTO_DIGEST_SHA1;
#endif
- JCR *jcr = (JCR *)vjcr;
BSOCK *sd = jcr->store_bsock;
if (job_canceled(jcr)) {
#include "bacula.h"
#include "filed.h"
-static int tally_file(FF_PKT *ff_pkt, void *pkt, bool);
+static int tally_file(JCR *jcr, FF_PKT *ff_pkt, bool);
/*
* Find all the requested files and count them.
set_jcr_job_status(jcr, JS_Running);
set_find_options((FF_PKT *)jcr->ff, jcr->incremental, jcr->mtime);
- stat = find_files(jcr, (FF_PKT *)jcr->ff, tally_file);
+ stat = find_files(jcr, (FF_PKT *)jcr->ff, tally_file, NULL);
return stat;
}
* Called here by find() for each file included.
*
*/
-static int tally_file(FF_PKT *ff_pkt, void *ijcr, bool top_level)
+static int tally_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
{
- JCR *jcr = (JCR *)ijcr;
ATTR attr;
if (job_canceled(jcr)) {
const int dbglvl = 50;
const char *plugin_type = "-fd.so";
-extern int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level);
+extern int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level);
/* Function pointers to be set here */
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(ff_pkt, (void *)jcr, true);
+ save_file(jcr, ff_pkt, true);
goto bail_out;
}
i++;
}
#endif
-static int do_file_digest(FF_PKT *ff_pkt, void *pkt, bool top_level)
+static int do_file_digest(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
{
- JCR *jcr = (JCR *)pkt;
Dmsg1(50, "do_file_digest jcr=%p\n", jcr);
return (digest_file(jcr, ff_pkt, jcr->crypto.digest));
}
#include "bacula.h"
#include "filed.h"
-static int verify_file(FF_PKT *ff_pkt, void *my_pkt, bool);
+static int verify_file(JCR *jcr, FF_PKT *ff_pkt, bool);
static int read_digest(BFILE *bfd, DIGEST *digest, JCR *jcr);
/*
set_find_options((FF_PKT *)jcr->ff, jcr->incremental, jcr->mtime);
Dmsg0(10, "Start find files\n");
/* Subroutine verify_file() is called for each file */
- find_files(jcr, (FF_PKT *)jcr->ff, verify_file);
+ find_files(jcr, (FF_PKT *)jcr->ff, verify_file, NULL);
Dmsg0(10, "End find files\n");
if (jcr->big_buf) {
*
* Find the file, compute the MD5 or SHA1 and send it back to the Director
*/
-static int verify_file(FF_PKT *ff_pkt, void *pkt, bool top_level)
+static int verify_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
{
char attribs[MAXSTRING];
char attribsEx[MAXSTRING];
int stat;
DIGEST *digest = NULL;
BSOCK *dir;
- JCR *jcr = (JCR *)pkt;
if (job_canceled(jcr)) {
return 0;
#undef bmalloc
#define bmalloc(x) sm_malloc(__FILE__, __LINE__, x)
#endif
-static int our_callback(FF_PKT *ff, void *hpkt, bool top_level);
+static int our_callback(JCR *jcr, FF_PKT *ff, bool top_level);
static bool accept_file(FF_PKT *ff);
static const int fnmode = 0;
* will be passed back to the callback subroutine as the last
* argument.
*
- * The callback subroutine gets called with:
- * arg1 -- the FF_PKT containing filename, link, stat, ftype, flags, etc
- * arg2 -- the user supplied packet
- *
*/
int
-find_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt, bool top_level))
+find_files(JCR *jcr, FF_PKT *ff, int file_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level),
+ int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level))
{
- ff->callback = callback;
+ ff->file_save = file_save;
+ ff->plugin_save = plugin_save;
/* This is the new way */
findFILESET *fileset = ff->fileset;
return 0; /* error return */
}
}
- foreach_dlist(node, &incexe->plugin_list) {
- char *fname = node->c_str();
- Dmsg1(100, "PluginCommand: %s\n", fname);
- ff->top_fname = fname;
- ff->cmd_plugin = true;
- generate_plugin_event(jcr, bEventPluginCommand, (void *)fname);
- ff->cmd_plugin = false;
+ if (plugin_save) {
+ foreach_dlist(node, &incexe->plugin_list) {
+ char *fname = node->c_str();
+ Dmsg1(100, "PluginCommand: %s\n", fname);
+ ff->top_fname = fname;
+ ff->cmd_plugin = true;
+ plugin_save(jcr, ff, true);
+ ff->cmd_plugin = false;
+ }
}
}
}
* We filter the files, then call the user's callback if
* the file is included.
*/
-static int our_callback(FF_PKT *ff, void *hpkt, bool top_level)
+static int our_callback(JCR *jcr, FF_PKT *ff, bool top_level)
{
if (top_level) {
- return ff->callback(ff, hpkt, top_level); /* accept file */
+ return ff->file_save(jcr, ff, top_level); /* accept file */
}
switch (ff->type) {
case FT_NOACCESS:
case FT_INVALIDDT:
case FT_NOOPEN:
case FT_REPARSE:
-// return ff->callback(ff, hpkt, top_level);
+// return ff->file_save(jcr, ff, top_level);
/* These items can be filtered */
case FT_LNKSAVED:
case FT_SPEC:
case FT_DIRNOCHG:
if (accept_file(ff)) {
- return ff->callback(ff, hpkt, top_level);
+ return ff->file_save(jcr, ff, top_level);
} else {
Dmsg1(100, "Skip file %s\n", ff->fname);
return -1; /* ignore this file */
struct s_excluded_file *excluded_files_list;
struct s_excluded_file *excluded_paths_list;
findFILESET *fileset;
- int (*callback)(FF_PKT *, void *, bool); /* User's callback */
+ int (*file_save)(JCR *, FF_PKT *, bool); /* User's callback */
+ int (*plugin_save)(JCR *, FF_PKT *, bool); /* User's callback */
/* Values set by accept_file while processing Options */
uint32_t flags; /* backup options */
*/
int
find_one_file(JCR *jcr, FF_PKT *ff_pkt,
- int handle_file(FF_PKT *ff, void *hpkt, bool top_level),
+ int handle_file(JCR *jcr, FF_PKT *ff, bool top_level),
char *fname, dev_t parent_device, bool top_level)
{
struct utimbuf restore_times;
/* Cannot stat file */
ff_pkt->type = FT_NOSTAT;
ff_pkt->ff_errno = errno;
- return handle_file(ff_pkt, jcr, top_level);
+ return handle_file(jcr, ff_pkt, top_level);
}
Dmsg1(300, "File ----: %s\n", fname);
ff_pkt->statp.st_ctime < ff_pkt->save_time)) {
/* Incremental option, file not changed */
ff_pkt->type = FT_NOCHG;
- return handle_file(ff_pkt, jcr, top_level);
+ return handle_file(jcr, ff_pkt, top_level);
}
}
sizeof(ff_pkt->hfsinfo), FSOPT_NOFOLLOW) != 0) {
ff_pkt->type = FT_NOSTAT;
ff_pkt->ff_errno = errno;
- return handle_file(ff_pkt, jcr, top_level);
+ return handle_file(jcr, ff_pkt, top_level);
}
}
#endif
ff_pkt->link = lp->name;
ff_pkt->type = FT_LNKSAVED; /* Handle link, file already saved */
ff_pkt->LinkFI = lp->FileIndex;
- return handle_file(ff_pkt, jcr, top_level);
+ return handle_file(jcr, ff_pkt, top_level);
}
/* File not previously dumped. Chain it into our list. */
} else {
ff_pkt->type = FT_REG;
}
- rtn_stat = handle_file(ff_pkt, jcr, top_level);
+ rtn_stat = handle_file(jcr, ff_pkt, top_level);
if (ff_pkt->linked) {
ff_pkt->linked->FileIndex = ff_pkt->FileIndex;
}
/* Could not follow link */
ff_pkt->type = FT_NOFOLLOW;
ff_pkt->ff_errno = errno;
- rtn_stat = handle_file(ff_pkt, jcr, top_level);
+ rtn_stat = handle_file(jcr, ff_pkt, top_level);
if (ff_pkt->linked) {
ff_pkt->linked->FileIndex = ff_pkt->FileIndex;
}
buffer[size] = 0;
ff_pkt->link = buffer; /* point to link */
ff_pkt->type = FT_LNK; /* got a real link */
- rtn_stat = handle_file(ff_pkt, jcr, top_level);
+ rtn_stat = handle_file(jcr, ff_pkt, top_level);
if (ff_pkt->linked) {
ff_pkt->linked->FileIndex = ff_pkt->FileIndex;
}
/* Could not access() directory */
ff_pkt->type = FT_NOACCESS;
ff_pkt->ff_errno = errno;
- rtn_stat = handle_file(ff_pkt, jcr, top_level);
+ rtn_stat = handle_file(jcr, ff_pkt, top_level);
if (ff_pkt->linked) {
ff_pkt->linked->FileIndex = ff_pkt->FileIndex;
}
* do not immediately save it, but do so only after everything
* in the directory is seen (i.e. the FT_DIREND).
*/
- rtn_stat = handle_file(ff_pkt, jcr, top_level);
+ rtn_stat = handle_file(jcr, ff_pkt, top_level);
if (rtn_stat < 1 || ff_pkt->type == FT_REPARSE) { /* ignore or error status */
free(link);
return rtn_stat;
}
/* If not recursing, just backup dir and return */
if (!recurse) {
- rtn_stat = handle_file(ff_pkt, jcr, top_level);
+ rtn_stat = handle_file(jcr, ff_pkt, top_level);
if (ff_pkt->linked) {
ff_pkt->linked->FileIndex = ff_pkt->FileIndex;
}
if ((directory = opendir(fname)) == NULL) {
ff_pkt->type = FT_NOOPEN;
ff_pkt->ff_errno = errno;
- rtn_stat = handle_file(ff_pkt, jcr, top_level);
+ rtn_stat = handle_file(jcr, ff_pkt, top_level);
if (ff_pkt->linked) {
ff_pkt->linked->FileIndex = ff_pkt->FileIndex;
}
* the directory modes and dates. Temp directory values
* were used without this record.
*/
- handle_file(dir_ff_pkt, jcr, top_level); /* handle directory entry */
+ handle_file(jcr, dir_ff_pkt, top_level); /* handle directory entry */
if (ff_pkt->linked) {
ff_pkt->linked->FileIndex = dir_ff_pkt->FileIndex;
}
/* The only remaining types are special (character, ...) files */
ff_pkt->type = FT_SPEC;
}
- rtn_stat = handle_file(ff_pkt, jcr, top_level);
+ rtn_stat = handle_file(jcr, ff_pkt, top_level);
if (ff_pkt->linked) {
ff_pkt->linked->FileIndex = ff_pkt->FileIndex;
}
/*
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.
int
-match_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt, bool))
+match_files(JCR *jcr, FF_PKT *ff, int file_save(JCR *, FF_PKT *ff_pkt, bool))
{
- ff->callback = callback;
+ ff->file_save = file_save;
struct s_included_file *inc = NULL;
bstrncat(ff->VerifyOpts, inc->VerifyOpts, sizeof(ff->VerifyOpts));
Dmsg1(100, "find_files: file=%s\n", inc->fname);
if (!file_is_excluded(ff, inc->fname)) {
- if (find_one_file(jcr, ff, callback, inc->fname, (dev_t)-1, 1) ==0) {
+ if (find_one_file(jcr, ff, file_save, inc->fname, (dev_t)-1, 1) ==0) {
return 0; /* error return */
}
}
/* From find.c */
FF_PKT *init_find_files();
void set_find_options(FF_PKT *ff, int incremental, time_t mtime);
-int find_files(JCR *jcr, FF_PKT *ff, int sub(FF_PKT *ff_pkt, void *hpkt, bool));
-int match_files(JCR *jcr, FF_PKT *ff, int sub(FF_PKT *ff_pkt, void *hpkt, bool));
+int find_files(JCR *jcr, FF_PKT *ff, int file_sub(JCR *, FF_PKT *ff_pkt, bool),
+ int plugin_sub(JCR *, FF_PKT *ff_pkt, bool));
+int match_files(JCR *jcr, FF_PKT *ff, int sub(JCR *, FF_PKT *ff_pkt, bool));
int term_find_files(FF_PKT *ff);
int get_win32_driveletters(FF_PKT *ff, char* szDrives);
/* From find_one.c */
int find_one_file(JCR *jcr, FF_PKT *ff,
- int handle_file(FF_PKT *ff_pkt, void *hpkt, bool top_level),
+ int handle_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level),
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);
static JCR *jcr;
-static int print_file(FF_PKT *ff, void *pkt, bool);
+static int print_file(JCR *jcr, FF_PKT *ff, bool);
static void count_files(FF_PKT *ff);
static bool copy_fileset(FF_PKT *ff, JCR *jcr);
static void set_options(findFOPTS *fo, const char *opts);
copy_fileset(ff, jcr);
- find_files(jcr, ff, print_file);
+ find_files(jcr, ff, print_file, NULL);
free_jcr(jcr);
free_config_resources();
exit(0);
}
-static int print_file(FF_PKT *ff, void *pkt, bool top_level)
+static int print_file(JCR *jcr, FF_PKT *ff, bool top_level)
{
switch (ff->type) {
static JCR *jcr;
-static int print_file(FF_PKT *ff, void *pkt, bool);
+static int print_file(JCR *jcr, FF_PKT *ff, bool);
static void print_ls_output(char *fname, char *link, int type, struct stat *statp);
static void usage()
exit(0);
}
-static int print_file(FF_PKT *ff, void *pkt, bool top_level)
+static int print_file(JCR *jcr, FF_PKT *ff, bool top_level)
{
switch (ff->type) {