From 2d190876aa97c53f802712a4c1a517bba241a294 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 10 Sep 2003 11:22:06 +0000 Subject: [PATCH] Implement new Include/Exclude + fix segfaults in variable expansion + print warning if job is blocked by user unmount. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@694 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 5 +++-- bacula/src/dird/dird_conf.c | 22 +++++++++--------- bacula/src/dird/dird_conf.h | 2 +- bacula/src/dird/expand.c | 6 ++++- bacula/src/dird/inc_conf.c | 45 +++++++++++++++++++++++-------------- bacula/src/dird/ua_cmds.c | 4 ++++ bacula/src/version.h | 4 ++-- 7 files changed, 54 insertions(+), 34 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index 369ef992ed..b5c8b1e9ad 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -37,9 +37,11 @@ For 1.32: - Don't print "Warning: Wrong Volume mounted ..." if mounting second volume. - Implement List Volume Job=xxx or List scheduled volumes or Status Director - +- Add heartbeat from FD to SD if hb interval expires. For 1.33 +- Suppress read error on blank tape when doing a label. +- Can we dynamically change FileSets. - If pool specified to label command and Label Format is specified, automatically generate the Volume name. - Take a careful look a the Basic recycling algorithm. When Bacula @@ -895,4 +897,3 @@ Done: (see kernsdone for more) - Check to see if "blocked" is set during restore. - Figure out what is interrupting sql command in console. - Make new job print warning User Unmounted Tape. - diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 2170928f4e..e455804ec7 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -227,10 +227,8 @@ static struct res_items job_items[] = { static struct res_items fs_items[] = { {"name", store_name, ITEM(res_fs.hdr.name), 0, ITEM_REQUIRED, 0}, {"description", store_str, ITEM(res_fs.hdr.desc), 0, 0, 0}, - {"include", store_inc, NULL, 0, 0, 0}, - {"finclude", store_finc, NULL, 0, ITEM_NO_EQUALS, 0}, - {"exclude", store_inc, NULL, 1, 0, 0}, - {"fexclude", store_finc, NULL, 1, ITEM_NO_EQUALS, 0}, + {"include", store_inc, NULL, 0, ITEM_NO_EQUALS, 0}, + {"exclude", store_inc, NULL, 1, ITEM_NO_EQUALS, 0}, {NULL, NULL, NULL, 0, 0, 0} }; @@ -433,17 +431,19 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ... res->res_con.hdr.name, res->res_con.enable_ssl); break; case R_COUNTER: - sendit(sock, "Counter: name=%s min=%d max=%d\n", - res->res_counter.hdr.name, res->res_counter.MinValue, - res->res_counter.MaxValue); + if (res->res_counter.WrapCounter) { + sendit(sock, "Counter: name=%s min=%d max=%d wrapcntr=%s\n", + res->res_counter.hdr.name, res->res_counter.MinValue, + res->res_counter.MaxValue, res->res_counter.WrapCounter->hdr.name); + } else { + sendit(sock, "Counter: name=%s min=%d max=%d\n", + res->res_counter.hdr.name, res->res_counter.MinValue, + res->res_counter.MaxValue); + } if (res->res_counter.Catalog) { sendit(sock, " --> "); dump_resource(-R_CATALOG, (RES *)res->res_counter.Catalog, sendit, sock); } - if (res->res_counter.WrapCounter) { - sendit(sock, " --> "); - dump_resource(-R_COUNTER, (RES *)res->res_counter.WrapCounter, sendit, sock); - } break; case R_CLIENT: diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index fad79e2e08..5c4aad6b66 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -235,7 +235,7 @@ struct INCEXE { struct FILESET { RES hdr; - int finclude; /* Set if finclude/fexclude used */ + int new_include; /* Set if new include used */ INCEXE **include_items; /* array of incexe structures */ int num_includes; /* number in array */ INCEXE **exclude_items; diff --git a/bacula/src/dird/expand.c b/bacula/src/dird/expand.c index 308624f794..4002dbb34a 100644 --- a/bacula/src/dird/expand.c +++ b/bacula/src/dird/expand.c @@ -212,7 +212,11 @@ static var_rc_t lookup_counter_var(var_t *ctx, void *my_ctx, counter->CurrentValue++; } cr.CurrentValue = counter->CurrentValue; - bstrncpy(cr.WrapCounter, counter->WrapCounter->hdr.name, sizeof(cr.WrapCounter)); + if (counter->WrapCounter) { + bstrncpy(cr.WrapCounter, counter->WrapCounter->hdr.name, sizeof(cr.WrapCounter)); + } else { + cr.WrapCounter[0] = 0; + } if (!db_update_counter_record(jcr, jcr->db, &cr)) { Jmsg(jcr, M_ERROR, 0, _("Count not update counter %s: ERR=%s\n"), counter->hdr.name, db_strerror(jcr->db)); diff --git a/bacula/src/dird/inc_conf.c b/bacula/src/dird/inc_conf.c index d4cf295371..bacd5bbead 100644 --- a/bacula/src/dird/inc_conf.c +++ b/bacula/src/dird/inc_conf.c @@ -1,6 +1,6 @@ /* - * Configuration file parser for Include, Exclude, Finclude - * and FExclude records. + * Configuration file parser for new and old Include and + * Exclude records * * Kern Sibbald, March MMIII * @@ -32,8 +32,8 @@ /* Forward referenced subroutines */ void store_inc(LEX *lc, struct res_items *item, int index, int pass); -void store_finc(LEX *lc, struct res_items *item, int index, int pass); +static void store_newinc(LEX *lc, struct res_items *item, int index, int pass); static void store_match(LEX *lc, struct res_items *item, int index, int pass); static void store_opts(LEX *lc, struct res_items *item, int index, int pass); static void store_fname(LEX *lc, struct res_items *item, int index, int pass); @@ -49,14 +49,14 @@ static void setup_current_opts(void); extern URES res_all; extern int res_all_size; -/* We build the current Finclude Fexclude item here */ +/* We build the current new Include and Exclude items here */ static INCEXE res_incexe; /* - * FInclude/FExclude items + * new Include/Exclude items * name handler value code flags default_value */ -static struct res_items finc_items[] = { +static struct res_items newinc_items[] = { {"compression", store_opts, NULL, 0, 0, 0}, {"signature", store_opts, NULL, 0, 0, 0}, {"verify", store_opts, NULL, 0, 0, 0}, @@ -87,7 +87,7 @@ static struct res_items finc_items[] = { #define INC_KW_PORTABLE 10 /* Include keywords -- these are keywords that can appear - * in the options lists of an include ( Include = compression= ...) + * in the options lists of an old include ( Include = compression= ...) */ static struct s_kw FS_option_kw[] = { {"compression", INC_KW_COMPRESSION}, @@ -151,7 +151,7 @@ static struct s_fs_opt FS_options[] = { /* - * Scan for Include options (keyword=option) is converted into one or + * Scan for old Include options (keyword=option) is converted into one or * two characters. Verifyopts=xxxx is Vxxxx: */ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen) @@ -204,12 +204,26 @@ void store_inc(LEX *lc, struct res_items *item, int index, int pass) char inc_opts[100]; int inc_opts_len; + /* + * Decide if we are doing a new Include or an old include. The + * new Include is followed immediately by {, whereas the + * old include has options following the Include. + */ + token = lex_get_token(lc, T_ALL); + if (token == T_BOB) { + store_newinc(lc, item, index, pass); + return; + } + if (token != T_EQUALS) { + scan_err1(lc, _("Expecting an equals sign, got: %s\n"), lc->str); + } lc->options |= LOPT_NO_IDENT; /* make spaces significant */ memset(&res_incexe, 0, sizeof(INCEXE)); /* Get include options */ inc_opts[0] = 0; while ((token=lex_get_token(lc, T_ALL)) != T_BOB) { + keyword = INC_KW_NONE; for (i=0; FS_option_kw[i].name; i++) { if (strcasecmp(lc->str, FS_option_kw[i].name) == 0) { @@ -230,6 +244,7 @@ void store_inc(LEX *lc, struct res_items *item, int index, int pass) break; } } + if (!inc_opts[0]) { strcat(inc_opts, "0"); /* set no options */ } @@ -312,7 +327,7 @@ void store_inc(LEX *lc, struct res_items *item, int index, int pass) * resource. We treat the Finclude/Fexeclude like a sort of * mini-resource within the FileSet resource. */ -void store_finc(LEX *lc, struct res_items *item, int index, int pass) +static void store_newinc(LEX *lc, struct res_items *item, int index, int pass) { int token, i; INCEXE *incexe; @@ -321,12 +336,8 @@ void store_finc(LEX *lc, struct res_items *item, int index, int pass) MD5Init(&res_all.res_fs.md5c); res_all.res_fs.have_MD5 = TRUE; } - res_all.res_fs.finclude = TRUE; - token = lex_get_token(lc, T_ALL); - if (token != T_BOB) { - scan_err1(lc, _("Expecting a beginning brace, got: %s\n"), lc->str); - } memset(&res_incexe, 0, sizeof(INCEXE)); + res_all.res_fs.new_include = TRUE; while ((token = lex_get_token(lc, T_ALL)) != T_EOF) { if (token == T_EOL) { continue; @@ -337,14 +348,14 @@ void store_finc(LEX *lc, struct res_items *item, int index, int pass) if (token != T_IDENTIFIER) { scan_err1(lc, _("Expecting keyword, got: %s\n"), lc->str); } - for (i=0; finc_items[i].name; i++) { - if (strcasecmp(finc_items[i].name, lc->str) == 0) { + for (i=0; newinc_items[i].name; i++) { + if (strcasecmp(newinc_items[i].name, lc->str) == 0) { token = lex_get_token(lc, T_ALL); if (token != T_EQUALS) { scan_err1(lc, "expected an equals, got: %s", lc->str); } /* Call item handler */ - finc_items[i].handler(lc, &finc_items[i], i, pass); + newinc_items[i].handler(lc, &newinc_items[i], i, pass); i = -1; break; } diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 214bc6a130..9056b087b6 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -1277,6 +1277,10 @@ static int setdebug_cmd(UAContext *ua, char *cmd) static int var_cmd(UAContext *ua, char *cmd) { POOLMEM *var = get_pool_memory(PM_FNAME); + + if (!open_db(ua)) { + return 1; + } for (int i=1; iargc; i++) { if (ua->argk[i] && variable_expansion(ua->jcr, ua->argk[i], &var)) { bsendmsg(ua, "%s\n", var); diff --git a/bacula/src/version.h b/bacula/src/version.h index 809c094d63..fd71f7c705 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -2,8 +2,8 @@ #undef VERSION #define VERSION "1.32" #define VSTRING "1" -#define BDATE "07 Sep 2003" -#define LSMDATE "07Sep03" +#define BDATE "10 Sep 2003" +#define LSMDATE "10Sep03" /* Debug flags */ #undef DEBUG -- 2.39.2