File ndctl-namespace-Fix-enable-namespace-error-for-seed-.patch of Package ndctl.14275

From b9cb03f6d5a8654bf53e6538b60d4b63beb761d4 Mon Sep 17 00:00:00 2001
From: Santosh Sivaraj <santosh@fossix.org>
Date: Mon, 13 Jan 2020 09:54:53 +0530
Subject: [PATCH] ndctl/namespace: Fix enable-namespace error for seed
 namespaces

Git-commit: b9cb03f6d5a8654bf53e6538b60d4b63beb761d4
Patch-mainline: pending - v68

'ndctl enable-namespace all' tries to enable seed namespaces too, which results
in a error like

libndctl: ndctl_namespace_enable: namespace1.0: failed to enable

Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/lib/libndctl.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index d6a28002e7d6..2d23dbb3caf7 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -4010,11 +4010,16 @@ NDCTL_EXPORT int ndctl_namespace_enable(struct ndctl_namespace *ndns)
 	const char *devname = ndctl_namespace_get_devname(ndns);
 	struct ndctl_ctx *ctx = ndctl_namespace_get_ctx(ndns);
 	struct ndctl_region *region = ndns->region;
+	unsigned long long size = ndctl_namespace_get_size(ndns);
 	int rc;
 
 	if (ndctl_namespace_is_enabled(ndns))
 		return 0;
 
+	/* Don't try to enable idle namespace (no capacity allocated) */
+	if (size == 0)
+		return -ENXIO;
+
 	rc = ndctl_bind(ctx, ndns->module, devname);
 
 	/*
-- 
2.23.0