summaryrefslogtreecommitdiffstats
path: root/lib/tdb/common/open.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2014-02-04 23:35:53 +0100
committerJeremy Allison <jra@samba.org>2014-05-22 21:05:15 +0200
commitc29e64d97ee18e9d7946151052d1757084f861c6 (patch)
treea812e911fe41dad0e4ed02ffcf9bbd9c895b299a /lib/tdb/common/open.c
parentc0b0648555cd6193a587da4810ac2b0543497ea8 (diff)
downloadsamba-c29e64d97ee18e9d7946151052d1757084f861c6.tar.gz
samba-c29e64d97ee18e9d7946151052d1757084f861c6.tar.xz
samba-c29e64d97ee18e9d7946151052d1757084f861c6.zip
tdb: introduce TDB_SUPPORTED_FEATURE_FLAGS
This will allow to store a feature mask in the tdb header on disk, so that openers can check if they can handle the features other openers are using. Pair-Programmed-With: Volker Lendecke <vl@samba.org> Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/tdb/common/open.c')
-rw-r--r--lib/tdb/common/open.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c
index d5c0432111..17ab0b7c28 100644
--- a/lib/tdb/common/open.c
+++ b/lib/tdb/common/open.c
@@ -76,6 +76,20 @@ static int tdb_new_database(struct tdb_context *tdb, struct tdb_header *header,
if (tdb->flags & TDB_INCOMPATIBLE_HASH)
newdb->rwlocks = TDB_HASH_RWLOCK_MAGIC;
+ /*
+ * If we have any features we add the FEATURE_FLAG_MAGIC, overwriting the
+ * TDB_HASH_RWLOCK_MAGIC above.
+ */
+ if (newdb->feature_flags != 0) {
+ newdb->rwlocks = TDB_FEATURE_FLAG_MAGIC;
+ }
+
+ /*
+ * It's required for some following code pathes
+ * to have the fields on 'tdb' up-to-date.
+ */
+ tdb->feature_flags = newdb->feature_flags;
+
if (tdb->flags & TDB_INTERNAL) {
tdb->map_size = size;
tdb->map_ptr = (char *)newdb;
@@ -390,6 +404,7 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td
goto fail;
if (header.rwlocks != 0 &&
+ header.rwlocks != TDB_FEATURE_FLAG_MAGIC &&
header.rwlocks != TDB_HASH_RWLOCK_MAGIC) {
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: spinlocks no longer supported\n"));
errno = ENOSYS;
@@ -397,6 +412,19 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td
}
tdb->hash_size = header.hash_size;
+ if (header.rwlocks == TDB_FEATURE_FLAG_MAGIC) {
+ tdb->feature_flags = header.feature_flags;
+ }
+
+ if (tdb->feature_flags & ~TDB_SUPPORTED_FEATURE_FLAGS) {
+ TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: unsupported "
+ "features in tdb %s: 0x%08x (supported: 0x%08x)\n",
+ name, (unsigned)tdb->feature_flags,
+ (unsigned)TDB_SUPPORTED_FEATURE_FLAGS));
+ errno = ENOSYS;
+ goto fail;
+ }
+
if ((header.magic1_hash == 0) && (header.magic2_hash == 0)) {
/* older TDB without magic hash references */
tdb->hash_fn = tdb_old_hash;