Prints more informative comments if the hash type is not defined or MD5.

This commit is contained in:
Andrea Mazzoleni 2013-01-30 19:26:38 +01:00
parent 452f88795f
commit 91752b255b
3 changed files with 21 additions and 6 deletions

15
state.c
View file

@ -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);
}

9
util.c
View file

@ -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;
}
}

3
util.h
View file

@ -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.