tdb: rename 'struct list_struct' into 'struct tdb_record'
authorStefan Metzmacher <metze@samba.org>
Fri, 23 Oct 2009 11:51:03 +0000 (13:51 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 23 Oct 2009 16:27:20 +0000 (18:27 +0200)
metze

lib/tdb/common/check.c
lib/tdb/common/dump.c
lib/tdb/common/freelist.c
lib/tdb/common/freelistcheck.c
lib/tdb/common/io.c
lib/tdb/common/tdb.c
lib/tdb/common/tdb_private.h
lib/tdb/common/transaction.c
lib/tdb/common/traverse.c

index 94240bbed1b0711e9d7a1d3b84d194b10827f0a6..4924734fdd8134c7db1a2b2972631d2988f280ce 100644 (file)
@@ -63,7 +63,7 @@ corrupt:
 /* Generic record header check. */
 static bool tdb_check_record(struct tdb_context *tdb,
                             tdb_off_t off,
-                            const struct list_struct *rec)
+                            const struct tdb_record *rec)
 {
        tdb_off_t tailer;
 
@@ -228,7 +228,7 @@ static void record_offset(unsigned char bits[], tdb_off_t off)
 /* Check that an in-use record is valid. */
 static bool tdb_check_used_record(struct tdb_context *tdb,
                                  tdb_off_t off,
-                                 const struct list_struct *rec,
+                                 const struct tdb_record *rec,
                                  unsigned char **hashes,
                                  int (*check)(TDB_DATA, TDB_DATA, void *),
                                  void *private_data)
@@ -287,7 +287,7 @@ fail_put_key:
 /* Check that an unused record is valid. */
 static bool tdb_check_free_record(struct tdb_context *tdb,
                                  tdb_off_t off,
-                                 const struct list_struct *rec,
+                                 const struct tdb_record *rec,
                                  unsigned char **hashes)
 {
        if (!tdb_check_record(tdb, off, rec))
@@ -308,7 +308,7 @@ int tdb_check(struct tdb_context *tdb,
        unsigned int h;
        unsigned char **hashes;
        tdb_off_t off, recovery_start;
-       struct list_struct rec;
+       struct tdb_record rec;
        bool found_recovery = false;
 
        if (tdb_lockall(tdb) == -1)
index d1c902ddfdab0d0f73983837a0b77c8dda30b413..bdcbfab139b3133acdae64c4e5dda0ad2c332cb7 100644 (file)
@@ -30,7 +30,7 @@
 static tdb_off_t tdb_dump_record(struct tdb_context *tdb, int hash,
                                 tdb_off_t offset)
 {
-       struct list_struct rec;
+       struct tdb_record rec;
        tdb_off_t tailer_ofs, tailer;
 
        if (tdb->methods->tdb_read(tdb, offset, (char *)&rec, 
@@ -95,7 +95,7 @@ int tdb_printfreelist(struct tdb_context *tdb)
        int ret;
        long total_free = 0;
        tdb_off_t offset, rec_ptr;
-       struct list_struct rec;
+       struct tdb_record rec;
 
        if ((ret = tdb_lock(tdb, -1, F_WRLCK)) != 0)
                return ret;
index dedf78cf921e98d80eeeb3968b3484b47b273bf2..8113b54951cf83324a086deb24521a5bb2c572f8 100644 (file)
@@ -34,7 +34,7 @@
 #define USE_RIGHT_MERGES 0
 
 /* read a freelist record and check for simple errors */
-int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off, struct list_struct *rec)
+int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off, struct tdb_record *rec)
 {
        if (tdb->methods->tdb_read(tdb, off, rec, sizeof(*rec),DOCONV()) == -1)
                return -1;
@@ -87,7 +87,7 @@ static int remove_from_freelist(struct tdb_context *tdb, tdb_off_t off, tdb_off_
 
 /* update a record tailer (must hold allocation lock) */
 static int update_tailer(struct tdb_context *tdb, tdb_off_t offset,
-                        const struct list_struct *rec)
+                        const struct tdb_record *rec)
 {
        tdb_off_t totalsize;
 
@@ -99,7 +99,7 @@ static int update_tailer(struct tdb_context *tdb, tdb_off_t offset,
 
 /* Add an element into the freelist. Merge adjacent records if
    neccessary. */
-int tdb_free(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec)
+int tdb_free(struct tdb_context *tdb, tdb_off_t offset, struct tdb_record *rec)
 {
        /* Allocation and tailer lock */
        if (tdb_lock(tdb, -1, F_WRLCK) != 0)
@@ -115,7 +115,7 @@ int tdb_free(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec)
        /* Look right first (I'm an Australian, dammit) */
        if (offset + sizeof(*rec) + rec->rec_len + sizeof(*rec) <= tdb->map_size) {
                tdb_off_t right = offset + sizeof(*rec) + rec->rec_len;
-               struct list_struct r;
+               struct tdb_record r;
 
                if (tdb->methods->tdb_read(tdb, right, &r, sizeof(r), DOCONV()) == -1) {
                        TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: right read failed at %u\n", right));
@@ -141,7 +141,7 @@ left:
        /* Look left */
        if (offset - sizeof(tdb_off_t) > TDB_DATA_START(tdb->header.hash_size)) {
                tdb_off_t left = offset - sizeof(tdb_off_t);
-               struct list_struct l;
+               struct tdb_record l;
                tdb_off_t leftsize;
                
                /* Read in tailer and jump back to header */
@@ -220,9 +220,9 @@ update:
  */
 static tdb_off_t tdb_allocate_ofs(struct tdb_context *tdb, 
                                  tdb_len_t length, tdb_off_t rec_ptr,
-                                 struct list_struct *rec, tdb_off_t last_ptr)
+                                 struct tdb_record *rec, tdb_off_t last_ptr)
 {
-#define MIN_REC_SIZE (sizeof(struct list_struct) + sizeof(tdb_off_t) + 8)
+#define MIN_REC_SIZE (sizeof(struct tdb_record) + sizeof(tdb_off_t) + 8)
 
        if (rec->rec_len < length + MIN_REC_SIZE) {
                /* we have to grab the whole record */
@@ -268,12 +268,12 @@ static tdb_off_t tdb_allocate_ofs(struct tdb_context *tdb,
 }
 
 /* allocate some space from the free list. The offset returned points
-   to a unconnected list_struct within the database with room for at
+   to a unconnected tdb_record within the database with room for at
    least length bytes of total data
 
    0 is returned if the space could not be allocated
  */
-tdb_off_t tdb_allocate(struct tdb_context *tdb, tdb_len_t length, struct list_struct *rec)
+tdb_off_t tdb_allocate(struct tdb_context *tdb, tdb_len_t length, struct tdb_record *rec)
 {
        tdb_off_t rec_ptr, last_ptr, newrec_ptr;
        struct {
index 972b2a41c49e32f8d7ff479490702973f43ecc95..8d1ebabe04e85c9c3650797bde2a83f187b9ce2b 100644 (file)
@@ -46,7 +46,7 @@ static int seen_insert(struct tdb_context *mem_tdb, tdb_off_t rec_ptr)
 int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries)
 {
        struct tdb_context *mem_tdb = NULL;
-       struct list_struct rec;
+       struct tdb_record rec;
        tdb_off_t rec_ptr, last_ptr;
        int ret = -1;
 
index cc52bcfd69f5b21c539f52b32172bd1a1a6ac119..d549715f831b414fc098b334a97f6572c74ffc76 100644 (file)
@@ -298,7 +298,7 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad
    file and doing the mmap again if necessary */
 int tdb_expand(struct tdb_context *tdb, tdb_off_t size)
 {
-       struct list_struct rec;
+       struct tdb_record rec;
        tdb_off_t offset, new_size;     
 
        if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
@@ -436,7 +436,7 @@ int tdb_parse_data(struct tdb_context *tdb, TDB_DATA key,
 }
 
 /* read/write a record */
-int tdb_rec_read(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec)
+int tdb_rec_read(struct tdb_context *tdb, tdb_off_t offset, struct tdb_record *rec)
 {
        if (tdb->methods->tdb_read(tdb, offset, rec, sizeof(*rec),DOCONV()) == -1)
                return -1;
@@ -449,9 +449,9 @@ int tdb_rec_read(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *
        return tdb->methods->tdb_oob(tdb, rec->next+sizeof(*rec), 0);
 }
 
-int tdb_rec_write(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec)
+int tdb_rec_write(struct tdb_context *tdb, tdb_off_t offset, struct tdb_record *rec)
 {
-       struct list_struct r = *rec;
+       struct tdb_record r = *rec;
        return tdb->methods->tdb_write(tdb, offset, CONVERT(r), sizeof(r));
 }
 
index 7ee0bb73005884280f3a31048f0fa691d3101e1a..0389d3cb961f83ceb6ab1eaa3246b5d99a2ca88a 100644 (file)
@@ -76,7 +76,7 @@ static int tdb_key_compare(TDB_DATA key, TDB_DATA data, void *private_data)
 /* Returns 0 on fail.  On success, return offset of record, and fills
    in rec */
 static tdb_off_t tdb_find(struct tdb_context *tdb, TDB_DATA key, uint32_t hash,
-                       struct list_struct *r)
+                       struct tdb_record *r)
 {
        tdb_off_t rec_ptr;
        
@@ -110,7 +110,7 @@ static tdb_off_t tdb_find(struct tdb_context *tdb, TDB_DATA key, uint32_t hash,
 
 /* As tdb_find, but if you succeed, keep the lock */
 tdb_off_t tdb_find_lock_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash, int locktype,
-                          struct list_struct *rec)
+                          struct tdb_record *rec)
 {
        uint32_t rec_ptr;
 
@@ -128,7 +128,7 @@ tdb_off_t tdb_find_lock_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t has
 */
 static int tdb_update_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash, TDB_DATA dbuf)
 {
-       struct list_struct rec;
+       struct tdb_record rec;
        tdb_off_t rec_ptr;
 
        /* find entry */
@@ -163,7 +163,7 @@ static int tdb_update_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash,
 static TDB_DATA _tdb_fetch(struct tdb_context *tdb, TDB_DATA key)
 {
        tdb_off_t rec_ptr;
-       struct list_struct rec;
+       struct tdb_record rec;
        TDB_DATA ret;
        uint32_t hash;
 
@@ -209,7 +209,7 @@ int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key,
                     void *private_data)
 {
        tdb_off_t rec_ptr;
-       struct list_struct rec;
+       struct tdb_record rec;
        int ret;
        uint32_t hash;
 
@@ -239,7 +239,7 @@ int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key,
 */
 static int tdb_exists_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash)
 {
-       struct list_struct rec;
+       struct tdb_record rec;
        
        if (tdb_find_lock_hash(tdb, key, hash, F_RDLCK, &rec) == 0)
                return 0;
@@ -258,10 +258,10 @@ int tdb_exists(struct tdb_context *tdb, TDB_DATA key)
 }
 
 /* actually delete an entry in the database given the offset */
-int tdb_do_delete(struct tdb_context *tdb, tdb_off_t rec_ptr, struct list_struct *rec)
+int tdb_do_delete(struct tdb_context *tdb, tdb_off_t rec_ptr, struct tdb_record *rec)
 {
        tdb_off_t last_ptr, i;
-       struct list_struct lastrec;
+       struct tdb_record lastrec;
 
        if (tdb->read_only || tdb->traverse_read) return -1;
 
@@ -297,7 +297,7 @@ static int tdb_count_dead(struct tdb_context *tdb, uint32_t hash)
 {
        int res = 0;
        tdb_off_t rec_ptr;
-       struct list_struct rec;
+       struct tdb_record rec;
        
        /* read in the hash top */
        if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1)
@@ -321,7 +321,7 @@ static int tdb_count_dead(struct tdb_context *tdb, uint32_t hash)
 static int tdb_purge_dead(struct tdb_context *tdb, uint32_t hash)
 {
        int res = -1;
-       struct list_struct rec;
+       struct tdb_record rec;
        tdb_off_t rec_ptr;
 
        if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
@@ -357,7 +357,7 @@ static int tdb_purge_dead(struct tdb_context *tdb, uint32_t hash)
 static int tdb_delete_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash)
 {
        tdb_off_t rec_ptr;
-       struct list_struct rec;
+       struct tdb_record rec;
        int ret;
 
        if (tdb->max_dead_records != 0) {
@@ -420,7 +420,7 @@ int tdb_delete(struct tdb_context *tdb, TDB_DATA key)
  * See if we have a dead record around with enough space
  */
 static tdb_off_t tdb_find_dead(struct tdb_context *tdb, uint32_t hash,
-                              struct list_struct *r, tdb_len_t length)
+                              struct tdb_record *r, tdb_len_t length)
 {
        tdb_off_t rec_ptr;
        
@@ -448,7 +448,7 @@ static tdb_off_t tdb_find_dead(struct tdb_context *tdb, uint32_t hash,
 static int _tdb_store(struct tdb_context *tdb, TDB_DATA key,
                       TDB_DATA dbuf, int flag, uint32_t hash)
 {
-       struct list_struct rec;
+       struct tdb_record rec;
        tdb_off_t rec_ptr;
        char *p = NULL;
        int ret = -1;
@@ -734,7 +734,7 @@ void tdb_enable_seqnum(struct tdb_context *tdb)
  */
 static int tdb_free_region(struct tdb_context *tdb, tdb_off_t offset, ssize_t length)
 {
-       struct list_struct rec;
+       struct tdb_record rec;
        if (length <= sizeof(rec)) {
                /* the region is not worth adding */
                return 0;
@@ -783,7 +783,7 @@ int tdb_wipe_all(struct tdb_context *tdb)
        }
 
        if (recovery_head != 0) {
-               struct list_struct rec;
+               struct tdb_record rec;
                if (tdb->methods->tdb_read(tdb, recovery_head, &rec, sizeof(rec), DOCONV()) == -1) {
                        TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_wipe_all: failed to read recovery record\n"));
                        return -1;
index adef447cda635031bb1f6f807c775b735dc7bdf7..be9be72b156ab96f107bc21f0407ffeb198f2c11 100644 (file)
@@ -116,9 +116,9 @@ void tdb_trace_2rec_retrec(struct tdb_context *tdb, const char *op,
 #define CONVERT(x) (DOCONV() ? tdb_convert(&x, sizeof(x)) : &x)
 
 
-/* the body of the database is made of one list_struct for the free space
+/* the body of the database is made of one tdb_record for the free space
    plus a separate data list for each hash value */
-struct list_struct {
+struct tdb_record {
        tdb_off_t next; /* offset of the next record in the list */
        tdb_len_t rec_len; /* total byte length of record */
        tdb_len_t key_len; /* byte length of key */
@@ -223,16 +223,16 @@ int tdb_write_unlock_record(struct tdb_context *tdb, tdb_off_t off);
 int tdb_ofs_read(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d);
 int tdb_ofs_write(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d);
 void *tdb_convert(void *buf, uint32_t size);
-int tdb_free(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec);
-tdb_off_t tdb_allocate(struct tdb_context *tdb, tdb_len_t length, struct list_struct *rec);
+int tdb_free(struct tdb_context *tdb, tdb_off_t offset, struct tdb_record *rec);
+tdb_off_t tdb_allocate(struct tdb_context *tdb, tdb_len_t length, struct tdb_record *rec);
 int tdb_ofs_read(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d);
 int tdb_ofs_write(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d);
 int tdb_lock_record(struct tdb_context *tdb, tdb_off_t off);
 int tdb_unlock_record(struct tdb_context *tdb, tdb_off_t off);
 int _tdb_transaction_cancel(struct tdb_context *tdb);
-int tdb_rec_read(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec);
-int tdb_rec_write(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec);
-int tdb_do_delete(struct tdb_context *tdb, tdb_off_t rec_ptr, struct list_struct *rec);
+int tdb_rec_read(struct tdb_context *tdb, tdb_off_t offset, struct tdb_record *rec);
+int tdb_rec_write(struct tdb_context *tdb, tdb_off_t offset, struct tdb_record *rec);
+int tdb_do_delete(struct tdb_context *tdb, tdb_off_t rec_ptr, struct tdb_record *rec);
 unsigned char *tdb_alloc_read(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t len);
 int tdb_parse_data(struct tdb_context *tdb, TDB_DATA key,
                   tdb_off_t offset, tdb_len_t len,
@@ -240,10 +240,10 @@ int tdb_parse_data(struct tdb_context *tdb, TDB_DATA key,
                                 void *private_data),
                   void *private_data);
 tdb_off_t tdb_find_lock_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash, int locktype,
-                          struct list_struct *rec);
+                          struct tdb_record *rec);
 void tdb_io_init(struct tdb_context *tdb);
 int tdb_expand(struct tdb_context *tdb, tdb_off_t size);
 int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off,
-                     struct list_struct *rec);
+                     struct tdb_record *rec);
 
 
index 16e12d647043f9df6c0387dc0189165c20232f74..035b4e1d54cec932d728683967337f84d1f1adc2 100644 (file)
@@ -657,7 +657,7 @@ static int tdb_recovery_allocate(struct tdb_context *tdb,
                                 tdb_off_t *recovery_offset,
                                 tdb_len_t *recovery_max_size)
 {
-       struct list_struct rec;
+       struct tdb_record rec;
        const struct tdb_methods *methods = tdb->transaction->io_methods;
        tdb_off_t recovery_head;
 
@@ -743,7 +743,7 @@ static int transaction_setup_recovery(struct tdb_context *tdb,
        tdb_len_t recovery_size;
        unsigned char *data, *p;
        const struct tdb_methods *methods = tdb->transaction->io_methods;
-       struct list_struct *rec;
+       struct tdb_record *rec;
        tdb_off_t recovery_offset, recovery_max_size;
        tdb_off_t old_map_size = tdb->transaction->old_map_size;
        uint32_t magic, tailer;
@@ -763,7 +763,7 @@ static int transaction_setup_recovery(struct tdb_context *tdb,
                return -1;
        }
 
-       rec = (struct list_struct *)data;
+       rec = (struct tdb_record *)data;
        memset(rec, 0, sizeof(*rec));
 
        rec->magic    = 0;
@@ -846,7 +846,7 @@ static int transaction_setup_recovery(struct tdb_context *tdb,
        magic = TDB_RECOVERY_MAGIC;
        CONVERT(magic);
 
-       *magic_offset = recovery_offset + offsetof(struct list_struct, magic);
+       *magic_offset = recovery_offset + offsetof(struct tdb_record, magic);
 
        if (methods->tdb_write(tdb, *magic_offset, &magic, sizeof(magic)) == -1) {
                TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_setup_recovery: failed to write recovery magic\n"));
@@ -1094,7 +1094,7 @@ int tdb_transaction_recover(struct tdb_context *tdb)
        tdb_off_t recovery_head, recovery_eof;
        unsigned char *data, *p;
        uint32_t zero = 0;
-       struct list_struct rec;
+       struct tdb_record rec;
 
        /* find the recovery area */
        if (tdb_ofs_read(tdb, TDB_RECOVERY_HEAD, &recovery_head) == -1) {
@@ -1181,7 +1181,7 @@ int tdb_transaction_recover(struct tdb_context *tdb)
        }
 
        /* remove the recovery magic */
-       if (tdb_ofs_write(tdb, recovery_head + offsetof(struct list_struct, magic), 
+       if (tdb_ofs_write(tdb, recovery_head + offsetof(struct tdb_record, magic),
                          &zero) == -1) {
                TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to remove recovery magic\n"));
                tdb->ecode = TDB_ERR_IO;
index 8d808206f96b6fc3dcf1ee70a7d7f4687f5282a3..c340dd354b7ad6a239aa8ecc7d4c6d2a13e11b32 100644 (file)
@@ -32,7 +32,7 @@
 /* Uses traverse lock: 0 = finish, TDB_NEXT_LOCK_ERR = error,
    other = record offset */
 static tdb_off_t tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock *tlock,
-                        struct list_struct *rec)
+                        struct tdb_record *rec)
 {
        int want_next = (tlock->off != 0);
 
@@ -145,7 +145,7 @@ static int tdb_traverse_internal(struct tdb_context *tdb,
                                 struct tdb_traverse_lock *tl)
 {
        TDB_DATA key, dbuf;
-       struct list_struct rec;
+       struct tdb_record rec;
        int ret = 0, count = 0;
        tdb_off_t off;
 
@@ -270,7 +270,7 @@ int tdb_traverse(struct tdb_context *tdb,
 TDB_DATA tdb_firstkey(struct tdb_context *tdb)
 {
        TDB_DATA key;
-       struct list_struct rec;
+       struct tdb_record rec;
        tdb_off_t off;
 
        /* release any old lock */
@@ -302,7 +302,7 @@ TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA oldkey)
 {
        uint32_t oldhash;
        TDB_DATA key = tdb_null;
-       struct list_struct rec;
+       struct tdb_record rec;
        unsigned char *k = NULL;
        tdb_off_t off;