ret = get_mapped_object(t, dsnc, i, &obj);
if (ret < 0)
return ret;
- hash_object(&obj, hashes + i * HASH_SIZE);
+ hash_object(t, &obj, hashes + i * HASH_SIZE);
hash_obj.data = hashes + i * HASH_SIZE;
osl_add_row(hash_tree_table, &hash_obj);
ds_name = disk_storage_name_of_hash(t, hashes + i * HASH_SIZE);
ret = get_mapped_object(t, dsnc, row_num, &obj);
if (ret < 0)
return ret;
- hash_object(&obj, hash);
+ hash_object(t, &obj, hash);
ds_name = disk_storage_name_of_hash(t, hash);
FOR_EACH_DISK_STORAGE_COLUMN(i, t, cd) {
filename = disk_storage_path(t, i, ds_name);
void sha1_hash(const char *data, unsigned long len, unsigned char *sha1);
-/** Our own sha1 implementation, see sha1.c. */
-#define hash_function sha1_hash
+static inline void hash_function(uint8_t table_version, const char *data,
+ unsigned long len, unsigned char *result)
+{
+ assert(table_version == 1);
+ sha1_hash(data, len, result);
+}
/**
* Compare two hashes.
const struct osl_object *obj)
{
HASH_TYPE hash[HASH_SIZE];
- hash_object(obj, hash);
+ hash_object(t, obj, hash);
return disk_storage_name_of_hash(t, hash);
}
return -E_OSL_NOMEM;
}
-static void column_name_hash(const char *col_name, HASH_TYPE *hash)
+static void column_name_hash(const struct osl_table *t, const char *col_name,
+ HASH_TYPE *hash)
{
- hash_function(col_name, strlen(col_name), hash);
+ hash_function(t->version, col_name, strlen(col_name), hash);
}
static int init_column_descriptions(struct osl_table *t)
if (ret < 0)
goto out;
}
- column_name_hash(cd->name, t->columns[i].name_hash);
+ column_name_hash(t, cd->name, t->columns[i].name_hash);
ret = -E_OSL_NOMEM;
filename = column_filename(t, i);
if (!filename)
FOR_EACH_COLUMN(i, t->desc, cd) {
if (cd->storage_type == OSL_NO_STORAGE)
continue;
- column_name_hash(cd->name, t->columns[i].name_hash);
+ column_name_hash(t, cd->name, t->columns[i].name_hash);
if (num_rows > 0 && cd->storage_type == OSL_MAPPED_STORAGE) {
ret = map_column(t, i);
if (ret < 0)
/**
* Compute a cryptographic hash of an osl object.
*
+ * \param t Determines the hash function to use.
* \param obj the Object to compute the hash value from.
* \param hash Result is returned here.
*/
-_static_inline_ void hash_object(const struct osl_object *obj, HASH_TYPE *hash)
+_static_inline_ void hash_object(const struct osl_table *t,
+ const struct osl_object *obj, HASH_TYPE *hash)
{
- hash_function(obj->data, obj->size, hash);
+ hash_function(t->version, obj->data, obj->size, hash);
}
/**