summaryrefslogtreecommitdiff
path: root/ctdb/common/path_tool.c
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2018-07-06 17:14:27 +1000
committerAmitay Isaacs <amitay@samba.org>2018-07-11 11:48:38 +0200
commit3bebc5d8a034f085bd53d7169a69129851b8f140 (patch)
tree7464d1c9a457d365969e5fc3e908f9dce0e2deb3 /ctdb/common/path_tool.c
parentbe1c3400587ccf4f04fa56f438cf815a12e04326 (diff)
downloadsamba-3bebc5d8a034f085bd53d7169a69129851b8f140.tar.gz
ctdb-common: Add path support for datadir
Signed-off-by: Martin Schwenke <martin@meltin.net> Pair-programmed-with: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/common/path_tool.c')
-rw-r--r--ctdb/common/path_tool.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/ctdb/common/path_tool.c b/ctdb/common/path_tool.c
index 339066b582e..1c60b023c42 100644
--- a/ctdb/common/path_tool.c
+++ b/ctdb/common/path_tool.c
@@ -100,6 +100,49 @@ static int path_tool_socket(TALLOC_CTX *mem_ctx,
return 0;
}
+static int path_tool_datadir(TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv,
+ void *private_data)
+{
+ struct path_tool_context *ctx = talloc_get_type_abort(
+ private_data, struct path_tool_context);
+
+ if (argc != 0) {
+ cmdline_usage(ctx->cmdline, "datadir");
+ return EINVAL;
+ }
+
+ printf("%s\n", path_datadir());
+
+ return 0;
+}
+
+static int path_tool_datadir_append(TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv,
+ void *private_data)
+{
+ struct path_tool_context *ctx = talloc_get_type_abort(
+ private_data, struct path_tool_context);
+ char *p;
+
+ if (argc != 1) {
+ cmdline_usage(ctx->cmdline, "datadir append");
+ return EINVAL;
+ }
+
+ p = path_datadir_append(mem_ctx, argv[0]);
+ if (p == NULL) {
+ D_ERR("Memory allocation error\n");
+ return 1;
+ }
+
+ printf("%s\n", p);
+
+ return 0;
+}
+
static int path_tool_etcdir(TALLOC_CTX *mem_ctx,
int argc,
const char **argv,
@@ -236,6 +279,10 @@ struct cmdline_command path_commands[] = {
"Get path of CTDB daemon pidfile", "<daemon>" },
{ "socket", path_tool_socket,
"Get path of CTDB daemon socket", "<daemon>" },
+ { "datadir append", path_tool_datadir_append,
+ "Get path relative to CTDB DATADIR", "<path>" },
+ { "datadir", path_tool_datadir,
+ "Get path of CTDB DATADIR", NULL },
{ "etcdir append", path_tool_etcdir_append,
"Get path relative to CTDB ETCDIR", "<path>" },
{ "etcdir", path_tool_etcdir,