check_srvids: remove the <pnn> from the commandline so that we only specify the list...
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 29 Nov 2011 22:50:12 +0000 (09:50 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 29 Nov 2011 22:50:12 +0000 (09:50 +1100)
Specifying the pnn can be done via '-n <pnn>'

(This used to be ctdb commit e9250775f5a1234f27a1a62caa902d7b86194285)

ctdb/tools/ctdb.c

index 823244691457addda5bd7cb9a87ea39922f85ebb..b902789ef3bec5c21a21495ba5002f2ad6b13aed 100644 (file)
@@ -2073,38 +2073,35 @@ static int check_srvids(struct ctdb_context *ctdb, int argc, const char **argv)
        int32_t status;
        char *errmsg;
        int ret;
-       uint32_t pnn;
        uint64_t *ids;
        int i;
        TDB_DATA data, outdata;
 
-       if (argc < 2) {
+       if (argc < 1) {
                usage();
        }
 
-       pnn = strtoul(argv[0], NULL, 0);
+       ids = talloc_array(ctdb, uint64_t, argc);
 
-       ids = talloc_array(ctdb, uint64_t, argc-1);
-
-       for (i=0; i<argc-1; i++) {
-               ids[i] = strtoull(argv[i+1], NULL, 0);
+       for (i = 0; i < argc; i++) {
+               ids[i] = strtoull(argv[i], NULL, 0);
        }
        data.dptr = (uint8_t *)ids;
        data.dsize = talloc_get_size(ids);
 
-       ret = ctdb_control(ctdb, pnn, 0, CTDB_CONTROL_CHECK_SRVIDS,
+       ret = ctdb_control(ctdb, options.pnn, 0, CTDB_CONTROL_CHECK_SRVIDS,
                           0, data, ctdb, &outdata, &status, NULL, &errmsg);
        if (ret != 0) {
                DEBUG(DEBUG_ERR, ("Unable to check server_id from node %u\n",
-                                 pnn));
+                                 options.pnn));
                return ret;
        }
-       for (i=0; i<argc-1; i++) {
+       for (i=0; i < argc; i++) {
                bool exists;
 
                exists = ((outdata.dptr[i/8] & (1<<(i%8))) != 0);
 
-               printf("Server id %d:%llu %s\n", pnn, ids[i],
+               printf("Server id %d:%llu %s\n", options.pnn, (long long)ids[i],
                       exists ? "exists" : "does not exist");
        }
        return 0;
@@ -5177,7 +5174,7 @@ static const struct {
        { "unregsrvid",      unregsrvid,                false,  false, "unregister a server id", "<pnn> <type> <id>" },
        { "chksrvid",        chksrvid,                  false,  false, "check if a server id exists", "<pnn> <type> <id>" },
        { "getsrvids",       getsrvids,                 false,  false, "get a list of all server ids"},
-       { "check_srvids",    check_srvids,              false,  false, "check if a srvid exists", "<pnn> <id>" },
+       { "check_srvids",    check_srvids,              false,  false, "check if a srvid exists", "<id>+" },
        { "vacuum",          ctdb_vacuum,               false,  false, "vacuum the databases of empty records", "[max_records]"},
        { "repack",          ctdb_repack,               false,  false, "repack all databases", "[max_freelist]"},
        { "listnodes",       control_listnodes,         false,  true, "list all nodes in the cluster"},