* [ndctl PATCH] ndctl, list: display named devices by default
@ 2016-05-25 23:26 Dan Williams
2016-05-25 23:42 ` Verma, Vishal L
0 siblings, 1 reply; 2+ messages in thread
From: Dan Williams @ 2016-05-25 23:26 UTC (permalink / raw)
To: linux-nvdimm
Instead of being silent when no list options are specified, default to
list the device if it is the only parameter specified. For example,
before:
# ndctl list -d nmem0
#
...after:
# ndctl list -d nmem0
{
"dev":"nmem0",
"id":"cdab-ffffffff"
}
#
...in other words omit the need for --dimms to be specified for this
case.
Reported-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
ndctl/builtin-list.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/ndctl/builtin-list.c b/ndctl/builtin-list.c
index 2080337252c8..5c5dc5a5db5b 100644
--- a/ndctl/builtin-list.c
+++ b/ndctl/builtin-list.c
@@ -179,6 +179,11 @@ static struct json_object *region_to_json(struct ndctl_region *region)
return NULL;
}
+static int num_list_flags(void)
+{
+ return list.buses + list.dimms + list.regions + list.namespaces;
+}
+
int cmd_list(int argc, const char **argv)
{
const struct option options[] = {
@@ -212,9 +217,6 @@ int cmd_list(int argc, const char **argv)
unsigned int type = 0;
int i, rc;
- if (argc == 1)
- list.namespaces = true;
-
argc = parse_options(argc, argv, options, u, 0);
for (i = 0; i < argc; i++)
error("unknown parameter \"%s\"\n", argv[i]);
@@ -228,6 +230,15 @@ int cmd_list(int argc, const char **argv)
if (argc)
usage_with_options(u, options);
+ if (num_list_flags() == 0) {
+ list.buses = !!param.bus;
+ list.regions = !!param.region;
+ list.dimms = !!param.dimm;
+ }
+
+ if (num_list_flags() == 0)
+ list.namespaces = true;
+
if (param.type) {
if (strcmp(param.type, "pmem") == 0)
type = ND_DEVICE_REGION_PMEM;
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [ndctl PATCH] ndctl, list: display named devices by default
2016-05-25 23:26 [ndctl PATCH] ndctl, list: display named devices by default Dan Williams
@ 2016-05-25 23:42 ` Verma, Vishal L
0 siblings, 0 replies; 2+ messages in thread
From: Verma, Vishal L @ 2016-05-25 23:42 UTC (permalink / raw)
To: Williams, Dan J, linux-nvdimm
On Wed, 2016-05-25 at 16:26 -0700, Dan Williams wrote:
> Instead of being silent when no list options are specified, default to
> list the device if it is the only parameter specified. For example,
> before:
>
> # ndctl list -d nmem0
> #
>
> ...after:
>
> # ndctl list -d nmem0
> {
> "dev":"nmem0",
> "id":"cdab-ffffffff"
> }
> #
>
> ...in other words omit the need for --dimms to be specified for this
> case.
>
> Reported-by: Vishal Verma <vishal.l.verma@intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> ndctl/builtin-list.c | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)
Looks good!
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-25 23:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-25 23:26 [ndctl PATCH] ndctl, list: display named devices by default Dan Williams
2016-05-25 23:42 ` 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.