summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/cluster/local.c2
-rw-r--r--source4/lib/messaging/messaging.c2
-rw-r--r--source4/lib/tdb_wrap.c117
-rw-r--r--source4/lib/tdb_wrap.h45
-rw-r--r--source4/lib/wscript_build9
-rw-r--r--source4/ntvfs/common/brlock_tdb.c2
-rw-r--r--source4/ntvfs/common/notify.c2
-rw-r--r--source4/ntvfs/common/opendb_tdb.c2
-rw-r--r--source4/ntvfs/posix/python/pyxattr_tdb.c2
-rw-r--r--source4/ntvfs/posix/vfs_posix.c2
-rw-r--r--source4/ntvfs/posix/xattr_tdb.c2
-rw-r--r--source4/param/secrets.c2
-rw-r--r--source4/torture/local/dbspeed.c2
13 files changed, 10 insertions, 181 deletions
diff --git a/source4/cluster/local.c b/source4/cluster/local.c
index b6ec7644d3..9977a2e648 100644
--- a/source4/cluster/local.c
+++ b/source4/cluster/local.c
@@ -23,7 +23,7 @@
#include "cluster/cluster.h"
#include "cluster/cluster_private.h"
#include <tdb.h>
-#include "tdb_wrap.h"
+#include "lib/util/tdb_wrap.h"
#include "system/filesys.h"
#include "param/param.h"
#include "librpc/gen_ndr/server_id4.h"
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 1b0fc1291c..3a330d5794 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -27,7 +27,7 @@
#include "lib/socket/socket.h"
#include "librpc/gen_ndr/ndr_irpc.h"
#include "lib/messaging/irpc.h"
-#include "tdb_wrap.h"
+#include "lib/util/tdb_wrap.h"
#include "../lib/util/unix_privs.h"
#include "librpc/rpc/dcerpc.h"
#include <tdb.h>
diff --git a/source4/lib/tdb_wrap.c b/source4/lib/tdb_wrap.c
deleted file mode 100644
index 97294e13d3..0000000000
--- a/source4/lib/tdb_wrap.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- TDB wrap functions
-
- Copyright (C) Andrew Tridgell 2004
- Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include <tdb.h>
-#include "../lib/util/dlinklist.h"
-#include "tdb_wrap.h"
-#include <tdb.h>
-
-static struct tdb_wrap *tdb_list;
-
-/* destroy the last connection to a tdb */
-static int tdb_wrap_destructor(struct tdb_wrap *w)
-{
- tdb_close(w->tdb);
- DLIST_REMOVE(tdb_list, w);
- return 0;
-}
-
-/*
- Log tdb messages via DEBUG().
-*/
-static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level,
- const char *format, ...) PRINTF_ATTRIBUTE(3,4);
-
-static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level,
- const char *format, ...)
-{
- va_list ap;
- char *ptr = NULL;
- int dl;
-
- va_start(ap, format);
- vasprintf(&ptr, format, ap);
- va_end(ap);
-
- switch (level) {
- case TDB_DEBUG_FATAL:
- dl = 0;
- break;
- case TDB_DEBUG_ERROR:
- dl = 1;
- break;
- case TDB_DEBUG_WARNING:
- dl = 2;
- break;
- case TDB_DEBUG_TRACE:
- dl = 5;
- break;
- default:
- dl = 0;
- }
-
- if (ptr != NULL) {
- const char *name = tdb_name(tdb);
- DEBUG(dl, ("tdb(%s): %s", name ? name : "unnamed", ptr));
- free(ptr);
- }
-}
-
-
-/*
- 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 *w;
- struct tdb_logging_context log_ctx;
- log_ctx.log_fn = tdb_wrap_log;
-
- for (w=tdb_list;w;w=w->next) {
- if (strcmp(name, w->name) == 0) {
- return talloc_reference(mem_ctx, w);
- }
- }
-
- w = talloc(mem_ctx, struct tdb_wrap);
- if (w == NULL) {
- return NULL;
- }
-
- w->name = talloc_strdup(w, name);
-
- w->tdb = tdb_open_ex(name, hash_size, tdb_flags,
- open_flags, mode, &log_ctx, NULL);
- if (w->tdb == NULL) {
- talloc_free(w);
- return NULL;
- }
-
- talloc_set_destructor(w, tdb_wrap_destructor);
-
- DLIST_ADD(tdb_list, w);
-
- return w;
-}
diff --git a/source4/lib/tdb_wrap.h b/source4/lib/tdb_wrap.h
deleted file mode 100644
index 94035c1bea..0000000000
--- a/source4/lib/tdb_wrap.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- database wrap headers
-
- Copyright (C) Andrew Tridgell 2004
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/* IMPORTANT: tdb_wrap should be always preferred over tdb_context for end consumer functions
- it's because if the code will be running inside smbd, then we must use the linked list
- of open tdb files, to determine if the tdb we desire is already open
- as otherwise, when you close the tdb (even on a different file descriptor),
- ALL LOCKS are lost (due to a real screwup in the POSIX specification that nobody has been able to get fixed)
-*/
-
-#ifndef _TDB_WRAP_H_
-#define _TDB_WRAP_H_
-
-#include <tdb.h>
-
-struct tdb_wrap {
- struct tdb_context *tdb;
-
- const char *name;
- struct tdb_wrap *next, *prev;
-};
-
-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);
-
-#endif /* _TDB_WRAP_H_ */
diff --git a/source4/lib/wscript_build b/source4/lib/wscript_build
index 872259d670..cf60820da7 100644
--- a/source4/lib/wscript_build
+++ b/source4/lib/wscript_build
@@ -5,12 +5,3 @@ bld.SAMBA_SUBSYSTEM('GENCACHE',
enabled=False,
deps='tdb-wrap'
)
-
-
-bld.SAMBA_LIBRARY('tdb-wrap',
- source='tdb_wrap.c',
- deps='tdb talloc samba-util',
- public_headers='tdb_wrap.h',
- private_library=True
- )
-
diff --git a/source4/ntvfs/common/brlock_tdb.c b/source4/ntvfs/common/brlock_tdb.c
index 630b4072db..ab4d91c4db 100644
--- a/source4/ntvfs/common/brlock_tdb.c
+++ b/source4/ntvfs/common/brlock_tdb.c
@@ -28,7 +28,7 @@
#include "system/filesys.h"
#include <tdb.h>
#include "messaging/messaging.h"
-#include "tdb_wrap.h"
+#include "lib/util/tdb_wrap.h"
#include "lib/messaging/irpc.h"
#include "libcli/libcli.h"
#include "cluster/cluster.h"
diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c
index d05f04707a..7260759341 100644
--- a/source4/ntvfs/common/notify.c
+++ b/source4/ntvfs/common/notify.c
@@ -28,7 +28,7 @@
#include <tdb.h>
#include "../lib/util/util_tdb.h"
#include "messaging/messaging.h"
-#include "tdb_wrap.h"
+#include "lib/util/tdb_wrap.h"
#include "lib/messaging/irpc.h"
#include "librpc/gen_ndr/ndr_s4_notify.h"
#include "../lib/util/dlinklist.h"
diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c
index 536d17f9c0..7c2707f7c6 100644
--- a/source4/ntvfs/common/opendb_tdb.c
+++ b/source4/ntvfs/common/opendb_tdb.c
@@ -42,7 +42,7 @@
#include "system/filesys.h"
#include <tdb.h>
#include "messaging/messaging.h"
-#include "tdb_wrap.h"
+#include "lib/util/tdb_wrap.h"
#include "lib/messaging/irpc.h"
#include "librpc/gen_ndr/ndr_opendb.h"
#include "ntvfs/ntvfs.h"
diff --git a/source4/ntvfs/posix/python/pyxattr_tdb.c b/source4/ntvfs/posix/python/pyxattr_tdb.c
index 5e72ac9dde..34b449f70f 100644
--- a/source4/ntvfs/posix/python/pyxattr_tdb.c
+++ b/source4/ntvfs/posix/python/pyxattr_tdb.c
@@ -21,7 +21,7 @@
#include <Python.h>
#include "includes.h"
#include <tdb.h>
-#include "tdb_wrap.h"
+#include "lib/util/tdb_wrap.h"
#include "librpc/ndr/libndr.h"
#include "lib/util/wrap_xattr.h"
#include "ntvfs/posix/vfs_posix.h"
diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c
index ca1d163327..b79ae957f3 100644
--- a/source4/ntvfs/posix/vfs_posix.c
+++ b/source4/ntvfs/posix/vfs_posix.c
@@ -27,7 +27,7 @@
#include "vfs_posix.h"
#include "librpc/gen_ndr/security.h"
#include <tdb.h>
-#include "tdb_wrap.h"
+#include "lib/util/tdb_wrap.h"
#include "libcli/security/security.h"
#include "lib/events/events.h"
#include "param/param.h"
diff --git a/source4/ntvfs/posix/xattr_tdb.c b/source4/ntvfs/posix/xattr_tdb.c
index de7c83677a..2d6f1d94d0 100644
--- a/source4/ntvfs/posix/xattr_tdb.c
+++ b/source4/ntvfs/posix/xattr_tdb.c
@@ -20,7 +20,7 @@
*/
#include "includes.h"
-#include "tdb_wrap.h"
+#include "lib/util/tdb_wrap.h"
#include <tdb.h>
#include "vfs_posix.h"
diff --git a/source4/param/secrets.c b/source4/param/secrets.c
index 0f3c1e36bb..287b2c7281 100644
--- a/source4/param/secrets.c
+++ b/source4/param/secrets.c
@@ -25,7 +25,7 @@
#include "secrets.h"
#include "param/param.h"
#include "system/filesys.h"
-#include "tdb_wrap.h"
+#include "lib/util/tdb_wrap.h"
#include "lib/ldb-samba/ldb_wrap.h"
#include <ldb.h>
#include "../lib/util/util_tdb.h"
diff --git a/source4/torture/local/dbspeed.c b/source4/torture/local/dbspeed.c
index 8768b349ef..55fed70b0a 100644
--- a/source4/torture/local/dbspeed.c
+++ b/source4/torture/local/dbspeed.c
@@ -25,7 +25,7 @@
#include <ldb.h>
#include <ldb_errors.h>
#include "ldb_wrap.h"
-#include "lib/tdb_wrap.h"
+#include "lib/util/tdb_wrap.h"
#include "torture/smbtorture.h"
#include "param/param.h"