From: Eric Bollengier Date: Wed, 9 Sep 2009 14:46:36 +0000 (+0200) Subject: Fix Exclude Dir Containing ignored when scanning the top_level dir X-Git-Tag: Release-7.0.0~2633^2~16^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a30fa11452a7ee878976b836a6d5d43e88029373;p=bacula%2Fbacula Fix Exclude Dir Containing ignored when scanning the top_level dir --- diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c index d089b703a8..38344f3ad5 100644 --- a/bacula/src/findlib/find.c +++ b/bacula/src/findlib/find.c @@ -274,8 +274,6 @@ static bool accept_file(FF_PKT *ff) basename = ff->fname; } - ff->ignoredir = incexe->ignoredir; - for (j = 0; j < incexe->opts_list.size(); j++) { findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j); ff->flags = fo->flags; diff --git a/bacula/src/findlib/find.h b/bacula/src/findlib/find.h index ff9be472eb..707f5290fb 100644 --- a/bacula/src/findlib/find.h +++ b/bacula/src/findlib/find.h @@ -215,7 +215,6 @@ struct FF_PKT { uint32_t flags; /* backup options */ int GZIP_level; /* compression level */ int strip_path; /* strip path count */ - char *ignoredir; /* ignore directories with this file */ bool cmd_plugin; /* set if we have a command plugin */ alist fstypes; /* allowed file system types */ alist drivetypes; /* allowed drive types */ diff --git a/bacula/src/findlib/find_one.c b/bacula/src/findlib/find_one.c index 5619ea43a8..f4f2e7be80 100644 --- a/bacula/src/findlib/find_one.c +++ b/bacula/src/findlib/find_one.c @@ -299,6 +299,29 @@ static bool check_changes(JCR *jcr, FF_PKT *ff_pkt) return true; } +static bool have_ignoredir(FF_PKT *ff_pkt) +{ + struct stat sb; + char tmp_name[MAXPATHLEN]; + char *ignoredir = ff_pkt->fileset->incexe->ignoredir; + + if (ignoredir) { + if (strlen(ff_pkt->fname) + strlen(ignoredir) + 2 > MAXPATHLEN) { + return false; + } + + strcpy(tmp_name, ff_pkt->fname); + strcat(tmp_name, "/"); + strcat(tmp_name, ignoredir); + if (stat(tmp_name, &sb) == 0) { + Dmsg2(100, "Directory '%s' ignored (found %s)\n", + ff_pkt->fname, ignoredir); + return true; /* Just ignore this directory */ + } + } + return false; +} + /* * Find a single file. * handle_file is the callback for handling the file. @@ -551,22 +574,8 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, * Ignore this directory and everything below if the file .nobackup * (or what is defined for IgnoreDir in this fileset) exists */ - if (ff_pkt->ignoredir != NULL) { - struct stat sb; - char fname[MAXPATHLEN]; - - if (strlen(ff_pkt->fname) + strlen("/") + - strlen(ff_pkt->ignoredir) + 1 > MAXPATHLEN) - return 1; /* Is this wisdom? */ - - strcpy(fname, ff_pkt->fname); - strcat(fname, "/"); - strcat(fname, ff_pkt->ignoredir); - if (stat(fname, &sb) == 0) { - Dmsg2(100, "Directory '%s' ignored (found %s)\n", - ff_pkt->fname, ff_pkt->ignoredir); - return 1; /* Just ignore this directory */ - } + if (have_ignoredir(ff_pkt)) { + return 1; /* Just ignore this directory */ } /* Build a canonical directory name with a trailing slash in link var */