Skip to content

Commit

Permalink
Multiple "Exclude Dir Containing" Flags not honored
Browse files Browse the repository at this point in the history
It seems when implementing the Exclude Dir Containing option in the
fileset unlike every other item it doesn't allow you to specify multiple
values for this config item. Which is kind of strange and would make it
somewhat better usable. This patch adds the missing support by just
storing the values in an alist just like all others. This also fixes a
memory leak which happens when you used to specify multiple entries as
then it would overwrite the previous string dupped value with the new
value without freeing the old value.

Fixes #311: Multiple "Exclude Dir Containing" Flags not honored
  • Loading branch information
Marco van Wieringen committed Jun 18, 2014
1 parent 8374b9a commit 467a786
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 130 deletions.
8 changes: 3 additions & 5 deletions src/dird/dird_conf.c
Expand Up @@ -991,8 +991,8 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
}
sendit(sock, " N\n");
}
if (incexe->ignoredir) {
sendit(sock, " Z %s\n", incexe->ignoredir);
for (j = 0; i < incexe->ignoredir.size(); i++) {
sendit(sock, " Z %s\n", incexe->ignoredir.get(j));
}
for (j = 0; j < incexe->name_list.size(); j++) {
sendit(sock, " I %s\n", incexe->name_list.get(j));
Expand Down Expand Up @@ -1223,9 +1223,7 @@ static void free_incexe(INCEXE *incexe)
if (incexe->opts_list) {
free(incexe->opts_list);
}
if (incexe->ignoredir) {
free(incexe->ignoredir);
}
incexe->ignoredir.destroy();
free(incexe);
}

Expand Down
50 changes: 25 additions & 25 deletions src/dird/dird_conf.h
Expand Up @@ -477,31 +477,31 @@ inline char *JOBRES::name() const { return hdr.name; }

/* File options structure */
struct FOPTS {
char opts[MAX_FOPTS]; /* options string */
alist regex; /* regex string(s) */
alist regexdir; /* regex string(s) for directories */
alist regexfile; /* regex string(s) for files */
alist wild; /* wild card strings */
alist wilddir; /* wild card strings for directories */
alist wildfile; /* wild card strings for files */
alist wildbase; /* wild card strings for files without '/' */
alist base; /* list of base names */
alist fstype; /* file system type limitation */
alist drivetype; /* drive type limitation */
alist meta; /* backup meta information */
char *reader; /* reader program */
char *writer; /* writer program */
char *plugin; /* plugin program */
char opts[MAX_FOPTS]; /* Options string */
alist regex; /* Regex string(s) */
alist regexdir; /* Regex string(s) for directories */
alist regexfile; /* Regex string(s) for files */
alist wild; /* Wild card strings */
alist wilddir; /* Wild card strings for directories */
alist wildfile; /* Wild card strings for files */
alist wildbase; /* Wild card strings for files without '/' */
alist base; /* List of base names */
alist fstype; /* File system type limitation */
alist drivetype; /* Drive type limitation */
alist meta; /* Backup meta information */
char *reader; /* Reader program */
char *writer; /* Writer program */
char *plugin; /* Plugin program */
};

/* This is either an include item or an exclude item */
struct INCEXE {
FOPTS *current_opts; /* points to current options structure */
FOPTS **opts_list; /* options list */
int32_t num_opts; /* number of options items */
alist name_list; /* filename list -- holds char * */
alist plugin_list; /* filename list for plugins */
char *ignoredir; /* ignoredir string */
FOPTS *current_opts; /* Points to current options structure */
FOPTS **opts_list; /* Options list */
int32_t num_opts; /* Number of options items */
alist name_list; /* Filename list -- holds char * */
alist plugin_list; /* Filename list for plugins */
alist ignoredir; /* Ignoredir string */
};

/*
Expand All @@ -513,13 +513,13 @@ class FILESETRES {
RES hdr;

bool new_include; /* Set if new include used */
INCEXE **include_items; /* array of incexe structures */
int32_t num_includes; /* number in array */
INCEXE **include_items; /* Array of incexe structures */
int32_t num_includes; /* Number in array */
INCEXE **exclude_items;
int32_t num_excludes;
bool have_MD5; /* set if MD5 initialized */
bool have_MD5; /* Set if MD5 initialized */
struct MD5Context md5c; /* MD5 of include/exclude */
char MD5[30]; /* base 64 representation of MD5 */
char MD5[30]; /* Base 64 representation of MD5 */
bool ignore_fs_changes; /* Don't force Full if FS changed */
bool enable_vss; /* Enable Volume Shadow Copy */

Expand Down
6 changes: 4 additions & 2 deletions src/dird/fd_cmds.c
Expand Up @@ -256,9 +256,11 @@ static bool send_fileset(JCR *jcr)
ie = fileset->exclude_items[i];
fd->fsend("E\n");
}
if (ie->ignoredir) {
bnet_fsend(fd, "Z %s\n", ie->ignoredir);

for (j = 0; j < ie->ignoredir.size(); j++) {
bnet_fsend(fd, "Z %s\n", ie->ignoredir.get(j));
}

for (j=0; j<ie->num_opts; j++) {
FOPTS *fo = ie->opts_list[j];

Expand Down
4 changes: 2 additions & 2 deletions src/dird/inc_conf.c
Expand Up @@ -601,14 +601,14 @@ static void store_fstype(LEX *lc, RES_ITEM *item, int index, int pass)
/* Store exclude directory containing info */
static void store_excludedir(LEX *lc, RES_ITEM2 *item, int index, int pass, bool exclude)
{

if (exclude) {
scan_err0(lc, _("ExcludeDirContaining directive not permitted in Exclude.\n"));
/* NOT REACHED */
}

lex_get_token(lc, T_NAME);
if (pass == 1) {
res_incexe.ignoredir = bstrdup(lc->str);
res_incexe.ignoredir.append(bstrdup(lc->str));
}
scan_to_eol(lc);
}
Expand Down
14 changes: 9 additions & 5 deletions src/filed/fileset.c
Expand Up @@ -431,7 +431,7 @@ void add_fileset(JCR *jcr, const char *item)
break;
case 'Z': /* Ignore dir */
state = state_include;
fileset->incexe->ignoredir = bstrdup(item);
fileset->incexe->ignoredir.append(bstrdup(item));
break;
case 'D':
current_opts = start_options(ff);
Expand Down Expand Up @@ -567,6 +567,7 @@ bool term_fileset(JCR *jcr)
}

#ifdef xxx_DEBUG_CODE
dlistString *node;
findFILESET *fileset = ff->fileset;
int i, j, k;

Expand Down Expand Up @@ -606,13 +607,15 @@ bool term_fileset(JCR *jcr)
Dmsg1(400, "XD %s\n", (char *)fo->drivetype.get(k));
}
}
if (incexe->ignoredir) {
Dmsg1(400, "Z %s\n", incexe->ignoredir);

for (int k = 0; k < incexe->ignoredir.size(); k++) {
Dmsg1(400, "Z %s\n", (char *)incexe->ignoredir.get(k));
}
dlistString *node;

foreach_dlist(node, &incexe->name_list) {
Dmsg1(400, "F %s\n", node->c_str());
}

foreach_dlist(node, &incexe->plugin_list) {
Dmsg1(400, "P %s\n", node->c_str());
}
Expand Down Expand Up @@ -653,10 +656,11 @@ bool term_fileset(JCR *jcr)
Dmsg1(400, "XD %s\n", (char *)fo->drivetype.get(k));
}
}
dlistString *node;

foreach_dlist(node, &incexe->name_list) {
Dmsg1(400, "F %s\n", node->c_str());
}

foreach_dlist(node, &incexe->plugin_list) {
Dmsg1(400, "P %s\n", node->c_str());
}
Expand Down
8 changes: 2 additions & 6 deletions src/filed/job.c
Expand Up @@ -365,9 +365,7 @@ void *handle_client_request(void *dirp)
incexe->opts_list.destroy();
incexe->name_list.destroy();
incexe->plugin_list.destroy();
if (incexe->ignoredir) {
free(incexe->ignoredir);
}
incexe->ignoredir.destroy();
}
fileset->include_list.destroy();

Expand All @@ -393,9 +391,7 @@ void *handle_client_request(void *dirp)
incexe->opts_list.destroy();
incexe->name_list.destroy();
incexe->plugin_list.destroy();
if (incexe->ignoredir) {
free(incexe->ignoredir);
}
incexe->ignoredir.destroy();
}
fileset->exclude_list.destroy();
free(fileset);
Expand Down

0 comments on commit 467a786

Please sign in to comment.