summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2012-02-07 10:53:49 +1100
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2012-02-07 10:53:49 +1100
commitc3bab541c99c1c9d5756111e4b14f1175219797a (patch)
treefdb0a634a3c9d6c100750529dbf801b03d06a06d
parentdaf28e095e2af5d8c4aa6ac6646a18dc7ec1be5d (diff)
downloadsamba-c3bab541c99c1c9d5756111e4b14f1175219797a.tar.gz
samba-c3bab541c99c1c9d5756111e4b14f1175219797a.tar.xz
samba-c3bab541c99c1c9d5756111e4b14f1175219797a.zip
TFETCH add verbose flag to print also the record ltdb heaer
(This used to be ctdb commit 25d797f61c3b5b7090fb662adde6ed9e434e8a61)
-rw-r--r--ctdb/tools/ctdb.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 8ef869b3eb..baf5d24535 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -3487,14 +3487,14 @@ static int control_tfetch(struct ctdb_context *ctdb, int argc, const char **argv
tdb = tdb_open(tdb_file, 0, 0, O_RDONLY, 0);
if (tdb == NULL) {
- fprintf(stderr, "Failed to open TDB file %s\n", tdb_file);
+ printf("Failed to open TDB file %s\n", tdb_file);
return -1;
}
if (!strncmp(argv[1], "0x", 2)) {
key = hextodata(tmp_ctx, argv[1] + 2);
if (key.dsize == 0) {
- fprintf(stderr, "Failed to convert \"%s\" into a TDB_DATA\n", argv[1]);
+ printf("Failed to convert \"%s\" into a TDB_DATA\n", argv[1]);
return -1;
}
} else {
@@ -3503,7 +3503,7 @@ static int control_tfetch(struct ctdb_context *ctdb, int argc, const char **argv
}
data = tdb_fetch(tdb, key);
if (data.dptr == NULL || data.dsize < sizeof(struct ctdb_ltdb_header)) {
- fprintf(stderr, "Failed to read record %s from tdb %s\n", argv[1], tdb_file);
+ printf("Failed to read record %s from tdb %s\n", argv[1], tdb_file);
tdb_close(tdb);
return -1;
}
@@ -3516,10 +3516,18 @@ static int control_tfetch(struct ctdb_context *ctdb, int argc, const char **argv
printf("Failed to open output file %s\n", argv[2]);
return -1;
}
- write(fd, data.dptr+sizeof(struct ctdb_ltdb_header), data.dsize-sizeof(struct ctdb_ltdb_header));
+ if (options.verbose){
+ write(fd, data.dptr, data.dsize);
+ } else {
+ write(fd, data.dptr+sizeof(struct ctdb_ltdb_header), data.dsize-sizeof(struct ctdb_ltdb_header));
+ }
close(fd);
} else {
- write(1, data.dptr+sizeof(struct ctdb_ltdb_header), data.dsize-sizeof(struct ctdb_ltdb_header));
+ if (options.verbose){
+ write(1, data.dptr, data.dsize);
+ } else {
+ write(1, data.dptr+sizeof(struct ctdb_ltdb_header), data.dsize-sizeof(struct ctdb_ltdb_header));
+ }
}
talloc_free(tmp_ctx);