Commit 26bcbdd5 authored by Mathieu Parent's avatar Mathieu Parent

New upstream version 1.2.3

parent b424b387
This diff is collapsed.
pyldb_Dn_FromDn: PyObject *(struct ldb_dn *)
pyldb_Object_AsDn: bool (TALLOC_CTX *, PyObject *, struct ldb_context *, struct ldb_dn **)
pyldb_Dn_FromDn: PyObject *(struct ldb_dn *)
pyldb_Object_AsDn: bool (TALLOC_CTX *, PyObject *, struct ldb_context *, struct ldb_dn **)
......@@ -115,7 +115,7 @@ def dist(appname='', version=''):
blacklisted = True
if blacklisted:
continue
if os.path.isdir(abspath) and not os.path.islink(abspath):
if os.path.isdir(abspath):
continue
if dstsubdir != '.':
f = dstsubdir + '/' + f
......@@ -182,7 +182,7 @@ def dist(appname='', version=''):
absfile = os.path.join(srcdir, file)
if os.path.isdir(absfile) and not os.path.islink(absfile):
if os.path.isdir(absfile):
destdir = destfile
dir = file
files = list_directory_files(dir)
......
......@@ -108,7 +108,6 @@ def write_build_options_header(fp):
fp.write(" output(screen,\" PIDDIR: %s\\n\", get_dyn_PIDDIR());\n")
fp.write(" output(screen,\" SMB_PASSWD_FILE: %s\\n\",get_dyn_SMB_PASSWD_FILE());\n")
fp.write(" output(screen,\" PRIVATE_DIR: %s\\n\",get_dyn_PRIVATE_DIR());\n")
fp.write(" output(screen,\" BINDDNS_DIR: %s\\n\",get_dyn_BINDDNS_DIR());\n")
fp.write("\n")
def write_build_options_footer(fp):
......
......@@ -885,31 +885,13 @@ def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
python_fixup=python_fixup, base_name=trim_path)
Build.BuildContext.INSTALL_WILDCARD = INSTALL_WILDCARD
def INSTALL_DIR(bld, path, chmod=0o755):
"""Install a directory if it doesn't exist, always set permissions."""
if not path:
return []
if bld.is_install > 0:
path = bld.EXPAND_VARIABLES(path)
if not os.path.isdir(path):
try:
os.makedirs(path)
os.chmod(path, chmod)
except OSError, e:
if not os.path.isdir(path):
raise Utils.WafError("Cannot create the folder '%s' (error: %s)" % (path, e))
else:
os.chmod(path, chmod)
Build.BuildContext.INSTALL_DIR = INSTALL_DIR
def INSTALL_DIRS(bld, destdir, dirs, chmod=0o755):
def INSTALL_DIRS(bld, destdir, dirs):
'''install a set of directories'''
destdir = bld.EXPAND_VARIABLES(destdir)
dirs = bld.EXPAND_VARIABLES(dirs)
for d in TO_LIST(dirs):
INSTALL_DIR(bld, os.path.join(destdir, d), chmod)
bld.install_dir(os.path.join(destdir, d))
Build.BuildContext.INSTALL_DIRS = INSTALL_DIRS
......
This diff is collapsed.
......@@ -355,6 +355,7 @@ static bool ldb_tdb_single_valued(const struct ldb_schema_attribute *a,
}
static int ltdb_add_internal(struct ldb_module *module,
struct ltdb_private *ltdb,
const struct ldb_message *msg,
bool check_single_value)
{
......@@ -419,7 +420,7 @@ static int ltdb_add_internal(struct ldb_module *module,
return ret;
}
ret = ltdb_index_add_new(module, msg);
ret = ltdb_index_add_new(module, ltdb, msg);
if (ret != LDB_SUCCESS) {
return ret;
}
......@@ -436,6 +437,8 @@ static int ltdb_add(struct ltdb_context *ctx)
{
struct ldb_module *module = ctx->module;
struct ldb_request *req = ctx->req;
void *data = ldb_module_get_private(module);
struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret = LDB_SUCCESS;
ret = ltdb_check_special_dn(module, req->op.add.message);
......@@ -449,7 +452,8 @@ static int ltdb_add(struct ltdb_context *ctx)
return LDB_ERR_OPERATIONS_ERROR;
}
ret = ltdb_add_internal(module, req->op.add.message, true);
ret = ltdb_add_internal(module, ltdb,
req->op.add.message, true);
return ret;
}
......@@ -609,6 +613,7 @@ static int ltdb_msg_add_element(struct ldb_message *msg,
delete all elements having a specified attribute name
*/
static int msg_delete_attribute(struct ldb_module *module,
struct ltdb_private *ltdb,
struct ldb_message *msg, const char *name)
{
unsigned int i;
......@@ -621,7 +626,7 @@ static int msg_delete_attribute(struct ldb_module *module,
}
i = el - msg->elements;
ret = ltdb_index_del_element(module, msg->dn, el);
ret = ltdb_index_del_element(module, ltdb, msg->dn, el);
if (ret != LDB_SUCCESS) {
return ret;
}
......@@ -643,6 +648,7 @@ static int msg_delete_attribute(struct ldb_module *module,
return LDB Error on failure
*/
static int msg_delete_element(struct ldb_module *module,
struct ltdb_private *ltdb,
struct ldb_message *msg,
const char *name,
const struct ldb_val *val)
......@@ -675,10 +681,11 @@ static int msg_delete_element(struct ldb_module *module,
}
if (matched) {
if (el->num_values == 1) {
return msg_delete_attribute(module, msg, name);
return msg_delete_attribute(module,
ltdb, msg, name);
}
ret = ltdb_index_del_value(module, msg->dn, el, i);
ret = ltdb_index_del_value(module, ltdb, msg->dn, el, i);
if (ret != LDB_SUCCESS) {
return ret;
}
......@@ -715,6 +722,8 @@ int ltdb_modify_internal(struct ldb_module *module,
struct ldb_request *req)
{
struct ldb_context *ldb = ldb_module_get_ctx(module);
void *data = ldb_module_get_private(module);
struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct ldb_message *msg2;
unsigned int i, j;
int ret = LDB_SUCCESS, idx;
......@@ -800,7 +809,8 @@ int ltdb_modify_internal(struct ldb_module *module,
ret = LDB_ERR_OTHER;
goto done;
}
ret = ltdb_index_add_element(module, msg2->dn,
ret = ltdb_index_add_element(module, ltdb,
msg2->dn,
el);
if (ret != LDB_SUCCESS) {
goto done;
......@@ -881,7 +891,8 @@ int ltdb_modify_internal(struct ldb_module *module,
el2->values = vals;
el2->num_values += el->num_values;
ret = ltdb_index_add_element(module, msg2->dn, el);
ret = ltdb_index_add_element(module, ltdb,
msg2->dn, el);
if (ret != LDB_SUCCESS) {
goto done;
}
......@@ -945,7 +956,8 @@ int ltdb_modify_internal(struct ldb_module *module,
}
/* Delete the attribute if it exists in the DB */
if (msg_delete_attribute(module, msg2,
if (msg_delete_attribute(module, ltdb,
msg2,
el->name) != 0) {
ret = LDB_ERR_OTHER;
goto done;
......@@ -958,7 +970,8 @@ int ltdb_modify_internal(struct ldb_module *module,
goto done;
}
ret = ltdb_index_add_element(module, msg2->dn, el);
ret = ltdb_index_add_element(module, ltdb,
msg2->dn, el);
if (ret != LDB_SUCCESS) {
goto done;
}
......@@ -974,7 +987,9 @@ int ltdb_modify_internal(struct ldb_module *module,
if (msg->elements[i].num_values == 0) {
/* Delete the whole attribute */
ret = msg_delete_attribute(module, msg2,
ret = msg_delete_attribute(module,
ltdb,
msg2,
msg->elements[i].name);
if (ret == LDB_ERR_NO_SUCH_ATTRIBUTE &&
control_permissive) {
......@@ -991,6 +1006,7 @@ int ltdb_modify_internal(struct ldb_module *module,
/* Delete specified values from an attribute */
for (j=0; j < msg->elements[i].num_values; j++) {
ret = msg_delete_element(module,
ltdb,
msg2,
msg->elements[i].name,
&msg->elements[i].values[j]);
......@@ -1142,7 +1158,7 @@ static int ltdb_rename(struct ltdb_context *ctx)
* deleted attributes. We could go through all elements but that's
* maybe not the most efficient way
*/
ret = ltdb_add_internal(module, msg, false);
ret = ltdb_add_internal(module, ltdb, msg, false);
talloc_free(msg);
......
......@@ -82,13 +82,21 @@ int ltdb_check_at_attributes_values(const struct ldb_val *value);
struct ldb_parse_tree;
int ltdb_search_indexed(struct ltdb_context *ctx, uint32_t *);
int ltdb_index_add_new(struct ldb_module *module, const struct ldb_message *msg);
int ltdb_index_add_new(struct ldb_module *module,
struct ltdb_private *ltdb,
const struct ldb_message *msg);
int ltdb_index_delete(struct ldb_module *module, const struct ldb_message *msg);
int ltdb_index_del_element(struct ldb_module *module, struct ldb_dn *dn,
int ltdb_index_del_element(struct ldb_module *module,
struct ltdb_private *ltdb,
struct ldb_dn *dn,
struct ldb_message_element *el);
int ltdb_index_add_element(struct ldb_module *module, struct ldb_dn *dn,
int ltdb_index_add_element(struct ldb_module *module,
struct ltdb_private *ltdb,
struct ldb_dn *dn,
struct ldb_message_element *el);
int ltdb_index_del_value(struct ldb_module *module, struct ldb_dn *dn,
int ltdb_index_del_value(struct ldb_module *module,
struct ltdb_private *ltdb,
struct ldb_dn *dn,
struct ldb_message_element *el, unsigned int v_idx);
int ltdb_reindex(struct ldb_module *module);
int ltdb_index_transaction_start(struct ldb_module *module);
......
......@@ -249,24 +249,15 @@ def configure(conf):
if conf.CONFIG_SET('HAVE_MEMALIGN'):
conf.CHECK_DECLS('memalign', headers='malloc.h')
# glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
if conf.CHECK_CODE('''
#define _XOPEN_SOURCE 600
#include <stdlib.h>
#if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
#error probably broken posix_fallocate
#endif
''',
'_POSIX_FALLOCATE_CAPABLE_LIBC',
msg='Checking for posix_fallocate-capable libc'):
conf.CHECK_FUNCS('posix_fallocate')
conf.CHECK_FUNCS('prctl dirname basename')
strlcpy_in_bsd = False
# libbsd on some platforms provides strlcpy and strlcat
if not conf.CHECK_FUNCS('strlcpy strlcat'):
conf.CHECK_FUNCS_IN('strlcpy strlcat', 'bsd', headers='bsd/string.h',
checklibc=True)
if conf.CHECK_FUNCS_IN('strlcpy strlcat', 'bsd', headers='bsd/string.h',
checklibc=True):
strlcpy_in_bsd = True
if not conf.CHECK_FUNCS('getpeereid'):
conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h')
if not conf.CHECK_FUNCS_IN('setproctitle', 'setproctitle', headers='setproctitle.h'):
......@@ -623,6 +614,9 @@ removeea setea
# look for a method of finding the list of network interfaces
for method in ['HAVE_IFACE_GETIFADDRS', 'HAVE_IFACE_AIX', 'HAVE_IFACE_IFCONF', 'HAVE_IFACE_IFREQ']:
bsd_for_strlcpy = ''
if strlcpy_in_bsd:
bsd_for_strlcpy = ' bsd'
if conf.CHECK_CODE('''
#define %s 1
#define NO_CONFIG_H 1
......@@ -635,7 +629,7 @@ removeea setea
#include "test/getifaddrs.c"
''' % method,
method,
lib='nsl socket',
lib='nsl socket' + bsd_for_strlcpy,
addmain=False,
execute=True):
break
......
_pytalloc_check_type: int (PyObject *, const char *)
_pytalloc_get_mem_ctx: TALLOC_CTX *(PyObject *)
_pytalloc_get_ptr: void *(PyObject *)
_pytalloc_get_type: void *(PyObject *, const char *)
pytalloc_BaseObject_PyType_Ready: int (PyTypeObject *)
pytalloc_BaseObject_check: int (PyObject *)
pytalloc_BaseObject_size: size_t (void)
pytalloc_CObject_FromTallocPtr: PyObject *(void *)
pytalloc_Check: int (PyObject *)
pytalloc_GenericObject_reference_ex: PyObject *(TALLOC_CTX *, void *)
pytalloc_GenericObject_steal_ex: PyObject *(TALLOC_CTX *, void *)
pytalloc_GetBaseObjectType: PyTypeObject *(void)
pytalloc_GetObjectType: PyTypeObject *(void)
pytalloc_reference_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
pytalloc_steal: PyObject *(PyTypeObject *, void *)
pytalloc_steal_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
_pytalloc_check_type: int (PyObject *, const char *)
_pytalloc_get_mem_ctx: TALLOC_CTX *(PyObject *)
_pytalloc_get_ptr: void *(PyObject *)
_pytalloc_get_type: void *(PyObject *, const char *)
pytalloc_BaseObject_PyType_Ready: int (PyTypeObject *)
pytalloc_BaseObject_check: int (PyObject *)
pytalloc_BaseObject_size: size_t (void)
pytalloc_Check: int (PyObject *)
pytalloc_GenericObject_reference_ex: PyObject *(TALLOC_CTX *, void *)
pytalloc_GenericObject_steal_ex: PyObject *(TALLOC_CTX *, void *)
pytalloc_GetBaseObjectType: PyTypeObject *(void)
pytalloc_GetObjectType: PyTypeObject *(void)
pytalloc_reference_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
pytalloc_steal: PyObject *(PyTypeObject *, void *)
pytalloc_steal_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
_talloc: void *(const void *, size_t)
_talloc_array: void *(const void *, size_t, unsigned int, const char *)
_talloc_free: int (void *, const char *)
_talloc_get_type_abort: void *(const void *, const char *, const char *)
_talloc_memdup: void *(const void *, const void *, size_t, const char *)
_talloc_move: void *(const void *, const void *)
_talloc_pooled_object: void *(const void *, size_t, const char *, unsigned int, size_t)
_talloc_realloc: void *(const void *, void *, size_t, const char *)
_talloc_realloc_array: void *(const void *, void *, size_t, unsigned int, const char *)
_talloc_reference_loc: void *(const void *, const void *, const char *)
_talloc_set_destructor: void (const void *, int (*)(void *))
_talloc_steal_loc: void *(const void *, const void *, const char *)
_talloc_zero: void *(const void *, size_t, const char *)
_talloc_zero_array: void *(const void *, size_t, unsigned int, const char *)
talloc_asprintf: char *(const void *, const char *, ...)
talloc_asprintf_append: char *(char *, const char *, ...)
talloc_asprintf_append_buffer: char *(char *, const char *, ...)
talloc_autofree_context: void *(void)
talloc_check_name: void *(const void *, const char *)
talloc_disable_null_tracking: void (void)
talloc_enable_leak_report: void (void)
talloc_enable_leak_report_full: void (void)
talloc_enable_null_tracking: void (void)
talloc_enable_null_tracking_no_autofree: void (void)
talloc_find_parent_byname: void *(const void *, const char *)
talloc_free_children: void (void *)
talloc_get_name: const char *(const void *)
talloc_get_size: size_t (const void *)
talloc_increase_ref_count: int (const void *)
talloc_init: void *(const char *, ...)
talloc_is_parent: int (const void *, const void *)
talloc_named: void *(const void *, size_t, const char *, ...)
talloc_named_const: void *(const void *, size_t, const char *)
talloc_parent: void *(const void *)
talloc_parent_name: const char *(const void *)
talloc_pool: void *(const void *, size_t)
talloc_realloc_fn: void *(const void *, void *, size_t)
talloc_reference_count: size_t (const void *)
talloc_reparent: void *(const void *, const void *, const void *)
talloc_report: void (const void *, FILE *)
talloc_report_depth_cb: void (const void *, int, int, void (*)(const void *, int, int, int, void *), void *)
talloc_report_depth_file: void (const void *, int, int, FILE *)
talloc_report_full: void (const void *, FILE *)
talloc_set_abort_fn: void (void (*)(const char *))
talloc_set_log_fn: void (void (*)(const char *))
talloc_set_log_stderr: void (void)
talloc_set_memlimit: int (const void *, size_t)
talloc_set_name: const char *(const void *, const char *, ...)
talloc_set_name_const: void (const void *, const char *)
talloc_show_parents: void (const void *, FILE *)
talloc_strdup: char *(const void *, const char *)
talloc_strdup_append: char *(char *, const char *)
talloc_strdup_append_buffer: char *(char *, const char *)
talloc_strndup: char *(const void *, const char *, size_t)
talloc_strndup_append: char *(char *, const char *, size_t)
talloc_strndup_append_buffer: char *(char *, const char *, size_t)
talloc_test_get_magic: int (void)
talloc_total_blocks: size_t (const void *)
talloc_total_size: size_t (const void *)
talloc_unlink: int (const void *, void *)
talloc_vasprintf: char *(const void *, const char *, va_list)
talloc_vasprintf_append: char *(char *, const char *, va_list)
talloc_vasprintf_append_buffer: char *(char *, const char *, va_list)
talloc_version_major: int (void)
talloc_version_minor: int (void)
#!/usr/bin/env python
APPNAME = 'talloc'
VERSION = '2.1.10'
VERSION = '2.1.9'
blddir = 'bin'
......@@ -74,22 +74,19 @@ def configure(conf):
implied_deps='replace'):
conf.define('USING_SYSTEM_TALLOC', 1)
if conf.env.disable_python:
using_system_pytalloc_util = True
if not conf.CHECK_BUNDLED_SYSTEM_PKG('pytalloc-util', minversion=VERSION,
implied_deps='talloc replace'):
using_system_pytalloc_util = False
else:
using_system_pytalloc_util = True
if not conf.CHECK_BUNDLED_SYSTEM_PKG('pytalloc-util', minversion=VERSION,
# We need to get a pytalloc-util for all the python versions
# we are building for
if conf.env['EXTRA_PYTHON']:
name = 'pytalloc-util' + conf.all_envs['extrapython']['PYTHON_SO_ABI_FLAG']
if not conf.CHECK_BUNDLED_SYSTEM_PKG(name, minversion=VERSION,
implied_deps='talloc replace'):
using_system_pytalloc_util = False
# We need to get a pytalloc-util for all the python versions
# we are building for
if conf.env['EXTRA_PYTHON']:
name = 'pytalloc-util' + conf.all_envs['extrapython']['PYTHON_SO_ABI_FLAG']
if not conf.CHECK_BUNDLED_SYSTEM_PKG(name, minversion=VERSION,
implied_deps='talloc replace'):
using_system_pytalloc_util = False
if using_system_pytalloc_util:
conf.define('USING_SYSTEM_PYTALLOC_UTIL', 1)
......@@ -174,18 +171,12 @@ def build(bld):
def test(ctx):
'''run talloc testsuite'''
import Utils, samba_utils
samba_utils.ADD_LD_LIBRARY_PATH('bin/shared')
samba_utils.ADD_LD_LIBRARY_PATH('bin/shared/private')
cmd = os.path.join(Utils.g_module.blddir, 'talloc_testsuite')
ret = samba_utils.RUN_COMMAND(cmd)
print("testsuite returned %d" % ret)
magic_helper_cmd = os.path.join(Utils.g_module.blddir, 'talloc_test_magic_differs_helper')
magic_cmd = os.path.join(srcdir, 'lib', 'talloc',
'test_magic_differs.sh')
if not os.path.exists(magic_cmd):
magic_cmd = os.path.join(srcdir, 'test_magic_differs.sh')
magic_ret = samba_utils.RUN_COMMAND(magic_cmd + " " + magic_helper_cmd)
print("magic differs test returned %d" % magic_ret)
......
tdb_add_flags: void (struct tdb_context *, unsigned int)
tdb_append: int (struct tdb_context *, TDB_DATA, TDB_DATA)
tdb_chainlock: int (struct tdb_context *, TDB_DATA)
tdb_chainlock_mark: int (struct tdb_context *, TDB_DATA)
tdb_chainlock_nonblock: int (struct tdb_context *, TDB_DATA)
tdb_chainlock_read: int (struct tdb_context *, TDB_DATA)
tdb_chainlock_read_nonblock: int (struct tdb_context *, TDB_DATA)
tdb_chainlock_unmark: int (struct tdb_context *, TDB_DATA)
tdb_chainunlock: int (struct tdb_context *, TDB_DATA)
tdb_chainunlock_read: int (struct tdb_context *, TDB_DATA)
tdb_check: int (struct tdb_context *, int (*)(TDB_DATA, TDB_DATA, void *), void *)
tdb_close: int (struct tdb_context *)
tdb_delete: int (struct tdb_context *, TDB_DATA)
tdb_dump_all: void (struct tdb_context *)
tdb_enable_seqnum: void (struct tdb_context *)
tdb_error: enum TDB_ERROR (struct tdb_context *)
tdb_errorstr: const char *(struct tdb_context *)
tdb_exists: int (struct tdb_context *, TDB_DATA)
tdb_fd: int (struct tdb_context *)
tdb_fetch: TDB_DATA (struct tdb_context *, TDB_DATA)
tdb_firstkey: TDB_DATA (struct tdb_context *)
tdb_freelist_size: int (struct tdb_context *)
tdb_get_flags: int (struct tdb_context *)
tdb_get_logging_private: void *(struct tdb_context *)
tdb_get_seqnum: int (struct tdb_context *)
tdb_hash_size: int (struct tdb_context *)
tdb_increment_seqnum_nonblock: void (struct tdb_context *)
tdb_jenkins_hash: unsigned int (TDB_DATA *)
tdb_lock_nonblock: int (struct tdb_context *, int, int)
tdb_lockall: int (struct tdb_context *)
tdb_lockall_mark: int (struct tdb_context *)
tdb_lockall_nonblock: int (struct tdb_context *)
tdb_lockall_read: int (struct tdb_context *)
tdb_lockall_read_nonblock: int (struct tdb_context *)
tdb_lockall_unmark: int (struct tdb_context *)
tdb_log_fn: tdb_log_func (struct tdb_context *)
tdb_map_size: size_t (struct tdb_context *)
tdb_name: const char *(struct tdb_context *)
tdb_nextkey: TDB_DATA (struct tdb_context *, TDB_DATA)
tdb_null: dptr = 0xXXXX, dsize = 0
tdb_open: struct tdb_context *(const char *, int, int, int, mode_t)
tdb_open_ex: struct tdb_context *(const char *, int, int, int, mode_t, const struct tdb_logging_context *, tdb_hash_func)
tdb_parse_record: int (struct tdb_context *, TDB_DATA, int (*)(TDB_DATA, TDB_DATA, void *), void *)
tdb_printfreelist: int (struct tdb_context *)
tdb_remove_flags: void (struct tdb_context *, unsigned int)
tdb_reopen: int (struct tdb_context *)
tdb_reopen_all: int (int)
tdb_repack: int (struct tdb_context *)
tdb_rescue: int (struct tdb_context *, void (*)(TDB_DATA, TDB_DATA, void *), void *)
tdb_runtime_check_for_robust_mutexes: bool (void)
tdb_set_logging_function: void (struct tdb_context *, const struct tdb_logging_context *)
tdb_set_max_dead: void (struct tdb_context *, int)
tdb_setalarm_sigptr: void (struct tdb_context *, volatile sig_atomic_t *)
tdb_store: int (struct tdb_context *, TDB_DATA, TDB_DATA, int)
tdb_storev: int (struct tdb_context *, TDB_DATA, const TDB_DATA *, int, int)
tdb_summary: char *(struct tdb_context *)
tdb_transaction_active: bool (struct tdb_context *)
tdb_transaction_cancel: int (struct tdb_context *)
tdb_transaction_commit: int (struct tdb_context *)
tdb_transaction_prepare_commit: int (struct tdb_context *)
tdb_transaction_start: int (struct tdb_context *)
tdb_transaction_start_nonblock: int (struct tdb_context *)
tdb_transaction_write_lock_mark: int (struct tdb_context *)
tdb_transaction_write_lock_unmark: int (struct tdb_context *)
tdb_traverse: int (struct tdb_context *, tdb_traverse_func, void *)
tdb_traverse_read: int (struct tdb_context *, tdb_traverse_func, void *)
tdb_unlock: int (struct tdb_context *, int, int)
tdb_unlockall: int (struct tdb_context *)
tdb_unlockall_read: int (struct tdb_context *)
tdb_validate_freelist: int (struct tdb_context *, int *)
tdb_wipe_all: int (struct tdb_context *)
......@@ -62,11 +62,7 @@ static int tdb_dump_chain(struct tdb_context *tdb, int i)
{
tdb_off_t rec_ptr, top;
if (i == -1) {
top = FREELIST_TOP;
} else {
top = TDB_HASH_TOP(i);
}
top = TDB_HASH_TOP(i);
if (tdb_lock(tdb, i, F_WRLCK) != 0)
return -1;
......
......@@ -52,68 +52,29 @@ static bool tdb_adjust_offset(struct tdb_context *tdb, off_t *off)
static ssize_t tdb_pwrite(struct tdb_context *tdb, const void *buf,
size_t count, off_t offset)
{
ssize_t ret;
if (!tdb_adjust_offset(tdb, &offset)) {
return -1;
}
do {
ret = pwrite(tdb->fd, buf, count, offset);
} while ((ret == -1) && (errno == EINTR));
return ret;
return pwrite(tdb->fd, buf, count, offset);
}
static ssize_t tdb_pread(struct tdb_context *tdb, void *buf,
size_t count, off_t offset)
{
ssize_t ret;
if (!tdb_adjust_offset(tdb, &offset)) {
return -1;
}
do {
ret = pread(tdb->fd, buf, count, offset);
} while ((ret == -1) && (errno == EINTR));
return ret;
return pread(tdb->fd, buf, count, offset);
}
static int tdb_ftruncate(struct tdb_context *tdb, off_t length)
{
ssize_t ret;
if (!tdb_adjust_offset(tdb, &length)) {
return -1;
}
do {
ret = ftruncate(tdb->fd, length);
} while ((ret == -1) && (errno == EINTR));
return ret;
return ftruncate(tdb->fd, length);
}
#if HAVE_POSIX_FALLOCATE
static int tdb_posix_fallocate(struct tdb_context *tdb, off_t offset,
off_t len)
{
ssize_t ret;
if (!tdb_adjust_offset(tdb, &offset)) {
return -1;
}
do {
ret = posix_fallocate(tdb->fd, offset, len);
} while ((ret == -1) && (errno == EINTR));
return ret;
}
#endif
static int tdb_fstat(struct tdb_context *tdb, struct stat *buf)
{
int ret;
......@@ -397,7 +358,6 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad
{
char buf[8192];
tdb_off_t new_size;
int ret;
if (tdb->read_only || tdb->traverse_read) {
tdb->ecode = TDB_ERR_RDONLY;
......@@ -413,36 +373,7 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad
return -1;
}
#if HAVE_POSIX_FALLOCATE
ret = tdb_posix_fallocate(tdb, size, addition);
if (ret == 0) {
return 0;
}
if (ret == ENOSPC) {
/*
* The Linux glibc (at least as of 2.24) fallback if
* the file system does not support fallocate does not
* reset the file size back to where it was. Also, to
* me it is unclear from the posix spec of
* posix_fallocate whether this is allowed or
* not. Better be safe than sorry and "goto fail" but
* "return -1" here, leaving the EOF pointer too
* large.
*/
goto fail;
}
/*
* Retry the "old" way. Possibly unnecessary, but looking at
* our configure script there seem to be weird failure modes
* for posix_fallocate. See commit 3264a98ff16de, which
* probably refers to
* https://sourceware.org/bugzilla/show_bug.cgi?id=1083.
*/
#endif
ret = tdb_ftruncate(tdb, new_size);
if (ret == -1) {
if (tdb_ftruncate(tdb, new_size) == -1) {
char b = 0;
ssize_t written = tdb_pwrite(tdb, &b, 1, new_size - 1);
if (written == 0) {
......@@ -478,14 +409,14 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad
TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file write "
"returned 0 twice: giving up!\n"));
errno = ENOSPC;
goto fail;
return -1;
}
if (written == -1) {
tdb->ecode = TDB_ERR_OOM;
TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file write of "
"%u bytes failed (%s)\n", (int)n,
strerror(errno)));
goto fail;
return -1;
}
if (written != n) {
TDB_LOG((tdb, TDB_DEBUG_WARNING, "expand_file: wrote "
......@@ -496,28 +427,6 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad
size += written;
}
return 0;
fail:
{
int err = errno;
/*
* We're holding the freelist lock or are inside a
* transaction. Cutting the file is safe, the space we
* tried to allocate can't have been used anywhere in
* the meantime.
*/
ret = tdb_ftruncate(tdb, size);
if (ret == -1) {
TDB_LOG((tdb, TDB_DEBUG_WARNING, "expand_file: "
"retruncate to %ju failed\n",
(uintmax_t)size));
}
errno = err;
}
return -1;
}
......
......@@ -137,33 +137,7 @@ static int fcntl_unlock(struct tdb_context *tdb, int rw, off_t off, off_t len)
return fcntl(tdb->fd, F_SETLKW, &fl);
}
/*
* Calculate the lock offset for a list
*
* list -1 is the freelist, otherwise a hash chain.
*
* Note that we consistently (but without real reason) lock hash chains at an
* offset that is 4 bytes below the real offset of the corresponding list head
* in the db.
*
* This is the memory layout of the hashchain array:
*
* FREELIST_TOP + 0 = freelist
* FREELIST_TOP + 4 = hashtbale list 0
* FREELIST_TOP + 8 = hashtbale list 1
* ...
*
* Otoh lock_offset computes:
*
* freelist = FREELIST_TOP - 4
* list 0 = FREELIST_TOP + 0
* list 1 = FREELIST_TOP + 4
* ...
*
* Unfortunately we can't change this calculation in order to align the locking
* offset with the memory layout, as that would make the locking incompatible
* between different tdb versions.
*/
/* list -1 is the alloc list, otherwise a hash chain. */
static tdb_off_t lock_offset(int list)
{
return FREELIST_TOP + 4*list;
......
......@@ -300,8 +300,7 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td
struct tdb_header header;
struct tdb_context *tdb;
struct stat st;