diff --git a/src/dird/dird_conf.c b/src/dird/dird_conf.c index f2da9125621..5f2b7cbb39b 100644 --- a/src/dird/dird_conf.c +++ b/src/dird/dird_conf.c @@ -1372,11 +1372,13 @@ bool FILESETRES::print_config(POOL_MEM &buff) } /* - * Ignore Dir Containing = entry. + * Exclude Dir Containing = entry. */ - if (incexe->ignoredir) { - Mmsg(temp, "Ignore Dir Containing = \"%s\"\n", incexe->ignoredir); - indent_config_item(cfg_str, 2, temp.c_str()); + if (incexe->ignoredir.size()) { + for (int l = 0; l < incexe->ignoredir.size(); l++) { + Mmsg(temp, "Exclude Dir Containing = \"%s\"\n", incexe->ignoredir.get(l)); + indent_config_item(cfg_str, 2, temp.c_str()); + } } indent_config_item(cfg_str, 1, "}\n"); @@ -1557,9 +1559,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); } diff --git a/src/dird/dird_conf.h b/src/dird/dird_conf.h index 369886fe93d..dfcbe32614f 100644 --- a/src/dird/dird_conf.h +++ b/src/dird/dird_conf.h @@ -488,33 +488,33 @@ class JOBRES : public BRSRES { * 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 */ }; /* @@ -525,13 +525,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 */ diff --git a/src/dird/fd_cmds.c b/src/dird/fd_cmds.c index 9c614282adb..f44e89fe27e 100644 --- a/src/dird/fd_cmds.c +++ b/src/dird/fd_cmds.c @@ -282,8 +282,8 @@ static bool send_fileset(JCR *jcr) fd->fsend("E\n"); } - if (ie->ignoredir) { - fd->fsend("Z %s\n", ie->ignoredir); + for (int j = 0; j < ie->ignoredir.size(); j++) { + fd->fsend("Z %s\n", ie->ignoredir.get(j)); } for (int j = 0; j < ie->num_opts; j++) { @@ -291,7 +291,7 @@ static bool send_fileset(JCR *jcr) bool enhanced_wild = false; for (int k = 0; fo->opts[k] != '\0'; k++) { - if (fo->opts[k]=='W') { + if (fo->opts[k] == 'W') { enhanced_wild = true; break; } @@ -302,7 +302,7 @@ static bool send_fileset(JCR *jcr) */ if (store && !store->AllowCompress) { char newopts[MAX_FOPTS]; - bool done=false; /* print warning only if compression enabled in FS */ + bool done = false; /* print warning only if compression enabled in FS */ int l = 0; for (int k = 0; fo->opts[k] != '\0'; k++) { diff --git a/src/dird/inc_conf.c b/src/dird/inc_conf.c index 16090eda28c..908696af1af 100644 --- a/src/dird/inc_conf.c +++ b/src/dird/inc_conf.c @@ -647,10 +647,12 @@ static void store_excludedir(LEX *lc, RES_ITEM *item, int index, int pass, bool if (exclude) { scan_err0(lc, _("ExcludeDirContaining directive not permitted in Exclude.\n")); /* NOT REACHED */ + return; } + 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); } diff --git a/src/filed/dir_cmd.c b/src/filed/dir_cmd.c index da158591139..2425e073d36 100644 --- a/src/filed/dir_cmd.c +++ b/src/filed/dir_cmd.c @@ -353,9 +353,7 @@ static inline void cleanup_fileset(JCR *jcr) 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(); @@ -383,9 +381,7 @@ static inline void cleanup_fileset(JCR *jcr) 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); diff --git a/src/filed/fileset.c b/src/filed/fileset.c index e8880fe17cc..8615ed7d848 100644 --- a/src/filed/fileset.c +++ b/src/filed/fileset.c @@ -433,7 +433,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); @@ -469,6 +469,7 @@ bool term_fileset(JCR *jcr) #ifdef xxx_DEBUG_CODE for (int i = 0; i < fileset->include_list.size(); i++) { + dlistString *node; findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i); Dmsg0(400, "I\n"); @@ -509,13 +510,15 @@ bool term_fileset(JCR *jcr) Dmsg1(400, "G %s\n", (char *)fo->plugin); } } - 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()); } diff --git a/src/findlib/find.h b/src/findlib/find.h index 4208bde3616..724cbb16c73 100644 --- a/src/findlib/find.h +++ b/src/findlib/find.h @@ -47,8 +47,8 @@ #include #else struct utimbuf { - long actime; - long modtime; + long actime; + long modtime; }; #endif @@ -66,8 +66,9 @@ struct utimbuf { int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result); #endif -/* For options FO_xxx values see src/fileopts.h */ - +/* + * For options FO_xxx values see src/fileopts.h + */ enum { state_none, state_options, @@ -99,11 +100,11 @@ struct s_sz_matching { struct s_included_file { struct s_included_file *next; - uint32_t options; /* backup options */ - uint32_t algo; /* compression algorithm. 4 letters stored as an interger */ - int level; /* compression level */ - int len; /* length of fname */ - int pattern; /* set if wild card pattern */ + uint32_t options; /* Backup options */ + uint32_t algo; /* Compression algorithm. 4 letters stored as an integer */ + int level; /* Compression level */ + int len; /* Length of fname */ + int pattern; /* Set if wild card pattern */ struct s_sz_matching *size_match; /* Perform size matching ? */ b_fileset_shadow_type shadow_type; /* Perform fileset shadowing check ? */ char VerifyOpts[20]; /* Options for verify */ @@ -116,55 +117,58 @@ struct s_excluded_file { char fname[1]; }; -/* FileSet definitions very similar to the resource - * contained in the Director because the components - * of the structure are passed by the Director to the - * File daemon and recompiled back into this structure +/* + * FileSet definitions very similar to the resource + * contained in the Director because the components + * of the structure are passed by the Director to the + * File daemon and recompiled back into this structure */ -#undef MAX_FOPTS +#undef MAX_FOPTS #define MAX_FOPTS 30 -/* File options structure */ +/* + * File options structure + */ struct findFOPTS { - uint32_t flags; /* options in bits */ - uint32_t Compress_algo; /* compression algorithm. 4 letters stored as an interger */ - int Compress_level; /* compression level */ - int strip_path; /* strip path count */ + uint32_t flags; /* Options in bits */ + uint32_t Compress_algo; /* Compression algorithm. 4 letters stored as an integer */ + int Compress_level; /* Compression level */ + int strip_path; /* Strip path count */ struct s_sz_matching *size_match; /* Perform size matching ? */ b_fileset_shadow_type shadow_type; /* Perform fileset shadowing check ? */ - char VerifyOpts[MAX_FOPTS]; /* verify options */ - char AccurateOpts[MAX_FOPTS]; /* accurate mode options */ - char BaseJobOpts[MAX_FOPTS]; /* basejob mode options */ + char VerifyOpts[MAX_FOPTS]; /* Verify options */ + char AccurateOpts[MAX_FOPTS]; /* Accurate mode options */ + char BaseJobOpts[MAX_FOPTS]; /* Basejob mode options */ char *plugin; /* Plugin that handle this section */ - 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 basenames */ - alist base; /* list of base names */ - alist fstype; /* file system type limitation */ - alist drivetype; /* drive type limitation */ + 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 basenames */ + alist base; /* List of base names */ + alist fstype; /* File system type limitation */ + alist drivetype; /* Drive type limitation */ }; - -/* This is either an include item or an exclude item */ +/* + * This is either an include item or an exclude item + */ struct findINCEXE { - findFOPTS *current_opts; /* points to current options structure */ - alist opts_list; /* options list */ - dlist name_list; /* filename list -- holds dlistString */ - dlist plugin_list; /* plugin list -- holds dlistString */ - char *ignoredir; /* ignore directories with this file */ + findFOPTS *current_opts; /* Points to current options structure */ + alist opts_list; /* Options list */ + dlist name_list; /* Filename list -- holds dlistString */ + dlist plugin_list; /* Plugin list -- holds dlistString */ + alist ignoredir; /* Ignore directories with this file(s) */ }; /* - * FileSet Resource - * + * FileSet Resource */ struct findFILESET { int state; - findINCEXE *incexe; /* current item */ + findINCEXE *incexe; /* Current item */ alist include_list; alist exclude_list; }; @@ -180,20 +184,20 @@ struct HFSPLUS_INFO { * first argument to the find_files callback subroutine. */ struct FF_PKT { - char *top_fname; /* full filename before descending */ - char *fname; /* full filename */ - char *link; /* link if file linked */ + char *top_fname; /* Full filename before descending */ + char *fname; /* Full filename */ + char *link; /* Link if file linked */ char *object_name; /* Object name */ - char *object; /* restore object */ + char *object; /* Restore object */ char *plugin; /* Current Options{Plugin=} name */ - POOLMEM *sys_fname; /* system filename */ - POOLMEM *fname_save; /* save when stripping path */ - POOLMEM *link_save; /* save when stripping path */ - POOLMEM *ignoredir_fname; /* used to ignore directories */ - char *digest; /* set to file digest when the file is a hardlink */ - struct stat statp; /* stat packet */ - uint32_t digest_len; /* set to the digest len when the file is a hardlink*/ - int32_t digest_stream; /* set to digest type when the file is hardlink */ + POOLMEM *sys_fname; /* System filename */ + POOLMEM *fname_save; /* Save when stripping path */ + POOLMEM *link_save; /* Save when stripping path */ + POOLMEM *ignoredir_fname; /* Used to ignore directories */ + char *digest; /* Set to file digest when the file is a hardlink */ + struct stat statp; /* Stat packet */ + uint32_t digest_len; /* Set to the digest len when the file is a hardlink*/ + int32_t digest_stream; /* Set to digest type when the file is hardlink */ int32_t FileIndex; /* FileIndex of this file */ int32_t LinkFI; /* FileIndex of main hard linked file */ int32_t delta_seq; /* Delta Sequence number */ @@ -202,13 +206,13 @@ struct FF_PKT { int32_t object_compression; /* Type of compression for object */ struct f_link *linked; /* Set if this file is hard linked */ int type; /* FT_ type from above */ - int ff_errno; /* errno */ + int ff_errno; /* Errno */ BFILE bfd; /* Bareos file descriptor */ - time_t save_time; /* start of incremental time */ + time_t save_time; /* Start of incremental time */ bool accurate_found; /* Found in the accurate hash (valid after check_changes()) */ - bool dereference; /* follow links (not implemented) */ - bool null_output_device; /* using null output device */ - bool incremental; /* incremental save */ + bool dereference; /* Follow links (not implemented) */ + bool null_output_device; /* Using null output device */ + bool incremental; /* Incremental save */ bool no_read; /* Do not read this file when using Plugin */ char VerifyOpts[20]; char AccurateOpts[20]; @@ -219,25 +223,31 @@ struct FF_PKT { findFILESET *fileset; int (*file_save)(JCR *, FF_PKT *, bool); /* User's callback */ int (*plugin_save)(JCR *, FF_PKT *, bool); /* User's callback */ - bool (*check_fct)(JCR *, FF_PKT *); /* optionnal user fct to check file changes */ + bool (*check_fct)(JCR *, FF_PKT *); /* Optionnal user fct to check file changes */ - /* Values set by accept_file while processing Options */ - uint32_t flags; /* backup options */ - uint32_t Compress_algo; /* compression algorithm. 4 letters stored as an interger */ - int Compress_level; /* compression level */ - int strip_path; /* strip path count */ + /* + * Values set by accept_file while processing Options + */ + uint32_t flags; /* Backup options */ + uint32_t Compress_algo; /* Compression algorithm. 4 letters stored as an integer */ + int Compress_level; /* Compression level */ + int strip_path; /* Strip path count */ struct s_sz_matching *size_match; /* Perform size matching ? */ - bool cmd_plugin; /* set if we have a command plugin */ - bool opt_plugin; /* set if we have an option plugin */ - alist fstypes; /* allowed file system types */ - alist drivetypes; /* allowed drive types */ + bool cmd_plugin; /* Set if we have a command plugin */ + bool opt_plugin; /* Set if we have an option plugin */ + alist fstypes; /* Allowed file system types */ + alist drivetypes; /* Allowed drive types */ - /* List of all hard linked files found */ - struct f_link **linkhash; /* hard linked files */ + /* + * List of all hard linked files found + */ + struct f_link **linkhash; /* Hard linked files */ - /* Darwin specific things. - * To avoid clutter, we always include rsrc_bfd and volhas_attrlist */ - BFILE rsrc_bfd; /* fd for resource forks */ + /* + * Darwin specific things. + * To avoid clutter, we always include rsrc_bfd and volhas_attrlist + */ + BFILE rsrc_bfd; /* Fd for resource forks */ bool volhas_attrlist; /* Volume supports getattrlist() */ struct HFSPLUS_INFO hfsinfo; /* Finder Info and resource fork size */ }; diff --git a/src/findlib/find_one.c b/src/findlib/find_one.c index 931e313c00c..8cbe4654f61 100644 --- a/src/findlib/find_one.c +++ b/src/findlib/find_one.c @@ -363,23 +363,29 @@ static inline bool have_ignoredir(FF_PKT *ff_pkt) struct stat sb; char *ignoredir; - /* Ensure that pointers are defined */ + /* + * Ensure that pointers are defined + */ if (!ff_pkt->fileset || !ff_pkt->fileset->incexe) { return false; } - ignoredir = ff_pkt->fileset->incexe->ignoredir; - if (ignoredir) { - if (!ff_pkt->ignoredir_fname) { - ff_pkt->ignoredir_fname = get_pool_memory(PM_FNAME); - } - Mmsg(ff_pkt->ignoredir_fname, "%s/%s", ff_pkt->fname, ignoredir); - if (stat(ff_pkt->ignoredir_fname, &sb) == 0) { - Dmsg2(100, "Directory '%s' ignored (found %s)\n", - ff_pkt->fname, ignoredir); - return true; /* Just ignore this directory */ + for (int i = 0; i < ff_pkt->fileset->incexe->ignoredir.size(); i++) { + ignoredir = (char *)ff_pkt->fileset->incexe->ignoredir.get(i); + + if (ignoredir) { + if (!ff_pkt->ignoredir_fname) { + ff_pkt->ignoredir_fname = get_pool_memory(PM_FNAME); + } + Mmsg(ff_pkt->ignoredir_fname, "%s/%s", ff_pkt->fname, ignoredir); + if (stat(ff_pkt->ignoredir_fname, &sb) == 0) { + Dmsg2(100, "Directory '%s' ignored (found %s)\n", + ff_pkt->fname, ignoredir); + return true; /* Just ignore this directory */ + } } } + return false; }