1 From aaf17ad370610f17fc998ff9aeb9e6d9e8832787 Mon Sep 17 00:00:00 2001
2 From: Eric Bollengier <eric@eb.homelinux.org>
3 Date: Wed, 9 Sep 2009 16:46:36 +0200
4 Subject: [PATCH 4/4] Fix Exclude Dir Containing ignored when scanning the top_level dir
7 bacula/src/findlib/find.c | 2 --
8 bacula/src/findlib/find.h | 1 -
9 bacula/src/findlib/find_one.c | 41 +++++++++++++++++++++++++----------------
10 3 files changed, 25 insertions(+), 19 deletions(-)
12 diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c
13 index d089b70..38344f3 100644
14 --- a/bacula/src/findlib/find.c
15 +++ b/bacula/src/findlib/find.c
16 @@ -274,8 +274,6 @@ static bool accept_file(FF_PKT *ff)
20 - ff->ignoredir = incexe->ignoredir;
22 for (j = 0; j < incexe->opts_list.size(); j++) {
23 findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
24 ff->flags = fo->flags;
25 diff --git a/bacula/src/findlib/find.h b/bacula/src/findlib/find.h
26 index ff9be47..707f529 100644
27 --- a/bacula/src/findlib/find.h
28 +++ b/bacula/src/findlib/find.h
29 @@ -215,7 +215,6 @@ struct FF_PKT {
30 uint32_t flags; /* backup options */
31 int GZIP_level; /* compression level */
32 int strip_path; /* strip path count */
33 - char *ignoredir; /* ignore directories with this file */
34 bool cmd_plugin; /* set if we have a command plugin */
35 alist fstypes; /* allowed file system types */
36 alist drivetypes; /* allowed drive types */
37 diff --git a/bacula/src/findlib/find_one.c b/bacula/src/findlib/find_one.c
38 index 5619ea4..f4f2e7b 100644
39 --- a/bacula/src/findlib/find_one.c
40 +++ b/bacula/src/findlib/find_one.c
41 @@ -299,6 +299,29 @@ static bool check_changes(JCR *jcr, FF_PKT *ff_pkt)
45 +static bool have_ignoredir(FF_PKT *ff_pkt)
48 + char tmp_name[MAXPATHLEN];
49 + char *ignoredir = ff_pkt->fileset->incexe->ignoredir;
52 + if (strlen(ff_pkt->fname) + strlen(ignoredir) + 2 > MAXPATHLEN) {
56 + strcpy(tmp_name, ff_pkt->fname);
57 + strcat(tmp_name, "/");
58 + strcat(tmp_name, ignoredir);
59 + if (stat(tmp_name, &sb) == 0) {
60 + Dmsg2(100, "Directory '%s' ignored (found %s)\n",
61 + ff_pkt->fname, ignoredir);
62 + return true; /* Just ignore this directory */
70 * handle_file is the callback for handling the file.
71 @@ -551,22 +574,8 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt,
72 * Ignore this directory and everything below if the file .nobackup
73 * (or what is defined for IgnoreDir in this fileset) exists
75 - if (ff_pkt->ignoredir != NULL) {
77 - char fname[MAXPATHLEN];
79 - if (strlen(ff_pkt->fname) + strlen("/") +
80 - strlen(ff_pkt->ignoredir) + 1 > MAXPATHLEN)
81 - return 1; /* Is this wisdom? */
83 - strcpy(fname, ff_pkt->fname);
85 - strcat(fname, ff_pkt->ignoredir);
86 - if (stat(fname, &sb) == 0) {
87 - Dmsg2(100, "Directory '%s' ignored (found %s)\n",
88 - ff_pkt->fname, ff_pkt->ignoredir);
89 - return 1; /* Just ignore this directory */
91 + if (have_ignoredir(ff_pkt)) {
92 + return 1; /* Just ignore this directory */
95 /* Build a canonical directory name with a trailing slash in link var */