* tdb_transaction_commit): if this succeeds then a transaction will only
* fail if the write() or fsync() calls fail.
*
+ * If this fails you must still call tdb_transaction_cancel() to cancel
+ * the transaction.
+ *
* See Also:
* tdb_transaction_commit()
*/
TDB_ATTRIBUTE_LOG = 0,
TDB_ATTRIBUTE_HASH = 1,
TDB_ATTRIBUTE_SEED = 2,
- TDB_ATTRIBUTE_STATS = 3
+ TDB_ATTRIBUTE_STATS = 3,
+ TDB_ATTRIBUTE_OPENHOOK = 4
};
/**
struct tdb_attribute_base base; /* .attr = TDB_ATTRIBUTE_LOG */
void (*fn)(struct tdb_context *tdb,
enum tdb_log_level level,
- void *data,
- const char *message);
+ const char *message,
+ void *data);
void *data;
};
uint64_t lock_nonblock;
};
+/**
+ * struct tdb_attribute_openhook - tdb special effects hook for open
+ *
+ * This attribute contains a function to call once we have the OPEN_LOCK
+ * for the tdb, but before we've examined its contents. If this succeeds,
+ * the tdb will be populated if it's then zero-length.
+ *
+ * This is a hack to allow support for TDB1-style TDB_CLEAR_IF_FIRST
+ * behaviour.
+ */
+struct tdb_attribute_openhook {
+ struct tdb_attribute_base base; /* .attr = TDB_ATTRIBUTE_OPENHOOK */
+ enum TDB_ERROR (*fn)(int fd, void *data);
+ void *data;
+};
+
/**
* union tdb_attribute - tdb attributes.
*
*
* See also:
* struct tdb_attribute_log, struct tdb_attribute_hash,
- * struct tdb_attribute_seed, struct tdb_attribute_stats.
+ * struct tdb_attribute_seed, struct tdb_attribute_stats,
+ * struct tdb_attribute_openhook.
*/
union tdb_attribute {
struct tdb_attribute_base base;
struct tdb_attribute_hash hash;
struct tdb_attribute_seed seed;
struct tdb_attribute_stats stats;
+ struct tdb_attribute_openhook openhook;
};
#ifdef __cplusplus