1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-31 17:18:04 +03:00

tdb_wrap: Remove tdb_wrap_open_ again

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2014-03-26 14:41:03 +00:00 committed by Jeremy Allison
parent f995c6e6d4
commit d6db35d7a5
15 changed files with 46 additions and 76 deletions

View File

@ -432,9 +432,9 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
hash_size = lpcfg_tdb_hash_size(lp_ctx, name);
}
db_tdb->wtdb = tdb_wrap_open_(db_tdb, name, hash_size,
lpcfg_tdb_flags(lp_ctx, tdb_flags),
open_flags, mode);
db_tdb->wtdb = tdb_wrap_open(db_tdb, name, hash_size,
lpcfg_tdb_flags(lp_ctx, tdb_flags),
open_flags, mode);
if (db_tdb->wtdb == NULL) {
DEBUG(3, ("Could not open tdb: %s\n", strerror(errno)));
goto fail;

View File

@ -123,9 +123,9 @@ fail:
wrapped connection to a tdb database
to close just talloc_free() the tdb_wrap pointer
*/
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)
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)
{
struct tdb_wrap *result;
struct tdb_wrap_private *w;
@ -175,29 +175,3 @@ fail:
TALLOC_FREE(result);
return NULL;
}
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,
struct loadparm_context *lp_ctx)
{
if (!lpcfg_use_mmap(lp_ctx)) {
tdb_flags |= TDB_NOMMAP;
}
if ((hash_size == 0) && (name != NULL)) {
const char *base;
base = strrchr_m(name, '/');
if (base != NULL) {
base += 1;
} else {
base = name;
}
hash_size = lpcfg_parm_int(lp_ctx, NULL,
"tdb_hashsize", base, 0);
}
return tdb_wrap_open_(mem_ctx, name, hash_size, tdb_flags, open_flags,
mode);
}

View File

@ -37,12 +37,8 @@ struct tdb_wrap {
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);
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,
struct loadparm_context *lp_ctx);
int open_flags, mode_t mode);
#endif /* _TDB_WRAP_H_ */

View File

@ -1665,9 +1665,9 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
hash_size = lpcfg_tdb_hash_size(lp_ctx, db_path);
}
db_ctdb->wtdb = tdb_wrap_open_(db_ctdb, db_path, hash_size,
lpcfg_tdb_flags(lp_ctx, tdb_flags),
O_RDWR, 0);
db_ctdb->wtdb = tdb_wrap_open(db_ctdb, db_path, hash_size,
lpcfg_tdb_flags(lp_ctx, tdb_flags),
O_RDWR, 0);
talloc_unlink(db_path, lp_ctx);
if (db_ctdb->wtdb == NULL) {
DEBUG(0, ("Could not open tdb %s: %s\n", db_path, strerror(errno)));

View File

@ -125,7 +125,7 @@ NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx,
fname = lock_path("messages.tdb");
ctx->tdb = tdb_wrap_open_(
ctx->tdb = tdb_wrap_open(
ctx, fname, lpcfg_tdb_hash_size(lp_ctx, fname),
lpcfg_tdb_flags(lp_ctx, TDB_CLEAR_IF_FIRST|TDB_DEFAULT|
TDB_VOLATILE| TDB_INCOMPATIBLE_HASH),
@ -189,7 +189,7 @@ bool messaging_tdb_parent_init(TALLOC_CTX *mem_ctx)
*/
fname = lock_path("messages.tdb");
db = tdb_wrap_open_(
db = tdb_wrap_open(
mem_ctx, fname, lpcfg_tdb_hash_size(lp_ctx, fname),
lpcfg_tdb_flags(lp_ctx, TDB_CLEAR_IF_FIRST|TDB_DEFAULT|
TDB_VOLATILE|TDB_INCOMPATIBLE_HASH),

View File

@ -72,13 +72,13 @@ struct named_mutex *grab_named_mutex(TALLOC_CTX *mem_ctx, const char *name,
fname = lock_path("mutex.tdb");
result->tdb = tdb_wrap_open_(result, fname,
lpcfg_tdb_hash_size(lp_ctx, fname),
lpcfg_tdb_flags(lp_ctx,
TDB_DEFAULT |
TDB_CLEAR_IF_FIRST |
TDB_INCOMPATIBLE_HASH),
O_RDWR|O_CREAT, 0600);
result->tdb = tdb_wrap_open(result, fname,
lpcfg_tdb_hash_size(lp_ctx, fname),
lpcfg_tdb_flags(lp_ctx,
TDB_DEFAULT |
TDB_CLEAR_IF_FIRST |
TDB_INCOMPATIBLE_HASH),
O_RDWR|O_CREAT, 0600);
talloc_unlink(result, lp_ctx);
if (result->tdb == NULL) {
DEBUG(1, ("Could not open mutex.tdb: %s\n",

View File

@ -59,12 +59,12 @@ bool serverid_parent_init(TALLOC_CTX *mem_ctx)
fname = lock_path("serverid.tdb");
db = tdb_wrap_open_(mem_ctx, fname,
lpcfg_tdb_hash_size(lp_ctx, fname),
lpcfg_tdb_flags(lp_ctx,
TDB_DEFAULT|TDB_CLEAR_IF_FIRST|
TDB_INCOMPATIBLE_HASH),
O_RDWR|O_CREAT, 0644);
db = tdb_wrap_open(mem_ctx, fname,
lpcfg_tdb_hash_size(lp_ctx, fname),
lpcfg_tdb_flags(lp_ctx,
TDB_DEFAULT|TDB_CLEAR_IF_FIRST|
TDB_INCOMPATIBLE_HASH),
O_RDWR|O_CREAT, 0644);
talloc_unlink(mem_ctx, lp_ctx);
if (db == NULL) {
DEBUG(1, ("could not open serverid.tdb: %s\n",

View File

@ -256,9 +256,9 @@ static bool posix_eadb_init(int snum, struct tdb_wrap **p_db)
lp_ctx = loadparm_init_s3(NULL, loadparm_s3_helpers());
become_root();
db = tdb_wrap_open_(NULL, eadb, 50000,
lpcfg_tdb_flags(lp_ctx, TDB_DEFAULT),
O_RDWR|O_CREAT, 0600);
db = tdb_wrap_open(NULL, eadb, 50000,
lpcfg_tdb_flags(lp_ctx, TDB_DEFAULT),
O_RDWR|O_CREAT, 0600);
unbecome_root();
talloc_unlink(NULL, lp_ctx);

View File

@ -240,7 +240,7 @@ static int partition_metadata_open(struct ldb_module *module, bool create)
lp_ctx = talloc_get_type_abort(ldb_get_opaque(ldb, "loadparm"),
struct loadparm_context);
data->metadata->db = tdb_wrap_open_(
data->metadata->db = tdb_wrap_open(
data->metadata, filename, 10,
lpcfg_tdb_flags(lp_ctx, TDB_DEFAULT), open_flags, 0660);
if (data->metadata->db == NULL) {

View File

@ -90,9 +90,9 @@ static int schema_metadata_open(struct ldb_module *module)
lp_ctx = talloc_get_type_abort(ldb_get_opaque(ldb, "loadparm"),
struct loadparm_context);
data->metadata = tdb_wrap_open_(data, filename, 10,
lpcfg_tdb_flags(lp_ctx, TDB_DEFAULT),
open_flags, 0660);
data->metadata = tdb_wrap_open(data, filename, 10,
lpcfg_tdb_flags(lp_ctx, TDB_DEFAULT),
open_flags, 0660);
if (data->metadata == NULL) {
talloc_free(tmp_ctx);
return LDB_ERR_OPERATIONS_ERROR;

View File

@ -899,10 +899,10 @@ static struct tdb_wrap *irpc_namedb_open(struct imessaging_context *msg_ctx)
if (path == NULL) {
return NULL;
}
t = tdb_wrap_open_(msg_ctx, path,
lpcfg_tdb_hash_size(msg_ctx->lp_ctx, path),
lpcfg_tdb_flags(msg_ctx->lp_ctx, 0),
O_RDWR|O_CREAT, 0660);
t = tdb_wrap_open(msg_ctx, path,
lpcfg_tdb_hash_size(msg_ctx->lp_ctx, path),
lpcfg_tdb_flags(msg_ctx->lp_ctx, 0),
O_RDWR|O_CREAT, 0660);
talloc_free(path);
return t;
}

View File

@ -50,7 +50,7 @@ static PyObject *py_wrap_setxattr(PyObject *self, PyObject *args)
blob.length = blobsize;
mem_ctx = talloc_new(NULL);
eadb = tdb_wrap_open_(
eadb = tdb_wrap_open(
mem_ctx, tdbname, 50000,
lpcfg_tdb_flags(py_default_loadparm_context(mem_ctx),
TDB_DEFAULT),
@ -85,7 +85,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args)
return NULL;
mem_ctx = talloc_new(NULL);
eadb = tdb_wrap_open_(
eadb = tdb_wrap_open(
mem_ctx, tdbname, 50000,
lpcfg_tdb_flags(py_default_loadparm_context(mem_ctx),
TDB_DEFAULT),

View File

@ -120,7 +120,7 @@ static void pvfs_setup_options(struct pvfs_state *pvfs)
/* allow xattrs to be stored in a external tdb */
eadb = share_string_option(pvfs, scfg, PVFS_EADB, NULL);
if (eadb != NULL) {
pvfs->ea_db = tdb_wrap_open_(
pvfs->ea_db = tdb_wrap_open(
pvfs, eadb, 50000,
lpcfg_tdb_flags(pvfs->ntvfs->ctx->lp_ctx, TDB_DEFAULT),
O_RDWR|O_CREAT, 0600);

View File

@ -59,10 +59,10 @@ bool randseed_init(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
fname = lpcfg_private_path(mem_ctx, lp_ctx, "randseed.tdb");
tdb = tdb_wrap_open_(mem_ctx, fname,
lpcfg_tdb_hash_size(lp_ctx, fname),
lpcfg_tdb_flags(lp_ctx, TDB_DEFAULT),
O_RDWR|O_CREAT, 0600);
tdb = tdb_wrap_open(mem_ctx, fname,
lpcfg_tdb_hash_size(lp_ctx, fname),
lpcfg_tdb_flags(lp_ctx, TDB_DEFAULT),
O_RDWR|O_CREAT, 0600);
if (!tdb) {
DEBUG(0,("Failed to open %s\n", fname));

View File

@ -64,9 +64,9 @@ static bool test_tdb_speed(struct torture_context *torture, const void *_data)
torture_comment(torture, "Testing tdb speed for sidmap\n");
tdbw = tdb_wrap_open_(tmp_ctx, "test.tdb", 10000,
lpcfg_tdb_flags(torture->lp_ctx, 0),
O_RDWR|O_CREAT|O_TRUNC, 0600);
tdbw = tdb_wrap_open(tmp_ctx, "test.tdb", 10000,
lpcfg_tdb_flags(torture->lp_ctx, 0),
O_RDWR|O_CREAT|O_TRUNC, 0600);
if (!tdbw) {
torture_result(torture, TORTURE_FAIL, "Failed to open test.tdb");
goto failed;