summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-10-12 23:01:08 +1100
committerAndrew Bartlett <abartlet@samba.org>2011-10-13 14:06:07 +0200
commit01c934c81e55b79601122d8e0740c7946077c37e (patch)
treef6e7909690bc399c3036ef80e22997aadbf88884 /lib/util
parent3cdb1fe4404e26ae383cfb73bfa8af36cb1d7f7c (diff)
downloadsamba-01c934c81e55b79601122d8e0740c7946077c37e.tar.gz
samba-01c934c81e55b79601122d8e0740c7946077c37e.tar.bz2
samba-01c934c81e55b79601122d8e0740c7946077c37e.zip
lib/util: Add back control of mmap and hash size in tdb for top level build
This passes down a struct loadparm_context to allow these parameters to be checked. This may be s3 or s4 context, allowing the #if _SAMBA_BUILD_ macro to go away safely. Andrew Bartlett
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/tdb_wrap.c21
-rw-r--r--lib/util/tdb_wrap.h5
-rwxr-xr-xlib/util/wscript_build2
3 files changed, 13 insertions, 15 deletions
diff --git a/lib/util/tdb_wrap.c b/lib/util/tdb_wrap.c
index a3dc76d6b7..7c3318bcad 100644
--- a/lib/util/tdb_wrap.c
+++ b/lib/util/tdb_wrap.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "lib/util/dlinklist.h"
#include "lib/util/tdb_wrap.h"
+#include "lib/param/param.h"
/* FIXME: TDB2 does this internally, so no need to wrap multiple opens! */
#if BUILD_TDB2
@@ -114,7 +115,8 @@ static struct tdb_wrap_private *tdb_wrap_private_open(TALLOC_CTX *mem_ctx,
int hash_size,
int tdb_flags,
int open_flags,
- mode_t mode)
+ mode_t mode,
+ struct loadparm_context *lp_ctx)
{
struct tdb_wrap_private *result;
@@ -127,14 +129,7 @@ static struct tdb_wrap_private *tdb_wrap_private_open(TALLOC_CTX *mem_ctx,
goto fail;
}
-#if _SAMBA_BUILD_ == 3
- /* This #if _SAMBA_BUILD == 3 is very unfortunate, as it means
- * that in the top level build, these options are not
- * available for these databases. However, having two
- * different tdb_wrap lists is a worse fate, so this will do
- * for now */
-
- if (!lp_use_mmap()) {
+ if (!lpcfg_use_mmap(lp_ctx)) {
tdb_flags |= TDB_NOMMAP;
}
@@ -147,9 +142,8 @@ static struct tdb_wrap_private *tdb_wrap_private_open(TALLOC_CTX *mem_ctx,
} else {
base = name;
}
- hash_size = lp_parm_int(-1, "tdb_hashsize", base, 0);
+ hash_size = lpcfg_parm_int(lp_ctx, NULL, "tdb_hashsize", base, 0);
}
-#endif
result->tdb = tdb_open_compat(name, hash_size, tdb_flags,
open_flags, mode, tdb_wrap_log, NULL);
@@ -171,7 +165,8 @@ fail:
*/
struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
const char *name, int hash_size, int tdb_flags,
- int open_flags, mode_t mode)
+ int open_flags, mode_t mode,
+ struct loadparm_context *lp_ctx)
{
struct tdb_wrap *result;
struct tdb_wrap_private *w;
@@ -189,7 +184,7 @@ struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
if (w == NULL) {
w = tdb_wrap_private_open(result, name, hash_size, tdb_flags,
- open_flags, mode);
+ open_flags, mode, lp_ctx);
} else {
/*
* Correctly use talloc_reference: The tdb will be
diff --git a/lib/util/tdb_wrap.h b/lib/util/tdb_wrap.h
index 6f9f3834d4..81e77e76a4 100644
--- a/lib/util/tdb_wrap.h
+++ b/lib/util/tdb_wrap.h
@@ -35,8 +35,11 @@ struct tdb_wrap {
struct tdb_context *tdb;
};
+struct loadparm_context;
+
struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
const char *name, int hash_size, int tdb_flags,
- int open_flags, mode_t mode);
+ int open_flags, mode_t mode,
+ struct loadparm_context *lp_ctx);
#endif /* _TDB_WRAP_H_ */
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index 8b4901a7de..1dc65fab5e 100755
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -88,7 +88,7 @@ bld.SAMBA_SUBSYSTEM('UTIL_PW',
bld.SAMBA_LIBRARY('tdb-wrap',
source='tdb_wrap.c',
- deps='tdb_compat talloc samba-util',
+ deps='tdb_compat talloc samba-util samba-hostconfig',
private_library=True,
local_include=False
)