summaryrefslogtreecommitdiff
path: root/lib/tdb2/open.c
AgeCommit message (Collapse)AuthorFilesLines
2012-02-21lib/tdb2: Mark public function as suchAmitay Isaacs1-6/+6
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-01-30tdb2: careful on wrap.Rusty Russell1-1/+1
It's much harder to wrap a 64-bit tdb2 than a 32-bit tdb1, but we should still take care against bugs. Also, we should *not* cast the length to a size_t when comparing it to the stat result, in case size_t is 32 bit. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 6f7cb26e589cea081e71c59801eae87178967861)
2011-12-05tdb2: add a capability list from the header.Rusty Russell1-0/+54
This allows even more extensibility in future: in particular, the top bits of each capability tell us what to do if we don't understand it: fail the open, fail to open for write, or don't try to check the format. tdb_check needs to understand the capability list so it can know to skip over it: each element in the list is prefixed with the type tag and the length. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 35f198de1851a7d57064546b7ced677b6fabee27)
2011-11-02tdb2: don't be fascist when TDB_VERSION1 is specified.Rusty Russell1-5/+2
We currently insist that a tdb file be a version1 file if tdb_open() is passed the TDB_VERSION1 flag; we fail if it's actually a tdb2. But that makes generic wrappers harder, and is unlikely to be what the user wants: if they do, they can check tdb_get_flags() & TDB_VERSION1 after opening. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 9691464a16ef22d6acadfef209666381dfe22b2f) Autobuild-User: Rusty Russell <rusty@rustcorp.com.au> Autobuild-Date: Wed Nov 2 08:38:38 CET 2011 on sn-devel-104
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>