X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Ftdb2.h;fp=ccan%2Ftdb2%2Ftdb2.h;h=24137b88722dc3acd30432ad6b4425030c96b1c5;hp=0731503b874ce130649f1bb64964460b1c7ad9f1;hb=0468e6992770e5082f2fb11cd93c2d8209e3f351;hpb=4ee7bd08f427b3e93d6225dd30e745ee62a4e85f diff --git a/ccan/tdb2/tdb2.h b/ccan/tdb2/tdb2.h index 0731503b..24137b88 100644 --- a/ccan/tdb2/tdb2.h +++ b/ccan/tdb2/tdb2.h @@ -606,7 +606,8 @@ enum tdb_attribute_type { TDB_ATTRIBUTE_LOG = 0, TDB_ATTRIBUTE_HASH = 1, TDB_ATTRIBUTE_SEED = 2, - TDB_ATTRIBUTE_STATS = 3 + TDB_ATTRIBUTE_STATS = 3, + TDB_ATTRIBUTE_OPENHOOK = 4 }; /** @@ -716,6 +717,22 @@ struct tdb_attribute_stats { 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. * @@ -723,7 +740,8 @@ struct tdb_attribute_stats { * * 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; @@ -731,6 +749,7 @@ union tdb_attribute { struct tdb_attribute_hash hash; struct tdb_attribute_seed seed; struct tdb_attribute_stats stats; + struct tdb_attribute_openhook openhook; }; #ifdef __cplusplus