diff --git a/snapraid.c b/snapraid.c index 92dd008c..65ba1a62 100644 --- a/snapraid.c +++ b/snapraid.c @@ -204,6 +204,7 @@ void log_close(const char* log) #define OPT_TEST_FORCE_SCRUB_EVEN 272 #define OPT_TEST_FORCE_CONTENT_WRITE 273 #define OPT_TEST_FORCE_CONTENT_TEXT 274 +#define OPT_TEST_SKIP_CONTENT_CHECK 275 #if HAVE_GETOPT_LONG struct option long_options[] = { @@ -286,6 +287,9 @@ struct option long_options[] = { /* Force the use of text content file . */ { "test-force-content-text", 0, 0, OPT_TEST_FORCE_CONTENT_TEXT }, + /* Relax the checks done at the content file */ + { "test-skip-content-check", 0, 0, OPT_TEST_SKIP_CONTENT_CHECK }, + { 0, 0, 0, 0 } }; #endif @@ -522,6 +526,9 @@ int main(int argc, char* argv[]) opt.skip_device = 1; period = 50; /* reduce period of the speed test */ break; + case OPT_TEST_SKIP_CONTENT_CHECK : + opt.skip_content_check = 1; + break; case OPT_TEST_FORCE_MURMUR3 : opt.force_murmur3 = 1; break; diff --git a/state.c b/state.c index b564c557..44f73b2e 100644 --- a/state.c +++ b/state.c @@ -2652,7 +2652,7 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST if (v_size / state->block_size > blockmax) { /* LCOV_EXCL_START */ decoding_error(path, f); - fprintf(stderr, "Internal inconsistency in file size!\n"); + fprintf(stderr, "Internal inconsistency in file size too big!\n"); exit(EXIT_FAILURE); /* LCOV_EXCL_STOP */ } @@ -2745,10 +2745,16 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST if (v_pos + v_count > blockmax) { /* LCOV_EXCL_START */ - decoding_error(path, f); - fprintf(stderr, "Internal inconsistency in block size!\n"); - exit(EXIT_FAILURE); - /* LCOV_EXCL_STOP */ + if (state->opt.skip_content_check) { + fprintf(stderr, "Internal inconsistency in block size!\n"); + fprintf(stderr, "Overriding from %u to %u...\n", blockmax, v_pos + v_count); + blockmax = v_pos + v_count; + } else { + fprintf(stderr, "Internal inconsistency in block size!\n"); + decoding_error(path, f); + exit(EXIT_FAILURE); + } + /* LCOV_EXCL_START */ } /* grow the array */ @@ -2873,9 +2879,15 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST if (v_pos + v_count > blockmax) { /* LCOV_EXCL_START */ - decoding_error(path, f); - fprintf(stderr, "Internal inconsistency in info size!\n"); - exit(EXIT_FAILURE); + if (state->opt.skip_content_check) { + fprintf(stderr, "Internal inconsistency in info size!\n"); + fprintf(stderr, "Overriding from %u to %u...\n", blockmax, v_pos + v_count); + blockmax = v_pos + v_count; + } else { + decoding_error(path, f); + fprintf(stderr, "Internal inconsistency in info size!\n"); + exit(EXIT_FAILURE); + } /* LCOV_EXCL_STOP */ } @@ -2968,9 +2980,15 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST if (v_pos + v_count > blockmax) { /* LCOV_EXCL_START */ - decoding_error(path, f); - fprintf(stderr, "Internal inconsistency in hole size!\n"); - exit(EXIT_FAILURE); + if (state->opt.skip_content_check) { + fprintf(stderr, "Internal inconsistency in hole size!\n"); + fprintf(stderr, "Overriding from %u to %u...\n", blockmax, v_pos + v_count); + blockmax = v_pos + v_count; + } else { + decoding_error(path, f); + fprintf(stderr, "Internal inconsistency in hole size!\n"); + exit(EXIT_FAILURE); + } /* LCOV_EXCL_STOP */ } @@ -3373,7 +3391,12 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST if (blockmax != parity_size(state)) { /* LCOV_EXCL_START */ fprintf(stderr, "Internal inconsistency in parity size in '%s' at offset %"PRIi64"\n", path, stell(f)); - exit(EXIT_FAILURE); + if (state->opt.skip_content_check) { + fprintf(stderr, "Overriding from %u to %u...\n", blockmax, parity_size(state)); + blockmax = parity_size(state); + } else { + exit(EXIT_FAILURE); + } /* LCOV_EXCL_STOP */ } diff --git a/state.h b/state.h index 2ff98dcf..82c4e3aa 100644 --- a/state.h +++ b/state.h @@ -73,6 +73,7 @@ struct snapraid_option { int skip_sequential; /**< Skip sequential hint. */ int skip_lock; /**< Skip the lock file protection. */ int skip_self; /**< Skip the self-test. */ + int skip_content_check; /**< Relax some content file checks. */ int kill_after_sync; /**< Kill the process after sync without saving the final state. */ int force_murmur3; /**< Force Murmur3 choice. */ int force_spooky2; /**< Force Spooky2 choice. */