From 99223533eb10e2c94aa37876599df4980c55c772 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Fri, 23 Nov 2012 00:01:02 +0100 Subject: [PATCH] Uses an inplicit AND operation between -d and -f filter options. --- TODO | 4 ++++ snapraid.1 | 7 +++++++ snapraid.c | 21 +++++++++++++-------- snapraid.d | 7 +++++++ snapraid.txt | 7 +++++++ 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index 72deac1d..28a16f0e 100644 --- a/TODO +++ b/TODO @@ -19,6 +19,10 @@ integrity check of the existing ones. It should restore only missing files, without recovering modified ones or check validity of data of existing ones. +* Adds a log option, to save log files with the date in the name. This could +help to keep track of what happens during automated operations. +We must keep the log to stdout/err, and only save a copy to the log file. + * In fix an existing symlink with the same name of a file to be recovered may stop the process making the create() operation to fail. diff --git a/snapraid.1 b/snapraid.1 index c9590e3f..68e9bcdc 100644 --- a/snapraid.1 +++ b/snapraid.1 @@ -378,8 +378,15 @@ process the whole array. .B \(hyd, \(hy\(hyfilter\(hydisk NAME Filters the files to process in the \(a"check\(a" and \(a"fix\(a" commands. +Only the files present in the specified disk are processed. You must specify a disk name as named in the configuration file. +If you combine \(hy\(hyfilter and \(hy\(hyfilter\(hydisk options, only files +matching both the two groups of rules are selected. +This option can be used many times. +This option can be used only with the \(a"check\(a" and \(a"fix\(a" commands. +Note that it cannot be used with \(a"sync\(a", because \(a"sync\(a" always +process the whole array. .TP .B \(hya, \(hy\(hyaudit\(hyonly When checking, only verify the hash of the files, without diff --git a/snapraid.c b/snapraid.c index 2df40977..161b5404 100644 --- a/snapraid.c +++ b/snapraid.c @@ -143,7 +143,8 @@ int main(int argc, char* argv[]) block_off_t blockstart; block_off_t blockcount; int ret; - tommy_list filterlist; + tommy_list filterlist_file; + tommy_list filterlist_disk; char* e; const char* command; @@ -164,7 +165,8 @@ int main(int argc, char* argv[]) test_skip_device = 0; blockstart = 0; blockcount = 0; - tommy_list_init(&filterlist); + tommy_list_init(&filterlist_file); + tommy_list_init(&filterlist_disk); opterr = 0; while ((c = @@ -184,7 +186,7 @@ int main(int argc, char* argv[]) fprintf(stderr, "Invalid filter specification '%s'\n", optarg); exit(EXIT_FAILURE); } - tommy_list_insert_tail(&filterlist, &filter->node, filter); + tommy_list_insert_tail(&filterlist_file, &filter->node, filter); } break; case 'd' : { struct snapraid_filter* filter = filter_alloc_disk(1, optarg); @@ -192,7 +194,7 @@ int main(int argc, char* argv[]) fprintf(stderr, "Invalid filter specification '%s'\n", optarg); exit(EXIT_FAILURE); } - tommy_list_insert_tail(&filterlist, &filter->node, filter); + tommy_list_insert_tail(&filterlist_disk, &filter->node, filter); } break; case 's' : blockstart = strtoul(optarg, &e, 0); @@ -307,7 +309,7 @@ int main(int argc, char* argv[]) case OPERATION_DRY : break; default: - if (!tommy_list_empty(&filterlist)) { + if (!tommy_list_empty(&filterlist_file) || !tommy_list_empty(&filterlist_disk)) { fprintf(stderr, "You cannot filter with the '%s' command\n", command); exit(EXIT_FAILURE); } @@ -374,7 +376,8 @@ int main(int argc, char* argv[]) state_read(&state); /* apply the command line filter */ - state_filter(&state, &filterlist); + state_filter(&state, &filterlist_file); + state_filter(&state, &filterlist_disk); /* intercept Ctrl+C */ signal(SIGINT, &signal_handler); @@ -388,7 +391,8 @@ int main(int argc, char* argv[]) state_read(&state); /* apply the command line filter */ - state_filter(&state, &filterlist); + state_filter(&state, &filterlist_file); + state_filter(&state, &filterlist_disk); /* intercept Ctrl+C */ signal(SIGINT, &signal_handler); @@ -401,7 +405,8 @@ int main(int argc, char* argv[]) } state_done(&state); - tommy_list_foreach(&filterlist, (tommy_foreach_func*)filter_free); + tommy_list_foreach(&filterlist_file, (tommy_foreach_func*)filter_free); + tommy_list_foreach(&filterlist_disk, (tommy_foreach_func*)filter_free); os_done(); diff --git a/snapraid.d b/snapraid.d index 2edd4a8b..4c6d034d 100644 --- a/snapraid.d +++ b/snapraid.d @@ -252,8 +252,15 @@ Options -d, --filter-disk NAME Filters the files to process in the "check" and "fix" commands. + Only the files present in the specified disk are processed. You must specify a disk name as named in the configuration file. + If you combine --filter and --filter-disk options, only files + matching both the two groups of rules are selected. + This option can be used many times. + This option can be used only with the "check" and "fix" commands. + Note that it cannot be used with "sync", because "sync" always + process the whole array. -a, --audit-only When checking, only verify the hash of the files, without diff --git a/snapraid.txt b/snapraid.txt index 86791d2f..c2100cd6 100644 --- a/snapraid.txt +++ b/snapraid.txt @@ -281,8 +281,15 @@ SnapRAID provides the following options: -d, --filter-disk NAME Filters the files to process in the "check" and "fix" commands. + Only the files present in the specified disk are processed. You must specify a disk name as named in the configuration file. + If you combine --filter and --filter-disk options, only files + matching both the two groups of rules are selected. + This option can be used many times. + This option can be used only with the "check" and "fix" commands. + Note that it cannot be used with "sync", because "sync" always + process the whole array. -a, --audit-only When checking, only verify the hash of the files, without