Changes the exclude rules to be applied also to directories.

This commit is contained in:
Andrea Mazzoleni 2012-11-04 00:46:16 +01:00
parent 2d6528fe90
commit 02f26ca9a1
6 changed files with 16 additions and 16 deletions

11
scan.c
View file

@ -480,6 +480,14 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, i
exit(EXIT_FAILURE);
}
/* exclude files before doing any check on them */
if (filter_path(&state->filterlist, disk->name, sub_next) != 0) {
if (state->verbose) {
printf("Excluding file '%s'\n", path_next);
}
continue;
}
/* get info about the file */
if (lstat(path_next, &st) != 0) {
fprintf(stderr, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
@ -489,7 +497,6 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, i
if (S_ISREG(st.st_mode)) {
if (filter_hidden(state->filter_hidden, dd, &st) == 0
&& filter_content(&state->contentlist, path_next) == 0
&& filter_path(&state->filterlist, disk->name, sub_next) == 0
) {
/* check for read permission */
if (access(path_next, R_OK) != 0) {
@ -514,7 +521,6 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, i
}
} else if (S_ISLNK(st.st_mode)) {
if (filter_hidden(state->filter_hidden, dd, &st) == 0
&& filter_path(&state->filterlist, disk->name, sub_next) == 0
) {
char subnew[PATH_MAX];
int ret;
@ -553,7 +559,6 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, i
} else {
if (filter_hidden(state->filter_hidden, dd, &st) == 0
&& filter_content(&state->contentlist, path_next) == 0
&& filter_path(&state->filterlist, disk->name, sub_next) == 0
) {
fprintf(stderr, "warning: Ignoring special '%s' file '%s'\n", stat_desc(&st), path_next);
} else {