From 292ca38cfc72f295b7b9afa325a281b4d59fcb34 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 26 Aug 2009 15:49:01 +0200 Subject: [PATCH] Add BaseJob option to fileset --- bacula/src/dird/inc_conf.c | 9 +++++++++ bacula/src/filed/accurate.c | 27 +++++++++++++++++++++++---- bacula/src/filed/backup.c | 8 +++++--- bacula/src/filed/job.c | 10 ++++++++++ bacula/src/findlib/find.c | 2 ++ bacula/src/findlib/find.h | 2 ++ 6 files changed, 51 insertions(+), 7 deletions(-) diff --git a/bacula/src/dird/inc_conf.c b/bacula/src/dird/inc_conf.c index ef15d3f2dd..5f34d8f00c 100644 --- a/bacula/src/dird/inc_conf.c +++ b/bacula/src/dird/inc_conf.c @@ -98,6 +98,7 @@ static RES_ITEM2 newinc_items[] = { static RES_ITEM options_items[] = { {"compression", store_opts, {0}, 0, 0, 0}, {"signature", store_opts, {0}, 0, 0, 0}, + {"basejob", store_opts, {0}, 0, 0, 0}, {"accurate", store_opts, {0}, 0, 0, 0}, {"verify", store_opts, {0}, 0, 0, 0}, {"onefs", store_opts, {0}, 0, 0, 0}, @@ -140,6 +141,7 @@ enum { INC_KW_DIGEST, INC_KW_ENCRYPTION, INC_KW_VERIFY, + INC_KW_BASEJOB, INC_KW_ACCURATE, INC_KW_ONEFS, INC_KW_RECURSE, @@ -173,6 +175,7 @@ static struct s_kw FS_option_kw[] = { {"signature", INC_KW_DIGEST}, {"encryption", INC_KW_ENCRYPTION}, {"verify", INC_KW_VERIFY}, + {"basejob", INC_KW_BASEJOB}, {"accurate", INC_KW_ACCURATE}, {"onefs", INC_KW_ONEFS}, {"recurse", INC_KW_RECURSE}, @@ -297,6 +300,12 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen) bstrncat(opts, lc->str, optlen); bstrncat(opts, ":", optlen); /* terminate it */ Dmsg3(900, "Catopts=%s option=%s optlen=%d\n", opts, option,optlen); + } else if (keyword == INC_KW_BASEJOB) { /* special case */ + /* ***FIXME**** ensure these are in permitted set */ + bstrncat(opts, "J", optlen); /* indicate BaseJob */ + bstrncat(opts, lc->str, optlen); + bstrncat(opts, ":", optlen); /* terminate it */ + Dmsg3(900, "Catopts=%s option=%s optlen=%d\n", opts, option,optlen); } else if (keyword == INC_KW_STRIPPATH) { /* another special case */ if (!is_an_integer(lc->str)) { scan_err1(lc, _("Expected a strip path positive integer, got:%s:"), lc->str); diff --git a/bacula/src/filed/accurate.c b/bacula/src/filed/accurate.c index 90e7ff24d3..2075de877a 100644 --- a/bacula/src/filed/accurate.c +++ b/bacula/src/filed/accurate.c @@ -242,6 +242,7 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt) struct stat statc; int32_t LinkFIc; bool stat = false; + char *opts; char *fname; CurFile elt; @@ -270,11 +271,17 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt) decode_stat(elt.lstat, &statc, &LinkFIc); /* decode catalog stat */ + if (jcr->get_JobLevel() == L_FULL) { + opts = ff_pkt->BaseJobOpts; + } else { + opts = ff_pkt->AccurateOpts; + } + /* * Loop over options supplied by user and verify the * fields he requests. */ - for (char *p=ff_pkt->AccurateOpts; !stat && *p; p++) { + for (char *p=opts; !stat && *p; p++) { char ed1[30], ed2[30]; switch (*p) { case 'i': /* compare INODEs */ @@ -287,6 +294,9 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt) } break; case 'p': /* permissions bits */ + /* TODO: If something change only in perm, user, group + * Backup only the attribute stream + */ if (statc.st_mode != ff_pkt->statp.st_mode) { Dmsg3(dbglvl-1, "%s st_mode differ. Cat: %x File: %x\n", fname, @@ -362,13 +372,21 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt) * The remainder of the function is all about getting the checksum. * First we initialise, then we read files, other streams and Finder Info. */ - if (!stat && *elt.chksum && ff_pkt->type != FT_LNKSAVED && + if (!stat && ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) && ff_pkt->flags & (FO_MD5|FO_SHA1|FO_SHA256|FO_SHA512))) { + + if (!*elt.chksum) { + Jmsg(jcr, M_WARNING, 0, _("Can't verify checksum for %s\n"), + ff_pkt->fname); + stat = true; + break; + } + /* - * Create our digest context. If this fails, the digest will be set to NULL - * and not used. + * Create our digest context. If this fails, the digest will be set + * to NULL and not used. */ if (ff_pkt->flags & FO_MD5) { digest = crypto_digest_new(jcr, CRYPTO_DIGEST_MD5); @@ -428,6 +446,7 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt) break; case ':': + case 'J': case 'C': default: break; diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index ef18dcda45..ff8265aea7 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -454,10 +454,12 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level) } /* - * Set up signature digest handling. If this fails, the signature digest will be set to - * NULL and not used. + * Set up signature digest handling. If this fails, the signature digest + * will be set to NULL and not used. + */ + /* TODO landonf: We should really only calculate the digest once, for + * both verification and signing. */ - // TODO landonf: We should really only calculate the digest once, for both verification and signing. if (jcr->crypto.pki_sign) { signing_digest = crypto_digest_new(jcr, signing_algorithm); diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 502d11439b..777bac36c4 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1112,6 +1112,16 @@ static void set_options(findFOPTS *fo, const char *opts) } fo->AccurateOpts[j] = 0; break; + case 'J': /* Basejob options */ + /* Copy BaseJob Options */ + for (j=0; *p && *p != ':'; p++) { + fo->BaseJobOpts[j] = *p; + if (j < (int)sizeof(fo->BaseJobOpts) - 1) { + j++; + } + } + fo->BaseJobOpts[j] = 0; + break; case 'P': /* strip path */ /* Get integer */ p++; /* skip P */ diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c index 0a4599e43a..258e4b1988 100644 --- a/bacula/src/findlib/find.c +++ b/bacula/src/findlib/find.c @@ -176,6 +176,7 @@ find_files(JCR *jcr, FF_PKT *ff, int file_save(JCR *jcr, FF_PKT *ff_pkt, bool to ff->VerifyOpts[0] = 'V'; ff->VerifyOpts[1] = 0; strcpy(ff->AccurateOpts, "C:mcs"); /* mtime+ctime+size by default */ + strcpy(ff->BaseJobOpts, "J:mspug5"); /* mtime+size+perm+user+group+chk */ for (i=0; iinclude_list.size(); i++) { findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i); fileset->incexe = incexe; @@ -192,6 +193,7 @@ find_files(JCR *jcr, FF_PKT *ff, int file_save(JCR *jcr, FF_PKT *ff_pkt, bool to ff->drivetypes = fo->drivetype; bstrncat(ff->VerifyOpts, fo->VerifyOpts, sizeof(ff->VerifyOpts)); bstrncat(ff->AccurateOpts, fo->AccurateOpts, sizeof(ff->AccurateOpts)); + bstrncat(ff->BaseJobOpts, fo->BaseJobOpts, sizeof(ff->BaseJobOpts)); } dlistString *node; foreach_dlist(node, &incexe->name_list) { diff --git a/bacula/src/findlib/find.h b/bacula/src/findlib/find.h index b1af739403..5f15769133 100644 --- a/bacula/src/findlib/find.h +++ b/bacula/src/findlib/find.h @@ -141,6 +141,7 @@ struct findFOPTS { int strip_path; /* strip path count */ char VerifyOpts[MAX_FOPTS]; /* verify options */ char AccurateOpts[MAX_FOPTS]; /* accurate mode options */ + char BaseJobOpts[MAX_FOPTS]; /* basejob mode options */ alist regex; /* regex string(s) */ alist regexdir; /* regex string(s) for directories */ alist regexfile; /* regex string(s) for files */ @@ -206,6 +207,7 @@ struct FF_PKT { bool incremental; /* incremental save */ char VerifyOpts[20]; char AccurateOpts[20]; + char BaseJobOpts[20]; struct s_included_file *included_files_list; struct s_excluded_file *excluded_files_list; struct s_excluded_file *excluded_paths_list; -- 2.39.5