The branch, master has been updated
       via  72cd5d5 tdb: Remove "header" from tdb_context
       via  71247ec tdb: Pass argument "header" to check_header_hash
       via  1436107 tdb: Pass argument "header" to tdb_new_database
      from  dc6c40b samba-tool/domain provision: add support for utf-8 
passwords for --adminpass

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 72cd5d5ff664dc46afb3dd6a5ea45a28ef7b8591
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Dec 20 16:36:02 2012 +0100

    tdb: Remove "header" from tdb_context
    
    header.hash_size was the only thing we ever referenced outside of
    tdb_open_ex and its direct callees. So this shrinks the tdb_context by
    164 bytes.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Stefan Metzmacher <me...@samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <me...@samba.org>
    Autobuild-Date(master): Tue Feb  5 13:18:28 CET 2013 on sn-devel-104

commit 71247ec4bdefb3a1b16619f7ea7404bcbafb5b60
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Dec 20 16:14:23 2012 +0100

    tdb: Pass argument "header" to check_header_hash
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Stefan Metzmacher <me...@samba.org>

commit 1436107b0769c88e7eb50057b5f05ad5b8573990
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Dec 20 16:14:23 2012 +0100

    tdb: Pass argument "header" to tdb_new_database
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Stefan Metzmacher <me...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/tdb/common/check.c         |   22 ++++++++--------
 lib/tdb/common/dump.c          |    2 +-
 lib/tdb/common/freelist.c      |    4 +-
 lib/tdb/common/freelistcheck.c |    2 +-
 lib/tdb/common/io.c            |    4 +-
 lib/tdb/common/lock.c          |   12 ++++----
 lib/tdb/common/open.c          |   55 +++++++++++++++++++++++----------------
 lib/tdb/common/rescue.c        |    6 ++--
 lib/tdb/common/summary.c       |    6 ++--
 lib/tdb/common/tdb.c           |   12 ++++----
 lib/tdb/common/tdb_private.h   |    6 ++--
 lib/tdb/common/transaction.c   |    4 +-
 lib/tdb/common/traverse.c      |    4 +-
 13 files changed, 74 insertions(+), 65 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/check.c b/lib/tdb/common/check.c
index 313f55c..dc38102 100644
--- a/lib/tdb/common/check.c
+++ b/lib/tdb/common/check.c
@@ -50,11 +50,11 @@ static bool tdb_check_header(struct tdb_context *tdb, 
tdb_off_t *recovery)
        if (hdr.hash_size == 0)
                goto corrupt;
 
-       if (hdr.hash_size != tdb->header.hash_size)
+       if (hdr.hash_size != tdb->hash_size)
                goto corrupt;
 
        if (hdr.recovery_start != 0 &&
-           hdr.recovery_start < TDB_DATA_START(tdb->header.hash_size))
+           hdr.recovery_start < TDB_DATA_START(tdb->hash_size))
                goto corrupt;
 
        *recovery = hdr.recovery_start;
@@ -74,7 +74,7 @@ static bool tdb_check_record(struct tdb_context *tdb,
        tdb_off_t tailer;
 
        /* Check rec->next: 0 or points to record offset, aligned. */
-       if (rec->next > 0 && rec->next < TDB_DATA_START(tdb->header.hash_size)){
+       if (rec->next > 0 && rec->next < TDB_DATA_START(tdb->hash_size)){
                TDB_LOG((tdb, TDB_DEBUG_ERROR,
                         "Record offset %d too small next %d\n",
                         off, rec->next));
@@ -352,7 +352,7 @@ _PUBLIC_ int tdb_check(struct tdb_context *tdb,
                goto unlock;
 
        /* We should have the whole header, too. */
-       if (tdb->map_size < TDB_DATA_START(tdb->header.hash_size)) {
+       if (tdb->map_size < TDB_DATA_START(tdb->hash_size)) {
                tdb->ecode = TDB_ERR_CORRUPT;
                TDB_LOG((tdb, TDB_DEBUG_ERROR, "File too short for hashes\n"));
                goto unlock;
@@ -360,20 +360,20 @@ _PUBLIC_ int tdb_check(struct tdb_context *tdb,
 
        /* One big malloc: pointers then bit arrays. */
        hashes = (unsigned char **)calloc(
-                       1, sizeof(hashes[0]) * (1+tdb->header.hash_size)
-                       + BITMAP_BITS / CHAR_BIT * (1+tdb->header.hash_size));
+                       1, sizeof(hashes[0]) * (1+tdb->hash_size)
+                       + BITMAP_BITS / CHAR_BIT * (1+tdb->hash_size));
        if (!hashes) {
                tdb->ecode = TDB_ERR_OOM;
                goto unlock;
        }
 
        /* Initialize pointers */
-       hashes[0] = (unsigned char *)(&hashes[1+tdb->header.hash_size]);
-       for (h = 1; h < 1+tdb->header.hash_size; h++)
+       hashes[0] = (unsigned char *)(&hashes[1+tdb->hash_size]);
+       for (h = 1; h < 1+tdb->hash_size; h++)
                hashes[h] = hashes[h-1] + BITMAP_BITS / CHAR_BIT;
 
        /* Freelist and hash headers are all in a row: read them. */
-       for (h = 0; h < 1+tdb->header.hash_size; h++) {
+       for (h = 0; h < 1+tdb->hash_size; h++) {
                if (tdb_ofs_read(tdb, FREELIST_TOP + h*sizeof(tdb_off_t),
                                 &off) == -1)
                        goto free;
@@ -382,7 +382,7 @@ _PUBLIC_ int tdb_check(struct tdb_context *tdb,
        }
 
        /* For each record, read it in and check it's ok. */
-       for (off = TDB_DATA_START(tdb->header.hash_size);
+       for (off = TDB_DATA_START(tdb->hash_size);
             off < tdb->map_size;
             off += sizeof(rec) + rec.rec_len) {
                if (tdb->methods->tdb_read(tdb, off, &rec, sizeof(rec),
@@ -436,7 +436,7 @@ _PUBLIC_ int tdb_check(struct tdb_context *tdb,
 
        /* Now, hashes should all be empty: each record exists and is referred
         * to by one other. */
-       for (h = 0; h < 1+tdb->header.hash_size; h++) {
+       for (h = 0; h < 1+tdb->hash_size; h++) {
                unsigned int i;
                for (i = 0; i < BITMAP_BITS / CHAR_BIT; i++) {
                        if (hashes[h][i] != 0) {
diff --git a/lib/tdb/common/dump.c b/lib/tdb/common/dump.c
index 207bb24..f4682fa 100644
--- a/lib/tdb/common/dump.c
+++ b/lib/tdb/common/dump.c
@@ -83,7 +83,7 @@ static int tdb_dump_chain(struct tdb_context *tdb, int i)
 _PUBLIC_ void tdb_dump_all(struct tdb_context *tdb)
 {
        int i;
-       for (i=0;i<tdb->header.hash_size;i++) {
+       for (i=0;i<tdb->hash_size;i++) {
                tdb_dump_chain(tdb, i);
        }
        printf("freelist:\n");
diff --git a/lib/tdb/common/freelist.c b/lib/tdb/common/freelist.c
index 0de1fb4..2c58c69 100644
--- a/lib/tdb/common/freelist.c
+++ b/lib/tdb/common/freelist.c
@@ -139,7 +139,7 @@ left:
 #endif
 
        /* Look left */
-       if (offset - sizeof(tdb_off_t) > TDB_DATA_START(tdb->header.hash_size)) 
{
+       if (offset - sizeof(tdb_off_t) > TDB_DATA_START(tdb->hash_size)) {
                tdb_off_t left = offset - sizeof(tdb_off_t);
                struct tdb_record l;
                tdb_off_t leftsize;
@@ -158,7 +158,7 @@ left:
                left = offset - leftsize;
 
                if (leftsize > offset ||
-                   left < TDB_DATA_START(tdb->header.hash_size)) {
+                   left < TDB_DATA_START(tdb->hash_size)) {
                        goto update;
                }
 
diff --git a/lib/tdb/common/freelistcheck.c b/lib/tdb/common/freelistcheck.c
index ab6e78f..3be7cfd 100644
--- a/lib/tdb/common/freelistcheck.c
+++ b/lib/tdb/common/freelistcheck.c
@@ -52,7 +52,7 @@ _PUBLIC_ int tdb_validate_freelist(struct tdb_context *tdb, 
int *pnum_entries)
 
        *pnum_entries = 0;
 
-       mem_tdb = tdb_open("flval", tdb->header.hash_size,
+       mem_tdb = tdb_open("flval", tdb->hash_size,
                                TDB_INTERNAL, O_RDWR, 0600);
        if (!mem_tdb) {
                return -1;
diff --git a/lib/tdb/common/io.c b/lib/tdb/common/io.c
index 2e0a206..0563635 100644
--- a/lib/tdb/common/io.c
+++ b/lib/tdb/common/io.c
@@ -204,14 +204,14 @@ static void tdb_next_hash_chain(struct tdb_context *tdb, 
uint32_t *chain)
 {
        uint32_t h = *chain;
        if (tdb->map_ptr) {
-               for (;h < tdb->header.hash_size;h++) {
+               for (;h < tdb->hash_size;h++) {
                        if (0 != *(uint32_t *)(TDB_HASH_TOP(h) + (unsigned char 
*)tdb->map_ptr)) {
                                break;
                        }
                }
        } else {
                uint32_t off=0;
-               for (;h < tdb->header.hash_size;h++) {
+               for (;h < tdb->hash_size;h++) {
                        if (tdb_ofs_read(tdb, TDB_HASH_TOP(h), &off) != 0 || 
off != 0) {
                                break;
                        }
diff --git a/lib/tdb/common/lock.c b/lib/tdb/common/lock.c
index b530c6e..dadc69e 100644
--- a/lib/tdb/common/lock.c
+++ b/lib/tdb/common/lock.c
@@ -259,7 +259,7 @@ int tdb_nest_lock(struct tdb_context *tdb, uint32_t offset, 
int ltype,
 {
        struct tdb_lock_type *new_lck;
 
-       if (offset >= lock_offset(tdb->header.hash_size)) {
+       if (offset >= lock_offset(tdb->hash_size)) {
                tdb->ecode = TDB_ERR_LOCK;
                TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_lock: invalid offset %u for 
ltype=%d\n",
                         offset, ltype));
@@ -422,8 +422,8 @@ int tdb_nest_unlock(struct tdb_context *tdb, uint32_t 
offset, int ltype,
                return 0;
 
        /* Sanity checks */
-       if (offset >= lock_offset(tdb->header.hash_size)) {
-               TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlock: offset %u invalid 
(%d)\n", offset, tdb->header.hash_size));
+       if (offset >= lock_offset(tdb->hash_size)) {
+               TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlock: offset %u invalid 
(%d)\n", offset, tdb->hash_size));
                return ret;
        }
 
@@ -588,15 +588,15 @@ int tdb_allrecord_lock(struct tdb_context *tdb, int ltype,
         * It is (1) which cause the starvation problem, so we're only
         * gradual for that. */
        if (tdb_chainlock_gradual(tdb, ltype, flags, FREELIST_TOP,
-                                 tdb->header.hash_size * 4) == -1) {
+                                 tdb->hash_size * 4) == -1) {
                return -1;
        }
 
        /* Grab individual record locks. */
-       if (tdb_brlock(tdb, ltype, lock_offset(tdb->header.hash_size), 0,
+       if (tdb_brlock(tdb, ltype, lock_offset(tdb->hash_size), 0,
                       flags) == -1) {
                tdb_brunlock(tdb, ltype, FREELIST_TOP,
-                            tdb->header.hash_size * 4);
+                            tdb->hash_size * 4);
                return -1;
        }
 
diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c
index b10f5eb..08b9450 100644
--- a/lib/tdb/common/open.c
+++ b/lib/tdb/common/open.c
@@ -51,7 +51,8 @@ void tdb_header_hash(struct tdb_context *tdb,
 }
 
 /* initialise a new database with a specified hash size */
-static int tdb_new_database(struct tdb_context *tdb, int hash_size)
+static int tdb_new_database(struct tdb_context *tdb, struct tdb_header *header,
+                           int hash_size)
 {
        struct tdb_header *newdb;
        size_t size;
@@ -78,7 +79,7 @@ static int tdb_new_database(struct tdb_context *tdb, int 
hash_size)
        if (tdb->flags & TDB_INTERNAL) {
                tdb->map_size = size;
                tdb->map_ptr = (char *)newdb;
-               memcpy(&tdb->header, newdb, sizeof(tdb->header));
+               memcpy(header, newdb, sizeof(*header));
                /* Convert the `ondisk' version if asked. */
                CONVERT(*newdb);
                return 0;
@@ -91,7 +92,7 @@ static int tdb_new_database(struct tdb_context *tdb, int 
hash_size)
 
        /* This creates an endian-converted header, as if read from disk */
        CONVERT(*newdb);
-       memcpy(&tdb->header, newdb, sizeof(tdb->header));
+       memcpy(header, newdb, sizeof(*header));
        /* Don't endian-convert the magic food! */
        memcpy(newdb->magic_food, TDB_MAGIC_FOOD, strlen(TDB_MAGIC_FOOD)+1);
 
@@ -143,11 +144,12 @@ static void null_log_fn(struct tdb_context *tdb, enum 
tdb_debug_level level, con
 }
 
 static bool check_header_hash(struct tdb_context *tdb,
+                             struct tdb_header *header,
                              bool default_hash, uint32_t *m1, uint32_t *m2)
 {
        tdb_header_hash(tdb, m1, m2);
-       if (tdb->header.magic1_hash == *m1 &&
-           tdb->header.magic2_hash == *m2) {
+       if (header->magic1_hash == *m1 &&
+           header->magic2_hash == *m2) {
                return true;
        }
 
@@ -160,7 +162,7 @@ static bool check_header_hash(struct tdb_context *tdb,
                tdb->hash_fn = tdb_jenkins_hash;
        else
                tdb->hash_fn = tdb_old_hash;
-       return check_header_hash(tdb, false, m1, m2);
+       return check_header_hash(tdb, header, false, m1, m2);
 }
 
 _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int 
tdb_flags,
@@ -168,6 +170,7 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, 
int hash_size, int td
                                const struct tdb_logging_context *log_ctx,
                                tdb_hash_func hash_fn)
 {
+       struct tdb_header header;
        struct tdb_context *tdb;
        struct stat st;
        int rev = 0, locked = 0;
@@ -177,6 +180,8 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, 
int hash_size, int td
        const char *hash_alg;
        uint32_t magic1, magic2;
 
+       ZERO_STRUCT(header);
+
        if (!(tdb = (struct tdb_context *)calloc(1, sizeof *tdb))) {
                /* Can't log this */
                errno = ENOMEM;
@@ -286,10 +291,11 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char 
*name, int hash_size, int td
        if (tdb->flags & TDB_INTERNAL) {
                tdb->flags |= (TDB_NOLOCK | TDB_NOMMAP);
                tdb->flags &= ~TDB_CLEAR_IF_FIRST;
-               if (tdb_new_database(tdb, hash_size) != 0) {
+               if (tdb_new_database(tdb, &header, hash_size) != 0) {
                        TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: 
tdb_new_database failed!"));
                        goto fail;
                }
+               tdb->hash_size = hash_size;
                goto internal;
        }
 
@@ -323,7 +329,7 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, 
int hash_size, int td
                                 name, strerror(errno)));
                        goto fail;
                }
-               ret = tdb_new_database(tdb, hash_size);
+               ret = tdb_new_database(tdb, &header, hash_size);
                if (ret == -1) {
                        TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: "
                                 "tdb_new_database failed for %s: %s\n",
@@ -348,22 +354,23 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char 
*name, int hash_size, int td
        }
 
        errno = 0;
-       if (read(tdb->fd, &tdb->header, sizeof(tdb->header)) != 
sizeof(tdb->header)
-           || strcmp(tdb->header.magic_food, TDB_MAGIC_FOOD) != 0) {
-               if (!(open_flags & O_CREAT) || tdb_new_database(tdb, hash_size) 
== -1) {
+       if (read(tdb->fd, &header, sizeof(header)) != sizeof(header)
+           || strcmp(header.magic_food, TDB_MAGIC_FOOD) != 0) {
+               if (!(open_flags & O_CREAT) ||
+                   tdb_new_database(tdb, &header, hash_size) == -1) {
                        if (errno == 0) {
                                errno = EIO; /* ie bad format or something */
                        }
                        goto fail;
                }
                rev = (tdb->flags & TDB_CONVERT);
-       } else if (tdb->header.version != TDB_VERSION
-                  && !(rev = (tdb->header.version==TDB_BYTEREV(TDB_VERSION)))) 
{
+       } else if (header.version != TDB_VERSION
+                  && !(rev = (header.version==TDB_BYTEREV(TDB_VERSION)))) {
                /* wrong version */
                errno = EIO;
                goto fail;
        }
-       vp = (unsigned char *)&tdb->header.version;
+       vp = (unsigned char *)&header.version;
        vertest = (((uint32_t)vp[0]) << 24) | (((uint32_t)vp[1]) << 16) |
                  (((uint32_t)vp[2]) << 8) | (uint32_t)vp[3];
        tdb->flags |= (vertest==TDB_VERSION) ? TDB_BIGENDIAN : 0;
@@ -371,31 +378,33 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char 
*name, int hash_size, int td
                tdb->flags &= ~TDB_CONVERT;
        else {
                tdb->flags |= TDB_CONVERT;
-               tdb_convert(&tdb->header, sizeof(tdb->header));
+               tdb_convert(&header, sizeof(header));
        }
        if (fstat(tdb->fd, &st) == -1)
                goto fail;
 
-       if (tdb->header.rwlocks != 0 &&
-           tdb->header.rwlocks != TDB_HASH_RWLOCK_MAGIC) {
+       if (header.rwlocks != 0 &&
+           header.rwlocks != TDB_HASH_RWLOCK_MAGIC) {
                TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: spinlocks no 
longer supported\n"));
                goto fail;
        }
+       tdb->hash_size = header.hash_size;
 
-       if ((tdb->header.magic1_hash == 0) && (tdb->header.magic2_hash == 0)) {
+       if ((header.magic1_hash == 0) && (header.magic2_hash == 0)) {
                /* older TDB without magic hash references */
                tdb->hash_fn = tdb_old_hash;
-       } else if (!check_header_hash(tdb, !hash_fn, &magic1, &magic2)) {
+       } else if (!check_header_hash(tdb, &header, !hash_fn,
+                                     &magic1, &magic2)) {
                TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: "
                         "%s was not created with %s hash function we are 
using\n"
                         "magic1_hash[0x%08X %s 0x%08X] "
                         "magic2_hash[0x%08X %s 0x%08X]\n",
                         name, hash_alg,
-                        tdb->header.magic1_hash,
-                        (tdb->header.magic1_hash == magic1) ? "==" : "!=",
+                        header.magic1_hash,
+                        (header.magic1_hash == magic1) ? "==" : "!=",
                         magic1,
-                        tdb->header.magic2_hash,
-                        (tdb->header.magic2_hash == magic2) ? "==" : "!=",
+                        header.magic2_hash,
+                        (header.magic2_hash == magic2) ? "==" : "!=",
                         magic2));
                errno = EINVAL;
                goto fail;
diff --git a/lib/tdb/common/rescue.c b/lib/tdb/common/rescue.c
index 03ae8d6..17e7ed8 100644
--- a/lib/tdb/common/rescue.c
+++ b/lib/tdb/common/rescue.c
@@ -57,7 +57,7 @@ static bool looks_like_valid_record(struct tdb_context *tdb,
                return false;
 
        /* Next pointer must make some sense. */
-       if (rec->next > 0 && rec->next < TDB_DATA_START(tdb->header.hash_size))
+       if (rec->next > 0 && rec->next < TDB_DATA_START(tdb->hash_size))
                return false;
 
        if (tdb->methods->tdb_oob(tdb, rec->next, sizeof(*rec), 1))
@@ -234,7 +234,7 @@ _PUBLIC_ int tdb_rescue(struct tdb_context *tdb,
        tdb->log.log_fn = logging_suppressed;
 
        /* Now walk entire db looking for records. */
-       for (off = TDB_DATA_START(tdb->header.hash_size);
+       for (off = TDB_DATA_START(tdb->hash_size);
             off < tdb->map_size;
             off += TDB_ALIGNMENT) {
                if (tdb->methods->tdb_read(tdb, off, &rec, sizeof(rec),
@@ -249,7 +249,7 @@ _PUBLIC_ int tdb_rescue(struct tdb_context *tdb,
        }
 
        /* Walk hash chains to positive vet. */
-       for (h = 0; h < 1+tdb->header.hash_size; h++) {
+       for (h = 0; h < 1+tdb->hash_size; h++) {
                bool slow_chase = false;
                tdb_off_t slow_off = FREELIST_TOP + h*sizeof(tdb_off_t);
 
diff --git a/lib/tdb/common/summary.c b/lib/tdb/common/summary.c
index 8257261..f4e6d2c 100644
--- a/lib/tdb/common/summary.c
+++ b/lib/tdb/common/summary.c
@@ -116,7 +116,7 @@ _PUBLIC_ char *tdb_summary(struct tdb_context *tdb)
        tally_init(&hash);
        tally_init(&uncoal);
 
-       for (off = TDB_DATA_START(tdb->header.hash_size);
+       for (off = TDB_DATA_START(tdb->hash_size);
             off < tdb->map_size - 1;
             off += sizeof(rec) + rec.rec_len) {
                if (tdb->methods->tdb_read(tdb, off, &rec, sizeof(rec),
@@ -159,7 +159,7 @@ _PUBLIC_ char *tdb_summary(struct tdb_context *tdb)
        if (unc > 1)
                tally_add(&uncoal, unc - 1);
 
-       for (off = 0; off < tdb->header.hash_size; off++)
+       for (off = 0; off < tdb->hash_size; off++)
                tally_add(&hash, get_hash_length(tdb, off));
 
        /* 20 is max length of a %zu. */
@@ -190,7 +190,7 @@ _PUBLIC_ char *tdb_summary(struct tdb_context *tdb)
                 (keys.num + freet.num + dead.num)
                 * (sizeof(struct tdb_record) + sizeof(uint32_t))
                 * 100.0 / tdb->map_size,
-                tdb->header.hash_size * sizeof(tdb_off_t)
+                tdb->hash_size * sizeof(tdb_off_t)
                 * 100.0 / tdb->map_size);
 
 unlock:
diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c
index 7d1a40e..a2ae187 100644
--- a/lib/tdb/common/tdb.c
+++ b/lib/tdb/common/tdb.c
@@ -713,7 +713,7 @@ _PUBLIC_ int tdb_get_seqnum(struct tdb_context *tdb)
 
 _PUBLIC_ int tdb_hash_size(struct tdb_context *tdb)
 {
-       return tdb->header.hash_size;
+       return tdb->hash_size;
 }
 
 _PUBLIC_ size_t tdb_map_size(struct tdb_context *tdb)
@@ -840,7 +840,7 @@ _PUBLIC_ int tdb_wipe_all(struct tdb_context *tdb)
        }
 
        /* wipe the hashes */
-       for (i=0;i<tdb->header.hash_size;i++) {
+       for (i=0;i<tdb->hash_size;i++) {
                if (tdb_ofs_write(tdb, TDB_HASH_TOP(i), &offset) == -1) {
                        TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to 
write hash %d\n", i));
                        goto failed;
@@ -857,8 +857,8 @@ _PUBLIC_ int tdb_wipe_all(struct tdb_context *tdb)
           for the recovery area */
        if (recovery_size == 0) {
                /* the simple case - the whole file can be used as a freelist */
-               data_len = (tdb->map_size - 
TDB_DATA_START(tdb->header.hash_size));
-               if (tdb_free_region(tdb, TDB_DATA_START(tdb->header.hash_size), 
data_len) != 0) {
+               data_len = (tdb->map_size - TDB_DATA_START(tdb->hash_size));
+               if (tdb_free_region(tdb, TDB_DATA_START(tdb->hash_size), 
data_len) != 0) {
                        goto failed;
                }
        } else {
@@ -870,8 +870,8 @@ _PUBLIC_ int tdb_wipe_all(struct tdb_context *tdb)
                   move the recovery area or we risk subtle data
                   corruption
                */
-               data_len = (recovery_head - 
TDB_DATA_START(tdb->header.hash_size));
-               if (tdb_free_region(tdb, TDB_DATA_START(tdb->header.hash_size), 
data_len) != 0) {
+               data_len = (recovery_head - TDB_DATA_START(tdb->hash_size));
+               if (tdb_free_region(tdb, TDB_DATA_START(tdb->hash_size), 
data_len) != 0) {
                        goto failed;
                }
                /* and the 2nd free list entry after the recovery area - if any 
*/
diff --git a/lib/tdb/common/tdb_private.h b/lib/tdb/common/tdb_private.h
index bbe8977..406fc5f 100644
--- a/lib/tdb/common/tdb_private.h
+++ b/lib/tdb/common/tdb_private.h
@@ -61,7 +61,7 @@ typedef uint32_t tdb_off_t;
 #define TDB_DEAD(r) ((r)->magic == TDB_DEAD_MAGIC)
 #define TDB_BAD_MAGIC(r) ((r)->magic != TDB_MAGIC && !TDB_DEAD(r))
 #define TDB_HASH_TOP(hash) (FREELIST_TOP + (BUCKET(hash)+1)*sizeof(tdb_off_t))
-#define TDB_HASHTABLE_SIZE(tdb) ((tdb->header.hash_size+1)*sizeof(tdb_off_t))
+#define TDB_HASHTABLE_SIZE(tdb) ((tdb->hash_size+1)*sizeof(tdb_off_t))
 #define TDB_DATA_START(hash_size) (TDB_HASH_TOP(hash_size-1) + 
sizeof(tdb_off_t))
 #define TDB_RECOVERY_HEAD offsetof(struct tdb_header, recovery_start)
 #define TDB_SEQNUM_OFS    offsetof(struct tdb_header, sequence_number)
@@ -114,7 +114,7 @@ void tdb_trace_2rec_retrec(struct tdb_context *tdb, const 
char *op,
 #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
 #endif
 
-#define BUCKET(hash) ((hash) % tdb->header.hash_size)
+#define BUCKET(hash) ((hash) % tdb->hash_size)
 
 #define DOCONV() (tdb->flags & TDB_CONVERT)
 #define CONVERT(x) (DOCONV() ? tdb_convert(&x, sizeof(x)) : &x)
@@ -198,7 +198,7 @@ struct tdb_context {
        int num_lockrecs;
        struct tdb_lock_type *lockrecs; /* only real locks, all with count>0 */
        enum TDB_ERROR ecode; /* error code for last tdb error */
-       struct tdb_header header; /* a cached copy of the header */
+       uint32_t hash_size;
        uint32_t flags; /* the flags passed to tdb_open */
        struct tdb_traverse_lock travlocks; /* current traversal locks */
        struct tdb_context *next; /* all tdbs to avoid multiple opens */
diff --git a/lib/tdb/common/transaction.c b/lib/tdb/common/transaction.c
index ee9beeb..42289fd 100644
--- a/lib/tdb/common/transaction.c


-- 
Samba Shared Repository

Reply via email to