From: Kern Sibbald Date: Sat, 9 Feb 2008 14:01:29 +0000 (+0000) Subject: kes Remove a redundant jcr argument to find_files, match_files, and X-Git-Tag: Release-7.0.0~5051 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c1a0b1825a43f851d5e343d8f43639ff967f5e7e;p=bacula%2Fbacula kes Remove a redundant jcr argument to find_files, match_files, and find_one_file. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6385 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index fcdb7e052b..4cb4b6e2b5 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -39,7 +39,8 @@ #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); @@ -130,7 +131,7 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr) 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); } @@ -238,6 +239,12 @@ 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. * This is a callback. The original is find_files() above. @@ -248,7 +255,7 @@ static bool crypto_session_send(JCR *jcr, BSOCK *sd) * 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; @@ -264,7 +271,6 @@ int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level) #else crypto_digest_t signing_algorithm = CRYPTO_DIGEST_SHA1; #endif - JCR *jcr = (JCR *)vjcr; BSOCK *sd = jcr->store_bsock; if (job_canceled(jcr)) { diff --git a/bacula/src/filed/estimate.c b/bacula/src/filed/estimate.c index bc552b2fe4..1058e01202 100644 --- a/bacula/src/filed/estimate.c +++ b/bacula/src/filed/estimate.c @@ -38,7 +38,7 @@ #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. @@ -50,7 +50,7 @@ int make_estimate(JCR *jcr) 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; } @@ -59,9 +59,8 @@ int make_estimate(JCR *jcr) * 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)) { diff --git a/bacula/src/filed/fd-plugins.c b/bacula/src/filed/fd-plugins.c index 96a01cd83b..88fee12530 100644 --- a/bacula/src/filed/fd-plugins.c +++ b/bacula/src/filed/fd-plugins.c @@ -37,7 +37,7 @@ 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 */ @@ -147,7 +147,7 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) 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++; diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index 7869df4b4e..0996f9a9a7 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -775,9 +775,8 @@ static const char *zlib_strerror(int stat) } #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)); } diff --git a/bacula/src/filed/verify.c b/bacula/src/filed/verify.c index b3dcca92c2..32c753ae6e 100644 --- a/bacula/src/filed/verify.c +++ b/bacula/src/filed/verify.c @@ -37,7 +37,7 @@ #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); /* @@ -56,7 +56,7 @@ void do_verify(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) { @@ -71,7 +71,7 @@ void do_verify(JCR *jcr) * * 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]; @@ -79,7 +79,6 @@ static int verify_file(FF_PKT *ff_pkt, void *pkt, bool top_level) int stat; DIGEST *digest = NULL; BSOCK *dir; - JCR *jcr = (JCR *)pkt; if (job_canceled(jcr)) { return 0; diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c index fc1ed509c6..c231115a6a 100644 --- a/bacula/src/findlib/find.c +++ b/bacula/src/findlib/find.c @@ -48,7 +48,7 @@ int32_t path_max; /* path name max length */ #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; @@ -153,15 +153,13 @@ get_win32_driveletters(FF_PKT *ff, char* szDrives) * 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; @@ -195,13 +193,15 @@ find_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt, bool t 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; + } } } } @@ -361,10 +361,10 @@ static bool accept_file(FF_PKT *ff) * 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: @@ -378,7 +378,7 @@ static int our_callback(FF_PKT *ff, void *hpkt, bool top_level) 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: @@ -392,7 +392,7 @@ static int our_callback(FF_PKT *ff, void *hpkt, bool top_level) 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 */ diff --git a/bacula/src/findlib/find.h b/bacula/src/findlib/find.h index 8bedc7a687..20f44aa33a 100644 --- a/bacula/src/findlib/find.h +++ b/bacula/src/findlib/find.h @@ -213,7 +213,8 @@ struct FF_PKT { 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 */ diff --git a/bacula/src/findlib/find_one.c b/bacula/src/findlib/find_one.c index aa5936eda5..1e508fa6b1 100644 --- a/bacula/src/findlib/find_one.c +++ b/bacula/src/findlib/find_one.c @@ -267,7 +267,7 @@ bool has_file_changed(JCR *jcr, FF_PKT *ff_pkt) */ 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; @@ -280,7 +280,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, /* 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); @@ -341,7 +341,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, 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); } } @@ -358,7 +358,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, 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 @@ -397,7 +397,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, 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. */ @@ -427,7 +427,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, } 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; } @@ -446,7 +446,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, /* 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; } @@ -455,7 +455,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, 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; } @@ -482,7 +482,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, /* 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; } @@ -523,7 +523,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, * 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; @@ -568,7 +568,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, } /* 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; } @@ -591,7 +591,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, 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; } @@ -652,7 +652,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, * 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; } @@ -690,7 +690,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, /* 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; } diff --git a/bacula/src/findlib/match.c b/bacula/src/findlib/match.c index 9d124b3f54..b48b4dde92 100644 --- a/bacula/src/findlib/match.c +++ b/bacula/src/findlib/match.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. @@ -64,9 +64,9 @@ static const int fnmode = 0; 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; @@ -76,7 +76,7 @@ match_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt, bool) 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 */ } } diff --git a/bacula/src/findlib/protos.h b/bacula/src/findlib/protos.h index 1bd177d962..c50a2db5d4 100644 --- a/bacula/src/findlib/protos.h +++ b/bacula/src/findlib/protos.h @@ -45,8 +45,9 @@ int create_file (JCR *jcr, ATTR *attr, BFILE *ofd, int replace); /* 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); @@ -62,7 +63,7 @@ struct s_included_file *get_next_included_file(FF_PKT *ff, /* 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); diff --git a/bacula/src/tools/testfind.c b/bacula/src/tools/testfind.c index 2604d394fe..246b4df825 100644 --- a/bacula/src/tools/testfind.c +++ b/bacula/src/tools/testfind.c @@ -55,7 +55,7 @@ static int attrs = 0; 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); @@ -163,7 +163,7 @@ main (int argc, char *const *argv) copy_fileset(ff, jcr); - find_files(jcr, ff, print_file); + find_files(jcr, ff, print_file, NULL); free_jcr(jcr); free_config_resources(); @@ -238,7 +238,7 @@ main (int argc, char *const *argv) 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) { diff --git a/bacula/src/tools/testls.c b/bacula/src/tools/testls.c index bf31fa7aa8..6af43785d6 100644 --- a/bacula/src/tools/testls.c +++ b/bacula/src/tools/testls.c @@ -47,7 +47,7 @@ int attrs = 0; 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() @@ -176,7 +176,7 @@ main (int argc, char *const *argv) 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) {