diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2011-12-05 17:04:30 +1030 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-12-05 17:04:30 +1030 |
commit | 80c3ba8123ed6708ebf3afad9ed78037e571a81d (patch) | |
tree | 242254821b79c3301e4af95b8c38ae8beeb04cba /lib/tdb2/private.h | |
parent | 3f99fc16a0a3aead82cf8cdfb9703f8f18388623 (diff) | |
download | samba-80c3ba8123ed6708ebf3afad9ed78037e571a81d.tar.gz samba-80c3ba8123ed6708ebf3afad9ed78037e571a81d.tar.bz2 samba-80c3ba8123ed6708ebf3afad9ed78037e571a81d.zip |
tdb2: add a capability list from the header.
This allows even more extensibility in future: in particular, the top
bits of each capability tell us what to do if we don't understand it:
fail the open, fail to open for write, or don't try to check the
format.
tdb_check needs to understand the capability list so it can know to
skip over it: each element in the list is prefixed with the type tag
and the length.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 35f198de1851a7d57064546b7ced677b6fabee27)
Diffstat (limited to 'lib/tdb2/private.h')
-rw-r--r-- | lib/tdb2/private.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/tdb2/private.h b/lib/tdb2/private.h index 87245a5970..85cd15a817 100644 --- a/lib/tdb2/private.h +++ b/lib/tdb2/private.h @@ -72,11 +72,18 @@ typedef uint64_t tdb_off_t; #define TDB_HTABLE_MAGIC ((uint64_t)0x1888) #define TDB_CHAIN_MAGIC ((uint64_t)0x1777) #define TDB_FTABLE_MAGIC ((uint64_t)0x1666) +#define TDB_CAP_MAGIC ((uint64_t)0x1555) #define TDB_FREE_MAGIC ((uint64_t)0xFE) #define TDB_HASH_MAGIC (0xA1ABE11A01092008ULL) #define TDB_RECOVERY_MAGIC (0xf53bc0e7ad124589ULL) #define TDB_RECOVERY_INVALID_MAGIC (0x0ULL) +/* Capability bits. */ +#define TDB_CAP_TYPE_MASK 0x1FFFFFFFFFFFFFFFULL +#define TDB_CAP_NOCHECK 0x8000000000000000ULL +#define TDB_CAP_NOWRITE 0x4000000000000000ULL +#define TDB_CAP_NOOPEN 0x2000000000000000ULL + #define TDB_OFF_IS_ERR(off) unlikely(off >= (tdb_off_t)(long)TDB_ERR_LAST) #define TDB_OFF_TO_ERR(off) ((enum TDB_ERROR)(long)(off)) #define TDB_ERR_TO_OFF(ecode) ((tdb_off_t)(long)(ecode)) @@ -242,7 +249,8 @@ struct tdb_header { uint64_t seqnum; /* Sequence number for TDB_SEQNUM */ - tdb_off_t reserved[23]; + tdb_off_t capabilities; /* Optional linked list of capabilities. */ + tdb_off_t reserved[22]; /* Top level hash table. */ tdb_off_t hashtable[1ULL << TDB_TOPLEVEL_HASH_BITS]; @@ -254,6 +262,13 @@ struct tdb_freetable { tdb_off_t buckets[TDB_FREE_BUCKETS]; }; +struct tdb_capability { + struct tdb_used_record hdr; + tdb_off_t type; + tdb_off_t next; + /* ... */ +}; + /* Information about a particular (locked) hash entry. */ struct hash_info { /* Full hash value of entry. */ @@ -389,6 +404,8 @@ enum TDB_ERROR delete_from_hash(struct tdb_context *tdb, struct hash_info *h); /* For tdb_check */ bool is_subhash(tdb_off_t val); +enum TDB_ERROR unknown_capability(struct tdb_context *tdb, const char *caller, + tdb_off_t type); /* free.c: */ enum TDB_ERROR tdb_ftable_init(struct tdb_context *tdb); @@ -407,7 +424,7 @@ enum TDB_ERROR add_free_record(struct tdb_context *tdb, enum tdb_lock_flags waitflag, bool coalesce_ok); -/* Set up header for a used/ftable/htable/chain record. */ +/* Set up header for a used/ftable/htable/chain/capability record. */ enum TDB_ERROR set_header(struct tdb_context *tdb, struct tdb_used_record *rec, unsigned magic, uint64_t keylen, uint64_t datalen, |