Add --dbdir to ctdbd. Necessary for shared operation between ctdbd and smbd.
authorVolker Lendecke <vl@samba.org>
Wed, 18 Apr 2007 14:36:22 +0000 (16:36 +0200)
committerVolker Lendecke <vl@samba.org>
Wed, 18 Apr 2007 14:36:22 +0000 (16:36 +0200)
common/ctdb.c
common/ctdb_ltdb.c
direct/ctdbd.c
include/ctdb.h
include/ctdb_private.h

index de7a36f0c479300d9e684bba2a236d9f9f1f49e1..835cf129970d8a5a4c58fe2e362fbdc1d1edd817 100644 (file)
@@ -73,6 +73,14 @@ void ctdb_set_max_lacount(struct ctdb_context *ctdb, unsigned count)
        ctdb->max_lacount = count;
 }
 
+/*
+  set the directory for the local databases
+*/
+void ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir)
+{
+       ctdb->db_directory = talloc_strdup(ctdb, dir);
+}
+
 /*
   add a node to the list of active nodes
 */
index 1d34d90e2eda35946ba45b2a1910c1730a5cbf04..63a1e22d496edd53ff63e9040a93616151665f2b 100644 (file)
@@ -84,7 +84,7 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name,
 
        /* add the node id to the database name, so when we run on loopback
           we don't conflict in the local filesystem */
-       name = talloc_asprintf(ctdb_db, "%s.%u", name, ctdb_get_vnn(ctdb));
+       name = talloc_asprintf(ctdb_db, "%s/%s", ctdb->db_directory, name);
 
        /* when we have a separate daemon this will need to be a real
           file, not a TDB_INTERNAL, so the parent can access it to
index 674b54d47a1fde45b7fdc29d2ea08fc5c1b281c2..58982b4367d669f778e8d44067d6566895f8b396 100644 (file)
@@ -45,12 +45,14 @@ int main(int argc, const char *argv[])
 {
        struct ctdb_context *ctdb;
        const char *db_list = "test.tdb";
+       const char *db_dir = ".";
        char *s, *tok;
 
        struct poptOption popt_options[] = {
                POPT_AUTOHELP
                POPT_CTDB_CMDLINE
                { "dblist", 0, POPT_ARG_STRING, &db_list, 0, "list of databases", NULL },
+               { "dbdir", 0, POPT_ARG_STRING, &db_dir, 0, "directory for the tdb files", NULL },
                POPT_TABLEEND
        };
        int opt;
@@ -84,6 +86,8 @@ int main(int argc, const char *argv[])
 
        ctdb = ctdb_cmdline_init(ev);
 
+       ctdb_set_tdb_dir(ctdb, db_dir);
+
        /* attach to the list of databases */
        s = talloc_strdup(ctdb, db_list);
        for (tok=strtok(s, ", "); tok; tok=strtok(NULL, ", ")) {
index a61b751812331d40e6a3a9c5f4a0a9d9c77d4d6b..160a56d975efddd74f9bc630ae066b0641b1cd26 100644 (file)
@@ -71,6 +71,11 @@ struct ctdb_context *ctdb_init(struct event_context *ev);
 */
 int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
 
+/*
+  set the directory for the local databases
+*/
+void ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir);
+
 /*
   set some flags
 */
index 72ee5dadd66844d58e86a4734db641bc66598a9f..e5aef487b9d3f5aa76724299ac0adfeb62dfe0a1 100644 (file)
@@ -119,6 +119,7 @@ struct ctdb_context {
        struct event_context *ev;
        struct ctdb_address address;
        const char *name;
+       const char *db_directory;
        uint32_t vnn; /* our own vnn */
        uint32_t num_nodes;
        uint32_t num_connected;