diff mbox

[ndctl,4/5] test, libndctl: get ndctl_btt_get_size() on v4.8+

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

Commit Message

Dan Williams April 20, 2017, 8:59 p.m. UTC
This support went into the kernel with commit abe8b4e3cef8 "nvdimm, btt:
add a size attribute for BTTs"

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/libndctl.c |    6 ++++++
 1 file changed, 6 insertions(+)
diff mbox

Patch

diff --git a/test/libndctl.c b/test/libndctl.c
index 38a0bb746905..0381ee2cdefb 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -970,6 +970,8 @@  static int check_pfn_create(struct ndctl_region *region,
 
 static int check_btt_size(struct ndctl_btt *btt)
 {
+	struct ndctl_ctx *ctx = ndctl_btt_get_ctx(btt);
+	struct ndctl_test *test = ndctl_get_private_data(ctx);
 	struct ndctl_namespace *ndns = ndctl_btt_get_namespace(btt);
 	unsigned long long ns_size = ndctl_namespace_get_size(ndns);
 	unsigned long sect_size = ndctl_btt_get_sector_size(btt);
@@ -1018,6 +1020,10 @@  static int check_btt_size(struct ndctl_btt *btt)
 		return -ENXIO;
 	}
 
+	/* prior to 4.8 btt devices did not have a size attribute */
+	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 8, 0)))
+		return 0;
+
 	expect = expect_table[size_select][sect_select];
 	actual = ndctl_btt_get_size(btt);
 	if (expect != actual) {