-static void *tdb_direct(struct tdb_context *tdb, tdb_off_t off, size_t len)
-{
- if (unlikely(!tdb->map_ptr))
- return NULL;
-
- /* FIXME: We can do a subset of this! */
- if (tdb->transaction)
- return NULL;
-
- if (unlikely(tdb_oob(tdb, off + len, true) == -1))
- return NULL;
- return (char *)tdb->map_ptr + off;
-}
-
-/* Either make a copy into pad and return that, or return ptr into mmap. */
-/* Note: pad has to be a real object, so we can't get here if len
- * overflows size_t */
-/* FIXME: Transaction */
-void *tdb_get(struct tdb_context *tdb, tdb_off_t off, void *pad, size_t len)
-{
- ssize_t r;
-
- if (likely(!(tdb->flags & TDB_CONVERT))) {
- void *ret = tdb_direct(tdb, off, len);
- if (ret)
- return ret;
- }
-
- if (unlikely(tdb_oob(tdb, off + len, false) == -1))
- return NULL;
-
- r = pread(tdb->fd, pad, len, off);
- if (r != (ssize_t)len) {
- /* Ensure ecode is set for log fn. */
- tdb->ecode = TDB_ERR_IO;
- tdb->log(tdb, TDB_DEBUG_FATAL, tdb->log_priv,
- "tdb_read failed at %llu "
- "len=%lld ret=%lld (%s) map_size=%lld\n",
- (long long)off, (long long)len,
- (long long)r, strerror(errno),
- (long long)tdb->map_size);
- return NULL;
- }
- return tdb_convert(tdb, pad, len);
-}
-