summaryrefslogtreecommitdiff
path: root/lib/tdb2/tdb1_private.h
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-09-14 07:32:13 +0930
committerRusty Russell <rusty@rustcorp.com.au>2011-09-14 07:32:13 +0930
commite613effeae7c9373c9e635fc708ec2ce29661d4c (patch)
treed8cdb019f54302de6aa813a62a34e036cf9c7faf /lib/tdb2/tdb1_private.h
parent50484d4bede6b59706457e44a32cbe2d3e9c28d2 (diff)
downloadsamba-e613effeae7c9373c9e635fc708ec2ce29661d4c.tar.gz
samba-e613effeae7c9373c9e635fc708ec2ce29661d4c.tar.bz2
samba-e613effeae7c9373c9e635fc708ec2ce29661d4c.zip
tdb2: make TDB1 code use tdb2's TDB_ERROR and tdb_logerr()
To do this, we make sure that the first few fields of tdb1_context and tdb_context are the same. This sweep also fixes up a few paths where we weren't setting tdb->ecode before our old logging function. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 919937354a331bb964564a11b5a5b80403ff8db9)
Diffstat (limited to 'lib/tdb2/tdb1_private.h')
-rw-r--r--lib/tdb2/tdb1_private.h34
1 files changed, 23 insertions, 11 deletions
diff --git a/lib/tdb2/tdb1_private.h b/lib/tdb2/tdb1_private.h
index 7ce192b9a6..932e76110b 100644
--- a/lib/tdb2/tdb1_private.h
+++ b/lib/tdb2/tdb1_private.h
@@ -28,10 +28,16 @@
#include "private.h"
#include "tdb1.h"
-#include <limits.h>
+/**** FIXME: Type overrides for tdb2, for transition! */
+#define tdb_logerr(tdb, ecode, level, ...) \
+ tdb_logerr((struct tdb_context *)(tdb), (ecode), (level), __VA_ARGS__)
+
+#define tdb_error(tdb) \
+ tdb_error((struct tdb_context *)(tdb))
-/* Temporary wrapper to avoid undue churn in test/ */
-#define tdb1_error(tdb) ((tdb)->ecode)
+/***** END FIXME ***/
+
+#include <limits.h>
/* #define TDB_TRACE 1 */
#ifndef HAVE_GETPAGESIZE
@@ -80,11 +86,6 @@ typedef uint32_t tdb1_off_t;
#define TDB1_PAD_BYTE 0x42
#define TDB1_PAD_U32 0x42424242
-/* NB assumes there is a local variable called "tdb" that is the
- * current context, also takes doubly-parenthesized print-style
- * argument. */
-#define TDB1_LOG(x) tdb->log.log_fn x
-
/* lock offsets */
#define TDB1_OPEN_LOCK 0
#define TDB1_ACTIVE_LOCK 4
@@ -167,7 +168,21 @@ struct tdb1_methods {
};
struct tdb1_context {
+ struct tdb1_context *next;
+
char *name; /* the name of the database */
+
+ /* Logging function */
+ void (*log_fn)(struct tdb1_context *tdb,
+ enum tdb_log_level level,
+ enum TDB_ERROR ecode,
+ const char *message,
+ void *data);
+ void *log_data;
+
+ /* Last error we returned. */
+ enum TDB_ERROR last_error; /* error code for last tdb error */
+
void *map_ptr; /* where it is currently mapped */
int fd; /* open file descriptor for the database */
tdb1_len_t map_size; /* how much space has been mapped */
@@ -177,14 +192,11 @@ struct tdb1_context {
struct tdb1_lock_type allrecord_lock; /* .offset == upgradable */
int num_lockrecs;
struct tdb1_lock_type *lockrecs; /* only real locks, all with count>0 */
- enum TDB1_ERROR ecode; /* error code for last tdb error */
struct tdb1_header header; /* a cached copy of the header */
uint32_t flags; /* the flags passed to tdb1_open */
struct tdb1_traverse_lock travlocks; /* current traversal locks */
- struct tdb1_context *next; /* all tdbs to avoid multiple opens */
dev_t device; /* uniquely identifies this tdb */
ino_t inode; /* uniquely identifies this tdb */
- struct tdb1_logging_context log;
unsigned int (*hash_fn)(TDB1_DATA *key);
int open_flags; /* flags used in the open - needed by reopen */
const struct tdb1_methods *methods;