tdb_compat: only use hashsize attribute when O_CREAT
authorRusty Russell <rusty@rustcorp.com.au>
Sun, 29 Jan 2012 23:36:55 +0000 (10:06 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Sun, 29 Jan 2012 23:36:55 +0000 (10:06 +1030)
tdb2 complains if you specify a tdb1 hashsize, and you're not actually
trying to create a new database.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
lib/tdb_compat/tdb_compat.c

index b37e6cc7ba03d01f22dc87009a66fcf566eefa8a..0406eff55e4d0b33d798d41c11fb218a18bef451 100644 (file)
@@ -136,7 +136,7 @@ tdb_open_compat_(const char *name, int hash_size,
                tdb_flags &= ~TDB_VOLATILE;
        }
 
-       if (hash_size && (tdb_flags & TDB_VERSION1)) {
+       if (hash_size && (tdb_flags & TDB_VERSION1) && (open_flags & O_CREAT)) {
                hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
                hsize.base.next = attr;
                hsize.tdb1_hashsize.hsize = hash_size;