merged the db_dir changes from volker. Changed them slightly,
authorAndrew Tridgell <tridge@samba.org>
Wed, 18 Apr 2007 23:14:25 +0000 (09:14 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 18 Apr 2007 23:14:25 +0000 (09:14 +1000)
to make the --dbdir option available to all ctdb tools, not just
the daemon

1  2 
common/cmdline.c
common/ctdb.c
include/ctdb.h
include/ctdb_private.h

index 4753d8286bc63ca9f191ad55c30a0a6af531ec91,4753d8286bc63ca9f191ad55c30a0a6af531ec91..4995cc8de131dd88a40d1916cefd9fcd1973a0e4
@@@ -31,11 -31,11 +31,13 @@@ static struct 
        const char *transport;
        const char *myaddress;
        int self_connect;
++      const char *db_dir;
  } ctdb_cmdline = {
        .nlist = NULL,
        .transport = "tcp",
        .myaddress = NULL,
        .self_connect = 0,
++      .db_dir = "."
  };
  
  
@@@ -45,6 -45,6 +47,7 @@@ struct poptOption popt_ctdb_cmdline[] 
        { "transport", 0, POPT_ARG_STRING, &ctdb_cmdline.transport, 0, "protocol transport", NULL },
        { "self-connect", 0, POPT_ARG_NONE, &ctdb_cmdline.self_connect, 0, "enable self connect", "boolean" },
        { "debug", 'd', POPT_ARG_INT, &LogLevel, 0, "debug level"},
++      { "dbdir", 0, POPT_ARG_STRING, &ctdb_cmdline.db_dir, 0, "directory for the tdb files", NULL },
        { NULL }
  };
  
@@@ -93,5 -93,5 +96,11 @@@ struct ctdb_context *ctdb_cmdline_init(
                exit(1);
        }
  
++      ret = ctdb_set_tdb_dir(ctdb, ctdb_cmdline.db_dir);
++      if (ret == -1) {
++              printf("ctdb_set_tdb_dir failed - %s\n", ctdb_errstr(ctdb));
++              exit(1);
++      }
++
        return ctdb;
  }
diff --cc common/ctdb.c
index de7a36f0c479300d9e684bba2a236d9f9f1f49e1,835cf129970d8a5a4c58fe2e362fbdc1d1edd817..691d0b30628bb5be4d92e80a71ac88aeb0cc04c5
@@@ -73,6 -73,14 +73,18 @@@ void ctdb_set_max_lacount(struct ctdb_c
        ctdb->max_lacount = count;
  }
  
 -void ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir)
+ /*
+   set the directory for the local databases
+ */
++int ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir)
+ {
+       ctdb->db_directory = talloc_strdup(ctdb, dir);
++      if (ctdb->db_directory == NULL) {
++              return -1;
++      }
++      return 0;
+ }
  /*
    add a node to the list of active nodes
  */
diff --cc include/ctdb.h
index a61b751812331d40e6a3a9c5f4a0a9d9c77d4d6b,160a56d975efddd74f9bc630ae066b0641b1cd26..7339a56b2b7a19db3c0191f1a3db88769dda9687
@@@ -71,6 -71,11 +71,11 @@@ struct ctdb_context *ctdb_init(struct e
  */
  int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
  
 -void ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir);
+ /*
+   set the directory for the local databases
+ */
++int ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir);
  /*
    set some flags
  */
index 72ee5dadd66844d58e86a4734db641bc66598a9f,e5aef487b9d3f5aa76724299ac0adfeb62dfe0a1..36a6c8de5da6b0385bece5e2907a58a72be013bf
@@@ -460,4 -461,4 +461,6 @@@ struct ctdb_call_state *ctdb_daemon_cal
                                                     struct ctdb_call *call, 
                                                     struct ctdb_ltdb_header *header);
  
++void ctdb_request_finished(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
++
  #endif