From cdbc6d92c6bf0645c5a23955e8ec5e253212e86d Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Thu, 2 Jul 2015 13:06:32 -0700 Subject: [PATCH] ctdb: Accept the key in hex format for the pstore command This follows the same pattern as the tstore command, and it allows specifying key strings with a trailing \0 character. Signed-off-by: Christof Schmitt Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Mon Jul 6 23:23:22 CEST 2015 on sn-devel-104 --- ctdb/tools/ctdb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 9b7fb11831e..91ada44a28b 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -4231,8 +4231,17 @@ static int control_pstore(struct ctdb_context *ctdb, int argc, const char **argv return -1; } - key.dptr = discard_const(argv[1]); - key.dsize = strlen(argv[1]); + if (!strncmp(argv[1], "0x", 2)) { + key = hextodata(tmp_ctx, argv[1] + 2); + if (key.dsize == 0) { + printf("Failed to convert \"%s\" into a TDB_DATA\n", argv[1]); + return -1; + } + } else { + key.dptr = discard_const(argv[1]); + key.dsize = strlen(argv[1]); + } + ret = ctdb_transaction_store(h, key, data); if (ret != 0) { DEBUG(DEBUG_ERR,("Failed to store record\n")); -- 2.11.4.GIT