#include <ccan/tdb2/lock.c>
#include <ccan/tdb2/io.c>
#include <ccan/tdb2/hash.c>
#include <ccan/tdb2/lock.c>
#include <ccan/tdb2/io.c>
#include <ccan/tdb2/hash.c>
- ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec) == 0);
+ ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec, NULL) == 0);
/* Should have created correct hash. */
ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
/* Should have located space in group 0, bucket 0. */
/* Should have created correct hash. */
ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
/* Should have located space in group 0, bucket 0. */
- new_off = alloc(tdb, key.dsize, dbuf.dsize, h.h, false);
+ new_off = alloc(tdb, key.dsize, dbuf.dsize, h.h,
+ TDB_USED_MAGIC, false);
- ok1(!tdb->methods->write(tdb, off, key.dptr, key.dsize));
+ ok1(!tdb->methods->twrite(tdb, off, key.dptr, key.dsize));
- ok1(!tdb->methods->write(tdb, off, dbuf.dptr, dbuf.dsize));
+ ok1(!tdb->methods->twrite(tdb, off, dbuf.dptr, dbuf.dsize));
/* We should be able to unlock that OK. */
ok1(tdb_unlock_hashes(tdb, h.hlock_start, h.hlock_range,
/* We should be able to unlock that OK. */
ok1(tdb_unlock_hashes(tdb, h.hlock_start, h.hlock_range,
ok1(tdb_check(tdb, NULL, NULL) == 0);
/* Now, this should give a successful lookup. */
ok1(tdb_check(tdb, NULL, NULL) == 0);
/* Now, this should give a successful lookup. */
- ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec) == new_off);
+ ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec, NULL)
+ == new_off);
/* Should have created correct hash. */
ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
/* Should have located space in group 0, bucket 0. */
/* Should have created correct hash. */
ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
/* Should have located space in group 0, bucket 0. */
- ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec) == 0);
+ ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec, NULL) == 0);
/* Should have created correct hash. */
ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
/* Should have located space in group 0, bucket 1. */
/* Should have created correct hash. */
ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
/* Should have located space in group 0, bucket 1. */
- ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec) == new_off);
+ ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec, NULL)
+ == new_off);
/* Should have created correct hash. */
ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
/* Should have located space in expanded group 0, bucket 0. */
/* Should have created correct hash. */
ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
/* Should have located space in expanded group 0, bucket 0. */
/* Simple delete should work. */
ok1(delete_from_hash(tdb, &h) == 0);
/* Simple delete should work. */
ok1(delete_from_hash(tdb, &h) == 0);
- ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec) == 0);
+ ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec, NULL) == 0);
/* Should have created correct hash. */
ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
/* Should have located space in group 0, bucket 0. */
/* Should have created correct hash. */
ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
/* Should have located space in group 0, bucket 0. */
/* Should be happy with expansion. */
ok1(tdb_check(tdb, NULL, NULL) == 0);
/* Should be happy with expansion. */
ok1(tdb_check(tdb, NULL, NULL) == 0);
- ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec) == 0);
+ ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec, NULL) == 0);
/* Should have created correct hash. */
ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
/* Should have located space in group 0, bucket 0. */
/* Should have created correct hash. */
ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
/* Should have located space in group 0, bucket 0. */
- new_off = alloc(tdb, key.dsize, dbuf.dsize, h.h, false);
+ new_off = alloc(tdb, key.dsize, dbuf.dsize, h.h,
+ TDB_USED_MAGIC, false);
ok1(new_off != TDB_OFF_ERR);
ok1(add_to_hash(tdb, &h, new_off) == 0);
/* Make sure we fill it in for later finding. */
off = new_off + sizeof(struct tdb_used_record);
ok1(new_off != TDB_OFF_ERR);
ok1(add_to_hash(tdb, &h, new_off) == 0);
/* Make sure we fill it in for later finding. */
off = new_off + sizeof(struct tdb_used_record);
- ok1(!tdb->methods->write(tdb, off, key.dptr, key.dsize));
+ ok1(!tdb->methods->twrite(tdb, off, key.dptr, key.dsize));
- ok1(!tdb->methods->write(tdb, off, dbuf.dptr, dbuf.dsize));
+ ok1(!tdb->methods->twrite(tdb, off, dbuf.dptr, dbuf.dsize));
/* We should be able to unlock that OK. */
ok1(tdb_unlock_hashes(tdb, h.hlock_start, h.hlock_range,
/* We should be able to unlock that OK. */
ok1(tdb_unlock_hashes(tdb, h.hlock_start, h.hlock_range,
- ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec) == new_off);
+ ok1(find_and_lock(tdb, key, F_WRLCK, &h, &rec, NULL)
+ == new_off);
/* Should have created correct hash. */
ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
/* Should have located space in expanded group 0, bucket 0. */
/* Should have created correct hash. */
ok1(h.h == tdb_hash(tdb, key.dptr, key.dsize));
/* Should have located space in expanded group 0, bucket 0. */