mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Centralize canonical SnapRAID block hashing semantics
This commit is contained in:
parent
0ab885d8e5
commit
1a5b5728d2
7 changed files with 87 additions and 33 deletions
|
|
@ -775,6 +775,36 @@ void memhash(unsigned kind, const unsigned char* seed, void* digest, const void*
|
|||
}
|
||||
}
|
||||
|
||||
void memhash_block(unsigned kind, const unsigned char* seed, void* digest, const void* src, size_t logical_size, size_t block_size)
|
||||
{
|
||||
assert(logical_size <= block_size);
|
||||
|
||||
switch (kind) {
|
||||
case HASH_MUSEAIR :
|
||||
/*
|
||||
* MuseAir defines the identity of the complete canonical RAID
|
||||
* block. The caller must have zero-padded the buffer after the
|
||||
* logical end of the file block.
|
||||
*/
|
||||
memhash(kind, seed, digest, src, block_size);
|
||||
break;
|
||||
case HASH_MURMUR3 :
|
||||
case HASH_SPOOKY2 :
|
||||
/*
|
||||
* Preserve the historical SnapRAID hash semantics for content
|
||||
* files using legacy hashes.
|
||||
*/
|
||||
memhash(kind, seed, digest, src, logical_size);
|
||||
break;
|
||||
default :
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal(EINTERNAL, "Internal inconsistency in hash function %u\n", kind);
|
||||
exit(EXIT_FAILURE);
|
||||
break;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
|
||||
const char* hash_config_name(unsigned kind)
|
||||
{
|
||||
switch (kind) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue