summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2011-07-20 12:30:33 +1000
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2011-08-23 10:22:41 +1000
commitb77142ccc0320fcc0a568f4180574c7ce867d9ec (patch)
tree69ac96323cc8a7d829d6ee976e5c7bdaeef76eb8
parenta224631e7bca994c9e74f7f16aa1aae12cad1175 (diff)
downloadsamba-b77142ccc0320fcc0a568f4180574c7ce867d9ec.tar.gz
samba-b77142ccc0320fcc0a568f4180574c7ce867d9ec.tar.xz
samba-b77142ccc0320fcc0a568f4180574c7ce867d9ec.zip
ReadOnly: Add a new command 'ctdb cattdb'. This fucntion differs from 'ctdb catdb' in that 'cattdb' will always traverse the local tdb file only, while 'catdb' does a cluster traverse.
Since some record flags may differ between nodes in the cluster when read only delegations are in use, cattdb is needed when you need to know the exact flag settings on the current node itself. (This used to be ctdb commit d2342b680a3a8160d903d12550b86ee21c8b277d)
-rw-r--r--ctdb/tools/ctdb.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index d760f6bc77..5fada16c20 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -3012,6 +3012,61 @@ static int control_catdb(struct ctdb_context *ctdb, int argc, const char **argv)
return 0;
}
+struct cattdb_data {
+ struct ctdb_context *ctdb;
+ uint32_t count;
+};
+
+static int cattdb_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *private_data)
+{
+ struct cattdb_data *d = private_data;
+
+ d->count++;
+
+ return ctdb_dumpdb_record(d->ctdb, key, data, stdout);
+}
+
+/*
+ cat the local tdb database using same format as catdb
+ */
+static int control_cattdb(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+ const char *db_name;
+ struct ctdb_db_context *ctdb_db;
+ struct cattdb_data d;
+
+ if (argc < 1) {
+ usage();
+ }
+
+ db_name = argv[0];
+
+
+ if (db_exists(ctdb, db_name)) {
+ DEBUG(DEBUG_ERR,("Database '%s' does not exist\n", db_name));
+ return -1;
+ }
+
+ ctdb_db = ctdb_attach(ctdb, db_name, false, 0);
+
+ if (ctdb_db == NULL) {
+ DEBUG(DEBUG_ERR,("Unable to attach to database '%s'\n", db_name));
+ return -1;
+ }
+
+ /* traverse the local tdb */
+ d.count = 0;
+ d.ctdb = ctdb;
+ if (tdb_traverse_read(ctdb_db->ltdb->tdb, cattdb_traverse, &d) == -1) {
+ printf("Failed to cattdb data\n");
+ exit(10);
+ }
+ talloc_free(ctdb_db);
+
+ printf("Dumped %d records\n", d.count);
+ return 0;
+}
+
/*
display the content of a database key
*/
@@ -4942,6 +4997,7 @@ static const struct {
{ "getdbmap", control_getdbmap, true, false, "show the database map" },
{ "getdbstatus", control_getdbstatus, true, false, "show the status of a database", "<dbname>" },
{ "catdb", control_catdb, true, false, "dump a database" , "<dbname>"},
+ { "cattdb", control_cattdb, true, false, "dump a database" , "<dbname>"},
{ "getmonmode", control_getmonmode, true, false, "show monitoring mode" },
{ "getcapabilities", control_getcapabilities, true, false, "show node capabilities" },
{ "pnn", control_pnn, true, false, "show the pnn of the currnet node" },