diff --git a/HISTORY b/HISTORY index 13c12dbd..ed5c7f9d 100644 --- a/HISTORY +++ b/HISTORY @@ -28,6 +28,9 @@ SnapRAID HISTORY You must use the 'nohidden' option in the configuration file. * When opening files in read-only mode, also specify the noatime flag, to avoid to update the file access time. + * Exclude rules are now also applied to directories. + This allows to excludes some file/directory without the need to call + the stat() function on them. 1.13 2012/11 ============ diff --git a/TODO b/TODO index f18449dd..2b569724 100644 --- a/TODO +++ b/TODO @@ -32,14 +32,6 @@ is too complex. - v2.x -* Checked the include/exclude rules for FILE to include also directories. -This is needed to allow to exclude files, before even calling stat() on them -to know if they are file or directory. -There are some cases where this is needed, like for the ".gvfs" mounted fuse directory by -gnome that cannot have stat() called *EVEN* by root. -This is totally wrong, because the stat() manpage explicitely tells that no permissions are -needed to call stat(). - * Remove the old MD5 support. * A new 'init' command to differentiate the first 'sync' operation. diff --git a/portable.h b/portable.h index b6fdded2..8640c0de 100644 --- a/portable.h +++ b/portable.h @@ -149,7 +149,7 @@ static int open_noatime(const char* file, int flags) return f; } #else -#define open_noatime open +#define open_noatime open #endif /** diff --git a/scan.c b/scan.c index 1a5a01ac..40948e09 100644 --- a/scan.c +++ b/scan.c @@ -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 { diff --git a/snapraid.1 b/snapraid.1 index dfbfaeda..d22636d3 100644 --- a/snapraid.1 +++ b/snapraid.1 @@ -644,7 +644,7 @@ There are four different types of patterns: .B FILE Selects any file named as FILE. You can use any globbing character like * and ?. -This pattern is applied only to files and not to directories. +This pattern is applied to both files and directories. .TP .B DIR/ Selects any directory named DIR. You can use any globbing @@ -655,7 +655,7 @@ This pattern is applied only to directories and not to files. Selects the exact specified file path. You can use any globbing character like * and ? but they never matches a directory slash. -This pattern is applied only to files and not to directories. +This pattern is applied to both files and directories. .TP .B /PATH/DIR/ Selects the exact specified directory path. You can use any diff --git a/snapraid.d b/snapraid.d index cb7c4441..dad1ea4a 100644 --- a/snapraid.d +++ b/snapraid.d @@ -465,7 +465,7 @@ Pattern =FILE Selects any file named as FILE. You can use any globbing character like * and ?. - This pattern is applied only to files and not to directories. + This pattern is applied to both files and directories. =DIR/ Selects any directory named DIR. You can use any globbing @@ -476,7 +476,7 @@ Pattern Selects the exact specified file path. You can use any globbing character like * and ? but they never matches a directory slash. - This pattern is applied only to files and not to directories. + This pattern is applied to both files and directories. =/PATH/DIR/ Selects the exact specified directory path. You can use any