tools/ctdb: allow "ctdb pfetch" only on persistent databases
authorStefan Metzmacher <metze@samba.org>
Tue, 14 Sep 2010 14:21:27 +0000 (16:21 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 8 Oct 2010 07:02:45 +0000 (09:02 +0200)
metze

tools/ctdb.c

index cc7988047a45a192330435d1c17e42f8b539b3ca..04b1a34dc24d62e009943f411cc650f65e698c0b 100644 (file)
@@ -2958,6 +2958,7 @@ static int control_pfetch(struct ctdb_context *ctdb, int argc, const char **argv
        struct ctdb_transaction_handle *h;
        TDB_DATA key, data;
        int fd, ret;
+       bool persistent;
 
        if (argc < 2) {
                talloc_free(tmp_ctx);
@@ -2967,13 +2968,19 @@ static int control_pfetch(struct ctdb_context *ctdb, int argc, const char **argv
        db_name = argv[0];
 
 
-       if (db_exists(ctdb, db_name, NULL)) {
+       if (db_exists(ctdb, db_name, &persistent)) {
                DEBUG(DEBUG_ERR,("Database '%s' does not exist\n", db_name));
                talloc_free(tmp_ctx);
                return -1;
        }
 
-       ctdb_db = ctdb_attach(ctdb, db_name, true, 0);
+       if (!persistent) {
+               DEBUG(DEBUG_ERR,("Database '%s' is not persistent\n", db_name));
+               talloc_free(tmp_ctx);
+               return -1;
+       }
+
+       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));