@@ -84,7 +84,7 @@ static struct json_object *list_namespaces(struct ndctl_region *region,
if (param.mode && mode_to_type(param.mode) != mode)
continue;
- if (!list.idle && !util_namespace_active(ndns))
+ if (!list.idle && !ndctl_namespace_is_active(ndns))
continue;
if (!jnamespaces) {
@@ -3234,6 +3234,21 @@ static void region_refresh_children(struct ndctl_region *region)
daxs_init(region);
}
+NDCTL_EXPORT bool ndctl_namespace_is_active(struct ndctl_namespace *ndns)
+{
+ struct ndctl_btt *btt = ndctl_namespace_get_btt(ndns);
+ struct ndctl_pfn *pfn = ndctl_namespace_get_pfn(ndns);
+ struct ndctl_dax *dax = ndctl_namespace_get_dax(ndns);
+
+ if ((btt && ndctl_btt_is_enabled(btt))
+ || (pfn && ndctl_pfn_is_enabled(pfn))
+ || (dax && ndctl_dax_is_enabled(dax))
+ || (!btt && !pfn && !dax
+ && ndctl_namespace_is_enabled(ndns)))
+ return true;
+ return false;
+}
+
/*
* Return 0 if enabled, < 0 if failed to enable, and > 0 if claimed by
* another device and that device is enabled. In the > 0 case a
@@ -172,6 +172,7 @@ global:
ndctl_namespace_enable;
ndctl_namespace_disable;
ndctl_namespace_disable_invalidate;
+ ndctl_namespace_is_active;
ndctl_namespace_is_valid;
ndctl_namespace_is_configured;
ndctl_namespace_delete;
@@ -13,6 +13,7 @@
#ifndef _LIBNDCTL_H_
#define _LIBNDCTL_H_
+#include <stdbool.h>
#include <stdarg.h>
#include <unistd.h>
@@ -484,6 +485,7 @@ int ndctl_namespace_is_enabled(struct ndctl_namespace *ndns);
int ndctl_namespace_enable(struct ndctl_namespace *ndns);
int ndctl_namespace_disable(struct ndctl_namespace *ndns);
int ndctl_namespace_disable_invalidate(struct ndctl_namespace *ndns);
+bool ndctl_namespace_is_active(struct ndctl_namespace *ndns);
int ndctl_namespace_is_valid(struct ndctl_namespace *ndns);
int ndctl_namespace_is_configured(struct ndctl_namespace *ndns);
int ndctl_namespace_delete(struct ndctl_namespace *ndns);
@@ -86,21 +86,6 @@ struct json_object *util_dimm_to_json(struct ndctl_dimm *dimm)
return NULL;
}
-bool util_namespace_active(struct ndctl_namespace *ndns)
-{
- struct ndctl_btt *btt = ndctl_namespace_get_btt(ndns);
- struct ndctl_pfn *pfn = ndctl_namespace_get_pfn(ndns);
- struct ndctl_dax *dax = ndctl_namespace_get_dax(ndns);
-
- if ((btt && ndctl_btt_is_enabled(btt))
- || (pfn && ndctl_pfn_is_enabled(pfn))
- || (dax && ndctl_dax_is_enabled(dax))
- || (!btt && !pfn && !dax
- && ndctl_namespace_is_enabled(ndns)))
- return true;
- return false;
-}
-
struct json_object *util_daxctl_dev_to_json(struct daxctl_dev *dev)
{
const char *devname = daxctl_dev_get_devname(dev);
@@ -334,7 +319,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
json_object_object_add(jndns, "blockdev", jobj);
}
- if (!util_namespace_active(ndns)) {
+ if (!ndctl_namespace_is_active(ndns)) {
jobj = json_object_new_string("disabled");
if (!jobj)
goto err;
@@ -6,7 +6,6 @@
struct json_object;
void util_display_json_array(FILE *f_out, struct json_object *jarray, int jflag);
-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);