]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
merge back some changes from Samba4
authorAndrew Tridgell <tridge@samba.org>
Wed, 4 Apr 2007 05:02:49 +0000 (15:02 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 4 Apr 2007 05:02:49 +0000 (15:02 +1000)
(This used to be ctdb commit b946ff61c0e4b3269d3c7e01093d0a6d5215d6ee)

ctdb/common/ctdb_ltdb.c
ctdb/include/ctdb.h
ctdb/include/includes.h

index 87550ff408d617cdf635e2e2a9f069fb714479bf..189816229f08be72acfe16522606ff533ae0a237 100644 (file)
 #include "system/filesys.h"
 #include "../include/ctdb_private.h"
 #include "db_wrap.h"
+#include "lib/util/dlinklist.h"
 
+/*
+  find an attached ctdb_db handle given a name
+ */
+struct ctdb_db_context *ctdb_db_handle(struct ctdb_context *ctdb, const char *name)
+{
+       struct ctdb_db_context *tmp_db;
+       for (tmp_db=ctdb->db_list;tmp_db;tmp_db=tmp_db->next) {
+               if (strcmp(name, tmp_db->db_name) == 0) {
+                       return tmp_db;
+               }
+       }
+       return NULL;
+}
 
 /*
   attach to a specific database
@@ -43,7 +57,7 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name,
        ctdb_db->db_name = talloc_strdup(ctdb_db, name);
        CTDB_NO_MEMORY_NULL(ctdb, ctdb_db->db_name);
 
-       data.dptr = name;
+       data.dptr = discard_const(name);
        data.dsize = strlen(name);
        ctdb_db->db_id = ctdb_hash(&data);
 
index 2859733044af9d80e69e5cc8453b8b77452134de..c5b6dbc7824fae43fb45b505e82d75036ec4fcf3 100644 (file)
@@ -94,6 +94,11 @@ int ctdb_start(struct ctdb_context *ctdb);
 struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, int tdb_flags, 
                                    int open_flags, mode_t mode);
 
+/*
+  find an attached ctdb_db handle given a name
+ */
+struct ctdb_db_context *ctdb_db_handle(struct ctdb_context *ctdb, const char *name);
+
 /*
   error string for last ctdb error
 */
index 199f416b20af26c968bb9b619e2302c62af2e86c..994c25452c8f86fa5e108a7084e464abfd899266 100644 (file)
@@ -20,6 +20,10 @@ typedef bool BOOL;
 
 #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
 
+#ifndef discard_const
+#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
+#endif
+
 struct timeval timeval_zero(void);
 bool timeval_is_zero(const struct timeval *tv);
 struct timeval timeval_current(void);