@@ -58,6 +58,7 @@ endif
ndctl_LDADD =\
lib/libndctl.la \
+ ../daxctl/lib/libdaxctl.la \
../libutil.a \
$(UUID_LIBS) \
$(KMOD_LIBS) \
@@ -68,7 +69,6 @@ ndctl_SOURCES += ../test/libndctl.c \
../test/dpa-alloc.c \
../test/parent-uuid.c \
../test/core.c
-ndctl_LDADD += ../daxctl/lib/libdaxctl.la
endif
@@ -74,7 +74,7 @@ static struct json_object *list_namespaces(struct ndctl_region *region,
jnamespaces);
}
- jndns = util_namespace_to_json(ndns);
+ jndns = util_namespace_to_json(ndns, list.idle);
if (!jndns) {
fail("\n");
continue;
@@ -327,7 +327,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);
+ struct json_object *jndns = util_namespace_to_json(ndns, 0);
if (jndns)
printf("%s\n", json_object_to_json_string_ext(jndns,
@@ -100,7 +100,8 @@ bool util_namespace_active(struct ndctl_namespace *ndns)
return false;
}
-static json_object *util_daxctl_region_to_json(struct daxctl_region *region)
+static json_object *util_daxctl_region_to_json(struct daxctl_region *region,
+ bool include_idle)
{
struct json_object *jdaxdevs = json_object_new_array();
struct json_object *jobj;
@@ -111,8 +112,12 @@ static json_object *util_daxctl_region_to_json(struct daxctl_region *region)
daxctl_dev_foreach(region, dev) {
const char *devname = daxctl_dev_get_devname(dev);
- struct json_object *jdev = json_object_new_object();
+ struct json_object *jdev;
+ if (daxctl_dev_get_size(dev) == 0 && !include_idle)
+ continue;
+
+ jdev = json_object_new_object();
if (!devname || !jdev)
continue;
jobj = json_object_new_string(devname);
@@ -133,7 +138,8 @@ static json_object *util_daxctl_region_to_json(struct daxctl_region *region)
return jdaxdevs;
}
-struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns)
+struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
+ bool include_idle)
{
struct json_object *jndns = json_object_new_object();
unsigned long long size = ULLONG_MAX;
@@ -223,7 +229,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns)
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);
+ 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) {
@@ -10,7 +10,8 @@ bool util_namespace_active(struct ndctl_namespace *ndns);
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);
+struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
+ bool include_idle);
#ifdef HAVE_NDCTL_SMART
struct json_object *util_dimm_health_to_json(struct ndctl_dimm *dimm);
#else
A 0-sized device-dax instance is an idle device-dax seed. Hide them by default unless we are explicitly listing idle objects. Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- ndctl/Makefile.am | 2 +- ndctl/builtin-list.c | 2 +- ndctl/builtin-xaction-namespace.c | 2 +- ndctl/util/json.c | 14 ++++++++++---- ndctl/util/json.h | 3 ++- 5 files changed, 15 insertions(+), 8 deletions(-)