]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/test/run-tdb1-3G-file.c
tdb2: Make tdb1 use the tdb_file structure.
[ccan] / ccan / tdb2 / test / run-tdb1-3G-file.c
index fd66c047b1f1e64e29229302965e895b8d024c42..43e9f2ad9bd831f847acfe954ab3e6305315b207 100644 (file)
@@ -15,12 +15,12 @@ static int tdb1_expand_file_sparse(struct tdb1_context *tdb,
                return -1;
        }
 
-       if (ftruncate(tdb->fd, size+addition) == -1) {
+       if (ftruncate(tdb->file->fd, size+addition) == -1) {
                char b = 0;
-               ssize_t written = pwrite(tdb->fd,  &b, 1, (size+addition) - 1);
+               ssize_t written = pwrite(tdb->file->fd,  &b, 1, (size+addition) - 1);
                if (written == 0) {
                        /* try once more, potentially revealing errno */
-                       written = pwrite(tdb->fd,  &b, 1, (size+addition) - 1);
+                       written = pwrite(tdb->file->fd,  &b, 1, (size+addition) - 1);
                }
                if (written == 0) {
                        /* again - give up, guessing errno */
@@ -46,10 +46,10 @@ static const struct tdb1_methods large_io_methods = {
        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)
 {
-       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);
@@ -60,13 +60,13 @@ static int test_traverse(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA data
 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;
 
        plan_tests(24);
-       tdb = tdb1_open_ex("run-36-file.tdb", 1024, TDB1_CLEAR_IF_FIRST,
+       tdb = tdb1_open_ex("run-36-file.tdb", 1024, TDB_DEFAULT,
                          O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
 
        ok1(tdb);
@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
        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"));
@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
 
        /* 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"));