+static tdb_off_t tdb_offset(struct tdb_context *tdb, struct tdb_data key)
+{
+ tdb_off_t off;
+ struct tdb_used_record rec;
+ struct hash_info h;
+
+ if (tdb_get_flags(tdb) & TDB_VERSION1) {
+ struct tdb1_record rec;
+ return tdb1_find(tdb, key, tdb_hash(tdb, key.dptr, key.dsize),
+ &rec);
+ }
+
+ off = find_and_lock(tdb, key, F_RDLCK, &h, &rec, NULL);
+ if (TDB_OFF_IS_ERR(off))
+ return 0;
+ tdb_unlock_hashes(tdb, h.hlock_start, h.hlock_range, F_RDLCK);
+ return off;
+}
+