tools/ctdb: add 'persistent' flag to "ctdb attach"
authorStefan Metzmacher <metze@samba.org>
Tue, 14 Sep 2010 12:49:42 +0000 (14:49 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 8 Oct 2010 07:02:45 +0000 (09:02 +0200)
metze

tools/ctdb.c

index cd8a259..cc79880 100644 (file)
@@ -3726,13 +3726,23 @@ static int control_attach(struct ctdb_context *ctdb, int argc, const char **argv
 {
        const char *db_name;
        struct ctdb_db_context *ctdb_db;
+       bool persistent = false;
 
        if (argc < 1) {
                usage();
        }
        db_name = argv[0];
+       if (argc > 2) {
+               usage();
+       }
+       if (argc == 2) {
+               if (strcmp(argv[1], "persistent") != 0) {
+                       usage();
+               }
+               persistent = true;
+       }
 
-       ctdb_db = ctdb_attach(ctdb, db_name, false, 0);
+       ctdb_db = ctdb_attach(ctdb, db_name, persistent, 0);
        if (ctdb_db == NULL) {
                DEBUG(DEBUG_ERR,("Unable to attach to database '%s'\n", db_name));
                return -1;
@@ -4721,7 +4731,7 @@ static const struct {
        { "getdebug",        control_getdebug,          true,   false,  "get debug level" },
        { "getlog",          control_getlog,            true,   false,  "get the log data from the in memory ringbuffer", "<level>" },
        { "clearlog",          control_clearlog,        true,   false,  "clear the log data from the in memory ringbuffer" },
-       { "attach",          control_attach,            true,   false,  "attach to a database",                 "<dbname>" },
+       { "attach",          control_attach,            true,   false,  "attach to a database",                 "<dbname> [persistent]" },
        { "dumpmemory",      control_dumpmemory,        true,   false,  "dump memory map to stdout" },
        { "rddumpmemory",    control_rddumpmemory,      true,   false,  "dump memory map from the recovery daemon to stdout" },
        { "getpid",          control_getpid,            true,   false,  "get ctdbd process ID" },