From a532ab1bc19416851acd47f50564d9609e407ad6 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 10 Sep 2003 16:29:12 +0000 Subject: [PATCH] Fix additional counter problem + fix pathconf() error bug git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@695 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 2 +- bacula/src/dird/dird.c | 5 +++-- bacula/src/dird/dird_conf.c | 5 +++-- bacula/src/dird/expand.c | 22 ++++++++++++---------- bacula/src/findlib/find.c | 4 ++-- bacula/src/findlib/find_one.c | 6 +++--- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index b5c8b1e9ad..5f8707e45c 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -1,5 +1,5 @@ Kern's ToDo List - 9 September 2003 + 10 September 2003 Documentation to do: (any release a little bit at a time) - Document running a test version. diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 91d7dd4e0a..eb0a4758ec 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -398,9 +398,10 @@ Without that I don't know who I am :-(\n"), configfile); if (db_create_counter_record(NULL, db, &cr)) { counter->CurrentValue = cr.CurrentValue; counter->created = true; -// Dmsg2(000, "Create counter %s val=%d\n", counter->hdr.name, counter->CurrentValue); + Dmsg2(100, "Create counter %s val=%d\n", counter->hdr.name, counter->CurrentValue); } - } else { + } + if (!counter->created) { counter->CurrentValue = counter->MinValue; /* default value */ } } diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index e455804ec7..00a8f9c7e5 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -432,9 +432,10 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ... break; case R_COUNTER: if (res->res_counter.WrapCounter) { - sendit(sock, "Counter: name=%s min=%d max=%d wrapcntr=%s\n", + sendit(sock, "Counter: name=%s min=%d max=%d cur=%d wrapcntr=%s\n", res->res_counter.hdr.name, res->res_counter.MinValue, - res->res_counter.MaxValue, res->res_counter.WrapCounter->hdr.name); + res->res_counter.MaxValue, res->res_counter.CurrentValue, + 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, diff --git a/bacula/src/dird/expand.c b/bacula/src/dird/expand.c index 4002dbb34a..265faa7678 100644 --- a/bacula/src/dird/expand.c +++ b/bacula/src/dird/expand.c @@ -195,11 +195,12 @@ static var_rc_t lookup_counter_var(var_t *ctx, void *my_ctx, LockRes(); for (COUNTER *counter=NULL; (counter = (COUNTER *)GetNextRes(R_COUNTER, (RES *)counter)); ) { if (strcmp(counter->hdr.name, buf) == 0) { + Dmsg2(100, "Counter=%s val=%d\n", buf, counter->CurrentValue); bsnprintf(buf, sizeof(buf), "%d", counter->CurrentValue); *val_ptr = bstrdup(buf); *val_len = strlen(buf); *val_size = *val_len; - if (var_inc) { + if (var_inc && counter->Catalog) { COUNTER_DBR cr; JCR *jcr = (JCR *)my_ctx; memset(&cr, 0, sizeof(cr)); @@ -212,6 +213,7 @@ static var_rc_t lookup_counter_var(var_t *ctx, void *my_ctx, counter->CurrentValue++; } cr.CurrentValue = counter->CurrentValue; + Dmsg1(100, "New value=%d\n", cr.CurrentValue); if (counter->WrapCounter) { bstrncpy(cr.WrapCounter, counter->WrapCounter->hdr.name, sizeof(cr.WrapCounter)); } else { @@ -258,7 +260,7 @@ static var_rc_t lookup_var(var_t *ctx, void *my_ctx, } memcpy(buf, var_ptr, var_len + 1); buf[var_len] = 0; -// Dmsg1(000, "Var=%s\n", buf); + Dmsg1(100, "Var=%s\n", buf); if ((val = getenv(buf)) == NULL) { return VAR_ERR_UNDEFINED_VARIABLE; @@ -280,8 +282,8 @@ static var_rc_t lookup_var(var_t *ctx, void *my_ctx, } } count++; -// Dmsg3(000, "For %s, reqest index=%d have=%d\n", -// buf, var_index, count); + Dmsg3(100, "For %s, reqest index=%d have=%d\n", + buf, var_index, count); if (var_index < 0 || var_index > count) { return VAR_ERR_SUBMATCH_OUT_OF_RANGE; } @@ -301,7 +303,7 @@ static var_rc_t lookup_var(var_t *ctx, void *my_ctx, if (p-val > (int)sizeof(buf) - 1) { return VAR_ERR_OUT_OF_MEMORY; } -// Dmsg2(000, "val=%s len=%d\n", val, p-val); + Dmsg2(100, "val=%s len=%d\n", val, p-val); /* Make a copy of item, and pass it back */ v = (char *)malloc(p-val+1); memcpy(v, val, p-val); @@ -309,7 +311,7 @@ static var_rc_t lookup_var(var_t *ctx, void *my_ctx, *val_ptr = v; *val_len = p-val; *val_size = p-val; -// Dmsg1(000, "v=%s\n", v); + Dmsg1(100, "v=%s\n", v); return VAR_OK; } @@ -327,7 +329,7 @@ static var_rc_t operate_var(var_t *var, void *my_ctx, char **out_ptr, int *out_len, int *out_size) { var_rc_t stat = VAR_ERR_UNDEFINED_OPERATION; -// Dmsg0(000, "Enter operate_var\n"); + Dmsg0(100, "Enter operate_var\n"); if (!val_ptr) { *out_size = 0; return stat; @@ -339,14 +341,14 @@ static var_rc_t operate_var(var_t *var, void *my_ctx, } memcpy(buf, arg_ptr, arg_len); buf[arg_len] = 0; -// Dmsg1(000, "Arg=%s\n", buf); + Dmsg1(100, "Arg=%s\n", buf); memcpy(buf, val_ptr, val_len); buf[val_len] = 0; -// Dmsg1(000, "Val=%s\n", buf); + Dmsg1(100, "Val=%s\n", buf); LockRes(); for (COUNTER *counter=NULL; (counter = (COUNTER *)GetNextRes(R_COUNTER, (RES *)counter)); ) { if (strcmp(counter->hdr.name, buf) == 0) { -// Dmsg2(000, "counter=%s val=%s\n", counter->hdr.name, buf); + Dmsg2(100, "counter=%s val=%s\n", counter->hdr.name, buf); break; } } diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c index e4d544e274..9a52dbd4c4 100644 --- a/bacula/src/findlib/find.c +++ b/bacula/src/findlib/find.c @@ -29,8 +29,8 @@ #include "find.h" -size_t name_max; /* filename max length */ -size_t path_max; /* path name max length */ +int32_t name_max; /* filename max length */ +int32_t path_max; /* path name max length */ /* ****FIXME**** debug until stable */ diff --git a/bacula/src/findlib/find_one.c b/bacula/src/findlib/find_one.c index f10b80b795..ff1c0df442 100755 --- a/bacula/src/findlib/find_one.c +++ b/bacula/src/findlib/find_one.c @@ -28,8 +28,8 @@ #include "bacula.h" #include "find.h" -extern size_t name_max; /* filename max length */ -extern size_t path_max; /* path name max length */ +extern int32_t name_max; /* filename max length */ +extern int32_t path_max; /* path name max length */ /* * Structure for keeping track of hard linked files, we @@ -329,7 +329,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt), if (status != 0 || result == NULL) { break; } - ASSERT(name_max+1 > sizeof(struct dirent) + (int)NAMELEN(entry)); + ASSERT(name_max+1 > (int)sizeof(struct dirent) + (int)NAMELEN(entry)); p = entry->d_name; /* Skip `.', `..', and excluded file names. */ if (p[0] == '\0' || (p[0] == '.' && (p[1] == '\0' || -- 2.39.5