summaryrefslogtreecommitdiff
path: root/lib/tdb/common/tdb_private.h
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2010-09-13 20:05:59 +0930
committerRusty Russell <rusty@rustcorp.com.au>2010-09-13 20:05:59 +0930
commit786b7263000dedcb97e7369402e2e9dc967e36c4 (patch)
tree11ac4c09070beae44e6c8e7c68f7ef27e2c20864 /lib/tdb/common/tdb_private.h
parentf77708e96268d18abbfb038f4e78fe9e11a2856f (diff)
downloadsamba-786b7263000dedcb97e7369402e2e9dc967e36c4.tar.gz
samba-786b7263000dedcb97e7369402e2e9dc967e36c4.tar.bz2
samba-786b7263000dedcb97e7369402e2e9dc967e36c4.zip
tdb: put example hashes into header, so we notice incorrect hash_fn.
This is Stefan Metzmacher <metze@samba.org>'s patch with minor changes: 1) Use the TDB_MAGIC constant so both hashes aren't of strings. 2) Check the hash in tdb_check (paranoia, really). 3) Additional check in the (unlikely!) case where both examples hash to 0. 4) Cosmetic changes to var names and complaint message. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/tdb/common/tdb_private.h')
-rw-r--r--lib/tdb/common/tdb_private.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/tdb/common/tdb_private.h b/lib/tdb/common/tdb_private.h
index 9d0f3bcd70..eccd6880ef 100644
--- a/lib/tdb/common/tdb_private.h
+++ b/lib/tdb/common/tdb_private.h
@@ -147,7 +147,9 @@ struct tdb_header {
tdb_off_t rwlocks; /* obsolete - kept to detect old formats */
tdb_off_t recovery_start; /* offset of transaction recovery region */
tdb_off_t sequence_number; /* used when TDB_SEQNUM is set */
- tdb_off_t reserved[29];
+ uint32_t magic1_hash; /* hash of TDB_MAGIC_FOOD. */
+ uint32_t magic2_hash; /* hash of TDB_MAGIC. */
+ tdb_off_t reserved[27];
};
struct tdb_lock_type {
@@ -268,3 +270,5 @@ int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off,
struct tdb_record *rec);
bool tdb_write_all(int fd, const void *buf, size_t count);
int tdb_transaction_recover(struct tdb_context *tdb);
+void tdb_header_hash(struct tdb_context *tdb,
+ uint32_t *magic1_hash, uint32_t *magic2_hash);