diff --git a/elem.c b/elem.c index 2ae198a4..f11cbf51 100644 --- a/elem.c +++ b/elem.c @@ -100,8 +100,36 @@ int filter_path(struct snapraid_filter* filter, const char* path, const char* na int filter_file(struct snapraid_filter* filter, struct snapraid_file* file) { - /* only partially correct as we are not filtering dirs */ - return filter_path(filter, file->sub, file_name(file), 0); + char path[PATH_MAX]; + char* name; + unsigned i; + + pathcpy(path, sizeof(path), file->sub); + + /* filter for all the directory */ + name = path; + for(i=0;path[i] != 0;++i) { + if (path[i] == '/') { + /* set a terminator */ + path[i] = 0; + + /* filter the directory */ + if (filter_path(filter, path, name, 1) == 0) + return 0; + + /* restore the slash */ + path[i] = '/'; + + /* next name */ + name = path + i + 1; + } + } + + /* filter the final file */ + if (filter_path(filter, path, name, 0) == 0) + return 0; + + return -1; } block_off_t block_file_pos(struct snapraid_block* block) diff --git a/scan.c b/scan.c index 26b3594f..77d645b0 100644 --- a/scan.c +++ b/scan.c @@ -240,7 +240,7 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, s scan_file(scan, state, disk, sub_next, &st); } else { if (state->verbose) { - printf("warning: Excluded file '/%s'\n", sub_next); + printf("Excluding file '/%s'\n", sub_next); } } } else if (S_ISDIR(st.st_mode)) { @@ -250,7 +250,7 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, s scan_dir(scan, state, disk, path_next, sub_next); } else { if (state->verbose) { - printf("warning: Excluded directory '/%s'\n", sub_next); + printf("Excluding directory '/%s'\n", sub_next); } } } else { diff --git a/state.c b/state.c index fbfd0001..870010e6 100644 --- a/state.c +++ b/state.c @@ -523,10 +523,7 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist) tommy_node* k; for(k=tommy_list_head(filterlist);k!=0;k=k->next) { struct snapraid_filter* filter = k->data; - printf("\t"); - if (filter->is_path) - printf("/"); - printf("%s", filter->pattern); + printf("\t%s", filter->pattern); if (filter->is_dir) printf("/"); printf("\n"); @@ -556,6 +553,10 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist) break; } } + + if (state->verbose && !file->is_filtered) { + printf("Processing file '%s'\n", file->sub); + } } } }