diff options
author | Michael Adam <obnox@samba.org> | 2011-11-28 17:19:03 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2011-11-29 13:43:32 +0100 |
commit | dc98c12ac96b3d9d7fd233c961e328c4ca2d1716 (patch) | |
tree | 6cfc0143b6d61a04bd784162ee9a6901067b863e | |
parent | 1dfdb9d887fe22023980b90ea40dc73fd8a34190 (diff) | |
download | samba-dc98c12ac96b3d9d7fd233c961e328c4ca2d1716.tar.gz samba-dc98c12ac96b3d9d7fd233c961e328c4ca2d1716.tar.xz samba-dc98c12ac96b3d9d7fd233c961e328c4ca2d1716.zip |
ctdb: add an option --print-datasize to only print datasize instead of dumping data in db dumps
Used in catdb, cattdb and dumpdbbackup.
(This used to be ctdb commit dd866116041e71cbf91e7fd91edcc9501634051d)
-rw-r--r-- | ctdb/client/ctdb_client.c | 18 | ||||
-rw-r--r-- | ctdb/include/ctdb_client.h | 1 | ||||
-rw-r--r-- | ctdb/tools/ctdb.c | 5 |
3 files changed, 17 insertions, 7 deletions
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c index 72c938da9f..31a6ffc665 100644 --- a/ctdb/client/ctdb_client.c +++ b/ctdb/client/ctdb_client.c @@ -2151,15 +2151,19 @@ int ctdb_dumpdb_record(struct ctdb_context *ctdb, TDB_DATA key, TDB_DATA data, v if (h->flags & CTDB_REC_RO_REVOKE_COMPLETE) printf(" RO_REVOKE_COMPLETE"); fprintf(f, "\n"); - fprintf(f, "data(%u) = \"", (unsigned)(data.dsize - sizeof(*h))); - for (i=sizeof(*h);i<data.dsize;i++) { - if (ISASCII(data.dptr[i])) { - fprintf(f, "%c", data.dptr[i]); - } else { - fprintf(f, "\\%02X", data.dptr[i]); + if (c->printdatasize) { + fprintf(f, "data size: %u\n", (unsigned)data.dsize); + } else { + fprintf(f, "data(%u) = \"", (unsigned)(data.dsize - sizeof(*h))); + for (i=sizeof(*h);i<data.dsize;i++) { + if (ISASCII(data.dptr[i])) { + fprintf(f, "%c", data.dptr[i]); + } else { + fprintf(f, "\\%02X", data.dptr[i]); + } } + fprintf(f, "\"\n"); } - fprintf(f, "\"\n"); fprintf(f, "\n"); diff --git a/ctdb/include/ctdb_client.h b/ctdb/include/ctdb_client.h index a6342c1ce3..610c6ccc1f 100644 --- a/ctdb/include/ctdb_client.h +++ b/ctdb/include/ctdb_client.h @@ -376,6 +376,7 @@ int ctdb_traverse(struct ctdb_db_context *ctdb_db, ctdb_traverse_func fn, void * struct ctdb_dump_db_context { FILE *f; bool printemptyrecords; + bool printdatasize; }; int ctdb_dumpdb_record(struct ctdb_context *ctdb, TDB_DATA key, TDB_DATA data, void *p); diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 905ecd739d..302c4dcdb3 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -47,6 +47,7 @@ static struct { int verbose; int maxruntime; int printemptyrecords; + int printdatasize; } options; #define TIMELIMIT() timeval_current_ofs(options.timelimit, 0) @@ -2999,6 +3000,7 @@ static int control_catdb(struct ctdb_context *ctdb, int argc, const char **argv) ZERO_STRUCT(c); c.f = stdout; c.printemptyrecords = (bool)options.printemptyrecords; + c.printdatasize = (bool)options.printdatasize; /* traverse and dump the cluster tdb */ ret = ctdb_dump_db(ctdb_db, &c); @@ -3030,6 +3032,7 @@ static int cattdb_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, ZERO_STRUCT(c); c.f = stdout; c.printemptyrecords = (bool)options.printemptyrecords; + c.printdatasize = (bool)options.printdatasize; return ctdb_dumpdb_record(d->ctdb, key, data, &c); } @@ -4597,6 +4600,7 @@ static int control_dumpdbbackup(struct ctdb_context *ctdb, int argc, const char ZERO_STRUCT(c); c.f = stdout; c.printemptyrecords = (bool)options.printemptyrecords; + c.printdatasize = (bool)options.printdatasize; for (i=0; i < m->count; i++) { uint32_t reqid = 0; @@ -5163,6 +5167,7 @@ int main(int argc, const char *argv[]) { "verbose", 'v', POPT_ARG_NONE, &options.verbose, 0, "enable verbose output", NULL }, { "maxruntime", 'T', POPT_ARG_INT, &options.maxruntime, 0, "die if runtime exceeds this limit (in seconds)", "integer" }, { "print-emptyrecords", 0, POPT_ARG_NONE, &options.printemptyrecords, 0, "print the empty records when dumping databases (catdb, cattdb, dumpdbbackup)", NULL }, + { "print-datasize", 0, POPT_ARG_NONE, &options.printdatasize, 0, "do not print record data when dumping databases, only the data size", NULL }, POPT_TABLEEND }; int opt; |