summaryrefslogtreecommitdiff
path: root/lib/tdb2/open.c
AgeCommit message (Collapse)AuthorFilesLines
2011-09-14tdb2: add error conversion functions.Rusty Russell1-7/+7
This clarifies the code a little, but also provides a more explicit mechanism which can be used to debug error handling (by introducing tdb_err_t and making it a pointer type). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit afa6d57b7d93fe4675a952f556eb462951baa257)
2011-09-14tdb2: add tdb_attribute_tdb1_max_deadRusty Russell1-4/+8
This allows us to simulate the old "volatile" flag for tdb1. It's not necessary for tdb2. As this is the last function in tdb1.h, we remove that file. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit b8e64e9346793164651a36eccb3c205077e5c91b)
2011-09-14tdb2: unify tdb1_open into tdb_openRusty Russell1-26/+107
Finally, we gut tdb1_open() to the tdb1-specific parts, and call it from tdb_open if they specify the TDB_VERSION1 flag or the version is a TDB1. We also unify tdb_close(), based on the TDB_VERSION1 flag. Note that tdb_open(TDB_VERSION1) will fail on an existing tdb if it's a TDB2. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit c8c3b3568677e8b0105f84e4ab068c580faf4591)
2011-09-14tdb2: disallow SEED attribute with TDB_VERSION1.Rusty Russell1-0/+26
It also only makes sense with O_CREAT. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit fc44729c471bcdc7ab0410448d991a65e74cec3d)
2011-09-14tdb2: add TDB_ATTRIBUTE_TDB1_HASHSIZERusty Russell1-2/+34
This replaces the tdb1_open "hash_size" argument. It will only be valid when you call tdb_open() with O_CREAT in open_flags, and TDB_VERSION1 in tdb_flags. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 49475d68deecd0b31597ed6094229171d2699b11)
2011-09-14tdb2: make jenkins_hash function non-static, rename to tdb_jenkins_hash.Rusty Russell1-12/+1
We're going to need access to it from tdb1_open, so expose it now. It's better in hash.c anyway. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit c8f6f8c2dea76042f74c02eff048847e62adcca6)
2011-09-14tdb2: merge tdb1_context into tdb_context.Rusty Russell1-5/+5
Finally, we split out the tdb2-specific parts of tdb_context, and put them into a "tdb2" sub-struct; the tdb1 parts go into a "tdb1" sub-struct. We get rido of tdb1_context and use tdb_context everywhere. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit bbeb528e74c0e234e1f724ac8d54be404cfc6f9a)
2011-09-14tdb2: tdb_foreach()Rusty Russell1-0/+10
Create an iterator over every open tdb (not internal TDBs). This is useful for re-establishing the tdb1-style active lock for CLEAR_IF_FIRST. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 1a0c636bc38213bd0322db47529f78f2dc22ffdd)
2011-09-14tdb2: keep link of every non-internal tdb.Rusty Russell1-22/+19
Instead of a per-file linked list, use a per-tdb list. This is needed for tdb_foreach(). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 2414f261918b4fb8a549dd385dba32118e37bf85)
2011-09-14tdb2: save openhook, allow tdb_get_attribute() on it.Rusty Russell1-13/+14
This makes it easy to call it again after a fork(), such as for re-establishing the CLEAR_IF_FIRST files locks. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 937d0babe99dcd315040a9e48430140e63e4a7df)
2011-09-14tdb2: add TDB_RDONLY flag, allow setting/unsetting it.Rusty Russell1-3/+10
You can only unset it if the TDB was originally opened O_RDWR. Also, cleaned up error handling in tdb_allrecord_lock() so we only get one log message on a r/o database. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit b87e14495d5b07e1b247218a72329f10ecb3da7f)
2011-09-14tdb2: save open_flags instead of mmap_flags.Rusty Russell1-2/+1
It's more consistent with what tdb1 does, and slightly more encapsulated. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 6b7c3c840eafbec211b9f58751c5ff754302a68e)
2011-09-14tdb2: enforce TDB_CONVERTRusty Russell1-0/+6
If the caller actually specifies TDB_CONVERT, fail if the TDB does not need conversion. It's unusual for the user to specify TDB_CONVERT (it's auto-detected) but better to be strict. (Imported from CCAN commit 3e3ee8b0c1e77340ab9e8678c2d23646d8cdb627) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14tdb2: cleanup oob handling.Rusty Russell1-1/+3
The tdb_oob() function can fail due to errors, as well as because the length asked for is greater than the size of the file. Clean that up: (1) If probe is true, only fail if there's an error, not if the length is too great. (2) Exit tdb_open() if it tdb_oob() probe fails; this helps cut down test time for failtest. (3) Don't set probe to true in tdb_direct() fail; a minor issue, but it means we log failure. (Imported from CCAN commit 77658070a3e4f712b94d659b2e399031ce3394c8) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14tdb2: fix internal tdb_write_convert() error handling in tdb_open()Rusty Russell1-4/+5
As noted, failtest was taking a long time, because a failure injected here was not detected. (Imported from CCAN commit 51f592dfcda4d58d6b9d8134b6e1aff791dc40f2) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-08-31tdb2: add full LGPL headersRusty Russell1-0/+17
This is for SAMBA, so we follow their rules and do full license headers. Two files were missing them. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 58025731) Autobuild-User: Rusty Russell <rusty@rustcorp.com.au> Autobuild-Date: Wed Aug 31 09:52:43 CEST 2011 on sn-devel-104
2011-06-20tdb2: add lib/tdb2 (from CCAN init-1161-g661d41f)Rusty Russell1-0/+661
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>