diff mbox

[ndctl,10/13] ndctl: emit namespace after successful create

Message ID 20160128225250.17855.32597.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit c74efe5c9276
Headers show

Commit Message

Dan Williams Jan. 28, 2016, 10:52 p.m. UTC
Give notification of a successful 'create' event in json-format.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 builtin-xaction-namespace.c |    8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox

Patch

diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c
index 5eb28bbeedfc..22e949a9ec6d 100644
--- a/builtin-xaction-namespace.c
+++ b/builtin-xaction-namespace.c
@@ -21,6 +21,8 @@ 
 #include <uuid/uuid.h>
 #include <sys/types.h>
 #include <util/size.h>
+#include <util/json.h>
+#include <json-c/json.h>
 #include <util/filter.h>
 #include <ndctl/libndctl.h>
 #include <util/parse-options.h>
@@ -275,6 +277,12 @@  static int setup_namespace(struct ndctl_region *region,
 	if (rc) {
 		error("%s: failed to enable\n",
 				ndctl_namespace_get_devname(ndns));
+	} else {
+		struct json_object *jndns = util_namespace_to_json(ndns);
+
+		if (jndns)
+			printf("%s\n", json_object_to_json_string_ext(jndns,
+						JSON_C_TO_STRING_PRETTY));
 	}
 	return rc;
 }