The branch, master has been updated
       via  c891df4 lib ldb key value: convert TDB_DATA structs to ldb_val
       via  f2d5c2c lib ldb: rename LTDB_* constants to LDB_KV_*
       via  19be0be lib ldb: move key value code to lib/ldb/ldb_key_value
       via  67c0554 lib ldb: rename ltdb_parse_data_unpack_ctx
       via  9191d3b lib ldb: remove unused function prototypes
       via  d3bfd37 lib ldb: rename ltdb_idxptr to ldb_kv_idxptr
       via  f6d5cf5 lib ldb: rename tdb_key_ctx to key_ctx
       via  72724f7 lib ldb: rename ltdb_cache to ldb_kv_cache
       via  b8c9c30 lib ldb: format rename ldb_kv_private
       via  e0186d1 lib ldb: rename ltdb_private to ldb_kv_private
       via  641b38e4 lib ldb: format rename of ltdb_req_spy
       via  17a84d12 lib ldb: rename ltdb_req_spy to ldb_kv_req_spy
       via  c782d71 lib ldb: rename ltdb_context to ldb_kv_context
       via  e969de0 lib ldb: reformat ltdb_reindex_context rename
       via  e8aa764 lib ldb: rename struct ltdb_reindex_context
       via  9e62946 lib ldb: fix formatting of ldb_kv rename.
       via  1c8ea09 lib ldb: Rename functions to ldb_kv
      from  4fcbaae ctdb-doc: Provide an example script for migrating old 
configuration

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


- Log -----------------------------------------------------------------
commit c891df421813781b32081b566600076562525261
Author: Gary Lockyer <[email protected]>
Date:   Mon Jul 23 13:20:46 2018 +1200

    lib ldb key value: convert TDB_DATA structs to ldb_val
    
    Convert the key value functions to use ldb_val instead of TDB_DATA.
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>
    
    Autobuild-User(master): Andrew Bartlett <[email protected]>
    Autobuild-Date(master): Mon Jul 30 17:23:22 CEST 2018 on sn-devel-144

commit f2d5c2c5cc52788a60fb2c390f681ea4cc767e58
Author: Gary Lockyer <[email protected]>
Date:   Mon Jul 23 10:08:26 2018 +1200

    lib ldb: rename LTDB_* constants to LDB_KV_*
    
    Rename all the LTDB_* constants to LDB_KV_* as they are key value level
    constants and not tdb specific.
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit 19be0be232c25250e79dc313fd43829de049b491
Author: Gary Lockyer <[email protected]>
Date:   Mon Jul 23 10:02:16 2018 +1200

    lib ldb: move key value code to lib/ldb/ldb_key_value
    
    Move the key value code to a separate subdirectory.
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit 67c055406c7ad6b92c89337acd72a751962e99f0
Author: Gary Lockyer <[email protected]>
Date:   Fri Jul 20 13:50:00 2018 +1200

    lib ldb: rename ltdb_parse_data_unpack_ctx
    
    Rename ltdb_parse_data_unpack_ctx to ldb_kv_parse_data_unpack_ctx, as
    it's a key value level structure and not ltdb specific.
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit 9191d3baf513f9cd2d15206f1378c24a5e7de2e3
Author: Gary Lockyer <[email protected]>
Date:   Fri Jul 20 13:47:16 2018 +1200

    lib ldb: remove unused function prototypes
    
    Remove unused function prototypes
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit d3bfd374a65b93f5a7d9f3bf3c356871a5879a12
Author: Gary Lockyer <[email protected]>
Date:   Fri Jul 20 13:40:02 2018 +1200

    lib ldb: rename ltdb_idxptr to ldb_kv_idxptr
    
    Rename ltdb_idxptr to ldb_kv_idxptr as it's key value level and not tdb
    specific.
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit f6d5cf5eb11533ac1e3388dbb21c7f0757fff969
Author: Gary Lockyer <[email protected]>
Date:   Fri Jul 20 13:36:07 2018 +1200

    lib ldb: rename tdb_key_ctx to key_ctx
    
    Rename tdb_key_ctx to key_ctx, as it's key value level and not tdb
    specific.
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit 72724f75ce97a1bf0b106bdf2e30cfb1729af765
Author: Gary Lockyer <[email protected]>
Date:   Fri Jul 20 13:31:27 2018 +1200

    lib ldb: rename ltdb_cache to ldb_kv_cache
    
    Rename ltdb_cache to ldb_kv_cache as it's key value level and not tdb
    specific
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit b8c9c305b3a1fa5103fb8af63768f8abf681106c
Author: Gary Lockyer <[email protected]>
Date:   Fri Jul 20 11:54:39 2018 +1200

    lib ldb: format rename ldb_kv_private
    
    Tidy up the code format after the rename of ltdb_private to
    ldb_kv_private
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit e0186d1f2da7d946ee140e6bb54b1d62766b43aa
Author: Gary Lockyer <[email protected]>
Date:   Fri Jul 20 11:53:21 2018 +1200

    lib ldb: rename ltdb_private to ldb_kv_private
    
    Rename ltdb_private to ldb_kv_private as it contains key value operation
    context.
    
    Note there is still some tdb specific context that can be refactored into a
    separate structure along the lines of the lmdb context.
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit 641b38e458b1f9ce848f76e2f226d42e7507a529
Author: Gary Lockyer <[email protected]>
Date:   Fri Jul 20 09:15:24 2018 +1200

    lib ldb: format rename of ltdb_req_spy
    
    Fix up the code formatting after the rename of ltdb_req_spy to
    ldb_kv_req_spy
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit 17a84d12e2cef7a42c94d0df404f1ec4854fb65c
Author: Gary Lockyer <[email protected]>
Date:   Fri Jul 20 09:14:52 2018 +1200

    lib ldb: rename ltdb_req_spy to ldb_kv_req_spy
    
    Rename ltdb_req_spy to ldb_kv_req_spy, as it is key value level and not
    tdb specific.
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit c782d710e97ffaed8fef18524b468e801be053d3
Author: Gary Lockyer <[email protected]>
Date:   Fri Jul 20 09:07:47 2018 +1200

    lib ldb: rename ltdb_context to ldb_kv_context
    
    Rename ltdb_context to ldb_kv_context as it is a key value level
    structure and not tdb specific.
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit e969de0797bed4a3663f0b638ac49b3b6ef2952f
Author: Gary Lockyer <[email protected]>
Date:   Fri Jul 20 08:53:28 2018 +1200

    lib ldb: reformat ltdb_reindex_context rename
    
    Fix up the formatting after the rename of ltdb_reindex_context to
    ldb_kv_reindex_context.
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit e8aa764ea7dffbb499882f6bdf986322cd17c20d
Author: Gary Lockyer <[email protected]>
Date:   Fri Jul 20 08:52:48 2018 +1200

    lib ldb: rename struct ltdb_reindex_context
    
    Rename struct ltdb_reindex_context to ldb_kv_reindex_context, as this is
    a key value level structure and not a tdb specific structure.
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit 9e6294668aa58408863bc6bb2c2510608bf916f3
Author: Gary Lockyer <[email protected]>
Date:   Fri Jul 20 07:25:32 2018 +1200

    lib ldb: fix formatting of ldb_kv rename.
    
    Clean up the code format after the rename in the previous commit.
    Hopefully doing a rename commit followed by a reformat commit makes the
    code easier to review.
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit 1c8ea099ce57ae35879e9a1cebcfd2de5c89bfdf
Author: Gary Lockyer <[email protected]>
Date:   Fri Jul 20 07:23:10 2018 +1200

    lib ldb: Rename functions to ldb_kv
    
    Rename the ldb key value functions from ltdb_* to ldb_kv_*. The renaming
    is preparation for the separation of the tdb specific code from the key
    value code.  This work is a follow on from the addition of the lmdb
    backend.
    
    Note that the next commit tidies up the code formatting.
    
    Signed-off-by: Gary Lockyer <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

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

Summary of changes:
 .../{ldb_tdb/ldb_tdb.c => ldb_key_value/ldb_kv.c}  | 1233 ++++-------
 lib/ldb/ldb_key_value/ldb_kv.h                     |  265 +++
 .../ldb_cache.c => ldb_key_value/ldb_kv_cache.c}   |  278 +--
 .../ldb_index.c => ldb_key_value/ldb_kv_index.c}   |  998 ++++-----
 .../ldb_search.c => ldb_key_value/ldb_kv_search.c} |  194 +-
 lib/ldb/ldb_mdb/ldb_mdb.c                          |  120 +-
 lib/ldb/ldb_tdb/ldb_tdb.c                          | 2306 ++------------------
 lib/ldb/ldb_tdb/ldb_tdb.h                          |  232 --
 .../ldb_tdb/{ldb_tdb_init.c => ldb_tdb_err_map.c}  |   33 +-
 lib/ldb/tests/ldb_kv_ops_test.c                    |  254 +--
 lib/ldb/tests/ldb_lmdb_test.c                      |    9 +-
 lib/ldb/tests/ldb_tdb_test.c                       |    9 +-
 lib/ldb/wscript                                    |   24 +-
 13 files changed, 1858 insertions(+), 4097 deletions(-)
 copy lib/ldb/{ldb_tdb/ldb_tdb.c => ldb_key_value/ldb_kv.c} (55%)
 create mode 100644 lib/ldb/ldb_key_value/ldb_kv.h
 rename lib/ldb/{ldb_tdb/ldb_cache.c => ldb_key_value/ldb_kv_cache.c} (63%)
 rename lib/ldb/{ldb_tdb/ldb_index.c => ldb_key_value/ldb_kv_index.c} (73%)
 rename lib/ldb/{ldb_tdb/ldb_search.c => ldb_key_value/ldb_kv_search.c} (82%)
 copy lib/ldb/ldb_tdb/{ldb_tdb_init.c => ldb_tdb_err_map.c} (69%)


Changeset truncated at 500 lines:

diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_key_value/ldb_kv.c
similarity index 55%
copy from lib/ldb/ldb_tdb/ldb_tdb.c
copy to lib/ldb/ldb_key_value/ldb_kv.c
index daf9a77..3ea8d5e 100644
--- a/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/lib/ldb/ldb_key_value/ldb_kv.c
@@ -25,11 +25,11 @@
 */
 
 /*
- *  Name: ldb_tdb
+ *  Name: ldb_kv
  *
- *  Component: ldb tdb backend
+ *  Component: ldb key value backend
  *
- *  Description: core functions for tdb backend
+ *  Description: core functions for ldb key value backend
  *
  *  Author: Andrew Tridgell
  *  Author: Stefan Metzmacher
@@ -49,158 +49,58 @@
  *    Author: Matthias Dieter Wallnöfer
  */
 
-#include "ldb_tdb.h"
+#include "ldb_kv.h"
 #include "ldb_private.h"
-#include <tdb.h>
 
 /*
   prevent memory errors on callbacks
 */
-struct ltdb_req_spy {
-       struct ltdb_context *ctx;
+struct ldb_kv_req_spy {
+       struct ldb_kv_context *ctx;
 };
 
 /*
-  map a tdb error code to a ldb error code
-*/
-int ltdb_err_map(enum TDB_ERROR tdb_code)
-{
-       switch (tdb_code) {
-       case TDB_SUCCESS:
-               return LDB_SUCCESS;
-       case TDB_ERR_CORRUPT:
-       case TDB_ERR_OOM:
-       case TDB_ERR_EINVAL:
-               return LDB_ERR_OPERATIONS_ERROR;
-       case TDB_ERR_IO:
-               return LDB_ERR_PROTOCOL_ERROR;
-       case TDB_ERR_LOCK:
-       case TDB_ERR_NOLOCK:
-               return LDB_ERR_BUSY;
-       case TDB_ERR_LOCK_TIMEOUT:
-               return LDB_ERR_TIME_LIMIT_EXCEEDED;
-       case TDB_ERR_EXISTS:
-               return LDB_ERR_ENTRY_ALREADY_EXISTS;
-       case TDB_ERR_NOEXIST:
-               return LDB_ERR_NO_SUCH_OBJECT;
-       case TDB_ERR_RDONLY:
-               return LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS;
-       default:
-               break;
-       }
-       return LDB_ERR_OTHER;
-}
-
-/*
-  lock the database for read - use by ltdb_search and ltdb_sequence_number
-*/
-static int ltdb_lock_read(struct ldb_module *module)
-{
-       void *data = ldb_module_get_private(module);
-       struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
-       int tdb_ret = 0;
-       int ret;
-       pid_t pid = getpid();
-
-       if (ltdb->pid != pid) {
-               ldb_asprintf_errstring(
-                       ldb_module_get_ctx(module),
-                       __location__": Reusing ldb opend by pid %d in "
-                       "process %d\n",
-                       ltdb->pid,
-                       pid);
-               return LDB_ERR_PROTOCOL_ERROR;
-       }
-
-       if (tdb_transaction_active(ltdb->tdb) == false &&
-           ltdb->read_lock_count == 0) {
-               tdb_ret = tdb_lockall_read(ltdb->tdb);
-       }
-       if (tdb_ret == 0) {
-               ltdb->read_lock_count++;
-               return LDB_SUCCESS;
-       }
-       ret = ltdb_err_map(tdb_error(ltdb->tdb));
-       if (ret == LDB_SUCCESS) {
-               ret = LDB_ERR_OPERATIONS_ERROR;
-       }
-       ldb_debug_set(ldb_module_get_ctx(module),
-                     LDB_DEBUG_FATAL,
-                     "Failure during ltdb_lock_read(): %s -> %s",
-                     tdb_errorstr(ltdb->tdb),
-                     ldb_strerror(ret));
-       return ret;
-}
-
-/*
-  unlock the database after a ltdb_lock_read()
-*/
-static int ltdb_unlock_read(struct ldb_module *module)
-{
-       void *data = ldb_module_get_private(module);
-       struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
-       pid_t pid = getpid();
-
-       if (ltdb->pid != pid) {
-               ldb_asprintf_errstring(
-                       ldb_module_get_ctx(module),
-                       __location__": Reusing ldb opend by pid %d in "
-                       "process %d\n",
-                       ltdb->pid,
-                       pid);
-               return LDB_ERR_PROTOCOL_ERROR;
-       }
-       if (!tdb_transaction_active(ltdb->tdb) && ltdb->read_lock_count == 1) {
-               tdb_unlockall_read(ltdb->tdb);
-               ltdb->read_lock_count--;
-               return 0;
-       }
-       ltdb->read_lock_count--;
-       return 0;
-}
-
-
-/* 
  * Determine if this key could hold a record.  We allow the new GUID
  * index, the old DN index and a possible future ID=
  */
-bool ltdb_key_is_record(TDB_DATA key)
+bool ldb_kv_key_is_record(struct ldb_val key)
 {
-       if (key.dsize < 4) {
+       if (key.length < 4) {
                return false;
        }
 
-       if (memcmp(key.dptr, "DN=", 3) == 0) {
+       if (memcmp(key.data, "DN=", 3) == 0) {
                return true;
        }
-       
-       if (memcmp(key.dptr, "ID=", 3) == 0) {
+
+       if (memcmp(key.data, "ID=", 3) == 0) {
                return true;
        }
 
-       if (key.dsize < sizeof(LTDB_GUID_KEY_PREFIX)) {
+       if (key.length < sizeof(LDB_KV_GUID_KEY_PREFIX)) {
                return false;
        }
 
-       if (memcmp(key.dptr, LTDB_GUID_KEY_PREFIX,
-                  sizeof(LTDB_GUID_KEY_PREFIX) - 1) == 0) {
+       if (memcmp(key.data, LDB_KV_GUID_KEY_PREFIX,
+                  sizeof(LDB_KV_GUID_KEY_PREFIX) - 1) == 0) {
                return true;
        }
-       
+
        return false;
 }
 
 /*
-  form a TDB_DATA for a record key
+  form a ldb_val for a record key
   caller frees
 
   note that the key for a record can depend on whether the
   dn refers to a case sensitive index record or not
 */
-TDB_DATA ltdb_key_dn(struct ldb_module *module, TALLOC_CTX *mem_ctx,
-                    struct ldb_dn *dn)
+struct ldb_val ldb_kv_key_dn(struct ldb_module *module,
+                            TALLOC_CTX *mem_ctx,
+                            struct ldb_dn *dn)
 {
-       TDB_DATA key;
+       struct ldb_val key;
        char *key_str = NULL;
        const char *dn_folded = NULL;
 
@@ -231,33 +131,33 @@ TDB_DATA ltdb_key_dn(struct ldb_module *module, 
TALLOC_CTX *mem_ctx,
                goto failed;
        }
 
-       key.dptr = (uint8_t *)key_str;
-       key.dsize = strlen(key_str) + 1;
+       key.data = (uint8_t *)key_str;
+       key.length = strlen(key_str) + 1;
 
        return key;
 
 failed:
        errno = ENOMEM;
-       key.dptr = NULL;
-       key.dsize = 0;
+       key.data = NULL;
+       key.length = 0;
        return key;
 }
 
 /* The caller is to provide a correctly sized key */
-int ltdb_guid_to_key(struct ldb_module *module,
-                    struct ltdb_private *ltdb,
-                    const struct ldb_val *GUID_val,
-                    TDB_DATA *key)
+int ldb_kv_guid_to_key(struct ldb_module *module,
+                      struct ldb_kv_private *ldb_kv,
+                      const struct ldb_val *GUID_val,
+                      struct ldb_val *key)
 {
-       const char *GUID_prefix = LTDB_GUID_KEY_PREFIX;
-       const int GUID_prefix_len = sizeof(LTDB_GUID_KEY_PREFIX) - 1;
+       const char *GUID_prefix = LDB_KV_GUID_KEY_PREFIX;
+       const int GUID_prefix_len = sizeof(LDB_KV_GUID_KEY_PREFIX) - 1;
 
-       if (key->dsize != (GUID_val->length+GUID_prefix_len)) {
+       if (key->length != (GUID_val->length+GUID_prefix_len)) {
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       memcpy(key->dptr, GUID_prefix, GUID_prefix_len);
-       memcpy(&key->dptr[GUID_prefix_len],
+       memcpy(key->data, GUID_prefix, GUID_prefix_len);
+       memcpy(&key->data[GUID_prefix_len],
               GUID_val->data, GUID_val->length);
        return LDB_SUCCESS;
 }
@@ -266,18 +166,17 @@ int ltdb_guid_to_key(struct ldb_module *module,
  * The caller is to provide a correctly sized key, used only in
  * the GUID index mode
  */
-int ltdb_idx_to_key(struct ldb_module *module,
-                   struct ltdb_private *ltdb,
-                   TALLOC_CTX *mem_ctx,
-                   const struct ldb_val *idx_val,
-                   TDB_DATA *key)
+int ldb_kv_idx_to_key(struct ldb_module *module,
+                     struct ldb_kv_private *ldb_kv,
+                     TALLOC_CTX *mem_ctx,
+                     const struct ldb_val *idx_val,
+                     struct ldb_val *key)
 {
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        struct ldb_dn *dn;
 
-       if (ltdb->cache->GUID_index_attribute != NULL) {
-               return ltdb_guid_to_key(module, ltdb,
-                                       idx_val, key);
+       if (ldb_kv->cache->GUID_index_attribute != NULL) {
+               return ldb_kv_guid_to_key(module, ldb_kv, idx_val, key);
        }
 
        dn = ldb_dn_from_ldb_val(mem_ctx, ldb, idx_val);
@@ -289,9 +188,9 @@ int ltdb_idx_to_key(struct ldb_module *module,
                return LDB_ERR_OPERATIONS_ERROR;
        }
        /* form the key */
-       *key = ltdb_key_dn(module, mem_ctx, dn);
+       *key = ldb_kv_key_dn(module, mem_ctx, dn);
        TALLOC_FREE(dn);
-       if (!key->dptr) {
+       if (!key->data) {
                return ldb_module_oom(module);
        }
        return LDB_SUCCESS;
@@ -305,54 +204,56 @@ int ltdb_idx_to_key(struct ldb_module *module,
   note that the key for a record can depend on whether a
   GUID index is in use, or the DN is used as the key
 */
-TDB_DATA ltdb_key_msg(struct ldb_module *module, TALLOC_CTX *mem_ctx,
-                     const struct ldb_message *msg)
+struct ldb_val ldb_kv_key_msg(struct ldb_module *module,
+                       TALLOC_CTX *mem_ctx,
+                       const struct ldb_message *msg)
 {
        void *data = ldb_module_get_private(module);
-       struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
-       TDB_DATA key;
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_val key;
        const struct ldb_val *guid_val;
        int ret;
 
-       if (ltdb->cache->GUID_index_attribute == NULL) {
-               return ltdb_key_dn(module, mem_ctx, msg->dn);
+       if (ldb_kv->cache->GUID_index_attribute == NULL) {
+               return ldb_kv_key_dn(module, mem_ctx, msg->dn);
        }
 
        if (ldb_dn_is_special(msg->dn)) {
-               return ltdb_key_dn(module, mem_ctx, msg->dn);
+               return ldb_kv_key_dn(module, mem_ctx, msg->dn);
        }
 
-       guid_val = ldb_msg_find_ldb_val(msg,
-                                      ltdb->cache->GUID_index_attribute);
+       guid_val =
+           ldb_msg_find_ldb_val(msg, ldb_kv->cache->GUID_index_attribute);
        if (guid_val == NULL) {
                ldb_asprintf_errstring(ldb_module_get_ctx(module),
                                       "Did not find GUID attribute %s "
                                       "in %s, required for TDB record "
-                                      "key in " LTDB_IDXGUID " mode.",
-                                      ltdb->cache->GUID_index_attribute,
+                                      "key in " LDB_KV_IDXGUID " mode.",
+                                      ldb_kv->cache->GUID_index_attribute,
                                       ldb_dn_get_linearized(msg->dn));
                errno = EINVAL;
-               key.dptr = NULL;
-               key.dsize = 0;
+               key.data = NULL;
+               key.length = 0;
                return key;
        }
 
        /* In this case, allocate with talloc */
-       key.dptr = talloc_size(mem_ctx, LTDB_GUID_KEY_SIZE);
-       if (key.dptr == NULL) {
+       key.data = talloc_size(mem_ctx, LDB_KV_GUID_KEY_SIZE);
+       if (key.data == NULL) {
                errno = ENOMEM;
-               key.dptr = NULL;
-               key.dsize = 0;
+               key.data = NULL;
+               key.length = 0;
                return key;
        }
-       key.dsize = talloc_get_size(key.dptr);
+       key.length = talloc_get_size(key.data);
 
-       ret = ltdb_guid_to_key(module, ltdb, guid_val, &key);
+       ret = ldb_kv_guid_to_key(module, ldb_kv, guid_val, &key);
 
        if (ret != LDB_SUCCESS) {
                errno = EINVAL;
-               key.dptr = NULL;
-               key.dsize = 0;
+               key.data = NULL;
+               key.length = 0;
                return key;
        }
        return key;
@@ -362,14 +263,14 @@ TDB_DATA ltdb_key_msg(struct ldb_module *module, 
TALLOC_CTX *mem_ctx,
   check special dn's have valid attributes
   currently only @ATTRIBUTES is checked
 */
-static int ltdb_check_special_dn(struct ldb_module *module,
-                                const struct ldb_message *msg)
+static int ldb_kv_check_special_dn(struct ldb_module *module,
+                                  const struct ldb_message *msg)
 {
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        unsigned int i, j;
 
        if (! ldb_dn_is_special(msg->dn) ||
-           ! ldb_dn_check_special(msg->dn, LTDB_ATTRIBUTES)) {
+           ! ldb_dn_check_special(msg->dn, LDB_KV_ATTRIBUTES)) {
                return LDB_SUCCESS;
        }
 
@@ -379,7 +280,8 @@ static int ltdb_check_special_dn(struct ldb_module *module,
                if (ldb_attr_cmp(msg->elements[i].name, "distinguishedName") == 
0) continue;
 
                for (j = 0; j < msg->elements[i].num_values; j++) {
-                       if 
(ltdb_check_at_attributes_values(&msg->elements[i].values[j]) != 0) {
+                       if (ldb_kv_check_at_attributes_values(
+                               &msg->elements[i].values[j]) != 0) {
                                ldb_set_errstring(ldb, "Invalid attribute value 
in an @ATTRIBUTES entry");
                                return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
                        }
@@ -394,136 +296,108 @@ static int ltdb_check_special_dn(struct ldb_module 
*module,
   we've made a modification to a dn - possibly reindex and
   update sequence number
 */
-static int ltdb_modified(struct ldb_module *module, struct ldb_dn *dn)
+static int ldb_kv_modified(struct ldb_module *module, struct ldb_dn *dn)
 {
        int ret = LDB_SUCCESS;
-       struct ltdb_private *ltdb = 
talloc_get_type(ldb_module_get_private(module), struct ltdb_private);
+       struct ldb_kv_private *ldb_kv = talloc_get_type(
+           ldb_module_get_private(module), struct ldb_kv_private);
 
        /* only allow modifies inside a transaction, otherwise the
         * ldb is unsafe */
-       if (ltdb->kv_ops->transaction_active(ltdb) == false) {
+       if (ldb_kv->kv_ops->transaction_active(ldb_kv) == false) {
                ldb_set_errstring(ldb_module_get_ctx(module), "ltdb modify 
without transaction");
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
        if (ldb_dn_is_special(dn) &&
-           (ldb_dn_check_special(dn, LTDB_INDEXLIST) ||
-            ldb_dn_check_special(dn, LTDB_ATTRIBUTES)) )
+           (ldb_dn_check_special(dn, LDB_KV_INDEXLIST) ||
+            ldb_dn_check_special(dn, LDB_KV_ATTRIBUTES)) )
        {
-               if (ltdb->warn_reindex) {
+               if (ldb_kv->warn_reindex) {
                        ldb_debug(ldb_module_get_ctx(module),
-                               LDB_DEBUG_ERROR, "Reindexing %s due to 
modification on %s",
-                               ltdb->kv_ops->name(ltdb), 
ldb_dn_get_linearized(dn));
+                                 LDB_DEBUG_ERROR,
+                                 "Reindexing %s due to modification on %s",
+                                 ldb_kv->kv_ops->name(ldb_kv),
+                                 ldb_dn_get_linearized(dn));
                }
-               ret = ltdb_reindex(module);
+               ret = ldb_kv_reindex(module);
        }
 
        /* If the modify was to a normal record, or any special except 
@BASEINFO, update the seq number */
        if (ret == LDB_SUCCESS &&
            !(ldb_dn_is_special(dn) &&
-             ldb_dn_check_special(dn, LTDB_BASEINFO)) ) {
-               ret = ltdb_increase_sequence_number(module);
+             ldb_dn_check_special(dn, LDB_KV_BASEINFO)) ) {
+               ret = ldb_kv_increase_sequence_number(module);
        }
 
        /* If the modify was to @OPTIONS, reload the cache */
        if (ret == LDB_SUCCESS &&
            ldb_dn_is_special(dn) &&
-           (ldb_dn_check_special(dn, LTDB_OPTIONS)) ) {
-               ret = ltdb_cache_reload(module);
+           (ldb_dn_check_special(dn, LDB_KV_OPTIONS)) ) {
+               ret = ldb_kv_cache_reload(module);
        }
 
        if (ret != LDB_SUCCESS) {
-               ltdb->reindex_failed = true;
+               ldb_kv->reindex_failed = true;
        }
 
        return ret;
 }
-
-static int ltdb_tdb_store(struct ltdb_private *ltdb, struct ldb_val ldb_key,
-                         struct ldb_val ldb_data, int flags)
-{
-       TDB_DATA key = {
-               .dptr = ldb_key.data,
-               .dsize = ldb_key.length
-       };
-       TDB_DATA data = {
-               .dptr = ldb_data.data,
-               .dsize = ldb_data.length
-       };
-       bool transaction_active = tdb_transaction_active(ltdb->tdb);
-       if (transaction_active == false){
-               return LDB_ERR_PROTOCOL_ERROR;
-       }
-       return tdb_store(ltdb->tdb, key, data, flags);
-}
-
-static int ltdb_error(struct ltdb_private *ltdb)
-{
-       return ltdb_err_map(tdb_error(ltdb->tdb));
-}
-
-static const char *ltdb_errorstr(struct ltdb_private *ltdb)
-{
-       return tdb_errorstr(ltdb->tdb);
-}
-
 /*
   store a record into the db
 */
-int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int 
flgs)
+int ldb_kv_store(struct ldb_module *module,
+                const struct ldb_message *msg,
+                int flgs)
 {
        void *data = ldb_module_get_private(module);
-       struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
-       TDB_DATA tdb_key;
-       struct ldb_val ldb_key;
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_val key;
        struct ldb_val ldb_data;
        int ret = LDB_SUCCESS;


-- 
Samba Shared Repository

Reply via email to