diff --git a/state.c b/state.c index 7b98eb1a..b8e5cb22 100644 --- a/state.c +++ b/state.c @@ -745,9 +745,9 @@ void state_read(struct snapraid_state* state) return; } - /* start with a MD5 default. */ + /* start with a undefined default. */ /* it's for compatibility with version 1.0 where MD5 was implicit. */ - state->hash = HASH_MD5; + state->hash = HASH_UNDEFINED; disk = 0; file = 0; @@ -1384,8 +1384,17 @@ void state_read(struct snapraid_state* state) sclose(f); + if (state->hash == HASH_UNDEFINED) { + fprintf(stderr, "The checksum to use is not specified.\n"); + fprintf(stderr, "This happens because you are likely upgrading from SnapRAID 1.0.\n"); + fprintf(stderr, "To use the SnapRAID 2.x branch, you must restart from scratch,\n"); + fprintf(stderr, "deleting all the content and parity files.\n"); + exit(EXIT_FAILURE); + } if (state->hash == HASH_MD5) { - fprintf(stderr, "MD5 is not supported anymore.\n"); + fprintf(stderr, "The MD5 checksum is not supported anymore.\n"); + fprintf(stderr, "To use the SnapRAID 2.x branch, you must restart from scratch,\n"); + fprintf(stderr, "deleting all the content and parity files.\n"); exit(EXIT_FAILURE); } diff --git a/util.c b/util.c index 3011f305..c33202c5 100644 --- a/util.c +++ b/util.c @@ -709,9 +709,14 @@ void* malloc_nofail_align(size_t size, void** freeptr) void memhash(unsigned kind, void* digest, const void* src, unsigned size) { - if (kind == HASH_MURMUR3) { + switch (kind) { + case HASH_MURMUR3 : MurmurHash3_x86_128(src, size, 0, digest); - return; + break; + default: + fprintf(stderr, "Internal inconsistency in hash function %u\n", kind); + exit(EXIT_FAILURE); + break; } } diff --git a/util.h b/util.h index 4572c379..f6bdf490 100644 --- a/util.h +++ b/util.h @@ -372,8 +372,9 @@ void* malloc_nofail_align(size_t size, void** freeptr); /** * Hash kinds. */ -#define HASH_MURMUR3 0 +#define HASH_UNDEFINED 0 #define HASH_MD5 1 +#define HASH_MURMUR3 2 /** * Computes the HASH of a memory block.