05ad79
From 2181ce4a5726c4c72e68e6964b7ef7442e507707 Mon Sep 17 00:00:00 2001
05ad79
From: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
05ad79
Date: Fri, 24 Jun 2016 11:59:35 +0200
05ad79
Subject: [PATCH] libblkid: Add metadata signature check for IMSM on 4Kn drives
05ad79
05ad79
Drives with 512 and 4K sectors have different offset for
05ad79
metadata signature. Without signature detected on 4Kn drives
05ad79
those drives will not be recognized as raid member. This
05ad79
patch adds checking for IMSM signature for 4Kn drives.
05ad79
05ad79
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1451704
05ad79
Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
05ad79
Signed-off-by: Karel Zak <kzak@redhat.com>
05ad79
---
05ad79
 libblkid/src/superblocks/isw_raid.c | 13 +++++++------
05ad79
 1 file changed, 7 insertions(+), 6 deletions(-)
05ad79
05ad79
diff --git a/libblkid/src/superblocks/isw_raid.c b/libblkid/src/superblocks/isw_raid.c
05ad79
index 065c2b2..81d53a1 100644
05ad79
--- a/libblkid/src/superblocks/isw_raid.c
05ad79
+++ b/libblkid/src/superblocks/isw_raid.c
05ad79
@@ -25,11 +25,11 @@ struct isw_metadata {
05ad79
 
05ad79
 #define ISW_SIGNATURE		"Intel Raid ISM Cfg Sig. "
05ad79
 
05ad79
-
05ad79
 static int probe_iswraid(blkid_probe pr,
05ad79
 		const struct blkid_idmag *mag __attribute__((__unused__)))
05ad79
 {
05ad79
 	uint64_t off;
05ad79
+	unsigned int sector_size;
05ad79
 	struct isw_metadata *isw;
05ad79
 
05ad79
 	if (pr->size < 0x10000)
05ad79
@@ -37,16 +37,17 @@ static int probe_iswraid(blkid_probe pr,
05ad79
 	if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr))
05ad79
 		return 1;
05ad79
 
05ad79
-	off = ((pr->size / 0x200) - 2) * 0x200;
05ad79
-	isw = (struct isw_metadata *)
05ad79
-			blkid_probe_get_buffer(pr,
05ad79
-					off,
05ad79
-					sizeof(struct isw_metadata));
05ad79
+	sector_size = blkid_probe_get_sectorsize(pr);
05ad79
+	off = ((pr->size / sector_size) - 2) * sector_size;
05ad79
+
05ad79
+	isw = (struct isw_metadata *)blkid_probe_get_buffer(pr,
05ad79
+			off, sizeof(struct isw_metadata));
05ad79
 	if (!isw)
05ad79
 		return errno ? -errno : 1;
05ad79
 
05ad79
 	if (memcmp(isw->sig, ISW_SIGNATURE, sizeof(ISW_SIGNATURE)-1) != 0)
05ad79
 		return 1;
05ad79
+
05ad79
 	if (blkid_probe_sprintf_version(pr, "%6s",
05ad79
 			&isw->sig[sizeof(ISW_SIGNATURE)-1]) != 0)
05ad79
 		return 1;
05ad79
-- 
05ad79
2.9.4
05ad79