summaryrefslogtreecommitdiff
path: root/lib/tdb/common
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-12-20 16:14:23 +0100
committerStefan Metzmacher <metze@samba.org>2013-02-05 08:54:28 +0100
commit1436107b0769c88e7eb50057b5f05ad5b8573990 (patch)
tree0b6c418d3971922f9234433e8026f76b05d8a202 /lib/tdb/common
parentdc6c40b193e125e8810cf95129fc99f7d4f6db27 (diff)
downloadsamba-1436107b0769c88e7eb50057b5f05ad5b8573990.tar.gz
samba-1436107b0769c88e7eb50057b5f05ad5b8573990.tar.bz2
samba-1436107b0769c88e7eb50057b5f05ad5b8573990.zip
tdb: Pass argument "header" to tdb_new_database
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib/tdb/common')
-rw-r--r--lib/tdb/common/open.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c
index b10f5ebe97..6079463945 100644
--- a/lib/tdb/common/open.c
+++ b/lib/tdb/common/open.c
@@ -51,7 +51,8 @@ void tdb_header_hash(struct tdb_context *tdb,
}
/* initialise a new database with a specified hash size */
-static int tdb_new_database(struct tdb_context *tdb, int hash_size)
+static int tdb_new_database(struct tdb_context *tdb, struct tdb_header *header,
+ int hash_size)
{
struct tdb_header *newdb;
size_t size;
@@ -78,7 +79,7 @@ static int tdb_new_database(struct tdb_context *tdb, int hash_size)
if (tdb->flags & TDB_INTERNAL) {
tdb->map_size = size;
tdb->map_ptr = (char *)newdb;
- memcpy(&tdb->header, newdb, sizeof(tdb->header));
+ memcpy(header, newdb, sizeof(*header));
/* Convert the `ondisk' version if asked. */
CONVERT(*newdb);
return 0;
@@ -91,7 +92,7 @@ static int tdb_new_database(struct tdb_context *tdb, int hash_size)
/* This creates an endian-converted header, as if read from disk */
CONVERT(*newdb);
- memcpy(&tdb->header, newdb, sizeof(tdb->header));
+ memcpy(header, newdb, sizeof(*header));
/* Don't endian-convert the magic food! */
memcpy(newdb->magic_food, TDB_MAGIC_FOOD, strlen(TDB_MAGIC_FOOD)+1);
@@ -286,7 +287,7 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td
if (tdb->flags & TDB_INTERNAL) {
tdb->flags |= (TDB_NOLOCK | TDB_NOMMAP);
tdb->flags &= ~TDB_CLEAR_IF_FIRST;
- if (tdb_new_database(tdb, hash_size) != 0) {
+ if (tdb_new_database(tdb, &tdb->header, hash_size) != 0) {
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: tdb_new_database failed!"));
goto fail;
}
@@ -323,7 +324,7 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td
name, strerror(errno)));
goto fail;
}
- ret = tdb_new_database(tdb, hash_size);
+ ret = tdb_new_database(tdb, &tdb->header, hash_size);
if (ret == -1) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: "
"tdb_new_database failed for %s: %s\n",
@@ -350,7 +351,8 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td
errno = 0;
if (read(tdb->fd, &tdb->header, sizeof(tdb->header)) != sizeof(tdb->header)
|| strcmp(tdb->header.magic_food, TDB_MAGIC_FOOD) != 0) {
- if (!(open_flags & O_CREAT) || tdb_new_database(tdb, hash_size) == -1) {
+ if (!(open_flags & O_CREAT) ||
+ tdb_new_database(tdb, &tdb->header, hash_size) == -1) {
if (errno == 0) {
errno = EIO; /* ie bad format or something */
}