From 54b509a5eb798b03f47ebe6368c66fc9308c41ec Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 29 Jul 2009 15:43:21 +0200 Subject: [PATCH] take ideas from previous try --- bacula/src/dird/dird_conf.c | 11 ++++ bacula/src/dird/dird_conf.h | 2 +- bacula/src/filed/accurate.c | 117 +++++++++++++++++++++++++++++++++--- bacula/src/filed/job.c | 2 + 4 files changed, 124 insertions(+), 8 deletions(-) diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 7a3f446030..2daba3b687 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -338,6 +338,7 @@ RES_ITEM job_items[] = { {"cancelqueuedduplicates", store_bool, ITEM(res_job.CancelQueuedDuplicates), 0, ITEM_DEFAULT, false}, {"cancelrunningduplicates", store_bool, ITEM(res_job.CancelRunningDuplicates), 0, ITEM_DEFAULT, false}, {"pluginoptions", store_str, ITEM(res_job.PluginOptions), 0, 0, 0}, + {"base", store_alist_res, ITEM(res_job.base), R_JOB, 0, 0}, {NULL, NULL, {0}, 0, 0, 0} }; @@ -700,6 +701,12 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm dump_resource(-R_STORAGE, (RES *)store, sendit, sock); } } + if (res->res_job.base) { + JOB *job; + foreach_alist(job, res->res_job.base) { + sendit(sock, _(" --> Base %s\n"), job->name()); + } + } if (res->res_job.RunScripts) { RUNSCRIPT *script; foreach_alist(script, res->res_job.RunScripts) { @@ -1294,6 +1301,9 @@ void free_resource(RES *sres, int type) if (res->res_job.storage) { delete res->res_job.storage; } + if (res->res_job.base) { + delete res->res_job.base; + } if (res->res_job.RunScripts) { free_runscripts(res->res_job.RunScripts); delete res->res_job.RunScripts; @@ -1429,6 +1439,7 @@ void save_resource(int type, RES_ITEM *items, int pass) res->res_job.client = res_all.res_job.client; res->res_job.fileset = res_all.res_job.fileset; res->res_job.storage = res_all.res_job.storage; + res->res_job.base = res_all.res_job.base; res->res_job.pool = res_all.res_job.pool; res->res_job.full_pool = res_all.res_job.full_pool; res->res_job.inc_pool = res_all.res_job.inc_pool; diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index 231dfabe5d..297f408e92 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -436,7 +436,7 @@ public: bool AllowHigherDuplicates; /* Permit Higher Level */ bool CancelQueuedDuplicates; /* Cancel queued jobs */ bool CancelRunningDuplicates; /* Cancel Running jobs */ - + alist *base; /* Base jobs */ /* Methods */ char *name() const; diff --git a/bacula/src/filed/accurate.c b/bacula/src/filed/accurate.c index 4d050b5df0..49d78ffb86 100644 --- a/bacula/src/filed/accurate.c +++ b/bacula/src/filed/accurate.c @@ -38,7 +38,7 @@ static int dbglvl=200; typedef struct PrivateCurFile { hlink link; char *fname; - utime_t ctime; + utime_t ctime; /* can be replaced by struct stat */ utime_t mtime; bool seen; } CurFile; @@ -102,7 +102,7 @@ bool accurate_send_deleted_list(JCR *jcr) FF_PKT *ff_pkt; int stream = STREAM_UNIX_ATTRIBUTES; - if (!jcr->accurate || jcr->get_JobLevel() == L_FULL) { + if (!jcr->accurate) { goto bail_out; } @@ -179,7 +179,7 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt) char *fname; CurFile elt; - if (!jcr->accurate || jcr->get_JobLevel() == L_FULL) { + if (!jcr->accurate) { return true; } @@ -202,6 +202,108 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt) goto bail_out; } +#if 0 + /* + * Loop over options supplied by user and verify the + * fields he requests. + */ + for (p=Opts_Digest; *p; p++) { + char ed1[30], ed2[30]; + switch (*p) { + case 'i': /* compare INODEs */ + if (statc.st_ino != statf.st_ino) { + prt_fname(jcr); + Jmsg(jcr, M_INFO, 0, _(" st_ino differ. Cat: %s File: %s\n"), + edit_uint64((uint64_t)statc.st_ino, ed1), + edit_uint64((uint64_t)statf.st_ino, ed2)); + set_jcr_job_status(jcr, JS_Differences); + } + break; + case 'p': /* permissions bits */ + if (statc.st_mode != statf.st_mode) { + prt_fname(jcr); + Jmsg(jcr, M_INFO, 0, _(" st_mode differ. Cat: %x File: %x\n"), + (uint32_t)statc.st_mode, (uint32_t)statf.st_mode); + set_jcr_job_status(jcr, JS_Differences); + } + break; + case 'n': /* number of links */ + if (statc.st_nlink != statf.st_nlink) { + prt_fname(jcr); + Jmsg(jcr, M_INFO, 0, _(" st_nlink differ. Cat: %d File: %d\n"), + (uint32_t)statc.st_nlink, (uint32_t)statf.st_nlink); + set_jcr_job_status(jcr, JS_Differences); + } + break; + case 'u': /* user id */ + if (statc.st_uid != statf.st_uid) { + prt_fname(jcr); + Jmsg(jcr, M_INFO, 0, _(" st_uid differ. Cat: %u File: %u\n"), + (uint32_t)statc.st_uid, (uint32_t)statf.st_uid); + set_jcr_job_status(jcr, JS_Differences); + } + break; + case 'g': /* group id */ + if (statc.st_gid != statf.st_gid) { + prt_fname(jcr); + Jmsg(jcr, M_INFO, 0, _(" st_gid differ. Cat: %u File: %u\n"), + (uint32_t)statc.st_gid, (uint32_t)statf.st_gid); + set_jcr_job_status(jcr, JS_Differences); + } + break; + case 's': /* size */ + if (statc.st_size != statf.st_size) { + prt_fname(jcr); + Jmsg(jcr, M_INFO, 0, _(" st_size differ. Cat: %s File: %s\n"), + edit_uint64((uint64_t)statc.st_size, ed1), + edit_uint64((uint64_t)statf.st_size, ed2)); + set_jcr_job_status(jcr, JS_Differences); + } + break; + case 'a': /* access time */ + if (statc.st_atime != statf.st_atime) { + prt_fname(jcr); + Jmsg(jcr, M_INFO, 0, _(" st_atime differs\n")); + set_jcr_job_status(jcr, JS_Differences); + } + break; + case 'm': + if (statc.st_mtime != statf.st_mtime) { + prt_fname(jcr); + Jmsg(jcr, M_INFO, 0, _(" st_mtime differs\n")); + set_jcr_job_status(jcr, JS_Differences); + } + break; + case 'c': /* ctime */ + if (statc.st_ctime != statf.st_ctime) { + prt_fname(jcr); + Jmsg(jcr, M_INFO, 0, _(" st_ctime differs\n")); + set_jcr_job_status(jcr, JS_Differences); + } + break; + case 'd': /* file size decrease */ + if (statc.st_size > statf.st_size) { + prt_fname(jcr); + Jmsg(jcr, M_INFO, 0, _(" st_size decrease. Cat: %s File: %s\n"), + edit_uint64((uint64_t)statc.st_size, ed1), + edit_uint64((uint64_t)statf.st_size, ed2)); + set_jcr_job_status(jcr, JS_Differences); + } + break; + case '5': /* compare MD5 */ + Dmsg1(500, "set Do_MD5 for %s\n", jcr->fname); + do_Digest = CRYPTO_DIGEST_MD5; + break; + case '1': /* compare SHA1 */ + do_Digest = CRYPTO_DIGEST_SHA1; + break; + case ':': + case 'V': + default: + break; + } + } +#endif /* * We check only mtime/ctime like with the normal * incremental/differential mode @@ -214,9 +316,8 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt) } else if (!(ff_pkt->flags & FO_MTIMEONLY) && (elt.ctime != ff_pkt->statp.st_ctime)) { // Jmsg(jcr, M_SAVED, 0, _("%s st_ctime differs\n"), fname); - Dmsg3(dbglvl, "%s st_ctime differs\n", - fname, elt.ctime, ff_pkt->statp.st_ctime); - stat = true; + Dmsg1(dbglvl, "%s st_ctime differs\n", fname); + stat = true; } accurate_mark_file_as_seen(jcr, &elt); @@ -236,7 +337,7 @@ int accurate_cmd(JCR *jcr) int len; int32_t nb; - if (!jcr->accurate || job_canceled(jcr) || jcr->get_JobLevel()==L_FULL) { + if (job_canceled(jcr)) { return true; } if (sscanf(dir->msg, "accurate files=%ld", &nb) != 1) { @@ -244,6 +345,8 @@ int accurate_cmd(JCR *jcr) return false; } + jcr->accurate = true; + accurate_init(jcr, nb); /* diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index af59139c5f..e41d7f270b 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1256,6 +1256,8 @@ static int level_cmd(JCR *jcr) level = get_memory(dir->msglen+1); Dmsg1(100, "level_cmd: %s", dir->msg); + + /* keep compatibility with older directors */ if (strstr(dir->msg, "accurate")) { jcr->accurate = true; } -- 2.39.5