Rev 106: added --dblist option to ctdbd, to allow list of databases to be specified on the command line in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Sun Apr 15 23:29:10 GMT 2007


------------------------------------------------------------
revno: 106
revision-id: tridge at samba.org-20070415232910-a604c82b6945e169
parent: tridge at samba.org-20070415225857-c848786395133f34
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge
timestamp: Mon 2007-04-16 09:29:10 +1000
message:
  added --dblist option to ctdbd, to allow list of databases to be specified on the command line
modified:
  direct/ctdbd.c                 ctdbd.c-20070411085044-dqmhr6mfeexnyt4m-1
=== modified file 'direct/ctdbd.c'
--- a/direct/ctdbd.c	2007-04-15 04:39:23 +0000
+++ b/direct/ctdbd.c	2007-04-15 23:29:10 +0000
@@ -43,12 +43,13 @@
 int main(int argc, const char *argv[])
 {
 	struct ctdb_context *ctdb;
-	struct ctdb_db_context *ctdb_db;
 	const char *nlist = NULL;
 	const char *transport = "tcp";
 	const char *myaddress = NULL;
 	int self_connect=0;
 	int daemon_mode=0;
+	const char *db_list = "test.tdb";
+	char *s, *tok;
 
 	struct poptOption popt_options[] = {
 		POPT_AUTOHELP
@@ -57,6 +58,7 @@
 		{ "transport", 0, POPT_ARG_STRING, &transport, 0, "protocol transport", NULL },
 		{ "self-connect", 0, POPT_ARG_NONE, &self_connect, 0, "enable self connect", "boolean" },
 		{ "daemon", 0, POPT_ARG_NONE, &daemon_mode, 0, "spawn a ctdb daemon", "boolean" },
+		{ "dblist", 0, POPT_ARG_STRING, &db_list, 0, "list of databases", NULL },
 		POPT_TABLEEND
 	};
 	int opt;
@@ -127,11 +129,18 @@
 		exit(1);
 	}
 
-	/* attach to a specific database */
-	ctdb_db = ctdb_attach(ctdb, "test.tdb", TDB_DEFAULT, O_RDWR|O_CREAT|O_TRUNC, 0666);
-	if (!ctdb_db) {
-		printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb));
-		exit(1);
+	/* attach to the list of databases */
+	s = talloc_strdup(ctdb, db_list);
+	for (tok=strtok(s, ", "); tok; tok=strtok(NULL, ", ")) {
+		struct ctdb_db_context *ctdb_db;
+		ctdb_db = ctdb_attach(ctdb, tok, TDB_DEFAULT, 
+				      O_RDWR|O_CREAT|O_TRUNC, 0666);
+		if (!ctdb_db) {
+			printf("ctdb_attach to '%s'failed - %s\n", tok, 
+			       ctdb_errstr(ctdb));
+			exit(1);
+		}
+		printf("Attached to database '%s'\n", tok);
 	}
 
 	/* start the protocol running */



More information about the samba-cvs mailing list