Christof Schmitt
2015-07-02 20:16:35 UTC
From 9864603a6529de70e08ef03928a2895e343f7c03 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <***@samba.org>
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 <***@samba.org>
---
ctdb/tools/ctdb.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 9b7fb11..91ada44 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"));
From: Christof Schmitt <***@samba.org>
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 <***@samba.org>
---
ctdb/tools/ctdb.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 9b7fb11..91ada44 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"));
--
1.7.1
1.7.1