* [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates
@ 2017-01-07 1:42 Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 1/7] ndctl, daxctl: refactor main boilerplate for a new 'daxctl' utility Dan Williams
` (7 more replies)
0 siblings, 8 replies; 11+ messages in thread
From: Dan Williams @ 2017-01-07 1:42 UTC (permalink / raw)
To: linux-nvdimm
* The 'ndctl list' command awkwardly prints out all the corresponding
device-dax information when a namespace is in 'dax' mode. Conversely if
someone is only interested in listing device-dax information they need to
contend with libnvdimm data.
Introduce a separate daxctl utility with its own 'list' command for this
purpose, and make the listing of device-dax data through 'ndctl list'
optional (new --device-dax option).
* Enhance 'ndctl list' with the option to filter by namespace mode (new
--mode option).
* Allow 'ndctl {enable,disable}-region' to limit itself to regions
matching a given type (blk or pmem).
* Fix 'ndctl list' to trim region mapping data (i.e. the dimms in a
region), when a specific dimm is indicated with --dimm.
---
Dan Williams (7):
ndctl, daxctl: refactor main boilerplate for a new 'daxctl' utility
ndctl, daxctl: move json helpers to be available across both utilities
ndctl, list: add option to filter namespace by mode
ndctl, list: add '--device-dax' option
daxctl: add list command
ndctl, {enable,disable}-region: filter by type
ndctl, list: limit mappings when --dimm is specified
Makefile.am | 4 +
builtin.h | 31 +++++++
configure.ac | 1
daxctl/Makefile.am | 13 +++
daxctl/daxctl.c | 91 +++++++++++++++++++++
daxctl/lib/Makefile.am | 3 +
daxctl/libdaxctl.h | 1
daxctl/list.c | 112 ++++++++++++++++++++++++++
ndctl.spec.in | 12 +++
ndctl/Makefile.am | 3 -
ndctl/builtin-bat.c | 2
ndctl/builtin-create-nfit.c | 2
ndctl/builtin-dimm.c | 14 ++-
ndctl/builtin-list.c | 45 ++++++++++
ndctl/builtin-test.c | 2
ndctl/builtin-xable-region.c | 35 +++++++-
ndctl/builtin-xaction-namespace.c | 10 +-
ndctl/builtin.h | 33 --------
ndctl/libndctl.h.in | 1
ndctl/ndctl.c | 160 +++++++++----------------------------
test/Makefile.am | 4 -
test/device-dax.c | 4 -
test/multi-pmem.c | 2
util/filter.c | 21 +++++
util/filter.h | 6 +
util/help.c | 44 ++--------
util/json.c | 121 ++++++++++++++++++++++------
util/json.h | 8 ++
util/main.c | 123 ++++++++++++++++++++++++++++
util/main.h | 10 ++
30 files changed, 671 insertions(+), 247 deletions(-)
create mode 100644 builtin.h
create mode 100644 daxctl/Makefile.am
create mode 100644 daxctl/daxctl.c
create mode 100644 daxctl/list.c
delete mode 100644 ndctl/builtin.h
rename ndctl/builtin-help.c => util/help.c
rename ndctl/util/json.c => util/json.c
rename ndctl/util/json.h => util/json.h
create mode 100644 util/main.c
create mode 100644 util/main.h
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 11+ messages in thread
* [ndctl PATCH 1/7] ndctl, daxctl: refactor main boilerplate for a new 'daxctl' utility
2017-01-07 1:42 [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates Dan Williams
@ 2017-01-07 1:42 ` Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 2/7] ndctl, daxctl: move json helpers to be available across both utilities Dan Williams
` (6 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Dan Williams @ 2017-01-07 1:42 UTC (permalink / raw)
To: linux-nvdimm
Prepare the generic command infrastructure for reuse with daxctl.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
Makefile.am | 2
ndctl/Makefile.am | 1
ndctl/builtin-bat.c | 2
ndctl/builtin-create-nfit.c | 2
ndctl/builtin-dimm.c | 14 ++-
ndctl/builtin-list.c | 2
ndctl/builtin-test.c | 2
ndctl/builtin-xable-region.c | 4 -
ndctl/builtin-xaction-namespace.c | 8 +-
ndctl/builtin.h | 36 ++++----
ndctl/ndctl.c | 160 +++++++++----------------------------
test/device-dax.c | 2
util/help.c | 44 ++--------
util/main.c | 123 ++++++++++++++++++++++++++++
util/main.h | 10 ++
15 files changed, 219 insertions(+), 193 deletions(-)
rename ndctl/builtin-help.c => util/help.c (73%)
create mode 100644 util/main.c
create mode 100644 util/main.h
diff --git a/Makefile.am b/Makefile.am
index 9eb396639efe..01caca803540 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -64,6 +64,8 @@ libutil_a_SOURCES = \
util/parse-options.h \
util/usage.c \
util/size.c \
+ util/main.c \
+ util/help.c \
util/strbuf.c \
util/wrapper.c \
util/filter.c
diff --git a/ndctl/Makefile.am b/ndctl/Makefile.am
index 2d0d8eb40841..f03647ae9d99 100644
--- a/ndctl/Makefile.am
+++ b/ndctl/Makefile.am
@@ -10,7 +10,6 @@ ndctl_SOURCES = ndctl.c \
../util/log.c \
builtin-list.c \
builtin-test.c \
- builtin-help.c \
util/json.c
if ENABLE_SMART
diff --git a/ndctl/builtin-bat.c b/ndctl/builtin-bat.c
index 48b41dab6d92..5e14d39cfac5 100644
--- a/ndctl/builtin-bat.c
+++ b/ndctl/builtin-bat.c
@@ -4,7 +4,7 @@
#include <limits.h>
#include <util/parse-options.h>
-int cmd_bat(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_bat(int argc, const char **argv, void *ctx)
{
int loglevel = LOG_DEBUG, i, rc;
struct ndctl_test *test;
diff --git a/ndctl/builtin-create-nfit.c b/ndctl/builtin-create-nfit.c
index 780bb84580f5..ebcd7446d14f 100644
--- a/ndctl/builtin-create-nfit.c
+++ b/ndctl/builtin-create-nfit.c
@@ -164,7 +164,7 @@ static int write_nfit(struct nfit *nfit, const char *file, int force)
}
struct ndctl_ctx;
-int cmd_create_nfit(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_create_nfit(int argc, const char **argv, void *ctx)
{
int i, rc = -ENXIO, force = 0;
const char * const u[] = {
diff --git a/ndctl/builtin-dimm.c b/ndctl/builtin-dimm.c
index 4c433d56dfe3..8a041cee8cab 100644
--- a/ndctl/builtin-dimm.c
+++ b/ndctl/builtin-dimm.c
@@ -772,7 +772,7 @@ static const struct option init_options[] = {
OPT_END(),
};
-static int dimm_action(int argc, const char **argv, struct ndctl_ctx *ctx,
+static int dimm_action(int argc, const char **argv, void *ctx,
int (*action)(struct ndctl_dimm *dimm, struct action_context *actx),
const struct option *options, const char *usage)
{
@@ -874,7 +874,7 @@ static int dimm_action(int argc, const char **argv, struct ndctl_ctx *ctx,
return count;
}
-int cmd_read_labels(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_read_labels(int argc, const char **argv, void *ctx)
{
int count = dimm_action(argc, argv, ctx, action_read, read_options,
"ndctl read-labels <nmem0> [<nmem1>..<nmemN>] [-o <filename>]");
@@ -884,7 +884,7 @@ int cmd_read_labels(int argc, const char **argv, struct ndctl_ctx *ctx)
return count >= 0 ? 0 : EXIT_FAILURE;
}
-int cmd_zero_labels(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_zero_labels(int argc, const char **argv, void *ctx)
{
int count = dimm_action(argc, argv, ctx, action_zero, base_options,
"ndctl zero-labels <nmem0> [<nmem1>..<nmemN>] [<options>]");
@@ -894,7 +894,7 @@ int cmd_zero_labels(int argc, const char **argv, struct ndctl_ctx *ctx)
return count >= 0 ? 0 : EXIT_FAILURE;
}
-int cmd_init_labels(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_init_labels(int argc, const char **argv, void *ctx)
{
int count = dimm_action(argc, argv, ctx, action_init, init_options,
"ndctl init-labels <nmem0> [<nmem1>..<nmemN>] [<options>]");
@@ -904,7 +904,7 @@ int cmd_init_labels(int argc, const char **argv, struct ndctl_ctx *ctx)
return count >= 0 ? 0 : EXIT_FAILURE;
}
-int cmd_check_labels(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_check_labels(int argc, const char **argv, void *ctx)
{
int count = dimm_action(argc, argv, ctx, action_check, base_options,
"ndctl check-labels <nmem0> [<nmem1>..<nmemN>] [<options>]");
@@ -914,7 +914,7 @@ int cmd_check_labels(int argc, const char **argv, struct ndctl_ctx *ctx)
return count >= 0 ? 0 : EXIT_FAILURE;
}
-int cmd_disable_dimm(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_disable_dimm(int argc, const char **argv, void *ctx)
{
int count = dimm_action(argc, argv, ctx, action_disable, base_options,
"ndctl disable-dimm <nmem0> [<nmem1>..<nmemN>] [<options>]");
@@ -924,7 +924,7 @@ int cmd_disable_dimm(int argc, const char **argv, struct ndctl_ctx *ctx)
return count >= 0 ? 0 : EXIT_FAILURE;
}
-int cmd_enable_dimm(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_enable_dimm(int argc, const char **argv, void *ctx)
{
int count = dimm_action(argc, argv, ctx, action_enable, base_options,
"ndctl enable-dimm <nmem0> [<nmem1>..<nmemN>] [<options>]");
diff --git a/ndctl/builtin-list.c b/ndctl/builtin-list.c
index 1486cb1dedc3..caafec8b8f39 100644
--- a/ndctl/builtin-list.c
+++ b/ndctl/builtin-list.c
@@ -188,7 +188,7 @@ static int num_list_flags(void)
return list.buses + list.dimms + list.regions + list.namespaces;
}
-int cmd_list(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_list(int argc, const char **argv, void *ctx)
{
const struct option options[] = {
OPT_STRING('b', "bus", ¶m.bus, "bus-id", "filter by bus"),
diff --git a/ndctl/builtin-test.c b/ndctl/builtin-test.c
index caa666b68e69..01ff981749fc 100644
--- a/ndctl/builtin-test.c
+++ b/ndctl/builtin-test.c
@@ -14,7 +14,7 @@ static char *result(int rc)
return "PASS";
}
-int cmd_test(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_test(int argc, const char **argv, void *ctx)
{
struct ndctl_test *test;
int loglevel = LOG_DEBUG, i, rc;
diff --git a/ndctl/builtin-xable-region.c b/ndctl/builtin-xable-region.c
index 41f465a4543f..50cbdef5b339 100644
--- a/ndctl/builtin-xable-region.c
+++ b/ndctl/builtin-xable-region.c
@@ -64,7 +64,7 @@ static int do_xable_region(const char *region_arg,
return rc;
}
-int cmd_disable_region(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_disable_region(int argc, const char **argv, void *ctx)
{
char *xable_usage = "ndctl disable-region <region> [<options>]";
const char *region = parse_region_options(argc, argv, xable_usage);
@@ -85,7 +85,7 @@ int cmd_disable_region(int argc, const char **argv, struct ndctl_ctx *ctx)
}
}
-int cmd_enable_region(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_enable_region(int argc, const char **argv, void *ctx)
{
char *xable_usage = "ndctl enable-region <region> [<options>]";
const char *region = parse_region_options(argc, argv, xable_usage);
diff --git a/ndctl/builtin-xaction-namespace.c b/ndctl/builtin-xaction-namespace.c
index 8257eb9cd65e..f7a4e5b74a16 100644
--- a/ndctl/builtin-xaction-namespace.c
+++ b/ndctl/builtin-xaction-namespace.c
@@ -781,7 +781,7 @@ static int do_xaction_namespace(const char *namespace,
return rc;
}
-int cmd_disable_namespace(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_disable_namespace(int argc, const char **argv, void *ctx)
{
char *xable_usage = "ndctl disable-namespace <namespace> [<options>]";
const char *namespace = parse_namespace_options(argc, argv,
@@ -802,7 +802,7 @@ int cmd_disable_namespace(int argc, const char **argv, struct ndctl_ctx *ctx)
}
}
-int cmd_enable_namespace(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_enable_namespace(int argc, const char **argv, void *ctx)
{
char *xable_usage = "ndctl enable-namespace <namespace> [<options>]";
const char *namespace = parse_namespace_options(argc, argv,
@@ -823,7 +823,7 @@ int cmd_enable_namespace(int argc, const char **argv, struct ndctl_ctx *ctx)
}
}
-int cmd_create_namespace(int argc, const char **argv, struct ndctl_ctx *ctx)
+int cmd_create_namespace(int argc, const char **argv, void *ctx)
{
char *xable_usage = "ndctl create-namespace [<options>]";
const char *namespace = parse_namespace_options(argc, argv,
@@ -853,7 +853,7 @@ int cmd_create_namespace(int argc, const char **argv, struct ndctl_ctx *ctx)
return 0;
}
-int cmd_destroy_namespace(int argc , const char **argv, struct ndctl_ctx *ctx)
+int cmd_destroy_namespace(int argc , const char **argv, void *ctx)
{
char *xable_usage = "ndctl destroy-namespace <namespace> [<options>]";
const char *namespace = parse_namespace_options(argc, argv,
diff --git a/ndctl/builtin.h b/ndctl/builtin.h
index 0293335c127e..9b66196450fd 100644
--- a/ndctl/builtin.h
+++ b/ndctl/builtin.h
@@ -3,31 +3,29 @@
extern const char ndctl_usage_string[];
extern const char ndctl_more_info_string[];
-struct ndctl_ctx;
struct cmd_struct {
const char *cmd;
- int (*fn)(int, const char **, struct ndctl_ctx *ctx);
+ int (*fn)(int, const char **, void *ctx);
};
-int cmd_create_nfit(int argc, const char **argv, struct ndctl_ctx *ctx);
-int cmd_enable_namespace(int argc, const char **argv, struct ndctl_ctx *ctx);
-int cmd_create_namespace(int argc, const char **argv, struct ndctl_ctx *ctx);
-int cmd_destroy_namespace(int argc, const char **argv, struct ndctl_ctx *ctx);
-int cmd_disable_namespace(int argc, const char **argv, struct ndctl_ctx *ctx);
-int cmd_enable_region(int argc, const char **argv, struct ndctl_ctx *ctx);
-int cmd_disable_region(int argc, const char **argv, struct ndctl_ctx *ctx);
-int cmd_enable_dimm(int argc, const char **argv, struct ndctl_ctx *ctx);
-int cmd_disable_dimm(int argc, const char **argv, struct ndctl_ctx *ctx);
-int cmd_zero_labels(int argc, const char **argv, struct ndctl_ctx *ctx);
-int cmd_read_labels(int argc, const char **argv, struct ndctl_ctx *ctx);
-int cmd_init_labels(int argc, const char **argv, struct ndctl_ctx *ctx);
-int cmd_check_labels(int argc, const char **argv, struct ndctl_ctx *ctx);
-int cmd_list(int argc, const char **argv, struct ndctl_ctx *ctx);
-int cmd_help(int argc, const char **argv, struct ndctl_ctx *ctx);
+int cmd_create_nfit(int argc, const char **argv, void *ctx);
+int cmd_enable_namespace(int argc, const char **argv, void *ctx);
+int cmd_create_namespace(int argc, const char **argv, void *ctx);
+int cmd_destroy_namespace(int argc, const char **argv, void *ctx);
+int cmd_disable_namespace(int argc, const char **argv, void *ctx);
+int cmd_enable_region(int argc, const char **argv, void *ctx);
+int cmd_disable_region(int argc, const char **argv, void *ctx);
+int cmd_enable_dimm(int argc, const char **argv, void *ctx);
+int cmd_disable_dimm(int argc, const char **argv, void *ctx);
+int cmd_zero_labels(int argc, const char **argv, void *ctx);
+int cmd_read_labels(int argc, const char **argv, void *ctx);
+int cmd_init_labels(int argc, const char **argv, void *ctx);
+int cmd_check_labels(int argc, const char **argv, void *ctx);
+int cmd_list(int argc, const char **argv, void *ctx);
#ifdef ENABLE_TEST
-int cmd_test(int argc, const char **argv, struct ndctl_ctx *ctx);
+int cmd_test(int argc, const char **argv, void *ctx);
#endif
#ifdef ENABLE_DESTRUCTIVE
-int cmd_bat(int argc, const char **argv, struct ndctl_ctx *ctx);
+int cmd_bat(int argc, const char **argv, void *ctx);
#endif
#endif /* _NDCTL_BUILTIN_H_ */
diff --git a/ndctl/ndctl.c b/ndctl/ndctl.c
index 4f000fe51fae..80a0491c440a 100644
--- a/ndctl/ndctl.c
+++ b/ndctl/ndctl.c
@@ -9,20 +9,47 @@
#include <ndctl/libndctl.h>
#include <ccan/array_size/array_size.h>
+#include <util/parse-options.h>
#include <util/strbuf.h>
#include <util/util.h>
+#include <util/main.h>
const char ndctl_usage_string[] = "ndctl [--version] [--help] COMMAND [ARGS]";
const char ndctl_more_info_string[] =
"See 'ndctl help COMMAND' for more information on a specific command.\n"
" ndctl --list-cmds to see all available commands";
-static int cmd_version(int argc, const char **argv, struct ndctl_ctx *ctx)
+static int cmd_version(int argc, const char **argv, void *ctx)
{
printf("%s\n", VERSION);
return 0;
}
+static int cmd_help(int argc, const char **argv, void *ctx)
+{
+ const char * const builtin_help_subcommands[] = {
+ "enable-region", "disable-region", "zero-labels",
+ "enable-namespace", "disable-namespace", NULL };
+ struct option builtin_help_options[] = {
+ OPT_END(),
+ };
+ const char *builtin_help_usage[] = {
+ "ndctl help [command]",
+ NULL
+ };
+
+ argc = parse_options_subcommand(argc, argv, builtin_help_options,
+ builtin_help_subcommands, builtin_help_usage, 0);
+
+ if (!argv[0]) {
+ printf("\n usage: %s\n\n", ndctl_usage_string);
+ printf("\n %s\n\n", ndctl_more_info_string);
+ return 0;
+ }
+
+ return help_show_man_page(argv[0], "ndctl", "NDCTL_MAN_VIEWER");
+}
+
static struct cmd_struct commands[] = {
{ "version", cmd_version },
{ "create-nfit", cmd_create_nfit },
@@ -48,131 +75,16 @@ static struct cmd_struct commands[] = {
#endif
};
-static int handle_options(const char ***argv, int *argc)
-{
- int handled = 0;
-
- while (*argc > 0) {
- const char *cmd = (*argv)[0];
- if (cmd[0] != '-')
- break;
-
- if (!strcmp(cmd, "--version") || !strcmp(cmd, "--help"))
- break;
-
- /*
- * Shortcut for '-h' and '-v' options to invoke help
- * and version command.
- */
- if (!strcmp(cmd, "-h")) {
- (*argv)[0] = "--help";
- break;
- }
-
- if (!strcmp(cmd, "-v")) {
- (*argv)[0] = "--version";
- break;
- }
-
- if (!strcmp(cmd, "--list-cmds")) {
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(commands); i++) {
- struct cmd_struct *p = commands+i;
-
- /* filter out commands from auto-complete */
- if (strcmp(p->cmd, "create-nfit") == 0)
- continue;
- if (strcmp(p->cmd, "test") == 0)
- continue;
- if (strcmp(p->cmd, "bat") == 0)
- continue;
- printf("%s\n", p->cmd);
- }
- exit(0);
- } else {
- fprintf(stderr, "Unknown option: %s\n", cmd);
- usage(ndctl_usage_string);
- }
-
- (*argv)++;
- (*argc)--;
- handled++;
- }
- return handled;
-}
-
-static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
+int main(int argc, const char **argv)
{
- int status;
- struct stat st;
struct ndctl_ctx *ctx;
+ int rc;
- /*
- * Yes, establishing the ndctl context here makes this code less
- * generic, but it allows for unit testing the top level
- * interface to the built-in commands.
- */
- status = ndctl_new(&ctx);
- if (status)
- return status;
- status = p->fn(argc, argv, ctx);
- ndctl_unref(ctx);
-
- if (status)
- return status & 0xff;
-
- /* Somebody closed stdout? */
- if (fstat(fileno(stdout), &st))
- return 0;
- /* Ignore write errors for pipes and sockets.. */
- if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode))
- return 0;
-
- status = 1;
- /* Check for ENOSPC and EIO errors.. */
- if (fflush(stdout)) {
- fprintf(stderr, "write failure on standard output: %s", strerror(errno));
- goto out;
- }
- if (ferror(stdout)) {
- fprintf(stderr, "unknown write failure on standard output");
- goto out;
- }
- if (fclose(stdout)) {
- fprintf(stderr, "close failed on standard output: %s", strerror(errno));
- goto out;
- }
- status = 0;
-out:
- return status;
-}
-
-static void handle_internal_command(int argc, const char **argv)
-{
- const char *cmd = argv[0];
- unsigned int i;
-
- /* Turn "ndctl cmd --help" into "ndctl help cmd" */
- if (argc > 1 && !strcmp(argv[1], "--help")) {
- argv[1] = argv[0];
- argv[0] = cmd = "help";
- }
-
- for (i = 0; i < ARRAY_SIZE(commands); i++) {
- struct cmd_struct *p = commands+i;
- if (strcmp(p->cmd, cmd))
- continue;
- exit(run_builtin(p, argc, argv));
- }
-}
-
-int main(int argc, const char **argv)
-{
/* Look for flags.. */
argv++;
argc--;
- handle_options(&argv, &argc);
+ main_handle_options(&argv, &argc, ndctl_usage_string, commands,
+ ARRAY_SIZE(commands));
if (argc > 0) {
if (!prefixcmp(argv[0], "--"))
@@ -183,7 +95,13 @@ int main(int argc, const char **argv)
printf("\n %s\n\n", ndctl_more_info_string);
goto out;
}
- handle_internal_command(argc, argv);
+
+ rc = ndctl_new(&ctx);
+ if (rc)
+ goto out;
+ main_handle_internal_command(argc, argv, ctx, commands,
+ ARRAY_SIZE(commands));
+ ndctl_unref(ctx);
fprintf(stderr, "Unknown command: '%s'\n", argv[0]);
out:
return 1;
diff --git a/test/device-dax.c b/test/device-dax.c
index 75b17ed63088..0ace922ee55d 100644
--- a/test/device-dax.c
+++ b/test/device-dax.c
@@ -23,7 +23,7 @@
static sigjmp_buf sj_env;
-static int create_namespace(int argc, const char **argv, struct ndctl_ctx *ctx)
+static int create_namespace(int argc, const char **argv, void *ctx)
{
builtin_xaction_namespace_reset();
return cmd_create_namespace(argc, argv, ctx);
diff --git a/ndctl/builtin-help.c b/util/help.c
similarity index 73%
rename from ndctl/builtin-help.c
rename to util/help.c
index 14ad9d5738d0..310a40bd83e8 100644
--- a/ndctl/builtin-help.c
+++ b/util/help.c
@@ -56,16 +56,16 @@ static void exec_man_man(const char *path, const char *page)
strerror_r(errno, sbuf, sizeof(sbuf)));
}
-static char *cmd_to_page(const char *ndctl_cmd, char **page)
+static char *cmd_to_page(const char *cmd, char **page, const char *util_name)
{
int rc;
- if (!ndctl_cmd)
- rc = asprintf(page, "ndctl");
- else if (!prefixcmp(ndctl_cmd, "ndctl"))
- rc = asprintf(page, "%s", ndctl_cmd);
+ if (!cmd)
+ rc = asprintf(page, "%s", util_name);
+ else if (!prefixcmp(cmd, util_name))
+ rc = asprintf(page, "%s", cmd);
else
- rc = asprintf(page, "ndctl-%s", ndctl_cmd);
+ rc = asprintf(page, "%s-%s", util_name, cmd);
if (rc < 0)
return NULL;
@@ -119,12 +119,13 @@ static void exec_viewer(const char *name, const char *page)
warning("'%s': unknown man viewer.", name);
}
-static int show_man_page(const char *ndctl_cmd)
+int help_show_man_page(const char *cmd, const char *util_name,
+ const char *viewer)
{
- const char *fallback = getenv("NDCTL_MAN_VIEWER");
+ const char *fallback = getenv(viewer);
char *page;
- page = cmd_to_page(ndctl_cmd, &page);
+ page = cmd_to_page(cmd, &page, util_name);
if (!page)
return -1;
setup_man_path();
@@ -136,28 +137,3 @@ static int show_man_page(const char *ndctl_cmd)
free(page);
return -1;
}
-
-int cmd_help(int argc, const char **argv, struct ndctl_ctx *ctx)
-{
- const char * const builtin_help_subcommands[] = {
- "enable-region", "disable-region", "zero-labels",
- "enable-namespace", "disable-namespace", NULL };
- struct option builtin_help_options[] = {
- OPT_END(),
- };
- const char *builtin_help_usage[] = {
- "ndctl help [command]",
- NULL
- };
-
- argc = parse_options_subcommand(argc, argv, builtin_help_options,
- builtin_help_subcommands, builtin_help_usage, 0);
-
- if (!argv[0]) {
- printf("\n usage: %s\n\n", ndctl_usage_string);
- printf("\n %s\n\n", ndctl_more_info_string);
- return 0;
- }
-
- return show_man_page(argv[0]);
-}
diff --git a/util/main.c b/util/main.c
new file mode 100644
index 000000000000..cb3c634e93f5
--- /dev/null
+++ b/util/main.c
@@ -0,0 +1,123 @@
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <builtin.h>
+
+#include <util/strbuf.h>
+#include <util/util.h>
+
+int main_handle_options(const char ***argv, int *argc, const char *usage_msg,
+ struct cmd_struct *cmds, int num_cmds)
+{
+ int handled = 0;
+
+ while (*argc > 0) {
+ const char *cmd = (*argv)[0];
+ if (cmd[0] != '-')
+ break;
+
+ if (!strcmp(cmd, "--version") || !strcmp(cmd, "--help"))
+ break;
+
+ /*
+ * Shortcut for '-h' and '-v' options to invoke help
+ * and version command.
+ */
+ if (!strcmp(cmd, "-h")) {
+ (*argv)[0] = "--help";
+ break;
+ }
+
+ if (!strcmp(cmd, "-v")) {
+ (*argv)[0] = "--version";
+ break;
+ }
+
+ if (!strcmp(cmd, "--list-cmds")) {
+ int i;
+
+ for (i = 0; i < num_cmds; i++) {
+ struct cmd_struct *p = cmds+i;
+
+ /* filter out commands from auto-complete */
+ if (strcmp(p->cmd, "create-nfit") == 0)
+ continue;
+ if (strcmp(p->cmd, "test") == 0)
+ continue;
+ if (strcmp(p->cmd, "bat") == 0)
+ continue;
+ printf("%s\n", p->cmd);
+ }
+ exit(0);
+ } else {
+ fprintf(stderr, "Unknown option: %s\n", cmd);
+ usage(usage_msg);
+ }
+
+ (*argv)++;
+ (*argc)--;
+ handled++;
+ }
+ return handled;
+}
+
+static int run_builtin(struct cmd_struct *p, int argc, const char **argv,
+ void *ctx)
+{
+ int status;
+ struct stat st;
+
+ status = p->fn(argc, argv, ctx);
+
+ if (status)
+ return status & 0xff;
+
+ /* Somebody closed stdout? */
+ if (fstat(fileno(stdout), &st))
+ return 0;
+ /* Ignore write errors for pipes and sockets.. */
+ if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode))
+ return 0;
+
+ status = 1;
+ /* Check for ENOSPC and EIO errors.. */
+ if (fflush(stdout)) {
+ fprintf(stderr, "write failure on standard output: %s", strerror(errno));
+ goto out;
+ }
+ if (ferror(stdout)) {
+ fprintf(stderr, "unknown write failure on standard output");
+ goto out;
+ }
+ if (fclose(stdout)) {
+ fprintf(stderr, "close failed on standard output: %s", strerror(errno));
+ goto out;
+ }
+ status = 0;
+out:
+ return status;
+}
+
+void main_handle_internal_command(int argc, const char **argv, void *ctx,
+ struct cmd_struct *cmds, int num_cmds)
+{
+ const char *cmd = argv[0];
+ int i;
+
+ /* Turn "<binary> cmd --help" into "<binary> help cmd" */
+ if (argc > 1 && !strcmp(argv[1], "--help")) {
+ argv[1] = argv[0];
+ argv[0] = cmd = "help";
+ }
+
+ for (i = 0; i < num_cmds; i++) {
+ struct cmd_struct *p = cmds+i;
+ if (strcmp(p->cmd, cmd))
+ continue;
+ exit(run_builtin(p, argc, argv, ctx));
+ }
+}
diff --git a/util/main.h b/util/main.h
new file mode 100644
index 000000000000..bdd4f701665c
--- /dev/null
+++ b/util/main.h
@@ -0,0 +1,10 @@
+#ifndef __MAIN_H__
+#define __MAIN_H__
+struct cmd_struct;
+int main_handle_options(const char ***argv, int *argc, const char *usage_msg,
+ struct cmd_struct *cmds, int num_cmds);
+void main_handle_internal_command(int argc, const char **argv, void *ctx,
+ struct cmd_struct *cmds, int num_cmds);
+int help_show_man_page(const char *cmd, const char *util_name,
+ const char *viewer);
+#endif /* __MAIN_H__ */
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ndctl PATCH 2/7] ndctl, daxctl: move json helpers to be available across both utilities
2017-01-07 1:42 [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 1/7] ndctl, daxctl: refactor main boilerplate for a new 'daxctl' utility Dan Williams
@ 2017-01-07 1:42 ` Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 3/7] ndctl, list: add option to filter namespace by mode Dan Williams
` (5 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Dan Williams @ 2017-01-07 1:42 UTC (permalink / raw)
To: linux-nvdimm
---
ndctl/Makefile.am | 2 +-
test/Makefile.am | 4 ++--
util/json.c | 0
util/json.h | 0
4 files changed, 3 insertions(+), 3 deletions(-)
rename ndctl/util/json.c => util/json.c (100%)
rename ndctl/util/json.h => util/json.h (100%)
diff --git a/ndctl/Makefile.am b/ndctl/Makefile.am
index f03647ae9d99..c563e9411cc3 100644
--- a/ndctl/Makefile.am
+++ b/ndctl/Makefile.am
@@ -10,7 +10,7 @@ ndctl_SOURCES = ndctl.c \
../util/log.c \
builtin-list.c \
builtin-test.c \
- util/json.c
+ ../util/json.c
if ENABLE_SMART
ndctl_SOURCES += util/json-smart.c
diff --git a/test/Makefile.am b/test/Makefile.am
index 46a1acf98f0d..9e3ae1dab411 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -75,7 +75,7 @@ device_dax_SOURCES = \
dax-pmd.c \
core.c \
../ndctl/builtin-xaction-namespace.c \
- ../ndctl/util/json.c
+ ../util/json.c
device_dax_LDADD = \
$(LIBNDCTL_LIB) \
$(JSON_LIBS) \
@@ -85,7 +85,7 @@ multi_pmem_SOURCES = \
multi-pmem.c \
core.c \
../ndctl/builtin-xaction-namespace.c \
- ../ndctl/util/json.c
+ ../util/json.c
multi_pmem_LDADD = \
$(LIBNDCTL_LIB) \
$(JSON_LIBS) \
diff --git a/ndctl/util/json.c b/util/json.c
similarity index 100%
rename from ndctl/util/json.c
rename to util/json.c
diff --git a/ndctl/util/json.h b/util/json.h
similarity index 100%
rename from ndctl/util/json.h
rename to util/json.h
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ndctl PATCH 3/7] ndctl, list: add option to filter namespace by mode
2017-01-07 1:42 [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 1/7] ndctl, daxctl: refactor main boilerplate for a new 'daxctl' utility Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 2/7] ndctl, daxctl: move json helpers to be available across both utilities Dan Williams
@ 2017-01-07 1:42 ` Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 4/7] ndctl, list: add '--device-dax' option Dan Williams
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Dan Williams @ 2017-01-07 1:42 UTC (permalink / raw)
To: linux-nvdimm
For example, "ndctl list -m dax" list all the namespaces that are
hosting a device-dax region.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
ndctl/builtin-list.c | 33 ++++++++++++++++++++++++++++++++-
ndctl/libndctl.h.in | 1 +
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/ndctl/builtin-list.c b/ndctl/builtin-list.c
index caafec8b8f39..b09da3057519 100644
--- a/ndctl/builtin-list.c
+++ b/ndctl/builtin-list.c
@@ -30,6 +30,7 @@ static struct {
const char *region;
const char *type;
const char *dimm;
+ const char *mode;
const char *namespace;
} param;
@@ -43,6 +44,25 @@ do { \
VERSION, __func__, __LINE__, ##__VA_ARGS__); \
} while (0)
+static enum ndctl_namespace_mode mode_to_type(const char *mode)
+{
+ if (!mode)
+ return -ENXIO;
+
+ if (strcasecmp(param.mode, "memory") == 0)
+ return NDCTL_NS_MODE_MEMORY;
+ else if (strcasecmp(param.mode, "sector") == 0)
+ return NDCTL_NS_MODE_SAFE;
+ else if (strcasecmp(param.mode, "safe") == 0)
+ return NDCTL_NS_MODE_SAFE;
+ else if (strcasecmp(param.mode, "dax") == 0)
+ return NDCTL_NS_MODE_DAX;
+ else if (strcasecmp(param.mode, "raw") == 0)
+ return NDCTL_NS_MODE_RAW;
+
+ return NDCTL_NS_MODE_UNKNOWN;
+}
+
static struct json_object *list_namespaces(struct ndctl_region *region,
struct json_object *container, struct json_object *jnamespaces,
bool continue_array)
@@ -50,6 +70,7 @@ static struct json_object *list_namespaces(struct ndctl_region *region,
struct ndctl_namespace *ndns;
ndctl_namespace_foreach(region, ndns) {
+ enum ndctl_namespace_mode mode = ndctl_namespace_get_mode(ndns);
struct json_object *jndns;
/* are we emitting namespaces? */
@@ -59,6 +80,9 @@ static struct json_object *list_namespaces(struct ndctl_region *region,
if (!util_namespace_filter(ndns, param.namespace))
continue;
+ if (param.mode && mode_to_type(param.mode) != mode)
+ continue;
+
if (!list.idle && !util_namespace_active(ndns))
continue;
@@ -197,7 +221,9 @@ int cmd_list(int argc, const char **argv, void *ctx)
OPT_STRING('d', "dimm", ¶m.dimm, "dimm-id",
"filter by dimm"),
OPT_STRING('n', "namespace", ¶m.namespace, "namespace-id",
- "filter by namespace"),
+ "filter by namespace id"),
+ OPT_STRING('m', "mode", ¶m.mode, "namespace-mode",
+ "filter by namespace mode"),
OPT_STRING('t', "type", ¶m.type, "region-type",
"filter by region-type"),
OPT_BOOLEAN('B', "buses", &list.buses, "include bus info"),
@@ -251,6 +277,11 @@ int cmd_list(int argc, const char **argv, void *ctx)
type = ND_DEVICE_REGION_BLK;
}
+ if (mode_to_type(param.mode) == NDCTL_NS_MODE_UNKNOWN) {
+ error("invalid mode: '%s'\n", param.mode);
+ return -EINVAL;
+ }
+
ndctl_bus_foreach(ctx, bus) {
struct json_object *jbus = NULL;
struct ndctl_region *region;
diff --git a/ndctl/libndctl.h.in b/ndctl/libndctl.h.in
index d45111775525..394d22e24c7a 100644
--- a/ndctl/libndctl.h.in
+++ b/ndctl/libndctl.h.in
@@ -475,6 +475,7 @@ enum ndctl_namespace_mode {
NDCTL_NS_MODE_SAFE,
NDCTL_NS_MODE_RAW,
NDCTL_NS_MODE_DAX,
+ NDCTL_NS_MODE_UNKNOWN,
};
enum ndctl_namespace_mode ndctl_namespace_get_mode(
struct ndctl_namespace *ndns);
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ndctl PATCH 4/7] ndctl, list: add '--device-dax' option
2017-01-07 1:42 [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates Dan Williams
` (2 preceding siblings ...)
2017-01-07 1:42 ` [ndctl PATCH 3/7] ndctl, list: add option to filter namespace by mode Dan Williams
@ 2017-01-07 1:42 ` Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 5/7] daxctl: add list command Dan Williams
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Dan Williams @ 2017-01-07 1:42 UTC (permalink / raw)
To: linux-nvdimm
Only include dax region and sub-device info when requested by this new
option to ndctl list. If '--device-dax' is the only option then the
listing will only include namespaces in device-dax mode.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
ndctl/builtin-list.c | 7 ++++++-
ndctl/builtin-xaction-namespace.c | 2 +-
util/json.c | 12 +++++++-----
util/json.h | 2 +-
4 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/ndctl/builtin-list.c b/ndctl/builtin-list.c
index b09da3057519..ed4edf6f0249 100644
--- a/ndctl/builtin-list.c
+++ b/ndctl/builtin-list.c
@@ -23,6 +23,7 @@ static struct {
bool namespaces;
bool idle;
bool health;
+ bool dax;
} list;
static struct {
@@ -98,7 +99,7 @@ static struct json_object *list_namespaces(struct ndctl_region *region,
jnamespaces);
}
- jndns = util_namespace_to_json(ndns, list.idle);
+ jndns = util_namespace_to_json(ndns, list.idle, list.dax);
if (!jndns) {
fail("\n");
continue;
@@ -233,6 +234,8 @@ int cmd_list(int argc, const char **argv, void *ctx)
"include region info"),
OPT_BOOLEAN('N', "namespaces", &list.namespaces,
"include namespace info (default)"),
+ OPT_BOOLEAN('X', "device-dax", &list.dax,
+ "include device-dax info"),
OPT_BOOLEAN('i', "idle", &list.idle, "include idle devices"),
OPT_END(),
};
@@ -265,6 +268,8 @@ int cmd_list(int argc, const char **argv, void *ctx)
list.buses = !!param.bus;
list.regions = !!param.region;
list.dimms = !!param.dimm;
+ if (list.dax && !param.mode)
+ param.mode = "dax";
}
if (num_list_flags() == 0)
diff --git a/ndctl/builtin-xaction-namespace.c b/ndctl/builtin-xaction-namespace.c
index f7a4e5b74a16..2c4f85f5e4ac 100644
--- a/ndctl/builtin-xaction-namespace.c
+++ b/ndctl/builtin-xaction-namespace.c
@@ -352,7 +352,7 @@ static int setup_namespace(struct ndctl_region *region,
error("%s: failed to enable\n",
ndctl_namespace_get_devname(ndns));
} else {
- struct json_object *jndns = util_namespace_to_json(ndns, 0);
+ struct json_object *jndns = util_namespace_to_json(ndns, 0, 0);
if (jndns)
printf("%s\n", json_object_to_json_string_ext(jndns,
diff --git a/util/json.c b/util/json.c
index 82e677c2c7a7..299c1b5782ee 100644
--- a/util/json.c
+++ b/util/json.c
@@ -139,7 +139,7 @@ static json_object *util_daxctl_region_to_json(struct daxctl_region *region,
}
struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
- bool include_idle)
+ bool include_idle, bool include_dax)
{
struct json_object *jndns = json_object_new_object();
unsigned long long size = ULLONG_MAX;
@@ -231,10 +231,12 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
if (!jobj)
goto err;
json_object_object_add(jndns, "uuid", jobj);
- dax_region = ndctl_dax_get_daxctl_region(dax);
- jobj = util_daxctl_region_to_json(dax_region, include_idle);
- if (jobj)
- json_object_object_add(jndns, "daxdevs", jobj);
+ if (include_dax) {
+ dax_region = ndctl_dax_get_daxctl_region(dax);
+ jobj = util_daxctl_region_to_json(dax_region, include_idle);
+ if (jobj)
+ json_object_object_add(jndns, "daxdevs", jobj);
+ }
} else if (ndctl_namespace_get_type(ndns) != ND_DEVICE_NAMESPACE_IO) {
const char *name;
diff --git a/util/json.h b/util/json.h
index 7492e51621a7..b8fc00f57ea8 100644
--- a/util/json.h
+++ b/util/json.h
@@ -11,7 +11,7 @@ struct json_object *util_bus_to_json(struct ndctl_bus *bus);
struct json_object *util_dimm_to_json(struct ndctl_dimm *dimm);
struct json_object *util_mapping_to_json(struct ndctl_mapping *mapping);
struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
- bool include_idle);
+ bool include_idle, bool include_dax);
#ifdef HAVE_NDCTL_SMART
struct json_object *util_dimm_health_to_json(struct ndctl_dimm *dimm);
#else
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ndctl PATCH 5/7] daxctl: add list command
2017-01-07 1:42 [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates Dan Williams
` (3 preceding siblings ...)
2017-01-07 1:42 ` [ndctl PATCH 4/7] ndctl, list: add '--device-dax' option Dan Williams
@ 2017-01-07 1:42 ` Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 6/7] ndctl, {enable,disable}-region: filter by type Dan Williams
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Dan Williams @ 2017-01-07 1:42 UTC (permalink / raw)
To: linux-nvdimm
Similar to "ndctl list", provide a utility for generically dumping all
the device-dax regions and device instances in a system.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
Makefile.am | 2 -
builtin.h | 0
configure.ac | 1
daxctl/Makefile.am | 13 ++++++
daxctl/daxctl.c | 91 +++++++++++++++++++++++++++++++++++++++
daxctl/lib/Makefile.am | 3 +
daxctl/libdaxctl.h | 1
daxctl/list.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++++
ndctl.spec.in | 12 +++++
test/device-dax.c | 2 -
test/multi-pmem.c | 2 -
util/filter.c | 21 +++++++++
util/filter.h | 6 ++-
util/json.c | 113 +++++++++++++++++++++++++++++++++++++++---------
util/json.h | 8 +++
15 files changed, 360 insertions(+), 27 deletions(-)
rename ndctl/builtin.h => builtin.h (100%)
create mode 100644 daxctl/Makefile.am
create mode 100644 daxctl/daxctl.c
create mode 100644 daxctl/list.c
diff --git a/Makefile.am b/Makefile.am
index 01caca803540..06cd1b059160 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
include Makefile.am.in
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
-SUBDIRS = . daxctl/lib ndctl/lib ndctl
+SUBDIRS = . daxctl/lib ndctl/lib ndctl daxctl
if ENABLE_DOCS
SUBDIRS += Documentation
endif
diff --git a/ndctl/builtin.h b/builtin.h
similarity index 100%
rename from ndctl/builtin.h
rename to builtin.h
diff --git a/configure.ac b/configure.ac
index 7b4af616cf2b..e79623ac1d82 100644
--- a/configure.ac
+++ b/configure.ac
@@ -263,6 +263,7 @@ AC_CONFIG_FILES([
daxctl/lib/Makefile
ndctl/lib/Makefile
ndctl/Makefile
+ daxctl/Makefile
test/Makefile
Documentation/Makefile
])
diff --git a/daxctl/Makefile.am b/daxctl/Makefile.am
new file mode 100644
index 000000000000..9153c418cdaf
--- /dev/null
+++ b/daxctl/Makefile.am
@@ -0,0 +1,13 @@
+include $(top_srcdir)/Makefile.am.in
+
+bin_PROGRAMS = daxctl
+
+daxctl_SOURCES =\
+ daxctl.c \
+ list.c \
+ ../util/json.c
+
+daxctl_LDADD =\
+ lib/libdaxctl.la \
+ ../libutil.a \
+ $(JSON_LIBS)
diff --git a/daxctl/daxctl.c b/daxctl/daxctl.c
new file mode 100644
index 000000000000..31d230a68756
--- /dev/null
+++ b/daxctl/daxctl.c
@@ -0,0 +1,91 @@
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <daxctl/libdaxctl.h>
+#include <util/parse-options.h>
+#include <ccan/array_size/array_size.h>
+
+#include <util/strbuf.h>
+#include <util/util.h>
+#include <util/main.h>
+#include <builtin.h>
+
+const char daxctl_usage_string[] = "daxctl [--version] [--help] COMMAND [ARGS]";
+const char daxctl_more_info_string[] =
+ "See 'daxctl help COMMAND' for more information on a specific command.\n"
+ " daxctl --list-cmds to see all available commands";
+
+static int cmd_version(int argc, const char **argv, void *ctx)
+{
+ printf("%s\n", VERSION);
+ return 0;
+}
+
+static int cmd_help(int argc, const char **argv, void *ctx)
+{
+ const char * const builtin_help_subcommands[] = {
+ "list", NULL,
+ };
+ struct option builtin_help_options[] = {
+ OPT_END(),
+ };
+ const char *builtin_help_usage[] = {
+ "daxctl help [command]",
+ NULL
+ };
+
+ argc = parse_options_subcommand(argc, argv, builtin_help_options,
+ builtin_help_subcommands, builtin_help_usage, 0);
+
+ if (!argv[0]) {
+ printf("\n usage: %s\n\n", daxctl_usage_string);
+ printf("\n %s\n\n", daxctl_more_info_string);
+ return 0;
+ }
+
+ return help_show_man_page(argv[0], "daxctl", "DAXCTL_MAN_VIEWER");
+}
+
+int cmd_list(int argc, const char **argv, void *ctx);
+
+static struct cmd_struct commands[] = {
+ { "version", cmd_version },
+ { "list", cmd_list },
+ { "help", cmd_help },
+};
+
+int main(int argc, const char **argv)
+{
+ struct daxctl_ctx *ctx;
+ int rc;
+
+ /* Look for flags.. */
+ argv++;
+ argc--;
+ main_handle_options(&argv, &argc, daxctl_usage_string, commands,
+ ARRAY_SIZE(commands));
+
+ if (argc > 0) {
+ if (!prefixcmp(argv[0], "--"))
+ argv[0] += 2;
+ } else {
+ /* The user didn't specify a command; give them help */
+ printf("\n usage: %s\n\n", daxctl_usage_string);
+ printf("\n %s\n\n", daxctl_more_info_string);
+ goto out;
+ }
+
+ rc = daxctl_new(&ctx);
+ if (rc)
+ goto out;
+ main_handle_internal_command(argc, argv, ctx, commands,
+ ARRAY_SIZE(commands));
+ daxctl_unref(ctx);
+ fprintf(stderr, "Unknown command: '%s'\n", argv[0]);
+out:
+ return 1;
+}
diff --git a/daxctl/lib/Makefile.am b/daxctl/lib/Makefile.am
index 92783847266a..0167e3995b00 100644
--- a/daxctl/lib/Makefile.am
+++ b/daxctl/lib/Makefile.am
@@ -15,6 +15,9 @@ libdaxctl_la_SOURCES =\
../../util/log.h \
libdaxctl.c
+libdaxctl_la_LIBADD =\
+ $(UUID_LIBS)
+
EXTRA_DIST += libdaxctl.sym
libdaxctl_la_LDFLAGS = $(AM_LDFLAGS) \
diff --git a/daxctl/libdaxctl.h b/daxctl/libdaxctl.h
index 071cb1b17e6e..b65dc3083048 100644
--- a/daxctl/libdaxctl.h
+++ b/daxctl/libdaxctl.h
@@ -15,6 +15,7 @@
#include <stdarg.h>
#include <unistd.h>
+#include <uuid.h>
#ifdef __cplusplus
extern "C" {
diff --git a/daxctl/list.c b/daxctl/list.c
new file mode 100644
index 000000000000..9a48ad7477ff
--- /dev/null
+++ b/daxctl/list.c
@@ -0,0 +1,112 @@
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <limits.h>
+#include <util/json.h>
+#include <util/filter.h>
+#include <json-c/json.h>
+#include <daxctl/libdaxctl.h>
+#include <util/parse-options.h>
+#include <ccan/array_size/array_size.h>
+
+static struct {
+ bool devs;
+ bool regions;
+ bool idle;
+} list;
+
+static struct {
+ const char *dev;
+ int region_id;
+} param = {
+ .region_id = -1,
+};
+
+static int did_fail;
+static int jflag = JSON_C_TO_STRING_PRETTY;
+
+#define fail(fmt, ...) \
+do { \
+ did_fail = 1; \
+ fprintf(stderr, "daxctl-%s:%s:%d: " fmt, \
+ VERSION, __func__, __LINE__, ##__VA_ARGS__); \
+} while (0)
+
+static int num_list_flags(void)
+{
+ return list.regions + list.devs;
+}
+
+int cmd_list(int argc, const char **argv, void *ctx)
+{
+ const struct option options[] = {
+ OPT_INTEGER('r', "region", ¶m.region_id, "filter by region"),
+ OPT_STRING('d', "dev", ¶m.dev, "dev-id",
+ "filter by dax device instance name"),
+ OPT_BOOLEAN('D', "devices", &list.devs, "include dax device info"),
+ OPT_BOOLEAN('R', "regions", &list.regions, "include dax region info"),
+ OPT_BOOLEAN('i', "idle", &list.idle, "include idle devices"),
+ OPT_END(),
+ };
+ const char * const u[] = {
+ "daxctl list [<options>]",
+ NULL
+ };
+ struct json_object *jregions = NULL;
+ struct json_object *jdevs = NULL;
+ struct daxctl_region *region;
+ int i;
+
+ argc = parse_options(argc, argv, options, u, 0);
+ for (i = 0; i < argc; i++)
+ error("unknown parameter \"%s\"\n", argv[i]);
+
+ if (argc)
+ usage_with_options(u, options);
+
+ if (num_list_flags() == 0) {
+ list.regions = param.region_id >= 0;
+ list.devs = !!param.dev;
+ }
+
+ if (num_list_flags() == 0)
+ list.devs = true;
+
+ daxctl_region_foreach(ctx, region) {
+ struct json_object *jregion = NULL;
+
+ if (param.region_id >= 0 && param.region_id
+ != daxctl_region_get_id(region))
+ continue;
+
+ if (list.regions) {
+ if (!jregions) {
+ jregions = json_object_new_array();
+ if (!jregions) {
+ fail("\n");
+ continue;
+ }
+ }
+
+ jregion = util_daxctl_region_to_json(region,
+ list.devs, param.dev, list.idle);
+ if (!jregion) {
+ fail("\n");
+ continue;
+ }
+ json_object_array_add(jregions, jregion);
+ } else if (list.devs)
+ jdevs = util_daxctl_devs_to_list(region,
+ jdevs, param.dev, list.idle);
+ }
+
+ if (jregions)
+ util_display_json_array(stdout, jregions, jflag);
+ else if (jdevs)
+ util_display_json_array(stdout, jdevs, jflag);
+
+ if (did_fail)
+ return -ENOMEM;
+ return 0;
+}
diff --git a/ndctl.spec.in b/ndctl.spec.in
index 06e0e390a17b..6453edd1954c 100644
--- a/ndctl.spec.in
+++ b/ndctl.spec.in
@@ -38,6 +38,18 @@ Requires: LNAME%{?_isa} = %{version}-%{release}
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
+%package -n daxctl
+Summary: Manage Device-DAX instances
+License: GPLv2
+Group: System Environment/Base
+Requires: DAX_LNAME%{?_isa} = %{version}-%{release}
+
+%description -n daxctl
+The daxctl utility provides enumeration and provisioning commands for
+the Linux kernel Device-DAX facility. This facility enables DAX mappings
+of performance / feature differentiated memory without need of a
+filesystem.
+
%package -n DAX_DNAME
Summary: Development files for libdaxctl
License: LGPLv2
diff --git a/test/device-dax.c b/test/device-dax.c
index 0ace922ee55d..f5ab3898f78c 100644
--- a/test/device-dax.c
+++ b/test/device-dax.c
@@ -18,7 +18,7 @@
#include <daxctl/libdaxctl.h>
#include <ccan/array_size/array_size.h>
-#include <ndctl/builtin.h>
+#include <builtin.h>
#include <test.h>
static sigjmp_buf sj_env;
diff --git a/test/multi-pmem.c b/test/multi-pmem.c
index a7aedd9b5025..126669bda88d 100644
--- a/test/multi-pmem.c
+++ b/test/multi-pmem.c
@@ -22,7 +22,7 @@
#include <ndctl.h>
#endif
-#include <ndctl/builtin.h>
+#include <builtin.h>
#include <test.h>
#define NUM_NAMESPACES 4
diff --git a/util/filter.c b/util/filter.c
index 97f0dec3569c..9e2133430433 100644
--- a/util/filter.c
+++ b/util/filter.c
@@ -4,6 +4,7 @@
#include <limits.h>
#include <util/filter.h>
#include <ndctl/libndctl.h>
+#include <daxctl/libdaxctl.h>
struct ndctl_bus *util_bus_filter(struct ndctl_bus *bus, const char *ident)
{
@@ -158,3 +159,23 @@ struct ndctl_region *util_region_filter_by_dimm(struct ndctl_region *region,
return NULL;
}
+
+struct daxctl_dev *util_daxctl_dev_filter(struct daxctl_dev *dev,
+ const char *ident)
+{
+ struct daxctl_region *region = daxctl_dev_get_region(dev);
+ int region_id, dev_id;
+
+ if (!ident || strcmp(ident, "all") == 0)
+ return dev;
+
+ if (strcmp(ident, daxctl_dev_get_devname(dev)) == 0)
+ return dev;
+
+ if (sscanf(ident, "%d.%d", ®ion_id, &dev_id) == 2
+ && daxctl_region_get_id(region) == region_id
+ && daxctl_dev_get_id(dev) == dev_id)
+ return dev;
+
+ return NULL;
+}
diff --git a/util/filter.h b/util/filter.h
index 52be4c32d5bf..cc23bfd7bfc8 100644
--- a/util/filter.h
+++ b/util/filter.h
@@ -1,5 +1,5 @@
-#ifndef _NDCTL_FILTER_H_
-#define _NDCTL_FILTER_H_
+#ifndef _UTIL_FILTER_H_
+#define _UTIL_FILTER_H_
struct ndctl_bus *util_bus_filter(struct ndctl_bus *bus, const char *ident);
struct ndctl_region *util_region_filter(struct ndctl_region *region,
const char *ident);
@@ -10,4 +10,6 @@ struct ndctl_bus *util_bus_filter_by_dimm(struct ndctl_bus *bus,
const char *ident);
struct ndctl_region *util_region_filter_by_dimm(struct ndctl_region *region,
const char *ident);
+struct daxctl_dev *util_daxctl_dev_filter(struct daxctl_dev *dev,
+ const char *ident);
#endif
diff --git a/util/json.c b/util/json.c
index 299c1b5782ee..d6a8d4c899ed 100644
--- a/util/json.c
+++ b/util/json.c
@@ -1,5 +1,6 @@
#include <limits.h>
#include <util/json.h>
+#include <util/filter.h>
#include <uuid/uuid.h>
#include <json-c/json.h>
#include <ndctl/libndctl.h>
@@ -100,42 +101,109 @@ bool util_namespace_active(struct ndctl_namespace *ndns)
return false;
}
-static json_object *util_daxctl_region_to_json(struct daxctl_region *region,
- bool include_idle)
+struct json_object *util_daxctl_dev_to_json(struct daxctl_dev *dev)
{
- struct json_object *jdaxdevs = json_object_new_array();
- struct json_object *jobj;
- struct daxctl_dev *dev;
+ const char *devname = daxctl_dev_get_devname(dev);
+ struct json_object *jdev, *jobj;
- if (!jdaxdevs)
+ jdev = json_object_new_object();
+ if (!devname || !jdev)
return NULL;
+ jobj = json_object_new_string(devname);
+ if (jobj)
+ json_object_object_add(jdev, "chardev", jobj);
+
+ jobj = json_object_new_int64(daxctl_dev_get_size(dev));
+ if (jobj)
+ json_object_object_add(jdev, "size", jobj);
+
+ return jdev;
+}
+
+struct json_object *util_daxctl_devs_to_list(struct daxctl_region *region,
+ struct json_object *jdevs, const char *ident, bool include_idle)
+{
+ struct daxctl_dev *dev;
+
daxctl_dev_foreach(region, dev) {
- const char *devname = daxctl_dev_get_devname(dev);
struct json_object *jdev;
- if (daxctl_dev_get_size(dev) == 0 && !include_idle)
+ if (!util_daxctl_dev_filter(dev, ident))
continue;
- jdev = json_object_new_object();
- if (!devname || !jdev)
+ if (!include_idle && !daxctl_dev_get_size(dev))
continue;
- jobj = json_object_new_string(devname);
- if (jobj)
- json_object_object_add(jdev, "chardev", jobj);
- jobj = json_object_new_int64(daxctl_dev_get_size(dev));
- if (jobj)
- json_object_object_add(jdev, "size", jobj);
+ if (!jdevs) {
+ jdevs = json_object_new_array();
+ if (!jdevs)
+ return NULL;
+ }
+
+ jdev = util_daxctl_dev_to_json(dev);
+ if (!jdev) {
+ json_object_put(jdevs);
+ return NULL;
+ }
- json_object_array_add(jdaxdevs, jdev);
+ json_object_array_add(jdevs, jdev);
}
- if (json_object_array_length(jdaxdevs) < 1) {
- json_object_put(jdaxdevs);
+ return jdevs;
+}
+
+struct json_object *util_daxctl_region_to_json(struct daxctl_region *region,
+ bool include_devs, const char *ident, bool include_idle)
+{
+ unsigned long align;
+ struct json_object *jregion, *jobj;
+ unsigned long long available_size, size;
+
+ jregion = json_object_new_object();
+ if (!jregion)
return NULL;
+
+ jobj = json_object_new_int(daxctl_region_get_id(region));
+ if (!jobj)
+ goto err;
+ json_object_object_add(jregion, "id", jobj);
+
+ size = daxctl_region_get_size(region);
+ if (size < ULLONG_MAX) {
+ jobj = json_object_new_int64(size);
+ if (!jobj)
+ goto err;
+ json_object_object_add(jregion, "size", jobj);
+ }
+
+ available_size = daxctl_region_get_available_size(region);
+ if (available_size) {
+ jobj = json_object_new_int64(available_size);
+ if (!jobj)
+ goto err;
+ json_object_object_add(jregion, "available_size", jobj);
}
- return jdaxdevs;
+
+ align = daxctl_region_get_align(region);
+ if (align < ULONG_MAX) {
+ jobj = json_object_new_int64(align);
+ if (!jobj)
+ goto err;
+ json_object_object_add(jregion, "align", jobj);
+ }
+
+ if (!include_devs)
+ return jregion;
+
+ jobj = util_daxctl_devs_to_list(region, NULL, ident, include_idle);
+ if (jobj)
+ json_object_object_add(jregion, "devices", jobj);
+
+ return jregion;
+ err:
+ json_object_put(jregion);
+ return NULL;
}
struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
@@ -233,9 +301,10 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
json_object_object_add(jndns, "uuid", jobj);
if (include_dax) {
dax_region = ndctl_dax_get_daxctl_region(dax);
- jobj = util_daxctl_region_to_json(dax_region, include_idle);
+ jobj = util_daxctl_region_to_json(dax_region,
+ true, NULL, include_idle);
if (jobj)
- json_object_object_add(jndns, "daxdevs", jobj);
+ json_object_object_add(jndns, "daxregion", jobj);
}
} else if (ndctl_namespace_get_type(ndns) != ND_DEVICE_NAMESPACE_IO) {
const char *name;
diff --git a/util/json.h b/util/json.h
index b8fc00f57ea8..a9afb2d43bbe 100644
--- a/util/json.h
+++ b/util/json.h
@@ -12,6 +12,14 @@ struct json_object *util_dimm_to_json(struct ndctl_dimm *dimm);
struct json_object *util_mapping_to_json(struct ndctl_mapping *mapping);
struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
bool include_idle, bool include_dax);
+struct daxctl_region;
+struct daxctl_dev;
+struct json_object *util_daxctl_region_to_json(struct daxctl_region *region,
+ bool include_devs, const char *ident, bool include_idle);
+struct json_object *util_daxctl_dev_to_json(struct daxctl_dev *dev);
+struct json_object *util_daxctl_devs_to_list(struct daxctl_region *region,
+ struct json_object *jdevs, const char *ident,
+ bool include_idle);
#ifdef HAVE_NDCTL_SMART
struct json_object *util_dimm_health_to_json(struct ndctl_dimm *dimm);
#else
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ndctl PATCH 6/7] ndctl, {enable,disable}-region: filter by type
2017-01-07 1:42 [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates Dan Williams
` (4 preceding siblings ...)
2017-01-07 1:42 ` [ndctl PATCH 5/7] daxctl: add list command Dan Williams
@ 2017-01-07 1:42 ` Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 7/7] ndctl, list: limit mappings when --dimm is specified Dan Williams
2017-01-09 21:56 ` [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates Vishal Verma
7 siblings, 0 replies; 11+ messages in thread
From: Dan Williams @ 2017-01-07 1:42 UTC (permalink / raw)
To: linux-nvdimm
Allow the region to be selected by type. For example, disable all pmem:
ndctl disable-region -t pmem all
One case this is useful for is scripting the bring-up of individual
namespaces rather than the default of all at once and in parallel. For
example:
* blacklist the nd_pmem module
* disable all pmem regions
* load the nd_pmem module
* individually enable pmem regions
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
ndctl/builtin-xable-region.c | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/ndctl/builtin-xable-region.c b/ndctl/builtin-xable-region.c
index 50cbdef5b339..0d46192fe6a4 100644
--- a/ndctl/builtin-xable-region.c
+++ b/ndctl/builtin-xable-region.c
@@ -6,11 +6,16 @@
#include <util/parse-options.h>
#include <ndctl/libndctl.h>
-static const char *region_bus;
+static struct {
+ const char *bus;
+ const char *type;
+} param;
static const struct option region_options[] = {
- OPT_STRING('b', "bus", ®ion_bus, "bus-id",
+ OPT_STRING('b', "bus", ¶m.bus, "bus-id",
"<region> must be on a bus with an id/provider of <bus-id>"),
+ OPT_STRING('t', "type", ¶m.type, "region-type",
+ "<region> must be of the specified type"),
OPT_END(),
};
@@ -33,6 +38,20 @@ static const char *parse_region_options(int argc, const char **argv,
usage_with_options(u, region_options);
return NULL; /* we won't return from usage_with_options() */
}
+
+ if (param.type) {
+ if (strcmp(param.type, "pmem") == 0)
+ /* pass */;
+ else if (strcmp(param.type, "blk") == 0)
+ /* pass */;
+ else {
+ error("unknown region type '%s', should be 'pmem' or 'blk'\n",
+ param.type);
+ usage_with_options(u, region_options);
+ return NULL;
+ }
+ }
+
return argv[0];
}
@@ -47,10 +66,14 @@ static int do_xable_region(const char *region_arg,
goto out;
ndctl_bus_foreach(ctx, bus) {
- if (!util_bus_filter(bus, region_bus))
+ if (!util_bus_filter(bus, param.bus))
continue;
ndctl_region_foreach(bus, region) {
+ const char *type = ndctl_region_get_type_name(region);
+
+ if (param.type && strcmp(param.type, type) != 0)
+ continue;
if (!util_region_filter(region, region_arg))
continue;
if (xable_fn(region) == 0)
@@ -60,7 +83,7 @@ static int do_xable_region(const char *region_arg,
rc = success;
out:
- region_bus = NULL;
+ param.bus = NULL;
return rc;
}
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ndctl PATCH 7/7] ndctl, list: limit mappings when --dimm is specified
2017-01-07 1:42 [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates Dan Williams
` (5 preceding siblings ...)
2017-01-07 1:42 ` [ndctl PATCH 6/7] ndctl, {enable,disable}-region: filter by type Dan Williams
@ 2017-01-07 1:42 ` Dan Williams
2017-01-09 21:56 ` [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates Vishal Verma
7 siblings, 0 replies; 11+ messages in thread
From: Dan Williams @ 2017-01-07 1:42 UTC (permalink / raw)
To: linux-nvdimm
Single out the mapping for the requested dimm device when specified.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
ndctl/builtin-list.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/ndctl/builtin-list.c b/ndctl/builtin-list.c
index ed4edf6f0249..e8d007003b62 100644
--- a/ndctl/builtin-list.c
+++ b/ndctl/builtin-list.c
@@ -173,6 +173,9 @@ static struct json_object *region_to_json(struct ndctl_region *region)
if (!list.dimms)
break;
+ if (!util_dimm_filter(dimm, param.dimm))
+ continue;
+
if (!list.idle && !ndctl_dimm_is_enabled(dimm))
continue;
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates
2017-01-07 1:42 [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates Dan Williams
` (6 preceding siblings ...)
2017-01-07 1:42 ` [ndctl PATCH 7/7] ndctl, list: limit mappings when --dimm is specified Dan Williams
@ 2017-01-09 21:56 ` Vishal Verma
2017-01-09 22:00 ` Dan Williams
7 siblings, 1 reply; 11+ messages in thread
From: Vishal Verma @ 2017-01-09 21:56 UTC (permalink / raw)
To: Dan Williams; +Cc: linux-nvdimm
On 01/06, Dan Williams wrote:
> * The 'ndctl list' command awkwardly prints out all the corresponding
> device-dax information when a namespace is in 'dax' mode. Conversely if
> someone is only interested in listing device-dax information they need to
> contend with libnvdimm data.
>
> Introduce a separate daxctl utility with its own 'list' command for this
> purpose, and make the listing of device-dax data through 'ndctl list'
> optional (new --device-dax option).
the 'rpmbuild' script was failing as the new daxctl utility wasn't
included in %files in the spec. The following patch fixes that.
8<-----
>From d26a582b4ae9e69a22e52908a5d4bbae0a79717f Mon Sep 17 00:00:00 2001
From: Vishal Verma <vishal.l.verma@intel.com>
Date: Mon, 9 Jan 2017 14:52:34 -0700
Subject: [PATCH] spec: add the new daxctl binary to the spec file
The missing binary was triggering the "installed but unpackaged file
found" check for rpmbuild. Add daxctl to the %files section as we do
want it to be packaged.
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
ndctl.spec.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/ndctl.spec.in b/ndctl.spec.in
index 6453edd..4a22597 100644
--- a/ndctl.spec.in
+++ b/ndctl.spec.in
@@ -114,6 +114,7 @@ make check
%defattr(-,root,root)
%license util/COPYING licenses/BSD-MIT licenses/CC0
%{_bindir}/ndctl
+%{_bindir}/daxctl
%{_mandir}/man1/*
%{bashcompdir}/
--
2.9.3
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates
2017-01-09 21:56 ` [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates Vishal Verma
@ 2017-01-09 22:00 ` Dan Williams
2017-01-09 22:05 ` Verma, Vishal L
0 siblings, 1 reply; 11+ messages in thread
From: Dan Williams @ 2017-01-09 22:00 UTC (permalink / raw)
To: Vishal Verma; +Cc: linux-nvdimm@lists.01.org
On Mon, Jan 9, 2017 at 1:56 PM, Vishal Verma <vishal.l.verma@intel.com> wrote:
> On 01/06, Dan Williams wrote:
>> * The 'ndctl list' command awkwardly prints out all the corresponding
>> device-dax information when a namespace is in 'dax' mode. Conversely if
>> someone is only interested in listing device-dax information they need to
>> contend with libnvdimm data.
>>
>> Introduce a separate daxctl utility with its own 'list' command for this
>> purpose, and make the listing of device-dax data through 'ndctl list'
>> optional (new --device-dax option).
>
> the 'rpmbuild' script was failing as the new daxctl utility wasn't
> included in %files in the spec. The following patch fixes that.
>
> 8<-----
>
> From d26a582b4ae9e69a22e52908a5d4bbae0a79717f Mon Sep 17 00:00:00 2001
> From: Vishal Verma <vishal.l.verma@intel.com>
> Date: Mon, 9 Jan 2017 14:52:34 -0700
> Subject: [PATCH] spec: add the new daxctl binary to the spec file
>
> The missing binary was triggering the "installed but unpackaged file
> found" check for rpmbuild. Add daxctl to the %files section as we do
> want it to be packaged.
Yes, we do want it packaged, but in it's own rpm. I have patch to add
that as well as a daxctl man page.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates
2017-01-09 22:00 ` Dan Williams
@ 2017-01-09 22:05 ` Verma, Vishal L
0 siblings, 0 replies; 11+ messages in thread
From: Verma, Vishal L @ 2017-01-09 22:05 UTC (permalink / raw)
To: Williams, Dan J; +Cc: linux-nvdimm@lists.01.org
On Mon, 2017-01-09 at 14:00 -0800, Dan Williams wrote:
> On Mon, Jan 9, 2017 at 1:56 PM, Vishal Verma <vishal.l.verma@intel.com
> > wrote:
> > On 01/06, Dan Williams wrote:
> > > * The 'ndctl list' command awkwardly prints out all the
> > > corresponding
> > > device-dax information when a namespace is in 'dax' mode.
> > > Conversely if
> > > someone is only interested in listing device-dax information
> > > they need to
> > > contend with libnvdimm data.
> > >
> > > Introduce a separate daxctl utility with its own 'list' command
> > > for this
> > > purpose, and make the listing of device-dax data through 'ndctl
> > > list'
> > > optional (new --device-dax option).
> >
> > the 'rpmbuild' script was failing as the new daxctl utility wasn't
> > included in %files in the spec. The following patch fixes that.
> >
> > 8<-----
> >
> > From d26a582b4ae9e69a22e52908a5d4bbae0a79717f Mon Sep 17 00:00:00
> > 2001
> > From: Vishal Verma <vishal.l.verma@intel.com>
> > Date: Mon, 9 Jan 2017 14:52:34 -0700
> > Subject: [PATCH] spec: add the new daxctl binary to the spec file
> >
> > The missing binary was triggering the "installed but unpackaged file
> > found" check for rpmbuild. Add daxctl to the %files section as we do
> > want it to be packaged.
>
> Yes, we do want it packaged, but in it's own rpm. I have patch to add
> that as well as a daxctl man page.
Ah ok - I thought it would just get installed as a part of the ndctl
rpm.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2017-01-09 22:05 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-07 1:42 [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 1/7] ndctl, daxctl: refactor main boilerplate for a new 'daxctl' utility Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 2/7] ndctl, daxctl: move json helpers to be available across both utilities Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 3/7] ndctl, list: add option to filter namespace by mode Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 4/7] ndctl, list: add '--device-dax' option Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 5/7] daxctl: add list command Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 6/7] ndctl, {enable,disable}-region: filter by type Dan Williams
2017-01-07 1:42 ` [ndctl PATCH 7/7] ndctl, list: limit mappings when --dimm is specified Dan Williams
2017-01-09 21:56 ` [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates Vishal Verma
2017-01-09 22:00 ` Dan Williams
2017-01-09 22:05 ` Verma, Vishal L
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.