#ifndef TDB_PRIVATE_H
#define TDB_PRIVATE_H
- /*
+ /*
Trivial Database 2: private types and prototypes
Copyright (C) Rusty Russell 2010
#include <ccan/tdb2/tdb2.h>
#include <ccan/likely/likely.h>
#include <ccan/compiler/compiler.h>
-#ifdef HAVE_BYTESWAP_H
+#if HAVE_BYTESWAP_H
#include <byteswap.h>
#endif
int mmap_flags;
/* Error code for last tdb error. */
- enum TDB_ERROR ecode;
+ enum TDB_ERROR ecode;
/* the flags passed to tdb_open, for tdb_reopen. */
uint32_t flags;
/* Logging function */
- tdb_logfn_t logfn;
+ void (*logfn)(struct tdb_context *tdb,
+ enum tdb_log_level level,
+ void *log_private,
+ const char *message);
void *log_private;
/* Hash function. */
/* Single list of all TDBs, to avoid multiple opens. */
struct tdb_context *next;
- dev_t device;
+ dev_t device;
ino_t inode;
};
struct tdb_methods {
- int (*read)(struct tdb_context *, tdb_off_t, void *, tdb_len_t);
- int (*write)(struct tdb_context *, tdb_off_t, const void *, tdb_len_t);
+ int (*tread)(struct tdb_context *, tdb_off_t, void *, tdb_len_t);
+ int (*twrite)(struct tdb_context *, tdb_off_t, const void *, tdb_len_t);
int (*oob)(struct tdb_context *, tdb_off_t, bool);
int (*expand_file)(struct tdb_context *, tdb_len_t);
void *(*direct)(struct tdb_context *, tdb_off_t, size_t, bool);
tdb_off_t tdb_find_zero_off(struct tdb_context *tdb, tdb_off_t off,
uint64_t num);
-/* Even on files, we can get partial writes due to signals. */
-bool tdb_pwrite_all(int fd, const void *buf, size_t len, tdb_off_t off);
-bool tdb_pread_all(int fd, void *buf, size_t len, tdb_off_t off);
-bool tdb_read_all(int fd, void *buf, size_t len);
-
/* Allocate and make a copy of some offset. */
void *tdb_alloc_read(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t len);
/* tdb.c: */
void COLD tdb_logerr(struct tdb_context *tdb,
enum TDB_ERROR ecode,
- enum tdb_debug_level level,
+ enum tdb_log_level level,
const char *fmt, ...);
#ifdef TDB_TRACE