]> git.ozlabs.org Git - ccan/commitdiff
tdb2: Make tdb1 share tdb_store flags, struct tdb_data and TDB_MAGIC_FOOD.
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 31 Aug 2011 05:49:16 +0000 (15:19 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 31 Aug 2011 05:49:16 +0000 (15:19 +0930)
27 files changed:
ccan/tdb2/tdb1.h
ccan/tdb2/tdb1_check.c
ccan/tdb2/tdb1_hash.c
ccan/tdb2/tdb1_io.c
ccan/tdb2/tdb1_lock.c
ccan/tdb2/tdb1_open.c
ccan/tdb2/tdb1_private.h
ccan/tdb2/tdb1_tdb.c
ccan/tdb2/tdb1_transaction.c
ccan/tdb2/tdb1_traverse.c
ccan/tdb2/test/run-tdb1-3G-file.c
ccan/tdb2/test/run-tdb1-check.c
ccan/tdb2/test/run-tdb1-corrupt.c
ccan/tdb2/test/run-tdb1-die-during-transaction.c
ccan/tdb2/test/run-tdb1-endian.c
ccan/tdb2/test/run-tdb1-incompatible.c
ccan/tdb2/test/run-tdb1-nested-transactions.c
ccan/tdb2/test/run-tdb1-nested-traverse.c
ccan/tdb2/test/run-tdb1-no-lock-during-traverse.c
ccan/tdb2/test/run-tdb1-open-during-transaction.c
ccan/tdb2/test/run-tdb1-readonly-check.c
ccan/tdb2/test/run-tdb1-summary.c
ccan/tdb2/test/run-tdb1-traverse-in-transaction.c
ccan/tdb2/test/run-tdb1-wronghash-fail.c
ccan/tdb2/test/run-tdb1-zero-append.c
ccan/tdb2/test/run-tdb1.c
ccan/tdb2/test/tdb1-external-agent.c

index 8b3130ad2a788fbe79e0b14ea0215dd4b2988807..b2435ba53e3eff8a1f04a2c35220aaf4c54c9fa5 100644 (file)
 #include <sys/stat.h>
 #endif
 
 #include <sys/stat.h>
 #endif
 
-/** Flags to tdb1_store() */
-#define TDB1_REPLACE 1         /** Unused */
-#define TDB1_INSERT 2          /** Don't overwrite an existing entry */
-#define TDB1_MODIFY 3          /** Don't create an existing entry    */
 
 /** Flags for tdb1_open() */
 #define TDB1_DEFAULT 0 /** just a readability place holder */
 
 /** Flags for tdb1_open() */
 #define TDB1_DEFAULT 0 /** just a readability place holder */
 #define TDB1_DISALLOW_NESTING 1024 /** Disallow transactions to nest */
 #define TDB1_INCOMPATIBLE_HASH 2048 /** Better hashing: can't be opened by tdb < 1.2.6. */
 
 #define TDB1_DISALLOW_NESTING 1024 /** Disallow transactions to nest */
 #define TDB1_INCOMPATIBLE_HASH 2048 /** Better hashing: can't be opened by tdb < 1.2.6. */
 
-/** The tdb data structure */
-typedef struct TDB1_DATA {
-       unsigned char *dptr;
-       size_t dsize;
-} TDB1_DATA;
-
 /** This is the context structure that is returned from a db open. */
 typedef struct tdb1_context TDB1_CONTEXT;
 
 /** This is the context structure that is returned from a db open. */
 typedef struct tdb1_context TDB1_CONTEXT;
 
-typedef int (*tdb1_traverse_func)(struct tdb1_context *, TDB1_DATA, TDB1_DATA, void *);
+typedef int (*tdb1_traverse_func)(struct tdb1_context *, TDB_DATA, TDB_DATA, void *);
 typedef void (*tdb1_log_func)(struct tdb1_context *, enum tdb_log_level, enum TDB_ERROR,
                              const char *, void *);
 typedef void (*tdb1_log_func)(struct tdb1_context *, enum tdb_log_level, enum TDB_ERROR,
                              const char *, void *);
-typedef unsigned int (*tdb1_hash_func)(TDB1_DATA *key);
+typedef unsigned int (*tdb1_hash_func)(TDB_DATA *key);
 
 struct tdb1_logging_context {
         tdb1_log_func log_fn;
 
 struct tdb1_logging_context {
         tdb1_log_func log_fn;
@@ -84,30 +74,30 @@ struct tdb1_context *tdb1_open_ex(const char *name, int hash_size, int tdb1_flag
 
 void tdb1_set_max_dead(struct tdb1_context *tdb, int max_dead);
 
 
 void tdb1_set_max_dead(struct tdb1_context *tdb, int max_dead);
 
-TDB1_DATA tdb1_fetch(struct tdb1_context *tdb, TDB1_DATA key);
+TDB_DATA tdb1_fetch(struct tdb1_context *tdb, TDB_DATA key);
 
 
-int tdb1_parse_record(struct tdb1_context *tdb, TDB1_DATA key,
-                             int (*parser)(TDB1_DATA key, TDB1_DATA data,
+int tdb1_parse_record(struct tdb1_context *tdb, TDB_DATA key,
+                             int (*parser)(TDB_DATA key, TDB_DATA data,
                                            void *private_data),
                              void *private_data);
 
                                            void *private_data),
                              void *private_data);
 
-int tdb1_delete(struct tdb1_context *tdb, TDB1_DATA key);
+int tdb1_delete(struct tdb1_context *tdb, TDB_DATA key);
 
 
-int tdb1_store(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA dbuf, int flag);
+int tdb1_store(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag);
 
 
-int tdb1_append(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA new_dbuf);
+int tdb1_append(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA new_dbuf);
 
 int tdb1_close(struct tdb1_context *tdb);
 
 
 int tdb1_close(struct tdb1_context *tdb);
 
-TDB1_DATA tdb1_firstkey(struct tdb1_context *tdb);
+TDB_DATA tdb1_firstkey(struct tdb1_context *tdb);
 
 
-TDB1_DATA tdb1_nextkey(struct tdb1_context *tdb, TDB1_DATA key);
+TDB_DATA tdb1_nextkey(struct tdb1_context *tdb, TDB_DATA key);
 
 int tdb1_traverse(struct tdb1_context *tdb, tdb1_traverse_func fn, void *private_data);
 
 int tdb1_traverse_read(struct tdb1_context *tdb, tdb1_traverse_func fn, void *private_data);
 
 
 int tdb1_traverse(struct tdb1_context *tdb, tdb1_traverse_func fn, void *private_data);
 
 int tdb1_traverse_read(struct tdb1_context *tdb, tdb1_traverse_func fn, void *private_data);
 
-int tdb1_exists(struct tdb1_context *tdb, TDB1_DATA key);
+int tdb1_exists(struct tdb1_context *tdb, TDB_DATA key);
 
 int tdb1_lockall(struct tdb1_context *tdb);
 
 
 int tdb1_lockall(struct tdb1_context *tdb);
 
@@ -131,19 +121,19 @@ int tdb1_hash_size(struct tdb1_context *tdb);
 
 void tdb1_increment_seqnum_nonblock(struct tdb1_context *tdb);
 
 
 void tdb1_increment_seqnum_nonblock(struct tdb1_context *tdb);
 
-unsigned int tdb1_jenkins_hash(TDB1_DATA *key);
+unsigned int tdb1_jenkins_hash(TDB_DATA *key);
 
 int tdb1_check(struct tdb1_context *tdb,
 
 int tdb1_check(struct tdb1_context *tdb,
-             int (*check) (TDB1_DATA key, TDB1_DATA data, void *private_data),
+             int (*check) (TDB_DATA key, TDB_DATA data, void *private_data),
              void *private_data);
 
 /* @} ******************************************************************/
 
 /* Low level locking functions: use with care */
              void *private_data);
 
 /* @} ******************************************************************/
 
 /* Low level locking functions: use with care */
-int tdb1_chainlock(struct tdb1_context *tdb, TDB1_DATA key);
-int tdb1_chainunlock(struct tdb1_context *tdb, TDB1_DATA key);
-int tdb1_chainlock_read(struct tdb1_context *tdb, TDB1_DATA key);
-int tdb1_chainunlock_read(struct tdb1_context *tdb, TDB1_DATA key);
+int tdb1_chainlock(struct tdb1_context *tdb, TDB_DATA key);
+int tdb1_chainunlock(struct tdb1_context *tdb, TDB_DATA key);
+int tdb1_chainlock_read(struct tdb1_context *tdb, TDB_DATA key);
+int tdb1_chainunlock_read(struct tdb1_context *tdb, TDB_DATA key);
 
 
 /* wipe and repack */
 
 
 /* wipe and repack */
@@ -153,6 +143,6 @@ int tdb1_repack(struct tdb1_context *tdb);
 /* Debug functions. Not used in production. */
 char *tdb1_summary(struct tdb1_context *tdb);
 
 /* Debug functions. Not used in production. */
 char *tdb1_summary(struct tdb1_context *tdb);
 
-extern TDB1_DATA tdb1_null;
+extern TDB_DATA tdb1_null;
 
 #endif /* tdb1.h */
 
 #endif /* tdb1.h */
index f0eb32bdef1baccbaf39fa15b69a588c3fd962c3..74b3a02d73401f31b0029ca507586d4313ac482f 100644 (file)
@@ -32,7 +32,7 @@ static bool tdb1_check_header(struct tdb1_context *tdb, tdb1_off_t *recovery)
 
        if (tdb->methods->tdb1_read(tdb, 0, &hdr, sizeof(hdr), 0) == -1)
                return false;
 
        if (tdb->methods->tdb1_read(tdb, 0, &hdr, sizeof(hdr), 0) == -1)
                return false;
-       if (strcmp(hdr.magic_food, TDB1_MAGIC_FOOD) != 0)
+       if (strcmp(hdr.magic_food, TDB_MAGIC_FOOD) != 0)
                goto corrupt;
 
        TDB1_CONV(hdr);
                goto corrupt;
 
        TDB1_CONV(hdr);
@@ -132,10 +132,10 @@ corrupt:
 
 /* Grab some bytes: may copy if can't use mmap.
    Caller has already done bounds check. */
 
 /* Grab some bytes: may copy if can't use mmap.
    Caller has already done bounds check. */
-static TDB1_DATA get_bytes(struct tdb1_context *tdb,
+static TDB_DATA get_bytes(struct tdb1_context *tdb,
                          tdb1_off_t off, tdb1_len_t len)
 {
                          tdb1_off_t off, tdb1_len_t len)
 {
-       TDB1_DATA d;
+       TDB_DATA d;
 
        d.dsize = len;
 
 
        d.dsize = len;
 
@@ -147,7 +147,7 @@ static TDB1_DATA get_bytes(struct tdb1_context *tdb,
 }
 
 /* Frees data if we're not able to simply use mmap. */
 }
 
 /* Frees data if we're not able to simply use mmap. */
-static void put_bytes(struct tdb1_context *tdb, TDB1_DATA d)
+static void put_bytes(struct tdb1_context *tdb, TDB_DATA d)
 {
        if (tdb->transaction == NULL && tdb->map_ptr != NULL)
                return;
 {
        if (tdb->transaction == NULL && tdb->map_ptr != NULL)
                return;
@@ -236,10 +236,10 @@ static bool tdb1_check_used_record(struct tdb1_context *tdb,
                                  tdb1_off_t off,
                                  const struct tdb1_record *rec,
                                  unsigned char **hashes,
                                  tdb1_off_t off,
                                  const struct tdb1_record *rec,
                                  unsigned char **hashes,
-                                 int (*check)(TDB1_DATA, TDB1_DATA, void *),
+                                 int (*check)(TDB_DATA, TDB_DATA, void *),
                                  void *private_data)
 {
                                  void *private_data)
 {
-       TDB1_DATA key, data;
+       TDB_DATA key, data;
 
        if (!tdb1_check_record(tdb, off, rec))
                return false;
 
        if (!tdb1_check_record(tdb, off, rec))
                return false;
@@ -323,7 +323,7 @@ size_t tdb1_dead_space(struct tdb1_context *tdb, tdb1_off_t off)
 }
 
 int tdb1_check(struct tdb1_context *tdb,
 }
 
 int tdb1_check(struct tdb1_context *tdb,
-             int (*check)(TDB1_DATA key, TDB1_DATA data, void *private_data),
+             int (*check)(TDB_DATA key, TDB_DATA data, void *private_data),
              void *private_data)
 {
        unsigned int h;
              void *private_data)
 {
        unsigned int h;
index a8dd065535e3a56b65888a2595928182f13f723c..50e49505ca936da61f4bcec9d7b0cf910fe91369 100644 (file)
@@ -25,7 +25,7 @@
 #include "tdb1_private.h"
 
 /* This is based on the hash algorithm from gdbm */
 #include "tdb1_private.h"
 
 /* This is based on the hash algorithm from gdbm */
-unsigned int tdb1_old_hash(TDB1_DATA *key)
+unsigned int tdb1_old_hash(TDB_DATA *key)
 {
        uint32_t value; /* Used to compute the hash value.  */
        uint32_t   i;   /* Used to cycle through random values. */
 {
        uint32_t value; /* Used to compute the hash value.  */
        uint32_t   i;   /* Used to cycle through random values. */
@@ -339,7 +339,7 @@ static uint32_t hashlittle( const void *key, size_t length )
   return c;
 }
 
   return c;
 }
 
-unsigned int tdb1_jenkins_hash(TDB1_DATA *key)
+unsigned int tdb1_jenkins_hash(TDB_DATA *key)
 {
        return hashlittle(key->dptr, key->dsize);
 }
 {
        return hashlittle(key->dptr, key->dsize);
 }
index cd6efc34b1b2f4141f799be12150654493ef5434..758eac6394c71c2c4fde5f157dfda062c6e7dff3 100644 (file)
@@ -427,13 +427,13 @@ unsigned char *tdb1_alloc_read(struct tdb1_context *tdb, tdb1_off_t offset, tdb1
 
 /* Give a piece of tdb data to a parser */
 
 
 /* Give a piece of tdb data to a parser */
 
-int tdb1_parse_data(struct tdb1_context *tdb, TDB1_DATA key,
+int tdb1_parse_data(struct tdb1_context *tdb, TDB_DATA key,
                   tdb1_off_t offset, tdb1_len_t len,
                   tdb1_off_t offset, tdb1_len_t len,
-                  int (*parser)(TDB1_DATA key, TDB1_DATA data,
+                  int (*parser)(TDB_DATA key, TDB_DATA data,
                                 void *private_data),
                   void *private_data)
 {
                                 void *private_data),
                   void *private_data)
 {
-       TDB1_DATA data;
+       TDB_DATA data;
        int result;
 
        data.dsize = len;
        int result;
 
        data.dsize = len;
index 68f394aad24c8b2ddeb1b4557e26fd1247d7b101..c427804893d465d5e3fbea7cd6a850dd2017f740 100644 (file)
@@ -130,7 +130,7 @@ static tdb1_off_t lock_offset(int list)
 */
 int tdb1_brlock(struct tdb1_context *tdb,
               int rw_type, tdb1_off_t offset, size_t len,
 */
 int tdb1_brlock(struct tdb1_context *tdb,
               int rw_type, tdb1_off_t offset, size_t len,
-              enum tdb1_lock_flags flags)
+              enum tdb_lock_flags flags)
 {
        int ret;
 
 {
        int ret;
 
@@ -145,7 +145,7 @@ int tdb1_brlock(struct tdb1_context *tdb,
 
        do {
                ret = fcntl_lock(tdb, rw_type, offset, len,
 
        do {
                ret = fcntl_lock(tdb, rw_type, offset, len,
-                                flags & TDB1_LOCK_WAIT);
+                                flags & TDB_LOCK_WAIT);
        } while (ret == -1 && errno == EINTR);
 
        if (ret == -1) {
        } while (ret == -1 && errno == EINTR);
 
        if (ret == -1) {
@@ -153,7 +153,7 @@ int tdb1_brlock(struct tdb1_context *tdb,
                /* Generic lock error. errno set by fcntl.
                 * EAGAIN is an expected return from non-blocking
                 * locks. */
                /* Generic lock error. errno set by fcntl.
                 * EAGAIN is an expected return from non-blocking
                 * locks. */
-               if (!(flags & TDB1_LOCK_PROBE) && errno != EAGAIN) {
+               if (!(flags & TDB_LOCK_PROBE) && errno != EAGAIN) {
                        tdb_logerr(tdb, TDB_ERR_LOCK, TDB_LOG_ERROR,
                                   "tdb1_brlock failed (fd=%d) at offset %d rw_type=%d flags=%d len=%d",
                                   tdb->fd, offset, rw_type, flags, (int)len);
                        tdb_logerr(tdb, TDB_ERR_LOCK, TDB_LOG_ERROR,
                                   "tdb1_brlock failed (fd=%d) at offset %d rw_type=%d flags=%d len=%d",
                                   tdb->fd, offset, rw_type, flags, (int)len);
@@ -213,7 +213,7 @@ int tdb1_allrecord_upgrade(struct tdb1_context *tdb)
        while (count--) {
                struct timeval tv;
                if (tdb1_brlock(tdb, F_WRLCK, TDB1_FREELIST_TOP, 0,
        while (count--) {
                struct timeval tv;
                if (tdb1_brlock(tdb, F_WRLCK, TDB1_FREELIST_TOP, 0,
-                              TDB1_LOCK_WAIT|TDB1_LOCK_PROBE) == 0) {
+                              TDB_LOCK_WAIT|TDB_LOCK_PROBE) == 0) {
                        tdb->allrecord_lock.ltype = F_WRLCK;
                        tdb->allrecord_lock.off = 0;
                        return 0;
                        tdb->allrecord_lock.ltype = F_WRLCK;
                        tdb->allrecord_lock.off = 0;
                        return 0;
@@ -246,7 +246,7 @@ static struct tdb1_lock_type *tdb1_find_nestlock(struct tdb1_context *tdb,
 
 /* lock an offset in the database. */
 int tdb1_nest_lock(struct tdb1_context *tdb, uint32_t offset, int ltype,
 
 /* lock an offset in the database. */
 int tdb1_nest_lock(struct tdb1_context *tdb, uint32_t offset, int ltype,
-                 enum tdb1_lock_flags flags)
+                 enum tdb_lock_flags flags)
 {
        struct tdb1_lock_type *new_lck;
 
 {
        struct tdb1_lock_type *new_lck;
 
@@ -298,11 +298,11 @@ static int tdb1_lock_and_recover(struct tdb1_context *tdb)
        int ret;
 
        /* We need to match locking order in transaction commit. */
        int ret;
 
        /* We need to match locking order in transaction commit. */
-       if (tdb1_brlock(tdb, F_WRLCK, TDB1_FREELIST_TOP, 0, TDB1_LOCK_WAIT)) {
+       if (tdb1_brlock(tdb, F_WRLCK, TDB1_FREELIST_TOP, 0, TDB_LOCK_WAIT)) {
                return -1;
        }
 
                return -1;
        }
 
-       if (tdb1_brlock(tdb, F_WRLCK, TDB1_OPEN_LOCK, 1, TDB1_LOCK_WAIT)) {
+       if (tdb1_brlock(tdb, F_WRLCK, TDB1_OPEN_LOCK, 1, TDB_LOCK_WAIT)) {
                tdb1_brunlock(tdb, F_WRLCK, TDB1_FREELIST_TOP, 0);
                return -1;
        }
                tdb1_brunlock(tdb, F_WRLCK, TDB1_FREELIST_TOP, 0);
                return -1;
        }
@@ -327,7 +327,7 @@ static bool have_data_locks(const struct tdb1_context *tdb)
 }
 
 static int tdb1_lock_list(struct tdb1_context *tdb, int list, int ltype,
 }
 
 static int tdb1_lock_list(struct tdb1_context *tdb, int list, int ltype,
-                        enum tdb1_lock_flags waitflag)
+                        enum tdb_lock_flags waitflag)
 {
        int ret;
        bool check = false;
 {
        int ret;
        bool check = false;
@@ -363,7 +363,7 @@ int tdb1_lock(struct tdb1_context *tdb, int list, int ltype)
 {
        int ret;
 
 {
        int ret;
 
-       ret = tdb1_lock_list(tdb, list, ltype, TDB1_LOCK_WAIT);
+       ret = tdb1_lock_list(tdb, list, ltype, TDB_LOCK_WAIT);
        if (ret) {
                tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
                           "tdb1_lock failed on list %d "
        if (ret) {
                tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
                           "tdb1_lock failed on list %d "
@@ -447,7 +447,7 @@ int tdb1_unlock(struct tdb1_context *tdb, int list, int ltype)
   get the transaction lock
  */
 int tdb1_transaction_lock(struct tdb1_context *tdb, int ltype,
   get the transaction lock
  */
 int tdb1_transaction_lock(struct tdb1_context *tdb, int ltype,
-                        enum tdb1_lock_flags lockflags)
+                        enum tdb_lock_flags lockflags)
 {
        return tdb1_nest_lock(tdb, TDB1_TRANSACTION_LOCK, ltype, lockflags);
 }
 {
        return tdb1_nest_lock(tdb, TDB1_TRANSACTION_LOCK, ltype, lockflags);
 }
@@ -462,7 +462,7 @@ int tdb1_transaction_unlock(struct tdb1_context *tdb, int ltype)
 
 /* Returns 0 if all done, -1 if error, 1 if ok. */
 static int tdb1_allrecord_check(struct tdb1_context *tdb, int ltype,
 
 /* Returns 0 if all done, -1 if error, 1 if ok. */
 static int tdb1_allrecord_check(struct tdb1_context *tdb, int ltype,
-                              enum tdb1_lock_flags flags, bool upgradable)
+                              enum tdb_lock_flags flags, bool upgradable)
 {
        /* There are no locks on read-only dbs */
        if (tdb->read_only || tdb->traverse_read) {
 {
        /* There are no locks on read-only dbs */
        if (tdb->read_only || tdb->traverse_read) {
@@ -498,11 +498,11 @@ static int tdb1_allrecord_check(struct tdb1_context *tdb, int ltype,
 /* We only need to lock individual bytes, but Linux merges consecutive locks
  * so we lock in contiguous ranges. */
 static int tdb1_chainlock_gradual(struct tdb1_context *tdb,
 /* We only need to lock individual bytes, but Linux merges consecutive locks
  * so we lock in contiguous ranges. */
 static int tdb1_chainlock_gradual(struct tdb1_context *tdb,
-                                int ltype, enum tdb1_lock_flags flags,
+                                int ltype, enum tdb_lock_flags flags,
                                 size_t off, size_t len)
 {
        int ret;
                                 size_t off, size_t len)
 {
        int ret;
-       enum tdb1_lock_flags nb_flags = (flags & ~TDB1_LOCK_WAIT);
+       enum tdb_lock_flags nb_flags = (flags & ~TDB_LOCK_WAIT);
 
        if (len <= 4) {
                /* Single record.  Just do blocking lock. */
 
        if (len <= 4) {
                /* Single record.  Just do blocking lock. */
@@ -533,7 +533,7 @@ static int tdb1_chainlock_gradual(struct tdb1_context *tdb,
  * other way of guaranteeing exclusivity (ie. transaction write lock).
  * We do the locking gradually to avoid being starved by smaller locks. */
 int tdb1_allrecord_lock(struct tdb1_context *tdb, int ltype,
  * other way of guaranteeing exclusivity (ie. transaction write lock).
  * We do the locking gradually to avoid being starved by smaller locks. */
 int tdb1_allrecord_lock(struct tdb1_context *tdb, int ltype,
-                      enum tdb1_lock_flags flags, bool upgradable)
+                      enum tdb_lock_flags flags, bool upgradable)
 {
        switch (tdb1_allrecord_check(tdb, ltype, flags, upgradable)) {
        case -1:
 {
        switch (tdb1_allrecord_check(tdb, ltype, flags, upgradable)) {
        case -1:
@@ -622,7 +622,7 @@ int tdb1_allrecord_unlock(struct tdb1_context *tdb, int ltype)
 /* lock entire database with write lock */
 int tdb1_lockall(struct tdb1_context *tdb)
 {
 /* lock entire database with write lock */
 int tdb1_lockall(struct tdb1_context *tdb)
 {
-       return tdb1_allrecord_lock(tdb, F_WRLCK, TDB1_LOCK_WAIT, false);
+       return tdb1_allrecord_lock(tdb, F_WRLCK, TDB_LOCK_WAIT, false);
 }
 
 /* unlock entire database with write lock */
 }
 
 /* unlock entire database with write lock */
@@ -634,7 +634,7 @@ int tdb1_unlockall(struct tdb1_context *tdb)
 /* lock entire database with read lock */
 int tdb1_lockall_read(struct tdb1_context *tdb)
 {
 /* lock entire database with read lock */
 int tdb1_lockall_read(struct tdb1_context *tdb)
 {
-       return tdb1_allrecord_lock(tdb, F_RDLCK, TDB1_LOCK_WAIT, false);
+       return tdb1_allrecord_lock(tdb, F_RDLCK, TDB_LOCK_WAIT, false);
 }
 
 /* unlock entire database with read lock */
 }
 
 /* unlock entire database with read lock */
@@ -645,25 +645,25 @@ int tdb1_unlockall_read(struct tdb1_context *tdb)
 
 /* lock/unlock one hash chain. This is meant to be used to reduce
    contention - it cannot guarantee how many records will be locked */
 
 /* lock/unlock one hash chain. This is meant to be used to reduce
    contention - it cannot guarantee how many records will be locked */
-int tdb1_chainlock(struct tdb1_context *tdb, TDB1_DATA key)
+int tdb1_chainlock(struct tdb1_context *tdb, TDB_DATA key)
 {
        int ret = tdb1_lock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_WRLCK);
        return ret;
 }
 
 {
        int ret = tdb1_lock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_WRLCK);
        return ret;
 }
 
-int tdb1_chainunlock(struct tdb1_context *tdb, TDB1_DATA key)
+int tdb1_chainunlock(struct tdb1_context *tdb, TDB_DATA key)
 {
        return tdb1_unlock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_WRLCK);
 }
 
 {
        return tdb1_unlock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_WRLCK);
 }
 
-int tdb1_chainlock_read(struct tdb1_context *tdb, TDB1_DATA key)
+int tdb1_chainlock_read(struct tdb1_context *tdb, TDB_DATA key)
 {
        int ret;
        ret = tdb1_lock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_RDLCK);
        return ret;
 }
 
 {
        int ret;
        ret = tdb1_lock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_RDLCK);
        return ret;
 }
 
-int tdb1_chainunlock_read(struct tdb1_context *tdb, TDB1_DATA key)
+int tdb1_chainunlock_read(struct tdb1_context *tdb, TDB_DATA key)
 {
        return tdb1_unlock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_RDLCK);
 }
 {
        return tdb1_unlock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_RDLCK);
 }
@@ -674,7 +674,7 @@ int tdb1_lock_record(struct tdb1_context *tdb, tdb1_off_t off)
        if (tdb->allrecord_lock.count) {
                return 0;
        }
        if (tdb->allrecord_lock.count) {
                return 0;
        }
-       return off ? tdb1_brlock(tdb, F_RDLCK, off, 1, TDB1_LOCK_WAIT) : 0;
+       return off ? tdb1_brlock(tdb, F_RDLCK, off, 1, TDB_LOCK_WAIT) : 0;
 }
 
 /*
 }
 
 /*
@@ -694,7 +694,7 @@ int tdb1_write_lock_record(struct tdb1_context *tdb, tdb1_off_t off)
                }
                return -1;
        }
                }
                return -1;
        }
-       return tdb1_brlock(tdb, F_WRLCK, off, 1, TDB1_LOCK_NOWAIT|TDB1_LOCK_PROBE);
+       return tdb1_brlock(tdb, F_WRLCK, off, 1, TDB_LOCK_NOWAIT|TDB_LOCK_PROBE);
 }
 
 int tdb1_write_unlock_record(struct tdb1_context *tdb, tdb1_off_t off)
 }
 
 int tdb1_write_unlock_record(struct tdb1_context *tdb, tdb1_off_t off)
index e1f16053666537eb91ba8501ab7c151fe8d35994..30c11956ac185b7daeb53de5b92e960a0cc18b6e 100644 (file)
@@ -34,11 +34,11 @@ static struct tdb1_context *tdb1s = NULL;
 void tdb1_header_hash(struct tdb1_context *tdb,
                     uint32_t *magic1_hash, uint32_t *magic2_hash)
 {
 void tdb1_header_hash(struct tdb1_context *tdb,
                     uint32_t *magic1_hash, uint32_t *magic2_hash)
 {
-       TDB1_DATA hash_key;
+       TDB_DATA hash_key;
        uint32_t tdb1_magic = TDB1_MAGIC;
 
        uint32_t tdb1_magic = TDB1_MAGIC;
 
-       hash_key.dptr = (unsigned char *)TDB1_MAGIC_FOOD;
-       hash_key.dsize = sizeof(TDB1_MAGIC_FOOD);
+       hash_key.dptr = (unsigned char *)TDB_MAGIC_FOOD;
+       hash_key.dsize = sizeof(TDB_MAGIC_FOOD);
        *magic1_hash = tdb->hash_fn(&hash_key);
 
        hash_key.dptr = (unsigned char *)TDB1_CONV(tdb1_magic);
        *magic1_hash = tdb->hash_fn(&hash_key);
 
        hash_key.dptr = (unsigned char *)TDB1_CONV(tdb1_magic);
@@ -93,7 +93,7 @@ static int tdb1_new_database(struct tdb1_context *tdb, int hash_size)
        TDB1_CONV(*newdb);
        memcpy(&tdb->header, newdb, sizeof(tdb->header));
        /* Don't endian-convert the magic food! */
        TDB1_CONV(*newdb);
        memcpy(&tdb->header, newdb, sizeof(tdb->header));
        /* Don't endian-convert the magic food! */
-       memcpy(newdb->magic_food, TDB1_MAGIC_FOOD, strlen(TDB1_MAGIC_FOOD)+1);
+       memcpy(newdb->magic_food, TDB_MAGIC_FOOD, strlen(TDB_MAGIC_FOOD)+1);
        /* we still have "ret == -1" here */
        if (tdb1_write_all(tdb->fd, newdb, size))
                ret = 0;
        /* we still have "ret == -1" here */
        if (tdb1_write_all(tdb->fd, newdb, size))
                ret = 0;
@@ -293,7 +293,7 @@ struct tdb1_context *tdb1_open_ex(const char *name, int hash_size, int tdb1_flag
         fcntl(tdb->fd, F_SETFD, v | FD_CLOEXEC);
 
        /* ensure there is only one process initialising at once */
         fcntl(tdb->fd, F_SETFD, v | FD_CLOEXEC);
 
        /* ensure there is only one process initialising at once */
-       if (tdb1_nest_lock(tdb, TDB1_OPEN_LOCK, F_WRLCK, TDB1_LOCK_WAIT) == -1) {
+       if (tdb1_nest_lock(tdb, TDB1_OPEN_LOCK, F_WRLCK, TDB_LOCK_WAIT) == -1) {
                tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
                           "tdb1_open_ex: failed to get open lock on %s: %s",
                           name, strerror(errno));
                tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
                           "tdb1_open_ex: failed to get open lock on %s: %s",
                           name, strerror(errno));
@@ -303,7 +303,7 @@ struct tdb1_context *tdb1_open_ex(const char *name, int hash_size, int tdb1_flag
        /* we need to zero database if we are the only one with it open */
        if ((tdb1_flags & TDB1_CLEAR_IF_FIRST) &&
            (!tdb->read_only) &&
        /* we need to zero database if we are the only one with it open */
        if ((tdb1_flags & TDB1_CLEAR_IF_FIRST) &&
            (!tdb->read_only) &&
-           (locked = (tdb1_nest_lock(tdb, TDB1_ACTIVE_LOCK, F_WRLCK, TDB1_LOCK_NOWAIT|TDB1_LOCK_PROBE) == 0))) {
+           (locked = (tdb1_nest_lock(tdb, TDB1_ACTIVE_LOCK, F_WRLCK, TDB_LOCK_NOWAIT|TDB_LOCK_PROBE) == 0))) {
                open_flags |= O_CREAT;
                if (ftruncate(tdb->fd, 0) == -1) {
                        tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
                open_flags |= O_CREAT;
                if (ftruncate(tdb->fd, 0) == -1) {
                        tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
@@ -316,7 +316,7 @@ struct tdb1_context *tdb1_open_ex(const char *name, int hash_size, int tdb1_flag
 
        errno = 0;
        if (read(tdb->fd, &tdb->header, sizeof(tdb->header)) != sizeof(tdb->header)
 
        errno = 0;
        if (read(tdb->fd, &tdb->header, sizeof(tdb->header)) != sizeof(tdb->header)
-           || strcmp(tdb->header.magic_food, TDB1_MAGIC_FOOD) != 0) {
+           || strcmp(tdb->header.magic_food, TDB_MAGIC_FOOD) != 0) {
                if (!(open_flags & O_CREAT) || tdb1_new_database(tdb, hash_size) == -1) {
                        if (errno == 0) {
                                errno = EIO; /* ie bad format or something */
                if (!(open_flags & O_CREAT) || tdb1_new_database(tdb, hash_size) == -1) {
                        if (errno == 0) {
                                errno = EIO; /* ie bad format or something */
@@ -401,7 +401,7 @@ struct tdb1_context *tdb1_open_ex(const char *name, int hash_size, int tdb1_flag
 
        if (tdb1_flags & TDB1_CLEAR_IF_FIRST) {
                /* leave this lock in place to indicate it's in use */
 
        if (tdb1_flags & TDB1_CLEAR_IF_FIRST) {
                /* leave this lock in place to indicate it's in use */
-               if (tdb1_nest_lock(tdb, TDB1_ACTIVE_LOCK, F_RDLCK, TDB1_LOCK_WAIT) == -1) {
+               if (tdb1_nest_lock(tdb, TDB1_ACTIVE_LOCK, F_RDLCK, TDB_LOCK_WAIT) == -1) {
                        goto fail;
                }
        }
                        goto fail;
                }
        }
index 932e76110bbfb61747e47b27d65c2e4e73ec36fc..20838bfe7b1f32b20cf0bcf5222aa2db798f67fc 100644 (file)
@@ -63,7 +63,6 @@ typedef uint32_t tdb1_off_t;
 #define offsetof(t,f) ((unsigned int)&((t *)0)->f)
 #endif
 
 #define offsetof(t,f) ((unsigned int)&((t *)0)->f)
 #endif
 
-#define TDB1_MAGIC_FOOD "TDB file\n"
 #define TDB1_VERSION (0x26011967 + 6)
 #define TDB1_MAGIC (0x26011999U)
 #define TDB1_FREE_MAGIC (~TDB1_MAGIC)
 #define TDB1_VERSION (0x26011967 + 6)
 #define TDB1_MAGIC (0x26011999U)
 #define TDB1_FREE_MAGIC (~TDB1_MAGIC)
@@ -131,7 +130,7 @@ struct tdb1_header {
        tdb1_off_t rwlocks; /* obsolete - kept to detect old formats */
        tdb1_off_t recovery_start; /* offset of transaction recovery region */
        tdb1_off_t sequence_number; /* used when TDB1_SEQNUM is set */
        tdb1_off_t rwlocks; /* obsolete - kept to detect old formats */
        tdb1_off_t recovery_start; /* offset of transaction recovery region */
        tdb1_off_t sequence_number; /* used when TDB1_SEQNUM is set */
-       uint32_t magic1_hash; /* hash of TDB1_MAGIC_FOOD. */
+       uint32_t magic1_hash; /* hash of TDB_MAGIC_FOOD. */
        uint32_t magic2_hash; /* hash of TDB1_MAGIC. */
        tdb1_off_t reserved[27];
 };
        uint32_t magic2_hash; /* hash of TDB1_MAGIC. */
        tdb1_off_t reserved[27];
 };
@@ -149,14 +148,6 @@ struct tdb1_traverse_lock {
        int lock_rw;
 };
 
        int lock_rw;
 };
 
-enum tdb1_lock_flags {
-       /* WAIT == F_SETLKW, NOWAIT == F_SETLK */
-       TDB1_LOCK_NOWAIT = 0,
-       TDB1_LOCK_WAIT = 1,
-       /* If set, don't log an error on failure. */
-       TDB1_LOCK_PROBE = 2,
-};
-
 struct tdb1_context;
 
 struct tdb1_methods {
 struct tdb1_context;
 
 struct tdb1_methods {
@@ -197,7 +188,7 @@ struct tdb1_context {
        struct tdb1_traverse_lock travlocks; /* current traversal locks */
        dev_t device;   /* uniquely identifies this tdb */
        ino_t inode;    /* uniquely identifies this tdb */
        struct tdb1_traverse_lock travlocks; /* current traversal locks */
        dev_t device;   /* uniquely identifies this tdb */
        ino_t inode;    /* uniquely identifies this tdb */
-       unsigned int (*hash_fn)(TDB1_DATA *key);
+       unsigned int (*hash_fn)(TDB_DATA *key);
        int open_flags; /* flags used in the open - needed by reopen */
        const struct tdb1_methods *methods;
        struct tdb1_transaction *transaction;
        int open_flags; /* flags used in the open - needed by reopen */
        const struct tdb1_methods *methods;
        struct tdb1_transaction *transaction;
@@ -212,25 +203,25 @@ int tdb1_munmap(struct tdb1_context *tdb);
 void tdb1_mmap(struct tdb1_context *tdb);
 int tdb1_lock(struct tdb1_context *tdb, int list, int ltype);
 int tdb1_nest_lock(struct tdb1_context *tdb, uint32_t offset, int ltype,
 void tdb1_mmap(struct tdb1_context *tdb);
 int tdb1_lock(struct tdb1_context *tdb, int list, int ltype);
 int tdb1_nest_lock(struct tdb1_context *tdb, uint32_t offset, int ltype,
-                 enum tdb1_lock_flags flags);
+                 enum tdb_lock_flags flags);
 int tdb1_nest_unlock(struct tdb1_context *tdb, uint32_t offset, int ltype);
 int tdb1_unlock(struct tdb1_context *tdb, int list, int ltype);
 int tdb1_brlock(struct tdb1_context *tdb,
               int rw_type, tdb1_off_t offset, size_t len,
 int tdb1_nest_unlock(struct tdb1_context *tdb, uint32_t offset, int ltype);
 int tdb1_unlock(struct tdb1_context *tdb, int list, int ltype);
 int tdb1_brlock(struct tdb1_context *tdb,
               int rw_type, tdb1_off_t offset, size_t len,
-              enum tdb1_lock_flags flags);
+              enum tdb_lock_flags flags);
 int tdb1_brunlock(struct tdb1_context *tdb,
                 int rw_type, tdb1_off_t offset, size_t len);
 bool tdb1_have_extra_locks(struct tdb1_context *tdb);
 void tdb1_release_transaction_locks(struct tdb1_context *tdb);
 int tdb1_transaction_lock(struct tdb1_context *tdb, int ltype,
 int tdb1_brunlock(struct tdb1_context *tdb,
                 int rw_type, tdb1_off_t offset, size_t len);
 bool tdb1_have_extra_locks(struct tdb1_context *tdb);
 void tdb1_release_transaction_locks(struct tdb1_context *tdb);
 int tdb1_transaction_lock(struct tdb1_context *tdb, int ltype,
-                        enum tdb1_lock_flags lockflags);
+                        enum tdb_lock_flags lockflags);
 int tdb1_transaction_unlock(struct tdb1_context *tdb, int ltype);
 int tdb1_recovery_area(struct tdb1_context *tdb,
                      const struct tdb1_methods *methods,
                      tdb1_off_t *recovery_offset,
                      struct tdb1_record *rec);
 int tdb1_allrecord_lock(struct tdb1_context *tdb, int ltype,
 int tdb1_transaction_unlock(struct tdb1_context *tdb, int ltype);
 int tdb1_recovery_area(struct tdb1_context *tdb,
                      const struct tdb1_methods *methods,
                      tdb1_off_t *recovery_offset,
                      struct tdb1_record *rec);
 int tdb1_allrecord_lock(struct tdb1_context *tdb, int ltype,
-                      enum tdb1_lock_flags flags, bool upgradable);
+                      enum tdb_lock_flags flags, bool upgradable);
 int tdb1_allrecord_unlock(struct tdb1_context *tdb, int ltype);
 int tdb1_allrecord_upgrade(struct tdb1_context *tdb);
 int tdb1_write_lock_record(struct tdb1_context *tdb, tdb1_off_t off);
 int tdb1_allrecord_unlock(struct tdb1_context *tdb, int ltype);
 int tdb1_allrecord_upgrade(struct tdb1_context *tdb);
 int tdb1_write_lock_record(struct tdb1_context *tdb, tdb1_off_t off);
@@ -249,12 +240,12 @@ int tdb1_rec_read(struct tdb1_context *tdb, tdb1_off_t offset, struct tdb1_recor
 int tdb1_rec_write(struct tdb1_context *tdb, tdb1_off_t offset, struct tdb1_record *rec);
 int tdb1_do_delete(struct tdb1_context *tdb, tdb1_off_t rec_ptr, struct tdb1_record *rec);
 unsigned char *tdb1_alloc_read(struct tdb1_context *tdb, tdb1_off_t offset, tdb1_len_t len);
 int tdb1_rec_write(struct tdb1_context *tdb, tdb1_off_t offset, struct tdb1_record *rec);
 int tdb1_do_delete(struct tdb1_context *tdb, tdb1_off_t rec_ptr, struct tdb1_record *rec);
 unsigned char *tdb1_alloc_read(struct tdb1_context *tdb, tdb1_off_t offset, tdb1_len_t len);
-int tdb1_parse_data(struct tdb1_context *tdb, TDB1_DATA key,
+int tdb1_parse_data(struct tdb1_context *tdb, TDB_DATA key,
                   tdb1_off_t offset, tdb1_len_t len,
                   tdb1_off_t offset, tdb1_len_t len,
-                  int (*parser)(TDB1_DATA key, TDB1_DATA data,
+                  int (*parser)(TDB_DATA key, TDB_DATA data,
                                 void *private_data),
                   void *private_data);
                                 void *private_data),
                   void *private_data);
-tdb1_off_t tdb1_find_lock_hash(struct tdb1_context *tdb, TDB1_DATA key, uint32_t hash, int locktype,
+tdb1_off_t tdb1_find_lock_hash(struct tdb1_context *tdb, TDB_DATA key, uint32_t hash, int locktype,
                           struct tdb1_record *rec);
 void tdb1_io_init(struct tdb1_context *tdb);
 int tdb1_expand(struct tdb1_context *tdb, tdb1_off_t size);
                           struct tdb1_record *rec);
 void tdb1_io_init(struct tdb1_context *tdb);
 int tdb1_expand(struct tdb1_context *tdb, tdb1_off_t size);
@@ -264,6 +255,6 @@ bool tdb1_write_all(int fd, const void *buf, size_t count);
 int tdb1_transaction_recover(struct tdb1_context *tdb);
 void tdb1_header_hash(struct tdb1_context *tdb,
                     uint32_t *magic1_hash, uint32_t *magic2_hash);
 int tdb1_transaction_recover(struct tdb1_context *tdb);
 void tdb1_header_hash(struct tdb1_context *tdb,
                     uint32_t *magic1_hash, uint32_t *magic2_hash);
-unsigned int tdb1_old_hash(TDB1_DATA *key);
+unsigned int tdb1_old_hash(TDB_DATA *key);
 size_t tdb1_dead_space(struct tdb1_context *tdb, tdb1_off_t off);
 #endif /* CCAN_TDB2_TDB1_PRIVATE_H */
 size_t tdb1_dead_space(struct tdb1_context *tdb, tdb1_off_t off);
 #endif /* CCAN_TDB2_TDB1_PRIVATE_H */
index 802311504508cca01c040cadc00849983897ba30..c9406c4b16448be789c761ba86355f6c52106a28 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "tdb1_private.h"
 
 
 #include "tdb1_private.h"
 
-TDB1_DATA tdb1_null;
+TDB_DATA tdb1_null;
 
 /*
   non-blocking increment of the tdb sequence number if the tdb has been opened using
 
 /*
   non-blocking increment of the tdb sequence number if the tdb has been opened using
@@ -60,7 +60,7 @@ static void tdb1_increment_seqnum(struct tdb1_context *tdb)
        }
 
        if (tdb1_nest_lock(tdb, TDB1_SEQNUM_OFS, F_WRLCK,
        }
 
        if (tdb1_nest_lock(tdb, TDB1_SEQNUM_OFS, F_WRLCK,
-                         TDB1_LOCK_WAIT|TDB1_LOCK_PROBE) != 0) {
+                          TDB_LOCK_WAIT|TDB_LOCK_PROBE) != 0) {
                return;
        }
 
                return;
        }
 
@@ -69,14 +69,14 @@ static void tdb1_increment_seqnum(struct tdb1_context *tdb)
        tdb1_nest_unlock(tdb, TDB1_SEQNUM_OFS, F_WRLCK);
 }
 
        tdb1_nest_unlock(tdb, TDB1_SEQNUM_OFS, F_WRLCK);
 }
 
-static int tdb1_key_compare(TDB1_DATA key, TDB1_DATA data, void *private_data)
+static int tdb1_key_compare(TDB_DATA key, TDB_DATA data, void *private_data)
 {
        return memcmp(data.dptr, key.dptr, data.dsize);
 }
 
 /* Returns 0 on fail.  On success, return offset of record, and fills
    in rec */
 {
        return memcmp(data.dptr, key.dptr, data.dsize);
 }
 
 /* Returns 0 on fail.  On success, return offset of record, and fills
    in rec */
-static tdb1_off_t tdb1_find(struct tdb1_context *tdb, TDB1_DATA key, uint32_t hash,
+static tdb1_off_t tdb1_find(struct tdb1_context *tdb, TDB_DATA key, uint32_t hash,
                        struct tdb1_record *r)
 {
        tdb1_off_t rec_ptr;
                        struct tdb1_record *r)
 {
        tdb1_off_t rec_ptr;
@@ -111,7 +111,7 @@ static tdb1_off_t tdb1_find(struct tdb1_context *tdb, TDB1_DATA key, uint32_t ha
 }
 
 /* As tdb1_find, but if you succeed, keep the lock */
 }
 
 /* As tdb1_find, but if you succeed, keep the lock */
-tdb1_off_t tdb1_find_lock_hash(struct tdb1_context *tdb, TDB1_DATA key, uint32_t hash, int locktype,
+tdb1_off_t tdb1_find_lock_hash(struct tdb1_context *tdb, TDB_DATA key, uint32_t hash, int locktype,
                           struct tdb1_record *rec)
 {
        uint32_t rec_ptr;
                           struct tdb1_record *rec)
 {
        uint32_t rec_ptr;
@@ -123,13 +123,13 @@ tdb1_off_t tdb1_find_lock_hash(struct tdb1_context *tdb, TDB1_DATA key, uint32_t
        return rec_ptr;
 }
 
        return rec_ptr;
 }
 
-static TDB1_DATA _tdb1_fetch(struct tdb1_context *tdb, TDB1_DATA key);
+static TDB_DATA _tdb1_fetch(struct tdb1_context *tdb, TDB_DATA key);
 
 /* update an entry in place - this only works if the new data size
    is <= the old data size and the key exists.
    on failure return -1.
 */
 
 /* update an entry in place - this only works if the new data size
    is <= the old data size and the key exists.
    on failure return -1.
 */
-static int tdb1_update_hash(struct tdb1_context *tdb, TDB1_DATA key, uint32_t hash, TDB1_DATA dbuf)
+static int tdb1_update_hash(struct tdb1_context *tdb, TDB_DATA key, uint32_t hash, TDB_DATA dbuf)
 {
        struct tdb1_record rec;
        tdb1_off_t rec_ptr;
 {
        struct tdb1_record rec;
        tdb1_off_t rec_ptr;
@@ -143,7 +143,7 @@ static int tdb1_update_hash(struct tdb1_context *tdb, TDB1_DATA key, uint32_t ha
        if (rec.key_len == key.dsize &&
            rec.data_len == dbuf.dsize &&
            rec.full_hash == hash) {
        if (rec.key_len == key.dsize &&
            rec.data_len == dbuf.dsize &&
            rec.full_hash == hash) {
-               TDB1_DATA data = _tdb1_fetch(tdb, key);
+               TDB_DATA data = _tdb1_fetch(tdb, key);
                if (data.dsize == dbuf.dsize &&
                    memcmp(data.dptr, dbuf.dptr, data.dsize) == 0) {
                        if (data.dptr) {
                if (data.dsize == dbuf.dsize &&
                    memcmp(data.dptr, dbuf.dptr, data.dsize) == 0) {
                        if (data.dptr) {
@@ -178,14 +178,14 @@ static int tdb1_update_hash(struct tdb1_context *tdb, TDB1_DATA key, uint32_t ha
 /* find an entry in the database given a key */
 /* If an entry doesn't exist tdb1_err will be set to
  * TDB_ERR_NOEXIST. If a key has no data attached
 /* find an entry in the database given a key */
 /* If an entry doesn't exist tdb1_err will be set to
  * TDB_ERR_NOEXIST. If a key has no data attached
- * then the TDB1_DATA will have zero length but
+ * then the TDB_DATA will have zero length but
  * a non-zero pointer
  */
  * a non-zero pointer
  */
-static TDB1_DATA _tdb1_fetch(struct tdb1_context *tdb, TDB1_DATA key)
+static TDB_DATA _tdb1_fetch(struct tdb1_context *tdb, TDB_DATA key)
 {
        tdb1_off_t rec_ptr;
        struct tdb1_record rec;
 {
        tdb1_off_t rec_ptr;
        struct tdb1_record rec;
-       TDB1_DATA ret;
+       TDB_DATA ret;
        uint32_t hash;
 
        /* find which hash bucket it is in */
        uint32_t hash;
 
        /* find which hash bucket it is in */
@@ -200,9 +200,9 @@ static TDB1_DATA _tdb1_fetch(struct tdb1_context *tdb, TDB1_DATA key)
        return ret;
 }
 
        return ret;
 }
 
-TDB1_DATA tdb1_fetch(struct tdb1_context *tdb, TDB1_DATA key)
+TDB_DATA tdb1_fetch(struct tdb1_context *tdb, TDB_DATA key)
 {
 {
-       TDB1_DATA ret = _tdb1_fetch(tdb, key);
+       TDB_DATA ret = _tdb1_fetch(tdb, key);
 
        return ret;
 }
 
        return ret;
 }
@@ -225,8 +225,8 @@ TDB1_DATA tdb1_fetch(struct tdb1_context *tdb, TDB1_DATA key)
  * Return -1 if the record was not found.
  */
 
  * Return -1 if the record was not found.
  */
 
-int tdb1_parse_record(struct tdb1_context *tdb, TDB1_DATA key,
-                    int (*parser)(TDB1_DATA key, TDB1_DATA data,
+int tdb1_parse_record(struct tdb1_context *tdb, TDB_DATA key,
+                    int (*parser)(TDB_DATA key, TDB_DATA data,
                                   void *private_data),
                     void *private_data)
 {
                                   void *private_data),
                     void *private_data)
 {
@@ -258,7 +258,7 @@ int tdb1_parse_record(struct tdb1_context *tdb, TDB1_DATA key,
    this doesn't match the conventions in the rest of this module, but is
    compatible with gdbm
 */
    this doesn't match the conventions in the rest of this module, but is
    compatible with gdbm
 */
-static int tdb1_exists_hash(struct tdb1_context *tdb, TDB1_DATA key, uint32_t hash)
+static int tdb1_exists_hash(struct tdb1_context *tdb, TDB_DATA key, uint32_t hash)
 {
        struct tdb1_record rec;
 
 {
        struct tdb1_record rec;
 
@@ -268,7 +268,7 @@ static int tdb1_exists_hash(struct tdb1_context *tdb, TDB1_DATA key, uint32_t ha
        return 1;
 }
 
        return 1;
 }
 
-int tdb1_exists(struct tdb1_context *tdb, TDB1_DATA key)
+int tdb1_exists(struct tdb1_context *tdb, TDB_DATA key)
 {
        uint32_t hash = tdb->hash_fn(&key);
        int ret;
 {
        uint32_t hash = tdb->hash_fn(&key);
        int ret;
@@ -374,7 +374,7 @@ static int tdb1_purge_dead(struct tdb1_context *tdb, uint32_t hash)
 }
 
 /* delete an entry in the database given a key */
 }
 
 /* delete an entry in the database given a key */
-static int tdb1_delete_hash(struct tdb1_context *tdb, TDB1_DATA key, uint32_t hash)
+static int tdb1_delete_hash(struct tdb1_context *tdb, TDB_DATA key, uint32_t hash)
 {
        tdb1_off_t rec_ptr;
        struct tdb1_record rec;
 {
        tdb1_off_t rec_ptr;
        struct tdb1_record rec;
@@ -427,7 +427,7 @@ static int tdb1_delete_hash(struct tdb1_context *tdb, TDB1_DATA key, uint32_t ha
        return ret;
 }
 
        return ret;
 }
 
-int tdb1_delete(struct tdb1_context *tdb, TDB1_DATA key)
+int tdb1_delete(struct tdb1_context *tdb, TDB_DATA key)
 {
        uint32_t hash = tdb->hash_fn(&key);
        int ret;
 {
        uint32_t hash = tdb->hash_fn(&key);
        int ret;
@@ -465,8 +465,8 @@ static tdb1_off_t tdb1_find_dead(struct tdb1_context *tdb, uint32_t hash,
        return 0;
 }
 
        return 0;
 }
 
-static int _tdb1_store(struct tdb1_context *tdb, TDB1_DATA key,
-                      TDB1_DATA dbuf, int flag, uint32_t hash)
+static int _tdb1_store(struct tdb1_context *tdb, TDB_DATA key,
+                      TDB_DATA dbuf, int flag, uint32_t hash)
 {
        struct tdb1_record rec;
        tdb1_off_t rec_ptr;
 {
        struct tdb1_record rec;
        tdb1_off_t rec_ptr;
@@ -474,7 +474,7 @@ static int _tdb1_store(struct tdb1_context *tdb, TDB1_DATA key,
        int ret = -1;
 
        /* check for it existing, on insert. */
        int ret = -1;
 
        /* check for it existing, on insert. */
-       if (flag == TDB1_INSERT) {
+       if (flag == TDB_INSERT) {
                if (tdb1_exists_hash(tdb, key, hash)) {
                        tdb->last_error = TDB_ERR_EXISTS;
                        goto fail;
                if (tdb1_exists_hash(tdb, key, hash)) {
                        tdb->last_error = TDB_ERR_EXISTS;
                        goto fail;
@@ -485,7 +485,7 @@ static int _tdb1_store(struct tdb1_context *tdb, TDB1_DATA key,
                        goto done;
                }
                if (tdb->last_error == TDB_ERR_NOEXIST &&
                        goto done;
                }
                if (tdb->last_error == TDB_ERR_NOEXIST &&
-                   flag == TDB1_MODIFY) {
+                   flag == TDB_MODIFY) {
                        /* if the record doesn't exist and we are in TDB1_MODIFY mode then
                         we should fail the store */
                        goto fail;
                        /* if the record doesn't exist and we are in TDB1_MODIFY mode then
                         we should fail the store */
                        goto fail;
@@ -497,7 +497,7 @@ static int _tdb1_store(struct tdb1_context *tdb, TDB1_DATA key,
        /* delete any existing record - if it doesn't exist we don't
            care.  Doing this first reduces fragmentation, and avoids
            coalescing with `allocated' block before it's updated. */
        /* delete any existing record - if it doesn't exist we don't
            care.  Doing this first reduces fragmentation, and avoids
            coalescing with `allocated' block before it's updated. */
-       if (flag != TDB1_INSERT)
+       if (flag != TDB_INSERT)
                tdb1_delete_hash(tdb, key, hash);
 
        /* Copy key+value *before* allocating free space in case malloc
                tdb1_delete_hash(tdb, key, hash);
 
        /* Copy key+value *before* allocating free space in case malloc
@@ -596,7 +596,7 @@ static int _tdb1_store(struct tdb1_context *tdb, TDB1_DATA key,
 
    return 0 on success, -1 on failure
 */
 
    return 0 on success, -1 on failure
 */
-int tdb1_store(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA dbuf, int flag)
+int tdb1_store(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag)
 {
        uint32_t hash;
        int ret;
 {
        uint32_t hash;
        int ret;
@@ -617,10 +617,10 @@ int tdb1_store(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA dbuf, int flag
 }
 
 /* Append to an entry. Create if not exist. */
 }
 
 /* Append to an entry. Create if not exist. */
-int tdb1_append(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA new_dbuf)
+int tdb1_append(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA new_dbuf)
 {
        uint32_t hash;
 {
        uint32_t hash;
-       TDB1_DATA dbuf;
+       TDB_DATA dbuf;
        int ret = -1;
 
        /* find which hash bucket it is in */
        int ret = -1;
 
        /* find which hash bucket it is in */
@@ -819,10 +819,10 @@ struct traverse_state {
 /*
   traverse function for repacking
  */
 /*
   traverse function for repacking
  */
-static int repack_traverse(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA data, void *private_data)
+static int repack_traverse(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA data, void *private_data)
 {
        struct traverse_state *state = (struct traverse_state *)private_data;
 {
        struct traverse_state *state = (struct traverse_state *)private_data;
-       if (tdb1_store(state->dest_db, key, data, TDB1_INSERT) != 0) {
+       if (tdb1_store(state->dest_db, key, data, TDB_INSERT) != 0) {
                state->error = state->dest_db->last_error;
                return -1;
        }
                state->error = state->dest_db->last_error;
                return -1;
        }
index 165fd7f972f5b74dd0d1de0271c97ec9e502ebbe..51aa2e11b00b38066f38afbc3e8b89b35c9e9f4b 100644 (file)
@@ -478,7 +478,7 @@ static int _tdb1_transaction_start(struct tdb1_context *tdb)
        /* get the transaction write lock. This is a blocking lock. As
           discussed with Volker, there are a number of ways we could
           make this async, which we will probably do in the future */
        /* get the transaction write lock. This is a blocking lock. As
           discussed with Volker, there are a number of ways we could
           make this async, which we will probably do in the future */
-       if (tdb1_transaction_lock(tdb, F_WRLCK, TDB1_LOCK_WAIT) == -1) {
+       if (tdb1_transaction_lock(tdb, F_WRLCK, TDB_LOCK_WAIT) == -1) {
                SAFE_FREE(tdb->transaction->blocks);
                SAFE_FREE(tdb->transaction);
                return -1;
                SAFE_FREE(tdb->transaction->blocks);
                SAFE_FREE(tdb->transaction);
                return -1;
@@ -486,7 +486,7 @@ static int _tdb1_transaction_start(struct tdb1_context *tdb)
 
        /* get a read lock from the freelist to the end of file. This
           is upgraded to a write lock during the commit */
 
        /* get a read lock from the freelist to the end of file. This
           is upgraded to a write lock during the commit */
-       if (tdb1_allrecord_lock(tdb, F_RDLCK, TDB1_LOCK_WAIT, true) == -1) {
+       if (tdb1_allrecord_lock(tdb, F_RDLCK, TDB_LOCK_WAIT, true) == -1) {
                tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
                           "tdb1_transaction_start: failed to get hash locks");
                goto fail_allrecord_lock;
                tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
                           "tdb1_transaction_start: failed to get hash locks");
                goto fail_allrecord_lock;
@@ -973,7 +973,7 @@ static int _tdb1_transaction_prepare_commit(struct tdb1_context *tdb)
 
        /* get the open lock - this prevents new users attaching to the database
           during the commit */
 
        /* get the open lock - this prevents new users attaching to the database
           during the commit */
-       if (tdb1_nest_lock(tdb, TDB1_OPEN_LOCK, F_WRLCK, TDB1_LOCK_WAIT) == -1) {
+       if (tdb1_nest_lock(tdb, TDB1_OPEN_LOCK, F_WRLCK, TDB_LOCK_WAIT) == -1) {
                tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
                           "tdb1_transaction_prepare_commit:"
                           " failed to get open lock");
                tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
                           "tdb1_transaction_prepare_commit:"
                           " failed to get open lock");
index 13813eebbb3179c3a0ee92578e944a11482b108e..23897c14419e6ec55212c1810944489f52265945 100644 (file)
@@ -147,7 +147,7 @@ static int tdb1_traverse_internal(struct tdb1_context *tdb,
                                 tdb1_traverse_func fn, void *private_data,
                                 struct tdb1_traverse_lock *tl)
 {
                                 tdb1_traverse_func fn, void *private_data,
                                 struct tdb1_traverse_lock *tl)
 {
-       TDB1_DATA key, dbuf;
+       TDB_DATA key, dbuf;
        struct tdb1_record rec;
        int ret = 0, count = 0;
        tdb1_off_t off;
        struct tdb1_record rec;
        int ret = 0, count = 0;
        tdb1_off_t off;
@@ -223,7 +223,7 @@ int tdb1_traverse_read(struct tdb1_context *tdb,
 
        /* we need to get a read lock on the transaction lock here to
           cope with the lock ordering semantics of solaris10 */
 
        /* we need to get a read lock on the transaction lock here to
           cope with the lock ordering semantics of solaris10 */
-       if (tdb1_transaction_lock(tdb, F_RDLCK, TDB1_LOCK_WAIT)) {
+       if (tdb1_transaction_lock(tdb, F_RDLCK, TDB_LOCK_WAIT)) {
                return -1;
        }
 
                return -1;
        }
 
@@ -253,7 +253,7 @@ int tdb1_traverse(struct tdb1_context *tdb,
                return tdb1_traverse_read(tdb, fn, private_data);
        }
 
                return tdb1_traverse_read(tdb, fn, private_data);
        }
 
-       if (tdb1_transaction_lock(tdb, F_WRLCK, TDB1_LOCK_WAIT)) {
+       if (tdb1_transaction_lock(tdb, F_WRLCK, TDB_LOCK_WAIT)) {
                return -1;
        }
 
                return -1;
        }
 
@@ -268,9 +268,9 @@ int tdb1_traverse(struct tdb1_context *tdb,
 
 
 /* find the first entry in the database and return its key */
 
 
 /* find the first entry in the database and return its key */
-TDB1_DATA tdb1_firstkey(struct tdb1_context *tdb)
+TDB_DATA tdb1_firstkey(struct tdb1_context *tdb)
 {
 {
-       TDB1_DATA key;
+       TDB_DATA key;
        struct tdb1_record rec;
        tdb1_off_t off;
 
        struct tdb1_record rec;
        tdb1_off_t off;
 
@@ -298,10 +298,10 @@ TDB1_DATA tdb1_firstkey(struct tdb1_context *tdb)
 }
 
 /* find the next entry in the database, returning its key */
 }
 
 /* find the next entry in the database, returning its key */
-TDB1_DATA tdb1_nextkey(struct tdb1_context *tdb, TDB1_DATA oldkey)
+TDB_DATA tdb1_nextkey(struct tdb1_context *tdb, TDB_DATA oldkey)
 {
        uint32_t oldhash;
 {
        uint32_t oldhash;
-       TDB1_DATA key = tdb1_null;
+       TDB_DATA key = tdb1_null;
        struct tdb1_record rec;
        unsigned char *k = NULL;
        tdb1_off_t off;
        struct tdb1_record rec;
        unsigned char *k = NULL;
        tdb1_off_t off;
index fd66c047b1f1e64e29229302965e895b8d024c42..6121b4de48f7ee35693b220d9e5729d2dad4269f 100644 (file)
@@ -46,10 +46,10 @@ static const struct tdb1_methods large_io_methods = {
        tdb1_expand_file_sparse
 };
 
        tdb1_expand_file_sparse
 };
 
-static int test_traverse(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA data,
+static int test_traverse(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA data,
                         void *_data)
 {
                         void *_data)
 {
-       TDB1_DATA *expect = _data;
+       TDB_DATA *expect = _data;
        ok1(key.dsize == strlen("hi"));
        ok1(memcmp(key.dptr, "hi", strlen("hi")) == 0);
        ok1(data.dsize == expect->dsize);
        ok1(key.dsize == strlen("hi"));
        ok1(memcmp(key.dptr, "hi", strlen("hi")) == 0);
        ok1(data.dsize == expect->dsize);
@@ -60,7 +60,7 @@ static int test_traverse(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA data
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
-       TDB1_DATA key, orig_data, data;
+       TDB_DATA key, orig_data, data;
        uint32_t hash;
        tdb1_off_t rec_ptr;
        struct tdb1_record rec;
        uint32_t hash;
        tdb1_off_t rec_ptr;
        struct tdb1_record rec;
@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
        orig_data.dsize = strlen("world");
        orig_data.dptr = (void *)"world";
 
        orig_data.dsize = strlen("world");
        orig_data.dptr = (void *)"world";
 
-       ok1(tdb1_store(tdb, key, orig_data, TDB1_INSERT) == 0);
+       ok1(tdb1_store(tdb, key, orig_data, TDB_INSERT) == 0);
 
        data = tdb1_fetch(tdb, key);
        ok1(data.dsize == strlen("world"));
 
        data = tdb1_fetch(tdb, key);
        ok1(data.dsize == strlen("world"));
@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
 
        /* Transactions should work. */
        ok1(tdb1_transaction_start(tdb) == 0);
 
        /* Transactions should work. */
        ok1(tdb1_transaction_start(tdb) == 0);
-       ok1(tdb1_store(tdb, key, orig_data, TDB1_INSERT) == 0);
+       ok1(tdb1_store(tdb, key, orig_data, TDB_INSERT) == 0);
 
        data = tdb1_fetch(tdb, key);
        ok1(data.dsize == strlen("world"));
 
        data = tdb1_fetch(tdb, key);
        ok1(data.dsize == strlen("world"));
index b3b240e0020fda8a14a499167ebc3a9af3aea733..fb49b64e48e0ff452f4acf6a3015702f727433c8 100644 (file)
@@ -7,7 +7,7 @@
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
-       TDB1_DATA key, data;
+       TDB_DATA key, data;
 
        plan_tests(13);
        tdb = tdb1_open_ex("run-check.tdb", 1, TDB1_CLEAR_IF_FIRST,
 
        plan_tests(13);
        tdb = tdb1_open_ex("run-check.tdb", 1, TDB1_CLEAR_IF_FIRST,
@@ -21,7 +21,7 @@ int main(int argc, char *argv[])
        data.dsize = strlen("world");
        data.dptr = (void *)"world";
 
        data.dsize = strlen("world");
        data.dptr = (void *)"world";
 
-       ok1(tdb1_store(tdb, key, data, TDB1_INSERT) == 0);
+       ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
        ok1(tdb1_check(tdb, NULL, NULL) == 0);
        tdb1_close(tdb);
 
        ok1(tdb1_check(tdb, NULL, NULL) == 0);
        tdb1_close(tdb);
 
index b2dcafadc0e110b59690d828547c575989e0a0d3..bfc25a571110d80e283dd2fdf6202950c155dff1 100644 (file)
@@ -4,7 +4,7 @@
 #include <err.h>
 #include "tdb1-logging.h"
 
 #include <err.h>
 #include "tdb1-logging.h"
 
-static int check(TDB1_DATA key, TDB1_DATA data, void *private)
+static int check(TDB_DATA key, TDB_DATA data, void *private)
 {
        unsigned int *sizes = private;
 
 {
        unsigned int *sizes = private;
 
@@ -42,7 +42,7 @@ static void tdb1_flip_bit(struct tdb1_context *tdb, unsigned int bit)
 
 static void check_test(struct tdb1_context *tdb)
 {
 
 static void check_test(struct tdb1_context *tdb)
 {
-       TDB1_DATA key, data;
+       TDB_DATA key, data;
        unsigned int i, verifiable, corrupt, sizes[2], dsize, ksize;
 
        ok1(tdb1_check(tdb, NULL, NULL) == 0);
        unsigned int i, verifiable, corrupt, sizes[2], dsize, ksize;
 
        ok1(tdb1_check(tdb, NULL, NULL) == 0);
@@ -58,13 +58,13 @@ static void check_test(struct tdb1_context *tdb)
        for (key.dsize = 1; key.dsize <= 5; key.dsize++) {
                ksize += key.dsize;
                dsize += data.dsize;
        for (key.dsize = 1; key.dsize <= 5; key.dsize++) {
                ksize += key.dsize;
                dsize += data.dsize;
-               if (tdb1_store(tdb, key, data, TDB1_INSERT) != 0)
+               if (tdb1_store(tdb, key, data, TDB_INSERT) != 0)
                        abort();
        }
 
        /* This is how many bytes we expect to be verifiable. */
        /* From the file header. */
                        abort();
        }
 
        /* This is how many bytes we expect to be verifiable. */
        /* From the file header. */
-       verifiable = strlen(TDB1_MAGIC_FOOD) + 1
+       verifiable = strlen(TDB_MAGIC_FOOD) + 1
                + 2 * sizeof(uint32_t) + 2 * sizeof(tdb1_off_t)
                + 2 * sizeof(uint32_t);
        /* From the free list chain and hash chains. */
                + 2 * sizeof(uint32_t) + 2 * sizeof(tdb1_off_t)
                + 2 * sizeof(uint32_t);
        /* From the free list chain and hash chains. */
index ae03d5f8b94d8cbc16b25b02e709167a8dbcf5a6..3097e13a3395896ebfffeb7c416beb9f1daaf9ec 100644 (file)
@@ -82,7 +82,7 @@ static int ftruncate_check(int fd, off_t length)
 static bool test_death(enum operation op, struct agent *agent)
 {
        struct tdb1_context *tdb = NULL;
 static bool test_death(enum operation op, struct agent *agent)
 {
        struct tdb1_context *tdb = NULL;
-       TDB1_DATA key;
+       TDB_DATA key;
        enum agent_return ret;
        int needed_recovery = 0;
 
        enum agent_return ret;
        int needed_recovery = 0;
 
@@ -150,7 +150,7 @@ reset:
        /* Put key for agent to fetch. */
        key.dsize = strlen(KEY_STRING);
        key.dptr = (void *)KEY_STRING;
        /* Put key for agent to fetch. */
        key.dsize = strlen(KEY_STRING);
        key.dptr = (void *)KEY_STRING;
-       if (tdb1_store(tdb, key, key, TDB1_INSERT) != 0)
+       if (tdb1_store(tdb, key, key, TDB_INSERT) != 0)
                return false;
 
        /* This is the key we insert in transaction. */
                return false;
 
        /* This is the key we insert in transaction. */
@@ -168,7 +168,7 @@ reset:
        if (tdb1_transaction_start(tdb) != 0)
                return false;
 
        if (tdb1_transaction_start(tdb) != 0)
                return false;
 
-       if (tdb1_store(tdb, key, key, TDB1_INSERT) != 0)
+       if (tdb1_store(tdb, key, key, TDB_INSERT) != 0)
                return false;
 
        if (tdb1_transaction_commit(tdb) != 0)
                return false;
 
        if (tdb1_transaction_commit(tdb) != 0)
index 7691260606fd486490131985606868d2b76d7d89..35067d7182b10794e9cdc5401db218925b9473f6 100644 (file)
@@ -7,7 +7,7 @@
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
-       TDB1_DATA key, data;
+       TDB_DATA key, data;
 
        plan_tests(13);
        tdb = tdb1_open_ex("run-endian.tdb", 1024,
 
        plan_tests(13);
        tdb = tdb1_open_ex("run-endian.tdb", 1024,
@@ -20,12 +20,12 @@ int main(int argc, char *argv[])
        data.dsize = strlen("world");
        data.dptr = (void *)"world";
 
        data.dsize = strlen("world");
        data.dptr = (void *)"world";
 
-       ok1(tdb1_store(tdb, key, data, TDB1_MODIFY) < 0);
+       ok1(tdb1_store(tdb, key, data, TDB_MODIFY) < 0);
        ok1(tdb_error(tdb) == TDB_ERR_NOEXIST);
        ok1(tdb_error(tdb) == TDB_ERR_NOEXIST);
-       ok1(tdb1_store(tdb, key, data, TDB1_INSERT) == 0);
-       ok1(tdb1_store(tdb, key, data, TDB1_INSERT) < 0);
+       ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
+       ok1(tdb1_store(tdb, key, data, TDB_INSERT) < 0);
        ok1(tdb_error(tdb) == TDB_ERR_EXISTS);
        ok1(tdb_error(tdb) == TDB_ERR_EXISTS);
-       ok1(tdb1_store(tdb, key, data, TDB1_MODIFY) == 0);
+       ok1(tdb1_store(tdb, key, data, TDB_MODIFY) == 0);
 
        data = tdb1_fetch(tdb, key);
        ok1(data.dsize == strlen("world"));
 
        data = tdb1_fetch(tdb, key);
        ok1(data.dsize == strlen("world"));
index 13ba810169f9bb9a53ed1fc9d8a937023938cbf6..51aa52d4b7e58744defbe0e86359f66051cb13c4 100644 (file)
@@ -3,7 +3,7 @@
 #include <stdlib.h>
 #include <err.h>
 
 #include <stdlib.h>
 #include <err.h>
 
-static unsigned int tdb1_dumb_hash(TDB1_DATA *key)
+static unsigned int tdb1_dumb_hash(TDB_DATA *key)
 {
        return key->dsize;
 }
 {
        return key->dsize;
 }
@@ -35,7 +35,7 @@ int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
        unsigned int log_count, flags;
 {
        struct tdb1_context *tdb;
        unsigned int log_count, flags;
-       TDB1_DATA d;
+       TDB_DATA d;
        struct tdb1_logging_context log_ctx = { log_fn, &log_count };
 
        plan_tests(38 * 2);
        struct tdb1_logging_context log_ctx = { log_fn, &log_count };
 
        plan_tests(38 * 2);
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
                ok1(log_count == 0);
                d.dptr = (void *)"Hello";
                d.dsize = 5;
                ok1(log_count == 0);
                d.dptr = (void *)"Hello";
                d.dsize = 5;
-               ok1(tdb1_store(tdb, d, d, TDB1_INSERT) == 0);
+               ok1(tdb1_store(tdb, d, d, TDB_INSERT) == 0);
                tdb1_close(tdb);
 
                /* Should not have marked rwlocks field. */
                tdb1_close(tdb);
 
                /* Should not have marked rwlocks field. */
@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
                ok1(log_count == 0);
                d.dptr = (void *)"Hello";
                d.dsize = 5;
                ok1(log_count == 0);
                d.dptr = (void *)"Hello";
                d.dsize = 5;
-               ok1(tdb1_store(tdb, d, d, TDB1_INSERT) == 0);
+               ok1(tdb1_store(tdb, d, d, TDB_INSERT) == 0);
                tdb1_close(tdb);
 
                /* Should have marked rwlocks field. */
                tdb1_close(tdb);
 
                /* Should have marked rwlocks field. */
@@ -149,7 +149,7 @@ int main(int argc, char *argv[])
                ok1(log_count == 0);
                d.dptr = (void *)"Hello";
                d.dsize = 5;
                ok1(log_count == 0);
                d.dptr = (void *)"Hello";
                d.dsize = 5;
-               ok1(tdb1_store(tdb, d, d, TDB1_INSERT) == 0);
+               ok1(tdb1_store(tdb, d, d, TDB_INSERT) == 0);
                tdb1_close(tdb);
 
                /* Should have marked rwlocks field. */
                tdb1_close(tdb);
 
                /* Should have marked rwlocks field. */
index e9640990e02945bddf952cabf3b431b8db0f912e..f9891fe70da3b6d66bfabbf13edbba06b6866aab 100644 (file)
@@ -8,7 +8,7 @@
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
-       TDB1_DATA key, data;
+       TDB_DATA key, data;
 
        plan_tests(27);
        key.dsize = strlen("hi");
 
        plan_tests(27);
        key.dsize = strlen("hi");
@@ -22,7 +22,7 @@ int main(int argc, char *argv[])
        ok1(tdb1_transaction_start(tdb) == 0);
        data.dptr = (void *)"world";
        data.dsize = strlen("world");
        ok1(tdb1_transaction_start(tdb) == 0);
        data.dptr = (void *)"world";
        data.dsize = strlen("world");
-       ok1(tdb1_store(tdb, key, data, TDB1_INSERT) == 0);
+       ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
        data = tdb1_fetch(tdb, key);
        ok1(data.dsize == strlen("world"));
        ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
        data = tdb1_fetch(tdb, key);
        ok1(data.dsize == strlen("world"));
        ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
index 9a17b5601983cfe7b2670f295c7506af8e3baf7f..a33efec735012f0991ca53dd6692313916fb1848 100644 (file)
 
 static struct agent *agent;
 
 
 static struct agent *agent;
 
-static bool correct_key(TDB1_DATA key)
+static bool correct_key(TDB_DATA key)
 {
        return key.dsize == strlen("hi")
                && memcmp(key.dptr, "hi", key.dsize) == 0;
 }
 
 {
        return key.dsize == strlen("hi")
                && memcmp(key.dptr, "hi", key.dsize) == 0;
 }
 
-static bool correct_data(TDB1_DATA data)
+static bool correct_data(TDB_DATA data)
 {
        return data.dsize == strlen("world")
                && memcmp(data.dptr, "world", data.dsize) == 0;
 }
 
 {
        return data.dsize == strlen("world")
                && memcmp(data.dptr, "world", data.dsize) == 0;
 }
 
-static int traverse2(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA data,
+static int traverse2(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA data,
                     void *p)
 {
        ok1(correct_key(key));
                     void *p)
 {
        ok1(correct_key(key));
@@ -31,7 +31,7 @@ static int traverse2(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA data,
        return 0;
 }
 
        return 0;
 }
 
-static int traverse1(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA data,
+static int traverse1(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA data,
                     void *p)
 {
        ok1(correct_key(key));
                     void *p)
 {
        ok1(correct_key(key));
@@ -49,7 +49,7 @@ static int traverse1(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA data,
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
-       TDB1_DATA key, data;
+       TDB_DATA key, data;
 
        plan_tests(17);
        agent = prepare_external_agent1();
 
        plan_tests(17);
        agent = prepare_external_agent1();
@@ -71,7 +71,7 @@ int main(int argc, char *argv[])
        data.dptr = (void *)"world";
        data.dsize = strlen("world");
 
        data.dptr = (void *)"world";
        data.dsize = strlen("world");
 
-       ok1(tdb1_store(tdb, key, data, TDB1_INSERT) == 0);
+       ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
        tdb1_traverse(tdb, traverse1, NULL);
        tdb1_traverse_read(tdb, traverse1, NULL);
        tdb1_close(tdb);
        tdb1_traverse(tdb, traverse1, NULL);
        tdb1_traverse_read(tdb, traverse1, NULL);
        tdb1_close(tdb);
index 570562991d4ce65b7d635d1653697ac3e893070d..4035c78c734d59c7e5cf376abe61aa82467733c9 100644 (file)
@@ -17,7 +17,7 @@
 static bool prepare_entries(struct tdb1_context *tdb)
 {
        unsigned int i;
 static bool prepare_entries(struct tdb1_context *tdb)
 {
        unsigned int i;
-       TDB1_DATA key, data;
+       TDB_DATA key, data;
 
        for (i = 0; i < NUM_ENTRIES; i++) {
                key.dsize = sizeof(i);
 
        for (i = 0; i < NUM_ENTRIES; i++) {
                key.dsize = sizeof(i);
@@ -34,7 +34,7 @@ static bool prepare_entries(struct tdb1_context *tdb)
 static void delete_entries(struct tdb1_context *tdb)
 {
        unsigned int i;
 static void delete_entries(struct tdb1_context *tdb)
 {
        unsigned int i;
-       TDB1_DATA key;
+       TDB_DATA key;
 
        for (i = 0; i < NUM_ENTRIES; i++) {
                key.dsize = sizeof(i);
 
        for (i = 0; i < NUM_ENTRIES; i++) {
                key.dsize = sizeof(i);
@@ -45,7 +45,7 @@ static void delete_entries(struct tdb1_context *tdb)
 }
 
 /* We don't know how many times this will run. */
 }
 
 /* We don't know how many times this will run. */
-static int delete_other(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA data,
+static int delete_other(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA data,
                        void *private_data)
 {
        unsigned int i;
                        void *private_data)
 {
        unsigned int i;
@@ -57,7 +57,7 @@ static int delete_other(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA data,
        return 0;
 }
 
        return 0;
 }
 
-static int delete_self(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA data,
+static int delete_self(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA data,
                        void *private_data)
 {
        ok1(tdb1_delete(tdb, key) == 0);
                        void *private_data)
 {
        ok1(tdb1_delete(tdb, key) == 0);
index 7b22320a730ab30aba48fe6e5760569d6c5baf1f..ad6c6d60747ad1fce02cd17bd0e52f5e863135e6 100644 (file)
@@ -138,7 +138,7 @@ int main(int argc, char *argv[])
                              TDB1_CLEAR_IF_FIRST | TDB1_NOMMAP };
        int i;
        struct tdb1_context *tdb;
                              TDB1_CLEAR_IF_FIRST | TDB1_NOMMAP };
        int i;
        struct tdb1_context *tdb;
-       TDB1_DATA key, data;
+       TDB_DATA key, data;
 
        plan_tests(20);
        agent = prepare_external_agent1();
 
        plan_tests(20);
        agent = prepare_external_agent1();
@@ -164,7 +164,7 @@ int main(int argc, char *argv[])
                data.dptr = (void *)"world";
                data.dsize = strlen("world");
 
                data.dptr = (void *)"world";
                data.dsize = strlen("world");
 
-               ok1(tdb1_store(tdb, key, data, TDB1_INSERT) == 0);
+               ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
                ok1(tdb1_transaction_commit(tdb) == 0);
                ok(!errors, "We had %u open errors", errors);
 
                ok1(tdb1_transaction_commit(tdb) == 0);
                ok(!errors, "We had %u open errors", errors);
 
index 6bfa0dc3f5ad4ac434c88c24c5c4b56532094a71..a764f2da428d68a5b1956237733ba364be808323 100644 (file)
@@ -9,7 +9,7 @@
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
-       TDB1_DATA key, data;
+       TDB_DATA key, data;
 
        plan_tests(11);
        tdb = tdb1_open_ex("run-readonly-check.tdb", 1024,
 
        plan_tests(11);
        tdb = tdb1_open_ex("run-readonly-check.tdb", 1024,
@@ -22,7 +22,7 @@ int main(int argc, char *argv[])
        data.dsize = strlen("world");
        data.dptr = (void *)"world";
 
        data.dsize = strlen("world");
        data.dptr = (void *)"world";
 
-       ok1(tdb1_store(tdb, key, data, TDB1_INSERT) == 0);
+       ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
        ok1(tdb1_check(tdb, NULL, NULL) == 0);
 
        /* We are also allowed to do a check inside a transaction. */
        ok1(tdb1_check(tdb, NULL, NULL) == 0);
 
        /* We are also allowed to do a check inside a transaction. */
@@ -34,7 +34,7 @@ int main(int argc, char *argv[])
                          TDB1_DEFAULT, O_RDONLY, 0, &taplogctx, NULL);
 
        ok1(tdb);
                          TDB1_DEFAULT, O_RDONLY, 0, &taplogctx, NULL);
 
        ok1(tdb);
-       ok1(tdb1_store(tdb, key, data, TDB1_MODIFY) == -1);
+       ok1(tdb1_store(tdb, key, data, TDB_MODIFY) == -1);
        ok1(tdb_error(tdb) == TDB_ERR_RDONLY);
        ok1(tdb1_check(tdb, NULL, NULL) == 0);
        ok1(tdb1_close(tdb) == 0);
        ok1(tdb_error(tdb) == TDB_ERR_RDONLY);
        ok1(tdb1_check(tdb, NULL, NULL) == 0);
        ok1(tdb1_close(tdb) == 0);
index ccfc0958e11a1cdcef3689d459b79faef3c97f9b..616c5225079d5fdcdbcadeb4519944ab583d4037 100644 (file)
@@ -10,8 +10,8 @@ int main(int argc, char *argv[])
        int flags[] = { TDB1_INTERNAL, TDB1_DEFAULT, TDB1_NOMMAP,
                        TDB1_INTERNAL|TDB1_CONVERT, TDB1_CONVERT,
                        TDB1_NOMMAP|TDB1_CONVERT };
        int flags[] = { TDB1_INTERNAL, TDB1_DEFAULT, TDB1_NOMMAP,
                        TDB1_INTERNAL|TDB1_CONVERT, TDB1_CONVERT,
                        TDB1_NOMMAP|TDB1_CONVERT };
-       TDB1_DATA key = { (unsigned char *)&j, sizeof(j) };
-       TDB1_DATA data = { (unsigned char *)&j, sizeof(j) };
+       TDB_DATA key = { (unsigned char *)&j, sizeof(j) };
+       TDB_DATA data = { (unsigned char *)&j, sizeof(j) };
        char *summary;
 
        plan_tests(sizeof(flags) / sizeof(flags[0]) * 14);
        char *summary;
 
        plan_tests(sizeof(flags) / sizeof(flags[0]) * 14);
@@ -26,7 +26,7 @@ int main(int argc, char *argv[])
                for (j = 0; j < 500; j++) {
                        /* Make sure padding varies to we get some graphs! */
                        data.dsize = j % (sizeof(j) + 1);
                for (j = 0; j < 500; j++) {
                        /* Make sure padding varies to we get some graphs! */
                        data.dsize = j % (sizeof(j) + 1);
-                       if (tdb1_store(tdb, key, data, TDB1_REPLACE) != 0)
+                       if (tdb1_store(tdb, key, data, TDB_REPLACE) != 0)
                                fail("Storing in tdb");
                }
 
                                fail("Storing in tdb");
                }
 
index 9cb70686fe4e85242c99d7294901ff827ee1b471..4d3a81f19ea3cf424fc52bf8e4de9a8081d19b1b 100644 (file)
 
 static struct agent *agent;
 
 
 static struct agent *agent;
 
-static bool correct_key(TDB1_DATA key)
+static bool correct_key(TDB_DATA key)
 {
        return key.dsize == strlen("hi")
                && memcmp(key.dptr, "hi", key.dsize) == 0;
 }
 
 {
        return key.dsize == strlen("hi")
                && memcmp(key.dptr, "hi", key.dsize) == 0;
 }
 
-static bool correct_data(TDB1_DATA data)
+static bool correct_data(TDB_DATA data)
 {
        return data.dsize == strlen("world")
                && memcmp(data.dptr, "world", data.dsize) == 0;
 }
 
 {
        return data.dsize == strlen("world")
                && memcmp(data.dptr, "world", data.dsize) == 0;
 }
 
-static int traverse(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA data,
+static int traverse(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA data,
                     void *p)
 {
        ok1(correct_key(key));
                     void *p)
 {
        ok1(correct_key(key));
@@ -35,7 +35,7 @@ static int traverse(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA data,
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
-       TDB1_DATA key, data;
+       TDB_DATA key, data;
 
        plan_tests(13);
        agent = prepare_external_agent1();
 
        plan_tests(13);
        agent = prepare_external_agent1();
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
        data.dptr = (void *)"world";
        data.dsize = strlen("world");
 
        data.dptr = (void *)"world";
        data.dsize = strlen("world");
 
-       ok1(tdb1_store(tdb, key, data, TDB1_INSERT) == 0);
+       ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
 
        ok1(external_agent_operation1(agent, OPEN, tdb->name) == SUCCESS);
 
 
        ok1(external_agent_operation1(agent, OPEN, tdb->name) == SUCCESS);
 
index 59bfbbeccb076ad73ab4442671a4f9ac7a7fc95b..368835ed7f263a73e0d34769da078b4965cc7c0c 100644 (file)
@@ -15,7 +15,7 @@ int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
        unsigned int log_count;
 {
        struct tdb1_context *tdb;
        unsigned int log_count;
-       TDB1_DATA d;
+       TDB_DATA d;
        struct tdb1_logging_context log_ctx = { log_fn, &log_count };
 
        plan_tests(28);
        struct tdb1_logging_context log_ctx = { log_fn, &log_count };
 
        plan_tests(28);
@@ -28,7 +28,7 @@ int main(int argc, char *argv[])
        ok1(log_count == 0);
        d.dptr = (void *)"Hello";
        d.dsize = 5;
        ok1(log_count == 0);
        d.dptr = (void *)"Hello";
        d.dsize = 5;
-       ok1(tdb1_store(tdb, d, d, TDB1_INSERT) == 0);
+       ok1(tdb1_store(tdb, d, d, TDB_INSERT) == 0);
        tdb1_close(tdb);
 
        /* Fail to open with different hash. */
        tdb1_close(tdb);
 
        /* Fail to open with different hash. */
index e79ab60a00e6f967ac18b4f92ef0f9ff7b2f5cf3..1ecab54ce41465c748bcf26152753bbe304d36a7 100644 (file)
@@ -7,7 +7,7 @@
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
-       TDB1_DATA key, data;
+       TDB_DATA key, data;
 
        plan_tests(4);
        tdb = tdb1_open_ex(NULL, 1024, TDB1_INTERNAL, O_CREAT|O_TRUNC|O_RDWR,
 
        plan_tests(4);
        tdb = tdb1_open_ex(NULL, 1024, TDB1_INTERNAL, O_CREAT|O_TRUNC|O_RDWR,
index 30de924cd205b970e5ce4d02f0e238d0309645e8..1f234b12e3433232e34391c4a383ee069fd6a651 100644 (file)
@@ -7,7 +7,7 @@
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
 int main(int argc, char *argv[])
 {
        struct tdb1_context *tdb;
-       TDB1_DATA key, data;
+       TDB_DATA key, data;
 
        plan_tests(10);
        tdb = tdb1_open_ex("run.tdb", 1024, TDB1_CLEAR_IF_FIRST,
 
        plan_tests(10);
        tdb = tdb1_open_ex("run.tdb", 1024, TDB1_CLEAR_IF_FIRST,
@@ -19,12 +19,12 @@ int main(int argc, char *argv[])
        data.dsize = strlen("world");
        data.dptr = (void *)"world";
 
        data.dsize = strlen("world");
        data.dptr = (void *)"world";
 
-       ok1(tdb1_store(tdb, key, data, TDB1_MODIFY) < 0);
+       ok1(tdb1_store(tdb, key, data, TDB_MODIFY) < 0);
        ok1(tdb_error(tdb) == TDB_ERR_NOEXIST);
        ok1(tdb_error(tdb) == TDB_ERR_NOEXIST);
-       ok1(tdb1_store(tdb, key, data, TDB1_INSERT) == 0);
-       ok1(tdb1_store(tdb, key, data, TDB1_INSERT) < 0);
+       ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
+       ok1(tdb1_store(tdb, key, data, TDB_INSERT) < 0);
        ok1(tdb_error(tdb) == TDB_ERR_EXISTS);
        ok1(tdb_error(tdb) == TDB_ERR_EXISTS);
-       ok1(tdb1_store(tdb, key, data, TDB1_MODIFY) == 0);
+       ok1(tdb1_store(tdb, key, data, TDB_MODIFY) == 0);
 
        data = tdb1_fetch(tdb, key);
        ok1(data.dsize == strlen("world"));
 
        data = tdb1_fetch(tdb, key);
        ok1(data.dsize == strlen("world"));
index 7ccbd9ca37164b17f38261e1ad86ee8d81c065dc..f60df5b7025b0feaca808bb585450ac4861b6265 100644 (file)
@@ -20,9 +20,9 @@ static struct tdb1_context *tdb;
 
 static enum agent_return do_operation(enum operation op, const char *name)
 {
 
 static enum agent_return do_operation(enum operation op, const char *name)
 {
-       TDB1_DATA k;
+       TDB_DATA k;
        enum agent_return ret;
        enum agent_return ret;
-       TDB1_DATA data;
+       TDB_DATA data;
 
        if (op != OPEN && op != OPEN_WITH_CLEAR_IF_FIRST && !tdb) {
                diag("external: No tdb open!");
 
        if (op != OPEN && op != OPEN_WITH_CLEAR_IF_FIRST && !tdb) {
                diag("external: No tdb open!");